summaryrefslogtreecommitdiff
authorzecke <zecke>2003-02-23 21:27:08 (UTC)
committer zecke <zecke>2003-02-23 21:27:08 (UTC)
commit041eda0d7482d60cd67731b81fd36104fcd3120f (patch) (unidiff)
treec7bc7730b9e76e22f828291d404821f7bd922d6f
parenta195865dfdb03b4c7c972acfc8cfd87743ab3e6f (diff)
downloadopie-041eda0d7482d60cd67731b81fd36104fcd3120f.zip
opie-041eda0d7482d60cd67731b81fd36104fcd3120f.tar.gz
opie-041eda0d7482d60cd67731b81fd36104fcd3120f.tar.bz2
Implement some of the new framework
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook2/bookmanager.cpp67
-rw-r--r--core/pim/datebook2/bookmanager.h7
-rw-r--r--core/pim/datebook2/datebook2.pro19
-rw-r--r--core/pim/datebook2/mainwindow.cpp178
-rw-r--r--core/pim/datebook2/mainwindow.h60
-rw-r--r--core/pim/datebook2/managertemplate.h39
-rw-r--r--core/pim/datebook2/show.cpp25
-rw-r--r--core/pim/datebook2/show.h15
-rw-r--r--core/pim/datebook2/stringmanager.cpp42
-rw-r--r--core/pim/datebook2/stringmanager.h9
-rw-r--r--core/pim/datebook2/templatemanager.cpp25
-rw-r--r--core/pim/datebook2/view.cpp62
-rw-r--r--core/pim/datebook2/view.h25
13 files changed, 545 insertions, 28 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
3using namespace Datebook;
4
5BookManager::BookManager() {
6 m_db = 0;
7}
8BookManager::~BookManager() {
9 delete m_db;
10}
11void BookManager::add( const OEvent& ev) {
12 if (!m_db ) return;
13
14 m_db->add( ev );
15}
16void 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}
20void BookManager::update( const OEvent& up) {
21 if ( !m_db ) return;
22 m_db->replace( up );
23}
24void BookManager::remove( int uid ) {
25 if ( !m_db ) return;
26 m_db->remove( uid );
27}
28void BookManager::remove( const QArray<int>& ar) {
29 uint count = ar.count();
30 for (uint i = 0; i < count; i++ )
31 remove( ar[i] );
32}
33QList<OPimRecord> BookManager::records( const QDate& , const QDate& ) {
34 return QList<OPimRecord>();
35}
36bool BookManager::isLoaded() const{
37 return ( m_db != 0 );
38}
39bool BookManager::load() {
40 m_db = new ODateBookAccess;
41 return m_db->load();
42}
43void BookManager::reload() {
44 if (!m_db ) return;
45
46 m_db->reload();
47}
48OEvent BookManager::event( int uid ) {
49 if (!m_db ) return OEvent();
50
51 return m_db->find( uid );
52}
53ODateBookAccess::List BookManager::allRecords()const {
54 if (!m_db) return ODateBookAccess::List();
55
56 return m_db->rawEvents();
57}
58OEffectiveEvent::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}
64bool 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
8INCLUDEPATH += $(OPIEDIR)/include 23INCLUDEPATH += $(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
16MainWindow::MainWindow() 24MainWindow::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}
26MainWindow::~MainWindow() { 43MainWindow::~MainWindow() {
27
28} 44}
29void MainWindow::doSetDocument( const QString& str ) { 45void MainWindow::doSetDocument( const QString& str ) {
30 46
31} 47}
32void MainWindow::flush() { 48void MainWindow::flush() {
33 49 manager()->save();
34} 50}
35void MainWindow::reload() { 51void MainWindow::reload() {
36 52 manager()->reload();
37} 53}
38int MainWindow::create() { 54int MainWindow::create() {
39 55 return 0;
40} 56}
41bool MainWindow::remove( int uid ) { 57bool MainWindow::remove( int uid ) {
42 58 manager()->remove( uid );
59 return true;
43} 60}
44void MainWindow::beam( int uid ) { 61void MainWindow::beam( int uid ) {
45 62
46} 63}
47void MainWindow::show( int uid ) { 64void MainWindow::show( int uid ) {
48 65
66 eventShow()->show( manager()->event( uid ) );
49} 67}
50void MainWindow::add( const OPimRecord& ) { 68void MainWindow::add( const OPimRecord& ad) {
51 69 manager()->add( ad );
70}
71void MainWindow::edit() {
72 edit ( currentView()->currentItem() );
52} 73}
53void MainWindow::edit( int uid ) { 74void MainWindow::edit( int uid ) {
54 75
55} 76}
77/*
78 * init tool bars layout and so on
79 */
56void MainWindow::initUI() { 80void 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}
59void MainWindow::initConfig() { 141void MainWindow::initConfig() {
60 142
@@ -63,8 +145,82 @@ void MainWindow::initView() {
63 145
64} 146}
65void MainWindow::initManagers() { 147void MainWindow::initManagers() {
66 148 m_manager = new BookManager;
149 m_locMan = new LocationManager( tr("Locations") );
150 m_descMan = new DescriptionManager( tr("Descriptions") );
67} 151}
68void MainWindow::raiseCurrentView() { 152void MainWindow::raiseCurrentView() {
69 153
70} 154}
155/*
156 * populate the view
157 */
158void MainWindow::populate() {
159 if (!manager()->isLoaded() )
160 manager()->load();
161}
162void MainWindow::slotGoToNow() {
163
164}
165View* MainWindow::currentView() {
166
167}
168void MainWindow::slotFind() {
169
170}
171void MainWindow::slotConfigure() {
172
173}
174void MainWindow::slotClockChanged( bool ) {
175
176}
177void MainWindow::slotWeekChanged(bool ) {
178
179}
180void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) {
181
182}
183void MainWindow::slotReceive( const QCString&, const QByteArray& ) {
184
185}
186BookManager* MainWindow::manager() {
187 return m_manager;
188}
189TemplateManager* MainWindow::templateManager() {
190 return m_tempMan;
191}
192LocationManager* MainWindow::locationManager() {
193 return m_locMan;
194}
195DescriptionManager* MainWindow::descriptionManager() {
196 return m_descMan;
197}
198Show* MainWindow::eventShow() {
199 return m_show;
200}
201void MainWindow::slotAction( QAction* act ) {
202
203}
204void MainWindow::slotConfigureLocs() {
205
206}
207void MainWindow::slotConfigureDesc() {
208
209}
210void MainWindow::hideShow() {
211
212}
213void MainWindow::viewPopup(int ) {
214
215}
216void MainWindow::viewAdd(const QDate& ) {
217
218}
219void MainWindow::viewAdd( const QDateTime&, const QDateTime& ) {
220
221}
222bool MainWindow::viewAP()const{
223}
224bool 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
12class QAction;
13class QWidgetStack;
14class QPopupMenu;
15class QPEToolBar;
8namespace Datebook { 16namespace 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
7namespace Datebook { 8namespace 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
4using namespace Datebook;
5
6Show::Show( MainWindow* win )
7 : m_win(win ) {
8}
9Show::~Show() {
10}
11void Show::hideMe() {
12 m_win->hideShow();
13}
14
15TextShow::TextShow( QWidget* parent, MainWindow* )
16 : QTextView( parent ){
17}
18TextShow::~TextShow() {
19}
20QWidget* TextShow::widget() {
21 return this;
22}
23void 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
5using namespace Datebook;
6
7StringManager::StringManager( const QString& str )
8 : m_base( str ) {
9}
10StringManager::~StringManager() {
11
12}
13void StringManager::add( const QString& str ) {
14 ManagerTemplate<QString>::add(str, str);
15}
16bool 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}
25bool 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
34StringManagerDialog::StringManagerDialog(const StringManager& )
35 : QDialog(0, 0, true ) {
36}
37StringManagerDialog::~StringManagerDialog() {
38
39}
40StringManager 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 /**
@@ -37,7 +38,7 @@ namespace Datebook {
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
3using namespace Datebook;
4
5
6TemplateManager::TemplateManager() {
7
8}
9TemplateManager::~TemplateManager() {
10}
11bool TemplateManager::doSave() {
12 return true;
13}
14bool TemplateManager::doLoad() {
15 return true;
16}
17
18TemplateDialog::TemplateDialog( const TemplateManager& )
19 : QDialog(0, 0, true ) {
20}
21TemplateDialog::~TemplateDialog() {
22}
23TemplateManager 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
8using namespace Datebook;
9
10View::View( MainWindow* window, QWidget* ) {
11 m_win = window;
12}
13View::~View() {
14}
15QDate View::dateFromWeek( int week, int year, bool startOnMon ) {
16
17}
18bool View::calcWeek( const QDate& d, int & week, int & year, bool ) {
19
20}
21void View::loadConfig( Config* conf ) {
22 doLoadConfig( conf );
23}
24void View::saveConfig( Config* conf ) {
25 doSaveConfig( conf );
26}
27void View::popup( int uid ) {
28 m_win->viewPopup( uid );
29}
30void View::add( const QDate& start ) {
31 m_win->viewAdd( start );
32}
33void View::add( const QDateTime& start, const QDateTime& end ) {
34 m_win->viewAdd( start, end );
35}
36void View::edit( int uid ) {
37 m_win->edit( uid );
38}
39void View::remove( int uid ) {
40 m_win->remove( uid );
41}
42ODateBookAccess::List View::allEvents() const{
43 return m_win->manager()->allRecords();
44}
45OEffectiveEvent::ValueList View::events( const QDate& from, const QDate& to ) {
46 return m_win->manager()->list( from, to );
47}
48OEvent View::event( int uid ) const{
49 return m_win->manager()->event( uid );
50}
51bool View::isAP()const {
52 return m_win->viewAP();
53}
54bool View::weekStartOnMonday()const {
55 return m_win->viewStartMonday();
56}
57QList<OPimRecord> View::records( const QDate& on ) {
58 return m_win->manager()->records( on, on );
59}
60QList<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