author | zecke <zecke> | 2003-02-23 21:27:08 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-02-23 21:27:08 (UTC) |
commit | 041eda0d7482d60cd67731b81fd36104fcd3120f (patch) (unidiff) | |
tree | c7bc7730b9e76e22f828291d404821f7bd922d6f /core/pim/datebook2 | |
parent | a195865dfdb03b4c7c972acfc8cfd87743ab3e6f (diff) | |
download | opie-041eda0d7482d60cd67731b81fd36104fcd3120f.zip opie-041eda0d7482d60cd67731b81fd36104fcd3120f.tar.gz opie-041eda0d7482d60cd67731b81fd36104fcd3120f.tar.bz2 |
Implement some of the new framework
-rw-r--r-- | core/pim/datebook2/bookmanager.cpp | 67 | ||||
-rw-r--r-- | core/pim/datebook2/bookmanager.h | 7 | ||||
-rw-r--r-- | core/pim/datebook2/datebook2.pro | 19 | ||||
-rw-r--r-- | core/pim/datebook2/mainwindow.cpp | 178 | ||||
-rw-r--r-- | core/pim/datebook2/mainwindow.h | 60 | ||||
-rw-r--r-- | core/pim/datebook2/managertemplate.h | 39 | ||||
-rw-r--r-- | core/pim/datebook2/show.cpp | 25 | ||||
-rw-r--r-- | core/pim/datebook2/show.h | 15 | ||||
-rw-r--r-- | core/pim/datebook2/stringmanager.cpp | 42 | ||||
-rw-r--r-- | core/pim/datebook2/stringmanager.h | 11 | ||||
-rw-r--r-- | core/pim/datebook2/templatemanager.cpp | 25 | ||||
-rw-r--r-- | core/pim/datebook2/view.cpp | 62 | ||||
-rw-r--r-- | core/pim/datebook2/view.h | 25 |
13 files changed, 546 insertions, 29 deletions
diff --git a/core/pim/datebook2/bookmanager.cpp b/core/pim/datebook2/bookmanager.cpp new file mode 100644 index 0000000..4fcd413 --- a/dev/null +++ b/core/pim/datebook2/bookmanager.cpp | |||
@@ -0,0 +1,67 @@ | |||
1 | #include "bookmanager.h" | ||
2 | |||
3 | using namespace Datebook; | ||
4 | |||
5 | BookManager::BookManager() { | ||
6 | m_db = 0; | ||
7 | } | ||
8 | BookManager::~BookManager() { | ||
9 | delete m_db; | ||
10 | } | ||
11 | void BookManager::add( const OEvent& ev) { | ||
12 | if (!m_db ) return; | ||
13 | |||
14 | m_db->add( ev ); | ||
15 | } | ||
16 | void BookManager::add( const OPimRecord& rec ) { | ||
17 | if (!m_db) load(); // we might where called by setDocument... before we even fully initialized | ||
18 | m_db->add( rec ); | ||
19 | } | ||
20 | void BookManager::update( const OEvent& up) { | ||
21 | if ( !m_db ) return; | ||
22 | m_db->replace( up ); | ||
23 | } | ||
24 | void BookManager::remove( int uid ) { | ||
25 | if ( !m_db ) return; | ||
26 | m_db->remove( uid ); | ||
27 | } | ||
28 | void BookManager::remove( const QArray<int>& ar) { | ||
29 | uint count = ar.count(); | ||
30 | for (uint i = 0; i < count; i++ ) | ||
31 | remove( ar[i] ); | ||
32 | } | ||
33 | QList<OPimRecord> BookManager::records( const QDate& , const QDate& ) { | ||
34 | return QList<OPimRecord>(); | ||
35 | } | ||
36 | bool BookManager::isLoaded() const{ | ||
37 | return ( m_db != 0 ); | ||
38 | } | ||
39 | bool BookManager::load() { | ||
40 | m_db = new ODateBookAccess; | ||
41 | return m_db->load(); | ||
42 | } | ||
43 | void BookManager::reload() { | ||
44 | if (!m_db ) return; | ||
45 | |||
46 | m_db->reload(); | ||
47 | } | ||
48 | OEvent BookManager::event( int uid ) { | ||
49 | if (!m_db ) return OEvent(); | ||
50 | |||
51 | return m_db->find( uid ); | ||
52 | } | ||
53 | ODateBookAccess::List BookManager::allRecords()const { | ||
54 | if (!m_db) return ODateBookAccess::List(); | ||
55 | |||
56 | return m_db->rawEvents(); | ||
57 | } | ||
58 | OEffectiveEvent::ValueList BookManager::list( const QDate& from, | ||
59 | const QDate& to ) { | ||
60 | if (!m_db) return OEffectiveEvent::ValueList(); | ||
61 | |||
62 | return m_db->effectiveEvents( from, to ); | ||
63 | } | ||
64 | bool BookManager::save() { | ||
65 | if (!m_db) return false; | ||
66 | return m_db->save(); | ||
67 | } | ||
diff --git a/core/pim/datebook2/bookmanager.h b/core/pim/datebook2/bookmanager.h index 44ad8ed..c5dee4a 100644 --- a/core/pim/datebook2/bookmanager.h +++ b/core/pim/datebook2/bookmanager.h | |||
@@ -20,6 +20,7 @@ namespace Datebook { | |||
20 | 20 | ||
21 | bool isLoaded()const; | 21 | bool isLoaded()const; |
22 | bool load(); | 22 | bool load(); |
23 | void reload(); | ||
23 | bool save(); | 24 | bool save(); |
24 | 25 | ||
25 | OEvent event( int uid ); | 26 | OEvent event( int uid ); |
@@ -28,12 +29,16 @@ namespace Datebook { | |||
28 | ODateBookAccess::List allRecords()const; | 29 | ODateBookAccess::List allRecords()const; |
29 | 30 | ||
30 | void add( const OEvent& ); | 31 | void add( const OEvent& ); |
32 | void add( const OPimRecord& ); | ||
31 | void update( const OEvent& ); | 33 | void update( const OEvent& ); |
32 | void remove( int uid ); | 34 | void remove( int uid ); |
33 | void remove( const QArray<int>& ); | 35 | void remove( const QArray<int>& ); |
34 | 36 | ||
35 | QPtrList<OPimRecord> records( const QDate& from, | 37 | QList<OPimRecord> records( const QDate& from, |
36 | const QDate& to ); | 38 | const QDate& to ); |
39 | |||
40 | private: | ||
41 | ODateBookAccess* m_db; | ||
37 | }; | 42 | }; |
38 | } | 43 | } |
39 | 44 | ||
diff --git a/core/pim/datebook2/datebook2.pro b/core/pim/datebook2/datebook2.pro index 9d6ef4c..2ad906e 100644 --- a/core/pim/datebook2/datebook2.pro +++ b/core/pim/datebook2/datebook2.pro | |||
@@ -1,9 +1,24 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS= mainwindow.h | 4 | HEADERS= mainwindow.h \ |
5 | bookmanager.h \ | ||
6 | locationmanager.h \ | ||
7 | show.h \ | ||
8 | view.h \ | ||
9 | descriptionmanager.h \ | ||
10 | stringmanager.h \ | ||
11 | editor.h \ | ||
12 | managertemplate.h \ | ||
13 | templatemanager.h | ||
14 | |||
5 | SOURCES= main.cpp \ | 15 | SOURCES= main.cpp \ |
6 | mainwindow.cpp | 16 | mainwindow.cpp \ |
17 | bookmanager.cpp \ | ||
18 | stringmanager.cpp \ | ||
19 | templatemanager.cpp \ | ||
20 | show.cpp \ | ||
21 | view.cpp | ||
7 | 22 | ||
8 | INCLUDEPATH += $(OPIEDIR)/include | 23 | INCLUDEPATH += $(OPIEDIR)/include |
9 | DEPENDPATH+= $(OPIEDIR)/include | 24 | DEPENDPATH+= $(OPIEDIR)/include |
diff --git a/core/pim/datebook2/mainwindow.cpp b/core/pim/datebook2/mainwindow.cpp index 2f214b8..44de6b0 100644 --- a/core/pim/datebook2/mainwindow.cpp +++ b/core/pim/datebook2/mainwindow.cpp | |||
@@ -1,13 +1,21 @@ | |||
1 | |||
2 | #include <qcopchannel_qws.h> | ||
1 | #include <qwidgetstack.h> | 3 | #include <qwidgetstack.h> |
2 | #include <qlabel.h> | 4 | #include <qlabel.h> |
3 | #include <qaction.h> | 5 | #include <qaction.h> |
6 | #include <qpopupmenu.h> | ||
7 | #include <qtimer.h> | ||
4 | 8 | ||
9 | #include <qpe/qpeapplication.h> | ||
5 | #include <qpe/ir.h> | 10 | #include <qpe/ir.h> |
6 | #include <qpe/qpemenubar.h> | 11 | #include <qpe/qpemenubar.h> |
12 | #include <qpe/qpetoolbar.h> | ||
7 | #include <qpe/qpemessagebox.h> | 13 | #include <qpe/qpemessagebox.h> |
8 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
9 | 15 | ||
10 | 16 | #include "show.h" | |
17 | #include "templatemanager.h" | ||
18 | #include "bookmanager.h" | ||
11 | #include "mainwindow.h" | 19 | #include "mainwindow.h" |
12 | 20 | ||
13 | 21 | ||
@@ -15,46 +23,120 @@ using namespace Datebook; | |||
15 | 23 | ||
16 | MainWindow::MainWindow() | 24 | MainWindow::MainWindow() |
17 | : OPimMainWindow( "Datebook", 0, 0 ) { | 25 | : OPimMainWindow( "Datebook", 0, 0 ) { |
26 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | ||
18 | initUI(); | 27 | initUI(); |
19 | initConfig(); | ||
20 | initView(); | ||
21 | initManagers(); | 28 | initManagers(); |
29 | initView(); | ||
30 | initConfig(); | ||
22 | 31 | ||
23 | raiseCurrentView(); | 32 | raiseCurrentView(); |
24 | QTimer::singleShot(0, this, SLOT(populate() ) ); | 33 | QTimer::singleShot(0, this, SLOT(populate() ) ); |
34 | |||
35 | QCopChannel* chan = new QCopChannel( "QPE/System", this ); | ||
36 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), | ||
37 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); | ||
38 | |||
39 | chan = new QCopChannel( "QPE/Datebook", this ); | ||
40 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), | ||
41 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); | ||
25 | } | 42 | } |
26 | MainWindow::~MainWindow() { | 43 | MainWindow::~MainWindow() { |
27 | |||
28 | } | 44 | } |
29 | void MainWindow::doSetDocument( const QString& str ) { | 45 | void MainWindow::doSetDocument( const QString& str ) { |
30 | 46 | ||
31 | } | 47 | } |
32 | void MainWindow::flush() { | 48 | void MainWindow::flush() { |
33 | 49 | manager()->save(); | |
34 | } | 50 | } |
35 | void MainWindow::reload() { | 51 | void MainWindow::reload() { |
36 | 52 | manager()->reload(); | |
37 | } | 53 | } |
38 | int MainWindow::create() { | 54 | int MainWindow::create() { |
39 | 55 | return 0; | |
40 | } | 56 | } |
41 | bool MainWindow::remove( int uid ) { | 57 | bool MainWindow::remove( int uid ) { |
42 | 58 | manager()->remove( uid ); | |
59 | return true; | ||
43 | } | 60 | } |
44 | void MainWindow::beam( int uid ) { | 61 | void MainWindow::beam( int uid ) { |
45 | 62 | ||
46 | } | 63 | } |
47 | void MainWindow::show( int uid ) { | 64 | void MainWindow::show( int uid ) { |
48 | 65 | ||
66 | eventShow()->show( manager()->event( uid ) ); | ||
49 | } | 67 | } |
50 | void MainWindow::add( const OPimRecord& ) { | 68 | void MainWindow::add( const OPimRecord& ad) { |
51 | 69 | manager()->add( ad ); | |
70 | } | ||
71 | void MainWindow::edit() { | ||
72 | edit ( currentView()->currentItem() ); | ||
52 | } | 73 | } |
53 | void MainWindow::edit( int uid ) { | 74 | void MainWindow::edit( int uid ) { |
54 | 75 | ||
55 | } | 76 | } |
77 | /* | ||
78 | * init tool bars layout and so on | ||
79 | */ | ||
56 | void MainWindow::initUI() { | 80 | void MainWindow::initUI() { |
81 | setToolBarsMovable( false ); | ||
82 | |||
83 | m_stack = new QWidgetStack( this ); | ||
84 | setCentralWidget( m_stack ); | ||
85 | |||
86 | m_toolBar = new QPEToolBar( this ); | ||
87 | m_toolBar->setHorizontalStretchable( TRUE ); | ||
88 | |||
89 | QPEMenuBar* mb = new QPEMenuBar( m_toolBar ); | ||
57 | 90 | ||
91 | m_popView = new QPopupMenu( this ); | ||
92 | m_popSetting = new QPopupMenu( this ); | ||
93 | |||
94 | mb->insertItem( tr("View"), m_popView ); | ||
95 | mb->insertItem( tr("Settings" ), m_popSetting ); | ||
96 | |||
97 | m_popTemplate = new QPopupMenu( this ); | ||
98 | m_popView->insertItem(tr("New from template"), m_popTemplate, -1, 0); | ||
99 | |||
100 | QAction* a = new QAction( tr("New Event"), Resource::loadPixmap("new"), | ||
101 | QString::null, 0, this, 0 ); | ||
102 | a->addTo( m_toolBar ); | ||
103 | a->addTo( m_popView ); | ||
104 | connect(a, SIGNAL( activated() ), this, SLOT( create() ) ); | ||
105 | |||
106 | a = new QAction( tr("Edit Event"), Resource::loadPixmap("edit"), | ||
107 | QString::null, 0, this, 0 ); | ||
108 | a->addTo( m_popView ); | ||
109 | connect(a, SIGNAL( activated() ), this, SLOT( edit() ) ); | ||
110 | |||
111 | a = new QAction( tr("Today" ), Resource::loadPixmap( "datebook/to_day"), | ||
112 | QString::null, 0, this, 0 ); | ||
113 | a->addTo( m_toolBar ); | ||
114 | connect(a, SIGNAL( activated() ), this, SLOT( slotGoToNow() ) ); | ||
115 | |||
116 | a = new QAction( tr("Find"), Resource::loadPixmap( "mag" ), | ||
117 | QString::null, 0, this, 0 ); | ||
118 | a->addTo( m_toolBar ); | ||
119 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | ||
120 | |||
121 | a = new QAction( tr("Configure"), QString::null, 0, 0 ); | ||
122 | a->addTo( m_popSetting ); | ||
123 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); | ||
124 | |||
125 | a = new QAction( tr("Configure Locations"), QString::null, 0, 0 ); | ||
126 | a->addTo( m_popSetting ); | ||
127 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigureLocs() ) ); | ||
128 | |||
129 | a = new QAction( tr("Configure Descriptions"), QString::null, 0, 0 ); | ||
130 | a->addTo( m_popSetting ); | ||
131 | connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) ); | ||
132 | |||
133 | connect( qApp, SIGNAL(clockChanged(bool) ), | ||
134 | this, SLOT(slotClockChanged(bool) ) ); | ||
135 | connect( qApp, SIGNAL(weekChanged(bool) ), | ||
136 | this, SLOT(slotWeekChanged(bool) ) ); | ||
137 | |||
138 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), | ||
139 | this, SLOT(slotAppMessage( const QCString&, const QByteArray& ) ) ); | ||
58 | } | 140 | } |
59 | void MainWindow::initConfig() { | 141 | void MainWindow::initConfig() { |
60 | 142 | ||
@@ -63,8 +145,82 @@ void MainWindow::initView() { | |||
63 | 145 | ||
64 | } | 146 | } |
65 | void MainWindow::initManagers() { | 147 | void MainWindow::initManagers() { |
66 | 148 | m_manager = new BookManager; | |
149 | m_locMan = new LocationManager( tr("Locations") ); | ||
150 | m_descMan = new DescriptionManager( tr("Descriptions") ); | ||
67 | } | 151 | } |
68 | void MainWindow::raiseCurrentView() { | 152 | void MainWindow::raiseCurrentView() { |
69 | 153 | ||
70 | } | 154 | } |
155 | /* | ||
156 | * populate the view | ||
157 | */ | ||
158 | void MainWindow::populate() { | ||
159 | if (!manager()->isLoaded() ) | ||
160 | manager()->load(); | ||
161 | } | ||
162 | void MainWindow::slotGoToNow() { | ||
163 | |||
164 | } | ||
165 | View* MainWindow::currentView() { | ||
166 | |||
167 | } | ||
168 | void MainWindow::slotFind() { | ||
169 | |||
170 | } | ||
171 | void MainWindow::slotConfigure() { | ||
172 | |||
173 | } | ||
174 | void MainWindow::slotClockChanged( bool ) { | ||
175 | |||
176 | } | ||
177 | void MainWindow::slotWeekChanged(bool ) { | ||
178 | |||
179 | } | ||
180 | void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) { | ||
181 | |||
182 | } | ||
183 | void MainWindow::slotReceive( const QCString&, const QByteArray& ) { | ||
184 | |||
185 | } | ||
186 | BookManager* MainWindow::manager() { | ||
187 | return m_manager; | ||
188 | } | ||
189 | TemplateManager* MainWindow::templateManager() { | ||
190 | return m_tempMan; | ||
191 | } | ||
192 | LocationManager* MainWindow::locationManager() { | ||
193 | return m_locMan; | ||
194 | } | ||
195 | DescriptionManager* MainWindow::descriptionManager() { | ||
196 | return m_descMan; | ||
197 | } | ||
198 | Show* MainWindow::eventShow() { | ||
199 | return m_show; | ||
200 | } | ||
201 | void MainWindow::slotAction( QAction* act ) { | ||
202 | |||
203 | } | ||
204 | void MainWindow::slotConfigureLocs() { | ||
205 | |||
206 | } | ||
207 | void MainWindow::slotConfigureDesc() { | ||
208 | |||
209 | } | ||
210 | void MainWindow::hideShow() { | ||
211 | |||
212 | } | ||
213 | void MainWindow::viewPopup(int ) { | ||
214 | |||
215 | } | ||
216 | void MainWindow::viewAdd(const QDate& ) { | ||
217 | |||
218 | } | ||
219 | void MainWindow::viewAdd( const QDateTime&, const QDateTime& ) { | ||
220 | |||
221 | } | ||
222 | bool MainWindow::viewAP()const{ | ||
223 | } | ||
224 | bool MainWindow::viewStartMonday()const { | ||
225 | |||
226 | } | ||
diff --git a/core/pim/datebook2/mainwindow.h b/core/pim/datebook2/mainwindow.h index 5ea0c89..60ea4c4 100644 --- a/core/pim/datebook2/mainwindow.h +++ b/core/pim/datebook2/mainwindow.h | |||
@@ -5,10 +5,23 @@ | |||
5 | 5 | ||
6 | #include <opie/opimmainwindow.h> | 6 | #include <opie/opimmainwindow.h> |
7 | 7 | ||
8 | #include "descriptionmanager.h" | ||
9 | #include "locationmanager.h" | ||
10 | #include "view.h" | ||
11 | |||
12 | class QAction; | ||
13 | class QWidgetStack; | ||
14 | class QPopupMenu; | ||
15 | class QPEToolBar; | ||
8 | namespace Datebook { | 16 | namespace Datebook { |
9 | 17 | ||
18 | class TemplateManager; | ||
19 | class BookManager; | ||
20 | class Show; | ||
10 | class MainWindow : public OPimMainWindow { | 21 | class MainWindow : public OPimMainWindow { |
11 | Q_OBJECT | 22 | Q_OBJECT |
23 | friend class Show; // to avoid QObject | ||
24 | friend class View; // to avoid QObject | ||
12 | public: | 25 | public: |
13 | MainWindow(); | 26 | MainWindow(); |
14 | ~MainWindow(); | 27 | ~MainWindow(); |
@@ -19,6 +32,17 @@ namespace Datebook { | |||
19 | void initView(); // init the Views.. | 32 | void initView(); // init the Views.. |
20 | void initManagers(); // init the Managers including templates, location and description | 33 | void initManagers(); // init the Managers including templates, location and description |
21 | void raiseCurrentView(); // raise the current View | 34 | void raiseCurrentView(); // raise the current View |
35 | void slotGoToNow(); // will switch the currentView to the curren date time | ||
36 | void slotFind(); // find!!! | ||
37 | void slotConfigure(); // configure the app | ||
38 | void slotClockChanged(bool); // clock changed | ||
39 | void slotWeekChanged( bool ); // week changed | ||
40 | void slotAppMessage( const QCString&, const QByteArray& ); // qApp message QPE/Application/datebook | ||
41 | void slotReceive( const QCString&, const QByteArray& ); // QPE/System and QPE/Datebook | ||
42 | void slotAction( QAction* ); // View changed | ||
43 | void slotConfigureLocs(); // Configure the Locations | ||
44 | void slotConfigureDesc(); // Configure the Desc | ||
45 | |||
22 | 46 | ||
23 | protected slots: | 47 | protected slots: |
24 | void populate(); | 48 | void populate(); |
@@ -30,11 +54,45 @@ namespace Datebook { | |||
30 | void beam( int uid ); | 54 | void beam( int uid ); |
31 | void show( int uid ); | 55 | void show( int uid ); |
32 | void edit( int uid ); | 56 | void edit( int uid ); |
57 | void edit(); | ||
33 | void add( const OPimRecord& ); | 58 | void add( const OPimRecord& ); |
34 | 59 | ||
35 | private: | 60 | private: |
36 | QList<View> m_view; // the Views.. not autoDelete | 61 | QPEToolBar* toolbar(); |
62 | QPopupMenu* viewMenu(); | ||
63 | QPopupMenu* settingsMenu(); | ||
64 | QPopupMenu* templateMenu(); | ||
65 | View* currentView(); | ||
66 | BookManager* manager(); | ||
67 | TemplateManager* templateManager(); | ||
68 | LocationManager* locationManager(); | ||
69 | DescriptionManager* descriptionManager(); | ||
70 | Show* eventShow(); | ||
71 | |||
72 | private: // friend functions for Show | ||
73 | void hideShow(); // to hide the view | ||
74 | // off friend Show | ||
37 | 75 | ||
76 | // friend of the view | ||
77 | private: | ||
78 | void viewPopup( int ); | ||
79 | void viewAdd( const QDate& date ); | ||
80 | void viewAdd( const QDateTime&, const QDateTime& ); | ||
81 | bool viewAP()const; | ||
82 | bool viewStartMonday()const; | ||
83 | // off view show | ||
84 | private: | ||
85 | QList<View> m_view; // the Views.. not autoDelete | ||
86 | QWidgetStack* m_stack; | ||
87 | QPEToolBar *m_toolBar; | ||
88 | QPopupMenu* m_popView; | ||
89 | QPopupMenu* m_popSetting; | ||
90 | QPopupMenu* m_popTemplate; | ||
91 | BookManager* m_manager; | ||
92 | TemplateManager* m_tempMan; | ||
93 | DescriptionManager* m_descMan; | ||
94 | LocationManager* m_locMan; | ||
95 | Show* m_show; | ||
38 | }; | 96 | }; |
39 | } | 97 | } |
40 | 98 | ||
diff --git a/core/pim/datebook2/managertemplate.h b/core/pim/datebook2/managertemplate.h index 668fda7..cdf121d 100644 --- a/core/pim/datebook2/managertemplate.h +++ b/core/pim/datebook2/managertemplate.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define OPIE_DATE_BOOK_MANAGER_TEMPLATE_H | 2 | #define OPIE_DATE_BOOK_MANAGER_TEMPLATE_H |
3 | 3 | ||
4 | #include <qdialog.h> | 4 | #include <qdialog.h> |
5 | #include <qmap.h> | ||
5 | #include <qstring.h> | 6 | #include <qstring.h> |
6 | 7 | ||
7 | namespace Datebook { | 8 | namespace Datebook { |
@@ -11,9 +12,10 @@ namespace Datebook { | |||
11 | */ | 12 | */ |
12 | template<class T> | 13 | template<class T> |
13 | class ManagerTemplate { | 14 | class ManagerTemplate { |
15 | typedef typename QMap<QString, T>::Iterator Iterator; | ||
14 | public: | 16 | public: |
15 | ManagerTemplate(); | 17 | ManagerTemplate(); |
16 | ~ManagerTemplate(); | 18 | virtual ~ManagerTemplate(); |
17 | 19 | ||
18 | virtual void add( const QString&, const T& t ); | 20 | virtual void add( const QString&, const T& t ); |
19 | void remove( const QString& ); | 21 | void remove( const QString& ); |
@@ -31,6 +33,41 @@ namespace Datebook { | |||
31 | virtual bool doLoad() = 0; | 33 | virtual bool doLoad() = 0; |
32 | 34 | ||
33 | }; | 35 | }; |
36 | template<class T> | ||
37 | ManagerTemplate<T>::ManagerTemplate() { | ||
38 | } | ||
39 | template<class T> | ||
40 | ManagerTemplate<T>::~ManagerTemplate() { | ||
41 | } | ||
42 | template<class T> | ||
43 | void ManagerTemplate<T>::add( const QString& str, const T& t ) { | ||
44 | m_map.insert( str, t ); | ||
45 | } | ||
46 | template<class T> | ||
47 | void ManagerTemplate<T>::remove( const QString& str ) { | ||
48 | m_map.remove( str ); | ||
49 | } | ||
50 | template<class T> | ||
51 | bool ManagerTemplate<T>::load() { | ||
52 | return doLoad(); | ||
53 | } | ||
54 | template<class T> | ||
55 | bool ManagerTemplate<T>::save() { | ||
56 | return doSave(); | ||
57 | } | ||
58 | template<class T> | ||
59 | QStringList ManagerTemplate<T>::names() { | ||
60 | QStringList lst; | ||
61 | Iterator it; | ||
62 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | ||
63 | lst << it.key(); | ||
64 | } | ||
65 | return lst; | ||
66 | } | ||
67 | template<class T> | ||
68 | T ManagerTemplate<T>::value( const QString& str)const { | ||
69 | return m_map[str]; | ||
70 | } | ||
34 | } | 71 | } |
35 | 72 | ||
36 | #endif | 73 | #endif |
diff --git a/core/pim/datebook2/show.cpp b/core/pim/datebook2/show.cpp new file mode 100644 index 0000000..ca06394 --- a/dev/null +++ b/core/pim/datebook2/show.cpp | |||
@@ -0,0 +1,25 @@ | |||
1 | #include "mainwindow.h" | ||
2 | #include "show.h" | ||
3 | |||
4 | using namespace Datebook; | ||
5 | |||
6 | Show::Show( MainWindow* win ) | ||
7 | : m_win(win ) { | ||
8 | } | ||
9 | Show::~Show() { | ||
10 | } | ||
11 | void Show::hideMe() { | ||
12 | m_win->hideShow(); | ||
13 | } | ||
14 | |||
15 | TextShow::TextShow( QWidget* parent, MainWindow* ) | ||
16 | : QTextView( parent ){ | ||
17 | } | ||
18 | TextShow::~TextShow() { | ||
19 | } | ||
20 | QWidget* TextShow::widget() { | ||
21 | return this; | ||
22 | } | ||
23 | void TextShow::show(const OEvent& ev) { | ||
24 | setText( ev.toRichText() ); | ||
25 | } | ||
diff --git a/core/pim/datebook2/show.h b/core/pim/datebook2/show.h index 37d22fe..72775a9 100644 --- a/core/pim/datebook2/show.h +++ b/core/pim/datebook2/show.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define OPIE_DATEBOOK_SHOW_H | 2 | #define OPIE_DATEBOOK_SHOW_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qtextview.h> | ||
5 | 6 | ||
6 | #include <opie/oevent.h> | 7 | #include <opie/oevent.h> |
7 | 8 | ||
@@ -25,7 +26,7 @@ namespace Datebook { | |||
25 | /** | 26 | /** |
26 | * show the OEvent | 27 | * show the OEvent |
27 | */ | 28 | */ |
28 | void show(const OEvent& str); | 29 | virtual void show(const OEvent& str) = 0; |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * the Widget | 32 | * the Widget |
@@ -38,6 +39,18 @@ namespace Datebook { | |||
38 | */ | 39 | */ |
39 | void hideMe(); | 40 | void hideMe(); |
40 | 41 | ||
42 | private: | ||
43 | MainWindow* m_win; | ||
44 | }; | ||
45 | class TextShow : public QTextView { | ||
46 | Q_OBJECT | ||
47 | public: | ||
48 | TextShow( QWidget* parent, MainWindow* win ); | ||
49 | ~TextShow(); | ||
50 | |||
51 | QWidget* widget(); | ||
52 | void show(const OEvent&); | ||
53 | |||
41 | }; | 54 | }; |
42 | } | 55 | } |
43 | 56 | ||
diff --git a/core/pim/datebook2/stringmanager.cpp b/core/pim/datebook2/stringmanager.cpp new file mode 100644 index 0000000..77bc88a --- a/dev/null +++ b/core/pim/datebook2/stringmanager.cpp | |||
@@ -0,0 +1,42 @@ | |||
1 | #include <qpe/config.h> | ||
2 | |||
3 | #include "stringmanager.h" | ||
4 | |||
5 | using namespace Datebook; | ||
6 | |||
7 | StringManager::StringManager( const QString& str ) | ||
8 | : m_base( str ) { | ||
9 | } | ||
10 | StringManager::~StringManager() { | ||
11 | |||
12 | } | ||
13 | void StringManager::add( const QString& str ) { | ||
14 | ManagerTemplate<QString>::add(str, str); | ||
15 | } | ||
16 | bool StringManager::doLoad() { | ||
17 | Config qpe( "datebook-"+m_base ); | ||
18 | qpe.setGroup(m_base ); | ||
19 | QStringList list = qpe.readListEntry( "Names", 0x1f ); | ||
20 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | ||
21 | add( (*it) ); | ||
22 | |||
23 | return true; | ||
24 | } | ||
25 | bool StringManager::doSave() { | ||
26 | Config qpe( "datebook"+m_base ); | ||
27 | qpe.setGroup(m_base); | ||
28 | qpe.writeEntry( "Names", names(), 0x1f ); | ||
29 | |||
30 | return false; | ||
31 | } | ||
32 | |||
33 | |||
34 | StringManagerDialog::StringManagerDialog(const StringManager& ) | ||
35 | : QDialog(0, 0, true ) { | ||
36 | } | ||
37 | StringManagerDialog::~StringManagerDialog() { | ||
38 | |||
39 | } | ||
40 | StringManager StringManagerDialog::manager()const { | ||
41 | return StringManager(); | ||
42 | } | ||
diff --git a/core/pim/datebook2/stringmanager.h b/core/pim/datebook2/stringmanager.h index a11bd2a..ac0d4bd 100644 --- a/core/pim/datebook2/stringmanager.h +++ b/core/pim/datebook2/stringmanager.h | |||
@@ -17,7 +17,7 @@ namespace Datebook { | |||
17 | /** | 17 | /** |
18 | * baseName is used for storing | 18 | * baseName is used for storing |
19 | */ | 19 | */ |
20 | StringManager(const QString& baseName); | 20 | StringManager(const QString& baseName = QString::null); |
21 | ~StringManager(); | 21 | ~StringManager(); |
22 | 22 | ||
23 | /** | 23 | /** |
@@ -26,8 +26,9 @@ namespace Datebook { | |||
26 | */ | 26 | */ |
27 | void add( const QString& ); | 27 | void add( const QString& ); |
28 | private: | 28 | private: |
29 | void doLoad(); | 29 | QString m_base; |
30 | void doSave(); | 30 | bool doLoad(); |
31 | bool doSave(); | ||
31 | }; | 32 | }; |
32 | 33 | ||
33 | /** | 34 | /** |
@@ -36,8 +37,8 @@ namespace Datebook { | |||
36 | class StringManagerDialog : public QDialog { | 37 | class StringManagerDialog : public QDialog { |
37 | Q_OBJECT | 38 | Q_OBJECT |
38 | public: | 39 | public: |
39 | StringManagerDialog( const StringManager& ); | 40 | StringManagerDialog( const StringManager&); |
40 | ~StringManager(); | 41 | ~StringManagerDialog(); |
41 | 42 | ||
42 | StringManager manager()const; | 43 | StringManager manager()const; |
43 | }; | 44 | }; |
diff --git a/core/pim/datebook2/templatemanager.cpp b/core/pim/datebook2/templatemanager.cpp new file mode 100644 index 0000000..b620cf7 --- a/dev/null +++ b/core/pim/datebook2/templatemanager.cpp | |||
@@ -0,0 +1,25 @@ | |||
1 | #include "templatemanager.h" | ||
2 | |||
3 | using namespace Datebook; | ||
4 | |||
5 | |||
6 | TemplateManager::TemplateManager() { | ||
7 | |||
8 | } | ||
9 | TemplateManager::~TemplateManager() { | ||
10 | } | ||
11 | bool TemplateManager::doSave() { | ||
12 | return true; | ||
13 | } | ||
14 | bool TemplateManager::doLoad() { | ||
15 | return true; | ||
16 | } | ||
17 | |||
18 | TemplateDialog::TemplateDialog( const TemplateManager& ) | ||
19 | : QDialog(0, 0, true ) { | ||
20 | } | ||
21 | TemplateDialog::~TemplateDialog() { | ||
22 | } | ||
23 | TemplateManager TemplateDialog::manager()const { | ||
24 | return TemplateManager(); | ||
25 | } | ||
diff --git a/core/pim/datebook2/view.cpp b/core/pim/datebook2/view.cpp new file mode 100644 index 0000000..b07c89a --- a/dev/null +++ b/core/pim/datebook2/view.cpp | |||
@@ -0,0 +1,62 @@ | |||
1 | |||
2 | #include <opie/odatebookaccess.h> | ||
3 | |||
4 | #include "bookmanager.h" | ||
5 | #include "mainwindow.h" | ||
6 | #include "view.h" | ||
7 | |||
8 | using namespace Datebook; | ||
9 | |||
10 | View::View( MainWindow* window, QWidget* ) { | ||
11 | m_win = window; | ||
12 | } | ||
13 | View::~View() { | ||
14 | } | ||
15 | QDate View::dateFromWeek( int week, int year, bool startOnMon ) { | ||
16 | |||
17 | } | ||
18 | bool View::calcWeek( const QDate& d, int & week, int & year, bool ) { | ||
19 | |||
20 | } | ||
21 | void View::loadConfig( Config* conf ) { | ||
22 | doLoadConfig( conf ); | ||
23 | } | ||
24 | void View::saveConfig( Config* conf ) { | ||
25 | doSaveConfig( conf ); | ||
26 | } | ||
27 | void View::popup( int uid ) { | ||
28 | m_win->viewPopup( uid ); | ||
29 | } | ||
30 | void View::add( const QDate& start ) { | ||
31 | m_win->viewAdd( start ); | ||
32 | } | ||
33 | void View::add( const QDateTime& start, const QDateTime& end ) { | ||
34 | m_win->viewAdd( start, end ); | ||
35 | } | ||
36 | void View::edit( int uid ) { | ||
37 | m_win->edit( uid ); | ||
38 | } | ||
39 | void View::remove( int uid ) { | ||
40 | m_win->remove( uid ); | ||
41 | } | ||
42 | ODateBookAccess::List View::allEvents() const{ | ||
43 | return m_win->manager()->allRecords(); | ||
44 | } | ||
45 | OEffectiveEvent::ValueList View::events( const QDate& from, const QDate& to ) { | ||
46 | return m_win->manager()->list( from, to ); | ||
47 | } | ||
48 | OEvent View::event( int uid ) const{ | ||
49 | return m_win->manager()->event( uid ); | ||
50 | } | ||
51 | bool View::isAP()const { | ||
52 | return m_win->viewAP(); | ||
53 | } | ||
54 | bool View::weekStartOnMonday()const { | ||
55 | return m_win->viewStartMonday(); | ||
56 | } | ||
57 | QList<OPimRecord> View::records( const QDate& on ) { | ||
58 | return m_win->manager()->records( on, on ); | ||
59 | } | ||
60 | QList<OPimRecord> View::records( const QDate& on, const QDate& to ) { | ||
61 | return m_win->manager()->records( on, to ); | ||
62 | } | ||
diff --git a/core/pim/datebook2/view.h b/core/pim/datebook2/view.h index a7bc1d8..e2312a3 100644 --- a/core/pim/datebook2/view.h +++ b/core/pim/datebook2/view.h | |||
@@ -13,7 +13,7 @@ namespace Datebook { | |||
13 | class View { | 13 | class View { |
14 | public: | 14 | public: |
15 | View( MainWindow* window, QWidget* parent ); | 15 | View( MainWindow* window, QWidget* parent ); |
16 | virtual ~View() = 0; | 16 | virtual ~View(); |
17 | 17 | ||
18 | static QDate dateFromWeek( int week, int year, bool startOnMonda ); | 18 | static QDate dateFromWeek( int week, int year, bool startOnMonda ); |
19 | static bool calcWeek( const QDate& d, int &week, int &year, bool startOnMonday = false ); | 19 | static bool calcWeek( const QDate& d, int &week, int &year, bool startOnMonday = false ); |
@@ -22,6 +22,11 @@ namespace Datebook { | |||
22 | virtual QString description()const = 0; | 22 | virtual QString description()const = 0; |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * return the uid of the current item or 0 | ||
26 | */ | ||
27 | virtual int currentItem()const = 0; | ||
28 | |||
29 | /** | ||
25 | * loadConfig | 30 | * loadConfig |
26 | * saveConfig | 31 | * saveConfig |
27 | */ | 32 | */ |
@@ -30,8 +35,10 @@ namespace Datebook { | |||
30 | 35 | ||
31 | /** | 36 | /** |
32 | * the current range | 37 | * the current range |
38 | * @param src Where to write the start datetime | ||
39 | * @param dest Where to write the end datetime | ||
33 | */ | 40 | */ |
34 | void currentRange( const QDateTime& src, const QDateTime& from); | 41 | virtual void currentRange( const QDateTime& src, const QDateTime& from) = 0; |
35 | 42 | ||
36 | /** | 43 | /** |
37 | * the clock format changed | 44 | * the clock format changed |
@@ -46,20 +53,21 @@ namespace Datebook { | |||
46 | 53 | ||
47 | /** | 54 | /** |
48 | * show date in your view!! | 55 | * show date in your view!! |
56 | * make the date visible in the current view | ||
49 | */ | 57 | */ |
50 | virtual void showDay( const QDate& date ) = 0; | 58 | virtual void showDay( const QDate& date ) = 0; |
51 | 59 | ||
52 | /** | 60 | /** |
53 | * return the widget | 61 | * return the widget |
54 | */ | 62 | */ |
55 | virtual QWidget* widget(); | 63 | virtual QWidget* widget() = 0; |
56 | 64 | ||
57 | /** | 65 | /** |
58 | * the view needs an update! | 66 | * the view needs an update! |
59 | */ | 67 | */ |
60 | virtual void reschedule() = 0 | 68 | virtual void reschedule() = 0; |
61 | protected: | 69 | protected: |
62 | void popup( int ); | 70 | void popup( int uid); |
63 | QString toShortText(const OEffectiveEvent& eff)const; | 71 | QString toShortText(const OEffectiveEvent& eff)const; |
64 | QString toText(const OEffectiveEvent& eff)const; | 72 | QString toText(const OEffectiveEvent& eff)const; |
65 | virtual void doLoadConfig( Config* ) = 0; | 73 | virtual void doLoadConfig( Config* ) = 0; |
@@ -114,8 +122,11 @@ namespace Datebook { | |||
114 | /** | 122 | /** |
115 | * return related records for days | 123 | * return related records for days |
116 | */ | 124 | */ |
117 | QPtrList<OPimRecord> records( const QDate& on ); | 125 | QList<OPimRecord> records( const QDate& on ); |
118 | QPtrList<OPimRecord> records( const QDate& start, const QDate& to ); | 126 | QList<OPimRecord> records( const QDate& start, const QDate& to ); |
127 | |||
128 | private: | ||
129 | MainWindow* m_win; | ||
119 | }; | 130 | }; |
120 | } | 131 | } |
121 | 132 | ||