-rw-r--r-- | core/pim/datebook2/datebook2.pro | 3 | ||||
-rw-r--r-- | core/pim/datebook2/editor.cpp | 24 | ||||
-rw-r--r-- | core/pim/datebook2/editor.h | 13 | ||||
-rw-r--r-- | core/pim/datebook2/mainwindow.cpp | 97 | ||||
-rw-r--r-- | core/pim/datebook2/mainwindow.h | 24 | ||||
-rw-r--r-- | core/pim/datebook2/managertemplate.h | 23 | ||||
-rw-r--r-- | core/pim/datebook2/stringmanager.cpp | 108 | ||||
-rw-r--r-- | core/pim/datebook2/stringmanager.h | 14 | ||||
-rw-r--r-- | core/pim/datebook2/templatemanager.cpp | 167 | ||||
-rw-r--r-- | core/pim/datebook2/templatemanager.h | 22 | ||||
-rw-r--r-- | core/pim/datebook2/view.h | 10 |
11 files changed, 447 insertions, 58 deletions
diff --git a/core/pim/datebook2/datebook2.pro b/core/pim/datebook2/datebook2.pro index 2ad906e..0b59309 100644 --- a/core/pim/datebook2/datebook2.pro +++ b/core/pim/datebook2/datebook2.pro | |||
@@ -1,28 +1,29 @@ | |||
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 \ | 5 | bookmanager.h \ |
6 | locationmanager.h \ | 6 | locationmanager.h \ |
7 | show.h \ | 7 | show.h \ |
8 | view.h \ | 8 | view.h \ |
9 | descriptionmanager.h \ | 9 | descriptionmanager.h \ |
10 | stringmanager.h \ | 10 | stringmanager.h \ |
11 | editor.h \ | 11 | editor.h \ |
12 | managertemplate.h \ | 12 | managertemplate.h \ |
13 | templatemanager.h | 13 | templatemanager.h |
14 | 14 | ||
15 | SOURCES= main.cpp \ | 15 | SOURCES= main.cpp \ |
16 | mainwindow.cpp \ | 16 | mainwindow.cpp \ |
17 | bookmanager.cpp \ | 17 | bookmanager.cpp \ |
18 | stringmanager.cpp \ | 18 | stringmanager.cpp \ |
19 | templatemanager.cpp \ | 19 | templatemanager.cpp \ |
20 | show.cpp \ | 20 | show.cpp \ |
21 | view.cpp | 21 | view.cpp \ |
22 | editor.cpp | ||
22 | 23 | ||
23 | INCLUDEPATH += $(OPIEDIR)/include | 24 | INCLUDEPATH += $(OPIEDIR)/include |
24 | DEPENDPATH+= $(OPIEDIR)/include | 25 | DEPENDPATH+= $(OPIEDIR)/include |
25 | LIBS += -lqpe -lopie | 26 | LIBS += -lqpe -lopie |
26 | TARGET = datebook2 | 27 | TARGET = datebook2 |
27 | 28 | ||
28 | include ( $(OPIEDIR)/include.pro ) | 29 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/core/pim/datebook2/editor.cpp b/core/pim/datebook2/editor.cpp new file mode 100644 index 0000000..a51aab6 --- a/dev/null +++ b/core/pim/datebook2/editor.cpp | |||
@@ -0,0 +1,24 @@ | |||
1 | #include "mainwindow.h" | ||
2 | |||
3 | #include "editor.h" | ||
4 | |||
5 | using namespace Datebook; | ||
6 | |||
7 | Editor::Editor( MainWindow* win, QWidget*) | ||
8 | : m_win( win ) | ||
9 | {} | ||
10 | Editor::~Editor() { | ||
11 | |||
12 | } | ||
13 | DescriptionManager Editor::descriptions()const { | ||
14 | return m_win->descriptionManager(); | ||
15 | } | ||
16 | LocationManager Editor::locations()const { | ||
17 | return m_win->locationManager(); | ||
18 | } | ||
19 | void Editor::setDescriptions( const DescriptionManager& dsc) { | ||
20 | m_win->setDescriptionManager( dsc ); | ||
21 | } | ||
22 | void Editor::setLocations( const LocationManager& loc) { | ||
23 | m_win->setLocationManager( loc ); | ||
24 | } | ||
diff --git a/core/pim/datebook2/editor.h b/core/pim/datebook2/editor.h index 53e8718..3fcfaa4 100644 --- a/core/pim/datebook2/editor.h +++ b/core/pim/datebook2/editor.h | |||
@@ -1,36 +1,39 @@ | |||
1 | #ifndef OPIE_DATEBOOK_EDITOR_H | 1 | #ifndef OPIE_DATEBOOK_EDITOR_H |
2 | #define OPIE_DATEBOOK_EDITOR_H | 2 | #define OPIE_DATEBOOK_EDITOR_H |
3 | 3 | ||
4 | #include <qdialog.h> | 4 | #include <qdialog.h> |
5 | 5 | ||
6 | #include <opie/oevent.h> | 6 | #include <opie/oevent.h> |
7 | 7 | ||
8 | #include "descriptionmanager.h" | 8 | #include "descriptionmanager.h" |
9 | #include "locationmanager.h" | 9 | #include "locationmanager.h" |
10 | 10 | ||
11 | namespace Datebook { | 11 | namespace Datebook { |
12 | class MainWindow; | 12 | class MainWindow; |
13 | /** | 13 | /** |
14 | * This is the editor interface | 14 | * This is the editor interface |
15 | */ | 15 | */ |
16 | class Editor { | 16 | class Editor { |
17 | public: | 17 | public: |
18 | Editor( MainWindow*, QWidget* parent ); | 18 | Editor( MainWindow*, QWidget* parent ); |
19 | virtual Editor(); | 19 | virtual ~Editor(); |
20 | 20 | ||
21 | bool newEvent( const QDate& ); | 21 | virtual bool newEvent( const QDate& ) = 0; |
22 | bool newEvent( const QDateTime& start, const QDateTime& end ); | 22 | virtual bool newEvent( const QDateTime& start, const QDateTime& end ) = 0; |
23 | bool edit( const OEvent& ); | 23 | virtual bool edit( const OEvent&, bool showRec = TRUE ) = 0; |
24 | 24 | ||
25 | OEvent event()const; | 25 | virtual OEvent event()const = 0; |
26 | 26 | ||
27 | protected: | 27 | protected: |
28 | DescriptionManager descriptions()const; | 28 | DescriptionManager descriptions()const; |
29 | LocationManager locations()const; | 29 | LocationManager locations()const; |
30 | void setDescriptions( const DescriptionManager& ); | 30 | void setDescriptions( const DescriptionManager& ); |
31 | void setLocations( const LocationManager& ); | 31 | void setLocations( const LocationManager& ); |
32 | 32 | ||
33 | private: | ||
34 | MainWindow* m_win; | ||
35 | |||
33 | }; | 36 | }; |
34 | } | 37 | } |
35 | 38 | ||
36 | #endif | 39 | #endif |
diff --git a/core/pim/datebook2/mainwindow.cpp b/core/pim/datebook2/mainwindow.cpp index 44de6b0..68525b3 100644 --- a/core/pim/datebook2/mainwindow.cpp +++ b/core/pim/datebook2/mainwindow.cpp | |||
@@ -1,226 +1,305 @@ | |||
1 | 1 | ||
2 | #include <qcopchannel_qws.h> | 2 | #include <qcopchannel_qws.h> |
3 | #include <qwidgetstack.h> | 3 | #include <qwidgetstack.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qaction.h> | 5 | #include <qaction.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtimer.h> | 7 | #include <qtimer.h> |
8 | 8 | ||
9 | #include <qpe/qpeapplication.h> | 9 | #include <qpe/qpeapplication.h> |
10 | #include <qpe/ir.h> | 10 | #include <qpe/ir.h> |
11 | #include <qpe/qpemenubar.h> | 11 | #include <qpe/qpemenubar.h> |
12 | #include <qpe/qpetoolbar.h> | 12 | #include <qpe/qpetoolbar.h> |
13 | #include <qpe/qpemessagebox.h> | 13 | #include <qpe/qpemessagebox.h> |
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | 15 | ||
16 | #include "editor.h" | ||
16 | #include "show.h" | 17 | #include "show.h" |
17 | #include "templatemanager.h" | 18 | #include "templatemanager.h" |
18 | #include "bookmanager.h" | 19 | #include "bookmanager.h" |
19 | #include "mainwindow.h" | 20 | #include "mainwindow.h" |
20 | 21 | ||
21 | 22 | ||
22 | using namespace Datebook; | 23 | using namespace Datebook; |
23 | 24 | ||
24 | MainWindow::MainWindow() | 25 | MainWindow::MainWindow() |
25 | : OPimMainWindow( "Datebook", 0, 0 ) { | 26 | : OPimMainWindow( "Datebook", 0, 0 ), m_descMan( "Descriptions" ), m_locMan( "Locations" ) |
27 | { | ||
26 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | 28 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); |
27 | initUI(); | 29 | initUI(); |
28 | initManagers(); | 30 | initManagers(); |
29 | initView(); | 31 | initView(); |
30 | initConfig(); | 32 | initConfig(); |
31 | 33 | ||
32 | raiseCurrentView(); | ||
33 | QTimer::singleShot(0, this, SLOT(populate() ) ); | 34 | QTimer::singleShot(0, this, SLOT(populate() ) ); |
34 | 35 | ||
35 | QCopChannel* chan = new QCopChannel( "QPE/System", this ); | 36 | QCopChannel* chan = new QCopChannel( "QPE/System", this ); |
36 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), | 37 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), |
37 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); | 38 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); |
38 | 39 | ||
39 | chan = new QCopChannel( "QPE/Datebook", this ); | 40 | chan = new QCopChannel( "QPE/Datebook", this ); |
40 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), | 41 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), |
41 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); | 42 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); |
42 | } | 43 | } |
43 | MainWindow::~MainWindow() { | 44 | MainWindow::~MainWindow() { |
45 | m_tempMan.save(); | ||
46 | m_locMan.save(); | ||
47 | m_descMan.save(); | ||
48 | |||
49 | manager()->save(); | ||
50 | delete m_manager; | ||
44 | } | 51 | } |
45 | void MainWindow::doSetDocument( const QString& str ) { | 52 | void MainWindow::doSetDocument( const QString& str ) { |
46 | 53 | ||
47 | } | 54 | } |
48 | void MainWindow::flush() { | 55 | void MainWindow::flush() { |
49 | manager()->save(); | 56 | manager()->save(); |
50 | } | 57 | } |
51 | void MainWindow::reload() { | 58 | void MainWindow::reload() { |
52 | manager()->reload(); | 59 | manager()->reload(); |
53 | } | 60 | } |
54 | int MainWindow::create() { | 61 | int MainWindow::create() { |
55 | return 0; | 62 | return 0; |
56 | } | 63 | } |
57 | bool MainWindow::remove( int uid ) { | 64 | bool MainWindow::remove( int uid ) { |
58 | manager()->remove( uid ); | 65 | manager()->remove( uid ); |
59 | return true; | 66 | return true; |
60 | } | 67 | } |
61 | void MainWindow::beam( int uid ) { | 68 | void MainWindow::beam( int uid ) { |
62 | 69 | ||
63 | } | 70 | } |
64 | void MainWindow::show( int uid ) { | 71 | void MainWindow::show( int uid ) { |
65 | 72 | ||
66 | eventShow()->show( manager()->event( uid ) ); | 73 | eventShow()->show( manager()->event( uid ) ); |
67 | } | 74 | } |
68 | void MainWindow::add( const OPimRecord& ad) { | 75 | void MainWindow::add( const OPimRecord& ad) { |
69 | manager()->add( ad ); | 76 | manager()->add( ad ); |
70 | } | 77 | } |
71 | void MainWindow::edit() { | 78 | void MainWindow::edit() { |
72 | edit ( currentView()->currentItem() ); | 79 | edit ( currentView()->currentItem() ); |
73 | } | 80 | } |
74 | void MainWindow::edit( int uid ) { | 81 | void MainWindow::edit( int uid ) { |
75 | 82 | ||
76 | } | 83 | } |
77 | /* | 84 | /* |
78 | * init tool bars layout and so on | 85 | * init tool bars layout and so on |
79 | */ | 86 | */ |
80 | void MainWindow::initUI() { | 87 | void MainWindow::initUI() { |
81 | setToolBarsMovable( false ); | 88 | setToolBarsMovable( false ); |
82 | 89 | ||
83 | m_stack = new QWidgetStack( this ); | 90 | m_stack = new QWidgetStack( this ); |
84 | setCentralWidget( m_stack ); | 91 | setCentralWidget( m_stack ); |
85 | 92 | ||
86 | m_toolBar = new QPEToolBar( this ); | 93 | m_toolBar = new QPEToolBar( this ); |
87 | m_toolBar->setHorizontalStretchable( TRUE ); | 94 | m_toolBar->setHorizontalStretchable( TRUE ); |
88 | 95 | ||
89 | QPEMenuBar* mb = new QPEMenuBar( m_toolBar ); | 96 | QPEMenuBar* mb = new QPEMenuBar( m_toolBar ); |
90 | 97 | ||
91 | m_popView = new QPopupMenu( this ); | 98 | m_popView = new QPopupMenu( this ); |
92 | m_popSetting = new QPopupMenu( this ); | 99 | m_popSetting = new QPopupMenu( this ); |
93 | 100 | ||
94 | mb->insertItem( tr("View"), m_popView ); | 101 | mb->insertItem( tr("View"), m_popView ); |
95 | mb->insertItem( tr("Settings" ), m_popSetting ); | 102 | mb->insertItem( tr("Settings" ), m_popSetting ); |
96 | 103 | ||
97 | m_popTemplate = new QPopupMenu( this ); | 104 | m_popTemplate = new QPopupMenu( this ); |
105 | m_popTemplate->setCheckable( TRUE ); | ||
106 | connect( m_popTemplate, SIGNAL(activated(int) ), | ||
107 | this, SLOT(slotNewFromTemplate(int) ) ); | ||
98 | m_popView->insertItem(tr("New from template"), m_popTemplate, -1, 0); | 108 | m_popView->insertItem(tr("New from template"), m_popTemplate, -1, 0); |
99 | 109 | ||
110 | |||
100 | QAction* a = new QAction( tr("New Event"), Resource::loadPixmap("new"), | 111 | QAction* a = new QAction( tr("New Event"), Resource::loadPixmap("new"), |
101 | QString::null, 0, this, 0 ); | 112 | QString::null, 0, this, 0 ); |
102 | a->addTo( m_toolBar ); | 113 | a->addTo( m_toolBar ); |
103 | a->addTo( m_popView ); | 114 | a->addTo( m_popView ); |
104 | connect(a, SIGNAL( activated() ), this, SLOT( create() ) ); | 115 | connect(a, SIGNAL( activated() ), this, SLOT( create() ) ); |
105 | 116 | ||
106 | a = new QAction( tr("Edit Event"), Resource::loadPixmap("edit"), | 117 | a = new QAction( tr("Edit Event"), Resource::loadPixmap("edit"), |
107 | QString::null, 0, this, 0 ); | 118 | QString::null, 0, this, 0 ); |
108 | a->addTo( m_popView ); | 119 | a->addTo( m_popView ); |
109 | connect(a, SIGNAL( activated() ), this, SLOT( edit() ) ); | 120 | connect(a, SIGNAL( activated() ), this, SLOT( edit() ) ); |
110 | 121 | ||
111 | a = new QAction( tr("Today" ), Resource::loadPixmap( "datebook/to_day"), | 122 | a = new QAction( tr("Today" ), Resource::loadPixmap( "datebook/to_day"), |
112 | QString::null, 0, this, 0 ); | 123 | QString::null, 0, this, 0 ); |
113 | a->addTo( m_toolBar ); | 124 | a->addTo( m_toolBar ); |
114 | connect(a, SIGNAL( activated() ), this, SLOT( slotGoToNow() ) ); | 125 | connect(a, SIGNAL( activated() ), this, SLOT( slotGoToNow() ) ); |
115 | 126 | ||
116 | a = new QAction( tr("Find"), Resource::loadPixmap( "mag" ), | 127 | a = new QAction( tr("Find"), Resource::loadPixmap( "mag" ), |
117 | QString::null, 0, this, 0 ); | 128 | QString::null, 0, this, 0 ); |
118 | a->addTo( m_toolBar ); | 129 | a->addTo( m_toolBar ); |
119 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 130 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
120 | 131 | ||
121 | a = new QAction( tr("Configure"), QString::null, 0, 0 ); | 132 | a = new QAction( tr("Configure"), QString::null, 0, 0 ); |
122 | a->addTo( m_popSetting ); | 133 | a->addTo( m_popSetting ); |
123 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); | 134 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); |
124 | 135 | ||
125 | a = new QAction( tr("Configure Locations"), QString::null, 0, 0 ); | 136 | a = new QAction( tr("Configure Locations"), QString::null, 0, 0 ); |
126 | a->addTo( m_popSetting ); | 137 | a->addTo( m_popSetting ); |
127 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigureLocs() ) ); | 138 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigureLocs() ) ); |
128 | 139 | ||
129 | a = new QAction( tr("Configure Descriptions"), QString::null, 0, 0 ); | 140 | a = new QAction( tr("Configure Descriptions"), QString::null, 0, 0 ); |
130 | a->addTo( m_popSetting ); | 141 | a->addTo( m_popSetting ); |
131 | connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) ); | 142 | connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) ); |
132 | 143 | ||
144 | a = new QAction( tr("Configure Templates"), QString::null, 0, 0 ); | ||
145 | a->addTo( m_popSetting ); | ||
146 | connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureTemp() ) ); | ||
147 | |||
133 | connect( qApp, SIGNAL(clockChanged(bool) ), | 148 | connect( qApp, SIGNAL(clockChanged(bool) ), |
134 | this, SLOT(slotClockChanged(bool) ) ); | 149 | this, SLOT(slotClockChanged(bool) ) ); |
135 | connect( qApp, SIGNAL(weekChanged(bool) ), | 150 | connect( qApp, SIGNAL(weekChanged(bool) ), |
136 | this, SLOT(slotWeekChanged(bool) ) ); | 151 | this, SLOT(slotWeekChanged(bool) ) ); |
137 | 152 | ||
138 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), | 153 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), |
139 | this, SLOT(slotAppMessage( const QCString&, const QByteArray& ) ) ); | 154 | this, SLOT(slotAppMessage( const QCString&, const QByteArray& ) ) ); |
140 | } | 155 | } |
141 | void MainWindow::initConfig() { | 156 | void MainWindow::initConfig() { |
142 | 157 | ||
143 | } | 158 | } |
144 | void MainWindow::initView() { | 159 | void MainWindow::initView() { |
145 | 160 | ||
146 | } | 161 | } |
147 | void MainWindow::initManagers() { | 162 | void MainWindow::initManagers() { |
148 | m_manager = new BookManager; | 163 | m_manager = new BookManager; |
149 | m_locMan = new LocationManager( tr("Locations") ); | 164 | |
150 | m_descMan = new DescriptionManager( tr("Descriptions") ); | 165 | m_tempMan.load(); |
166 | m_locMan.load(); | ||
167 | m_descMan.load(); | ||
168 | |||
169 | setTemplateMenu(); | ||
151 | } | 170 | } |
152 | void MainWindow::raiseCurrentView() { | 171 | void MainWindow::raiseCurrentView() { |
153 | 172 | ||
154 | } | 173 | } |
155 | /* | 174 | /* |
156 | * populate the view | 175 | * populate the view |
157 | */ | 176 | */ |
158 | void MainWindow::populate() { | 177 | void MainWindow::populate() { |
159 | if (!manager()->isLoaded() ) | 178 | if (!manager()->isLoaded() ) |
160 | manager()->load(); | 179 | manager()->load(); |
161 | } | 180 | } |
162 | void MainWindow::slotGoToNow() { | 181 | void MainWindow::slotGoToNow() { |
163 | 182 | ||
164 | } | 183 | } |
165 | View* MainWindow::currentView() { | 184 | View* MainWindow::currentView() { |
166 | 185 | ||
167 | } | 186 | } |
168 | void MainWindow::slotFind() { | 187 | void MainWindow::slotFind() { |
169 | 188 | ||
170 | } | 189 | } |
171 | void MainWindow::slotConfigure() { | 190 | void MainWindow::slotConfigure() { |
172 | 191 | ||
173 | } | 192 | } |
174 | void MainWindow::slotClockChanged( bool ) { | 193 | void MainWindow::slotClockChanged( bool ) { |
175 | 194 | ||
176 | } | 195 | } |
177 | void MainWindow::slotWeekChanged(bool ) { | 196 | void MainWindow::slotWeekChanged(bool ) { |
178 | 197 | ||
179 | } | 198 | } |
180 | void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) { | 199 | void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) { |
181 | 200 | ||
182 | } | 201 | } |
183 | void MainWindow::slotReceive( const QCString&, const QByteArray& ) { | 202 | void MainWindow::slotReceive( const QCString&, const QByteArray& ) { |
184 | 203 | ||
185 | } | 204 | } |
186 | BookManager* MainWindow::manager() { | 205 | BookManager* MainWindow::manager() { |
187 | return m_manager; | 206 | return m_manager; |
188 | } | 207 | } |
189 | TemplateManager* MainWindow::templateManager() { | 208 | TemplateManager MainWindow::templateManager() { |
190 | return m_tempMan; | 209 | return m_tempMan; |
191 | } | 210 | } |
192 | LocationManager* MainWindow::locationManager() { | 211 | LocationManager MainWindow::locationManager() { |
193 | return m_locMan; | 212 | return m_locMan; |
194 | } | 213 | } |
195 | DescriptionManager* MainWindow::descriptionManager() { | 214 | DescriptionManager MainWindow::descriptionManager() { |
196 | return m_descMan; | 215 | return m_descMan; |
197 | } | 216 | } |
217 | void MainWindow::setLocationManager( const LocationManager& loc) { | ||
218 | m_locMan = loc; | ||
219 | } | ||
220 | void MainWindow::setDescriptionManager( const DescriptionManager& dsc ) { | ||
221 | m_descMan = dsc; | ||
222 | } | ||
198 | Show* MainWindow::eventShow() { | 223 | Show* MainWindow::eventShow() { |
199 | return m_show; | 224 | return m_show; |
200 | } | 225 | } |
201 | void MainWindow::slotAction( QAction* act ) { | 226 | void MainWindow::slotAction( QAction* act ) { |
202 | 227 | ||
203 | } | 228 | } |
204 | void MainWindow::slotConfigureLocs() { | 229 | void MainWindow::slotConfigureLocs() { |
205 | 230 | LocationManagerDialog dlg( locationManager() ); | |
231 | dlg.setCaption( tr("Configure Locations") ); | ||
232 | dlg.showMaximized(); | ||
233 | if (dlg.exec() == QDialog::Accepted ) { | ||
234 | setLocationManager( dlg.manager() ); | ||
235 | } | ||
206 | } | 236 | } |
207 | void MainWindow::slotConfigureDesc() { | 237 | void MainWindow::slotConfigureDesc() { |
208 | 238 | DescriptionManagerDialog dlg( descriptionManager() ); | |
239 | dlg.setCaption( tr("Configure Descriptions") ); | ||
240 | dlg.showMaximized(); | ||
241 | if (dlg.exec() == QDialog::Accepted ) { | ||
242 | setDescriptionManager( dlg.manager() ); | ||
243 | } | ||
244 | } | ||
245 | void MainWindow::slotConfigureTemp() { | ||
246 | TemplateDialog dlg( templateManager(), editor() ); | ||
247 | dlg.setCaption( tr("Configure Templates") ); | ||
248 | dlg.showMaximized(); | ||
249 | if ( dlg.exec() == QDialog::Accepted ) { | ||
250 | m_tempMan = dlg.manager(); | ||
251 | setTemplateMenu(); | ||
252 | } | ||
209 | } | 253 | } |
210 | void MainWindow::hideShow() { | 254 | void MainWindow::hideShow() { |
211 | 255 | ||
212 | } | 256 | } |
213 | void MainWindow::viewPopup(int ) { | 257 | void MainWindow::viewPopup(int ) { |
214 | 258 | ||
215 | } | 259 | } |
216 | void MainWindow::viewAdd(const QDate& ) { | 260 | void MainWindow::viewAdd(const QDate& ) { |
217 | 261 | ||
218 | } | 262 | } |
219 | void MainWindow::viewAdd( const QDateTime&, const QDateTime& ) { | 263 | void MainWindow::viewAdd( const QDateTime&, const QDateTime& ) { |
220 | 264 | ||
221 | } | 265 | } |
222 | bool MainWindow::viewAP()const{ | 266 | bool MainWindow::viewAP()const{ |
223 | } | 267 | } |
224 | bool MainWindow::viewStartMonday()const { | 268 | bool MainWindow::viewStartMonday()const { |
225 | 269 | ||
226 | } | 270 | } |
271 | void MainWindow::setTemplateMenu() { | ||
272 | m_popTemplate->clear(); | ||
273 | |||
274 | QStringList list = templateManager().names(); | ||
275 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | ||
276 | m_popTemplate->insertItem( (*it) ); | ||
277 | } | ||
278 | } | ||
279 | /* | ||
280 | * get the name of the item with the id id | ||
281 | * then ask for an OEvent from the manager | ||
282 | */ | ||
283 | void MainWindow::slotNewFromTemplate(int id ) { | ||
284 | QString name = m_popTemplate->text( id ); | ||
285 | |||
286 | OEvent ev = templateManager().value( name ); | ||
287 | |||
288 | if ( editor()->edit( ev ) ) { | ||
289 | ev = editor()->event(); | ||
290 | ev.setUid( -1 ); | ||
291 | manager()->add( ev ); | ||
292 | |||
293 | /* | ||
294 | * no we'll find out if the current view | ||
295 | * should show the new event | ||
296 | * and then we will ask it to refresh | ||
297 | * FIXME for now we'll call a refresh | ||
298 | */ | ||
299 | currentView()->reschedule(); | ||
300 | raiseCurrentView(); | ||
301 | } | ||
302 | } | ||
303 | Editor* MainWindow::editor() { | ||
304 | return m_edit; | ||
305 | } | ||
diff --git a/core/pim/datebook2/mainwindow.h b/core/pim/datebook2/mainwindow.h index 60ea4c4..3c22637 100644 --- a/core/pim/datebook2/mainwindow.h +++ b/core/pim/datebook2/mainwindow.h | |||
@@ -1,99 +1,107 @@ | |||
1 | #ifndef DATE_BOOK_MAIN_WINDOW_H | 1 | #ifndef DATE_BOOK_MAIN_WINDOW_H |
2 | #define DATE_BOOK_MAIN_WINDOW_H | 2 | #define DATE_BOOK_MAIN_WINDOW_H |
3 | 3 | ||
4 | #include <qlist.h> | 4 | #include <qlist.h> |
5 | 5 | ||
6 | #include <opie/opimmainwindow.h> | 6 | #include <opie/opimmainwindow.h> |
7 | 7 | ||
8 | #include "descriptionmanager.h" | 8 | #include "descriptionmanager.h" |
9 | #include "locationmanager.h" | 9 | #include "locationmanager.h" |
10 | #include "templatemanager.h" | ||
10 | #include "view.h" | 11 | #include "view.h" |
11 | 12 | ||
12 | class QAction; | 13 | class QAction; |
13 | class QWidgetStack; | 14 | class QWidgetStack; |
14 | class QPopupMenu; | 15 | class QPopupMenu; |
15 | class QPEToolBar; | 16 | class QPEToolBar; |
16 | namespace Datebook { | 17 | namespace Datebook { |
17 | |||
18 | class TemplateManager; | ||
19 | class BookManager; | 18 | class BookManager; |
20 | class Show; | 19 | class Show; |
20 | class Editor; | ||
21 | class MainWindow : public OPimMainWindow { | 21 | class MainWindow : public OPimMainWindow { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | friend class Show; // to avoid QObject | 23 | friend class Show; // to avoid QObject |
24 | friend class View; // to avoid QObject | 24 | friend class View; // to avoid QObject |
25 | friend class Editor; | ||
25 | public: | 26 | public: |
26 | MainWindow(); | 27 | MainWindow(); |
27 | ~MainWindow(); | 28 | ~MainWindow(); |
28 | 29 | ||
29 | private slots: | 30 | private slots: |
30 | void initUI(); // init the UI | 31 | void initUI(); // init the UI |
31 | void initConfig(); // apply the config | 32 | void initConfig(); // apply the config |
32 | void initView(); // init the Views.. | 33 | void initView(); // init the Views.. |
33 | void initManagers(); // init the Managers including templates, location and description | 34 | void initManagers(); // init the Managers including templates, location and description |
34 | void raiseCurrentView(); // raise the current View | 35 | void raiseCurrentView(); // raise the current View |
35 | void slotGoToNow(); // will switch the currentView to the curren date time | 36 | void slotGoToNow(); // will switch the currentView to the curren date time |
36 | void slotFind(); // find!!! | 37 | void slotFind(); // find!!! |
37 | void slotConfigure(); // configure the app | 38 | void slotConfigure(); // configure the app |
38 | void slotClockChanged(bool); // clock changed | 39 | void slotClockChanged(bool); // clock changed |
39 | void slotWeekChanged( bool ); // week changed | 40 | void slotWeekChanged( bool ); // week changed |
40 | void slotAppMessage( const QCString&, const QByteArray& ); // qApp message QPE/Application/datebook | 41 | 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 slotReceive( const QCString&, const QByteArray& ); // QPE/System and QPE/Datebook |
42 | void slotAction( QAction* ); // View changed | 43 | void slotAction( QAction* ); // View changed |
43 | void slotConfigureLocs(); // Configure the Locations | 44 | void slotConfigureLocs(); // Configure the Locations |
44 | void slotConfigureDesc(); // Configure the Desc | 45 | void slotConfigureDesc(); // Configure the Desc |
46 | void slotConfigureTemp(); | ||
47 | void slotNewFromTemplate(int ); // called when someone chooses the template menu | ||
45 | 48 | ||
49 | void setTemplateMenu(); // updates the templateMenu | ||
46 | 50 | ||
47 | protected slots: | 51 | protected slots: |
48 | void populate(); | 52 | void populate(); |
49 | void doSetDocument( const QString& str ); | 53 | void doSetDocument( const QString& str ); |
50 | void flush(); | 54 | void flush(); |
51 | void reload(); | 55 | void reload(); |
52 | int create(); | 56 | int create(); |
53 | bool remove( int uid ); | 57 | bool remove( int uid ); |
54 | void beam( int uid ); | 58 | void beam( int uid ); |
55 | void show( int uid ); | 59 | void show( int uid ); |
56 | void edit( int uid ); | 60 | void edit( int uid ); |
57 | void edit(); | 61 | void edit(); |
58 | void add( const OPimRecord& ); | 62 | void add( const OPimRecord& ); |
59 | 63 | ||
60 | private: | 64 | private: |
61 | QPEToolBar* toolbar(); | 65 | QPEToolBar* toolbar(); |
62 | QPopupMenu* viewMenu(); | 66 | QPopupMenu* viewMenu(); |
63 | QPopupMenu* settingsMenu(); | 67 | QPopupMenu* settingsMenu(); |
64 | QPopupMenu* templateMenu(); | 68 | QPopupMenu* templateMenu(); |
65 | View* currentView(); | 69 | View* currentView(); |
66 | BookManager* manager(); | 70 | BookManager* manager(); |
67 | TemplateManager* templateManager(); | 71 | TemplateManager templateManager(); |
68 | LocationManager* locationManager(); | 72 | LocationManager locationManager(); |
69 | DescriptionManager* descriptionManager(); | 73 | DescriptionManager descriptionManager(); |
74 | void setLocationManager( const LocationManager& ); | ||
75 | void setDescriptionManager( const DescriptionManager& ); | ||
70 | Show* eventShow(); | 76 | Show* eventShow(); |
77 | Editor* editor(); | ||
71 | 78 | ||
72 | private: // friend functions for Show | 79 | private: // friend functions for Show |
73 | void hideShow(); // to hide the view | 80 | void hideShow(); // to hide the view |
74 | // off friend Show | 81 | // off friend Show |
75 | 82 | ||
76 | // friend of the view | 83 | // friend of the view |
77 | private: | 84 | private: |
78 | void viewPopup( int ); | 85 | void viewPopup( int ); |
79 | void viewAdd( const QDate& date ); | 86 | void viewAdd( const QDate& date ); |
80 | void viewAdd( const QDateTime&, const QDateTime& ); | 87 | void viewAdd( const QDateTime&, const QDateTime& ); |
81 | bool viewAP()const; | 88 | bool viewAP()const; |
82 | bool viewStartMonday()const; | 89 | bool viewStartMonday()const; |
83 | // off view show | 90 | // off view show |
84 | private: | 91 | private: |
85 | QList<View> m_view; // the Views.. not autoDelete | 92 | QList<View> m_view; // the Views.. not autoDelete |
86 | QWidgetStack* m_stack; | 93 | QWidgetStack* m_stack; |
87 | QPEToolBar *m_toolBar; | 94 | QPEToolBar *m_toolBar; |
88 | QPopupMenu* m_popView; | 95 | QPopupMenu* m_popView; |
89 | QPopupMenu* m_popSetting; | 96 | QPopupMenu* m_popSetting; |
90 | QPopupMenu* m_popTemplate; | 97 | QPopupMenu* m_popTemplate; |
91 | BookManager* m_manager; | 98 | BookManager* m_manager; |
92 | TemplateManager* m_tempMan; | 99 | TemplateManager m_tempMan; |
93 | DescriptionManager* m_descMan; | 100 | DescriptionManager m_descMan; |
94 | LocationManager* m_locMan; | 101 | LocationManager m_locMan; |
95 | Show* m_show; | 102 | Show* m_show; |
103 | Editor* m_edit; | ||
96 | }; | 104 | }; |
97 | } | 105 | } |
98 | 106 | ||
99 | #endif | 107 | #endif |
diff --git a/core/pim/datebook2/managertemplate.h b/core/pim/datebook2/managertemplate.h index cdf121d..72fab3a 100644 --- a/core/pim/datebook2/managertemplate.h +++ b/core/pim/datebook2/managertemplate.h | |||
@@ -1,73 +1,60 @@ | |||
1 | #ifndef OPIE_DATE_BOOK_MANAGER_TEMPLATE_H | 1 | #ifndef OPIE_DATE_BOOK_MANAGER_TEMPLATE_H |
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 <qmap.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | 7 | ||
8 | namespace Datebook { | 8 | namespace Datebook { |
9 | /** | 9 | /** |
10 | * ManagerTemplate is a template which manages | 10 | * ManagerTemplate is a template which manages |
11 | * all kind of managers :) | 11 | * all kind of managers :) |
12 | */ | 12 | */ |
13 | template<class T> | 13 | template<class T> |
14 | class ManagerTemplate { | 14 | class ManagerTemplate { |
15 | typedef typename QMap<QString, T>::Iterator Iterator; | 15 | typedef typename QMap<QString, T>::ConstIterator Iterator; |
16 | public: | 16 | public: |
17 | ManagerTemplate(); | 17 | ManagerTemplate(); |
18 | virtual ~ManagerTemplate(); | 18 | virtual ~ManagerTemplate(); |
19 | 19 | ||
20 | virtual void add( const QString&, const T& t ); | 20 | virtual void add( const QString&, const T& t ); |
21 | void remove( const QString& ); | 21 | void remove( const QString& ); |
22 | bool load(); | 22 | virtual bool load() = 0; |
23 | bool save(); | 23 | virtual bool save() = 0; |
24 | 24 | ||
25 | QStringList names(); | 25 | QStringList names()const; |
26 | T value(const QString&)const; | 26 | T value(const QString&)const; |
27 | 27 | ||
28 | protected: | 28 | protected: |
29 | QMap<QString, T> m_map; | 29 | QMap<QString, T> m_map; |
30 | |||
31 | private: | ||
32 | virtual bool doSave() = 0; | ||
33 | virtual bool doLoad() = 0; | ||
34 | |||
35 | }; | 30 | }; |
36 | template<class T> | 31 | template<class T> |
37 | ManagerTemplate<T>::ManagerTemplate() { | 32 | ManagerTemplate<T>::ManagerTemplate() { |
38 | } | 33 | } |
39 | template<class T> | 34 | template<class T> |
40 | ManagerTemplate<T>::~ManagerTemplate() { | 35 | ManagerTemplate<T>::~ManagerTemplate() { |
41 | } | 36 | } |
42 | template<class T> | 37 | template<class T> |
43 | void ManagerTemplate<T>::add( const QString& str, const T& t ) { | 38 | void ManagerTemplate<T>::add( const QString& str, const T& t ) { |
44 | m_map.insert( str, t ); | 39 | m_map.insert( str, t ); |
45 | } | 40 | } |
46 | template<class T> | 41 | template<class T> |
47 | void ManagerTemplate<T>::remove( const QString& str ) { | 42 | void ManagerTemplate<T>::remove( const QString& str ) { |
48 | m_map.remove( str ); | 43 | m_map.remove( str ); |
49 | } | 44 | } |
50 | template<class T> | 45 | template<class T> |
51 | bool ManagerTemplate<T>::load() { | 46 | QStringList ManagerTemplate<T>::names()const { |
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; | 47 | QStringList lst; |
61 | Iterator it; | 48 | Iterator it; |
62 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | 49 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { |
63 | lst << it.key(); | 50 | lst << it.key(); |
64 | } | 51 | } |
65 | return lst; | 52 | return lst; |
66 | } | 53 | } |
67 | template<class T> | 54 | template<class T> |
68 | T ManagerTemplate<T>::value( const QString& str)const { | 55 | T ManagerTemplate<T>::value( const QString& str)const { |
69 | return m_map[str]; | 56 | return m_map[str]; |
70 | } | 57 | } |
71 | } | 58 | } |
72 | 59 | ||
73 | #endif | 60 | #endif |
diff --git a/core/pim/datebook2/stringmanager.cpp b/core/pim/datebook2/stringmanager.cpp index 77bc88a..715a4b1 100644 --- a/core/pim/datebook2/stringmanager.cpp +++ b/core/pim/datebook2/stringmanager.cpp | |||
@@ -1,42 +1,138 @@ | |||
1 | #include <qhbox.h> | ||
2 | #include <qpushbutton.h> | ||
3 | #include <qlayout.h> | ||
4 | #include <qlistview.h> | ||
5 | #include <qlineedit.h> | ||
6 | |||
1 | #include <qpe/config.h> | 7 | #include <qpe/config.h> |
2 | 8 | ||
3 | #include "stringmanager.h" | 9 | #include "stringmanager.h" |
4 | 10 | ||
5 | using namespace Datebook; | 11 | using namespace Datebook; |
6 | 12 | ||
7 | StringManager::StringManager( const QString& str ) | 13 | StringManager::StringManager( const QString& str ) |
8 | : m_base( str ) { | 14 | : m_base( str ) { |
9 | } | 15 | } |
10 | StringManager::~StringManager() { | 16 | StringManager::~StringManager() { |
11 | 17 | ||
12 | } | 18 | } |
13 | void StringManager::add( const QString& str ) { | 19 | void StringManager::add( const QString& str ) { |
14 | ManagerTemplate<QString>::add(str, str); | 20 | ManagerTemplate<QString>::add(str, str); |
15 | } | 21 | } |
16 | bool StringManager::doLoad() { | 22 | bool StringManager::load() { |
17 | Config qpe( "datebook-"+m_base ); | 23 | Config qpe( "datebook-"+m_base ); |
18 | qpe.setGroup(m_base ); | 24 | qpe.setGroup(m_base ); |
19 | QStringList list = qpe.readListEntry( "Names", 0x1f ); | 25 | QStringList list = qpe.readListEntry( "Names", 0x1f ); |
20 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 26 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
21 | add( (*it) ); | 27 | add( (*it) ); |
22 | 28 | ||
23 | return true; | 29 | return true; |
24 | } | 30 | } |
25 | bool StringManager::doSave() { | 31 | bool StringManager::save() { |
26 | Config qpe( "datebook"+m_base ); | 32 | Config qpe( "datebook-"+m_base ); |
27 | qpe.setGroup(m_base); | 33 | qpe.setGroup(m_base); |
28 | qpe.writeEntry( "Names", names(), 0x1f ); | 34 | qpe.writeEntry( "Names", names(), 0x1f ); |
29 | 35 | ||
30 | return false; | 36 | return false; |
31 | } | 37 | } |
38 | QString StringManager::baseName()const { | ||
39 | return m_base; | ||
40 | } | ||
41 | |||
32 | 42 | ||
33 | 43 | ||
34 | StringManagerDialog::StringManagerDialog(const StringManager& ) | 44 | StringManagerDialog::StringManagerDialog(const StringManager& man) |
35 | : QDialog(0, 0, true ) { | 45 | : QDialog(0, 0, true ) { |
46 | m_base = man.baseName(); | ||
47 | |||
48 | QVBoxLayout* lay = new QVBoxLayout( this ); | ||
49 | |||
50 | m_view = new QListView( this ); | ||
51 | m_view->addColumn( QString::null ); | ||
52 | lay->addWidget( m_view ); | ||
53 | |||
54 | QHBox* box = new QHBox( this ); | ||
55 | |||
56 | QPushButton* b = new QPushButton( box ); | ||
57 | b->setText( tr("&Add") ); | ||
58 | connect(b, SIGNAL(clicked() ), this, SLOT(slotAdd() ) ); | ||
59 | |||
60 | b = new QPushButton( box ); | ||
61 | b->setText( tr("&Remove") ); | ||
62 | connect(b, SIGNAL(clicked() ), this, SLOT(slotRemove() ) ); | ||
63 | |||
64 | b = new QPushButton( box ); | ||
65 | b->setText( tr("Rename") ); | ||
66 | connect(b, SIGNAL(clicked() ), this, SLOT(slotRename() ) ); | ||
67 | |||
68 | lay->addWidget( box ); | ||
69 | |||
70 | init( man ); | ||
36 | } | 71 | } |
37 | StringManagerDialog::~StringManagerDialog() { | 72 | StringManagerDialog::~StringManagerDialog() { |
38 | |||
39 | } | 73 | } |
40 | StringManager StringManagerDialog::manager()const { | 74 | StringManager StringManagerDialog::manager()const { |
41 | return StringManager(); | 75 | StringManager man(m_base ); |
76 | QListViewItemIterator it(m_view); | ||
77 | while ( it.current() ) { | ||
78 | man.add( it.current()->text(0) ); | ||
79 | ++it; | ||
80 | } | ||
81 | |||
82 | return man; | ||
83 | } | ||
84 | void StringManagerDialog::init( const StringManager& _man ) { | ||
85 | QStringList::Iterator it; | ||
86 | QStringList man = _man.names(); | ||
87 | for ( it = man.begin(); it != man.end(); ++it ) | ||
88 | (void)new QListViewItem( m_view, (*it) ); | ||
89 | |||
90 | } | ||
91 | |||
92 | namespace { | ||
93 | class InputDialog : public QDialog{ | ||
94 | public: | ||
95 | InputDialog( const QString& text ); | ||
96 | ~InputDialog(); | ||
97 | |||
98 | QString text()const; | ||
99 | private: | ||
100 | QLineEdit* m_lneEdit; | ||
101 | }; | ||
102 | InputDialog::InputDialog(const QString& text ) | ||
103 | : QDialog(0, 0, true ) { | ||
104 | m_lneEdit = new QLineEdit( this ); | ||
105 | m_lneEdit->setText( text ); | ||
106 | } | ||
107 | InputDialog::~InputDialog() { | ||
108 | } | ||
109 | QString InputDialog::text() const{ | ||
110 | return m_lneEdit->text(); | ||
111 | } | ||
112 | |||
113 | } | ||
114 | |||
115 | void StringManagerDialog::slotAdd() { | ||
116 | InputDialog dlg(QString::null); | ||
117 | dlg.setCaption( tr("Add") ); | ||
118 | if ( dlg.exec() == QDialog::Accepted ) | ||
119 | (void)new QListViewItem( m_view, dlg.text() ); | ||
120 | |||
121 | } | ||
122 | void StringManagerDialog::slotRename() { | ||
123 | QListViewItem* item = m_view->currentItem(); | ||
124 | if (!item) return; | ||
125 | |||
126 | InputDialog dlg(item->text(0) ); | ||
127 | dlg.setCaption( tr("Rename") ); | ||
128 | |||
129 | if ( dlg.exec() == QDialog::Accepted ) | ||
130 | item->setText( 0, dlg.text() ); | ||
131 | } | ||
132 | void StringManagerDialog::slotRemove() { | ||
133 | QListViewItem* item = m_view->currentItem(); | ||
134 | if (!item) return; | ||
135 | |||
136 | m_view->takeItem( item ); | ||
137 | delete item; | ||
42 | } | 138 | } |
diff --git a/core/pim/datebook2/stringmanager.h b/core/pim/datebook2/stringmanager.h index ac0d4bd..2eee43f 100644 --- a/core/pim/datebook2/stringmanager.h +++ b/core/pim/datebook2/stringmanager.h | |||
@@ -1,47 +1,57 @@ | |||
1 | #ifndef OPIE_STRING_DATEBOOK_MANAGER_H | 1 | #ifndef OPIE_STRING_DATEBOOK_MANAGER_H |
2 | #define OPIE_STRING_DATEBOOK_MANAGER_H | 2 | #define OPIE_STRING_DATEBOOK_MANAGER_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | 5 | ||
6 | #include "managertemplate.h" | 6 | #include "managertemplate.h" |
7 | 7 | ||
8 | class QListView; | ||
8 | namespace Datebook { | 9 | namespace Datebook { |
9 | /** | 10 | /** |
10 | * StringManager is a generic manager | 11 | * StringManager is a generic manager |
11 | * whick keeps track of strings | 12 | * whick keeps track of strings |
12 | * It'll be used with the Location | 13 | * It'll be used with the Location |
13 | * and the Description Manager | 14 | * and the Description Manager |
14 | */ | 15 | */ |
15 | class StringManager : public ManagerTemplate<QString> { | 16 | class StringManager : public ManagerTemplate<QString> { |
16 | public: | 17 | public: |
17 | /** | 18 | /** |
18 | * baseName is used for storing | 19 | * baseName is used for storing |
19 | */ | 20 | */ |
20 | StringManager(const QString& baseName = QString::null); | 21 | StringManager(const QString& baseName = QString::null); |
21 | ~StringManager(); | 22 | ~StringManager(); |
22 | 23 | ||
23 | /** | 24 | /** |
24 | * override the add implementation | 25 | * override the add implementation |
25 | * cause we do not have a value :) | 26 | * cause we do not have a value :) |
26 | */ | 27 | */ |
27 | void add( const QString& ); | 28 | void add( const QString& ); |
29 | bool load(); | ||
30 | bool save(); | ||
31 | QString baseName()const; | ||
28 | private: | 32 | private: |
29 | QString m_base; | 33 | QString m_base; |
30 | bool doLoad(); | ||
31 | bool doSave(); | ||
32 | }; | 34 | }; |
33 | 35 | ||
34 | /** | 36 | /** |
35 | * A Generic Editor for StringManager | 37 | * A Generic Editor for StringManager |
36 | */ | 38 | */ |
37 | class StringManagerDialog : public QDialog { | 39 | class StringManagerDialog : public QDialog { |
38 | Q_OBJECT | 40 | Q_OBJECT |
39 | public: | 41 | public: |
40 | StringManagerDialog( const StringManager&); | 42 | StringManagerDialog( const StringManager&); |
41 | ~StringManagerDialog(); | 43 | ~StringManagerDialog(); |
42 | 44 | ||
43 | StringManager manager()const; | 45 | StringManager manager()const; |
46 | private slots: | ||
47 | void init( const StringManager& ); | ||
48 | void slotAdd(); | ||
49 | void slotRemove(); | ||
50 | void slotRename(); | ||
51 | private: | ||
52 | QListView* m_view; | ||
53 | QString m_base; | ||
44 | }; | 54 | }; |
45 | } | 55 | } |
46 | 56 | ||
47 | #endif | 57 | #endif |
diff --git a/core/pim/datebook2/templatemanager.cpp b/core/pim/datebook2/templatemanager.cpp index b620cf7..541fec0 100644 --- a/core/pim/datebook2/templatemanager.cpp +++ b/core/pim/datebook2/templatemanager.cpp | |||
@@ -1,25 +1,184 @@ | |||
1 | #include <qdatetime.h> | ||
2 | #include <qlistview.h> | ||
3 | #include <qlayout.h> | ||
4 | #include <qhbox.h> | ||
5 | #include <qlineedit.h> | ||
6 | #include <qpushbutton.h> | ||
7 | |||
8 | #include <qpe/config.h> | ||
9 | |||
10 | #include <opie/odatebookaccess.h> | ||
11 | #include <opie/odatebookaccessbackend_xml.h> | ||
12 | |||
13 | #include "editor.h" | ||
1 | #include "templatemanager.h" | 14 | #include "templatemanager.h" |
2 | 15 | ||
3 | using namespace Datebook; | 16 | using namespace Datebook; |
4 | 17 | ||
5 | 18 | ||
6 | TemplateManager::TemplateManager() { | 19 | TemplateManager::TemplateManager() { |
7 | 20 | ||
8 | } | 21 | } |
9 | TemplateManager::~TemplateManager() { | 22 | TemplateManager::~TemplateManager() { |
10 | } | 23 | } |
11 | bool TemplateManager::doSave() { | 24 | bool TemplateManager::save() { |
25 | QStringList lst = names(); | ||
26 | Config conf( "datebook-templates"); | ||
27 | conf.setGroup( "___Names___"); | ||
28 | conf.writeEntry( "Names", names(), 0x1f ); | ||
29 | |||
30 | for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | ||
31 | conf.setGroup( (*it) ); | ||
32 | conf.writeEntry( "Uid", value( (*it) ).uid() ); | ||
33 | } | ||
34 | |||
12 | return true; | 35 | return true; |
13 | } | 36 | } |
14 | bool TemplateManager::doLoad() { | 37 | bool TemplateManager::load() { |
38 | Config conf( "datebook-templates"); | ||
39 | conf.setGroup( "___Names___"); | ||
40 | QStringList lst = conf.readListEntry( "Names", 0x1f ); | ||
41 | for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | ||
42 | conf.setGroup( (*it) ); | ||
43 | add( (*it), OEvent() ); | ||
44 | } | ||
15 | return true; | 45 | return true; |
16 | } | 46 | } |
17 | 47 | ||
18 | TemplateDialog::TemplateDialog( const TemplateManager& ) | 48 | namespace { |
49 | class TemplateItem : public QListViewItem { | ||
50 | public: | ||
51 | TemplateItem( QListView*, const QString& text, | ||
52 | const OEvent& ); | ||
53 | ~TemplateItem(); | ||
54 | |||
55 | QString text()const; | ||
56 | OEvent event()const; | ||
57 | |||
58 | void setText( const QString& text ); | ||
59 | void setEvent( const OEvent& ); | ||
60 | private: | ||
61 | QString m_text; | ||
62 | OEvent m_event; | ||
63 | }; | ||
64 | TemplateItem::TemplateItem( QListView* view, | ||
65 | const QString& text, | ||
66 | const OEvent& ev ) | ||
67 | : QListViewItem( view ), m_event(ev) { | ||
68 | QListViewItem::setText( 0, text ); | ||
69 | } | ||
70 | TemplateItem::~TemplateItem() { | ||
71 | } | ||
72 | void TemplateItem::setText( const QString& text ) { | ||
73 | QListViewItem::setText( 0, text ); | ||
74 | m_text = text; | ||
75 | } | ||
76 | void TemplateItem::setEvent( const OEvent& ev ) { | ||
77 | m_event = ev; | ||
78 | } | ||
79 | QString TemplateItem::text()const { | ||
80 | return m_text; | ||
81 | } | ||
82 | OEvent TemplateItem::event()const { | ||
83 | |||
84 | } | ||
85 | |||
86 | class InputDialog : public QDialog{ | ||
87 | public: | ||
88 | InputDialog( const QString& text ); | ||
89 | ~InputDialog(); | ||
90 | |||
91 | QString text()const; | ||
92 | private: | ||
93 | QLineEdit* m_lneEdit; | ||
94 | }; | ||
95 | InputDialog::InputDialog(const QString& text ) | ||
96 | : QDialog(0, 0, true ) { | ||
97 | m_lneEdit = new QLineEdit( this ); | ||
98 | m_lneEdit->setText( text ); | ||
99 | } | ||
100 | InputDialog::~InputDialog() { | ||
101 | } | ||
102 | QString InputDialog::text() const{ | ||
103 | return m_lneEdit->text(); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | TemplateDialog::TemplateDialog( const TemplateManager& man, Editor* edit ) | ||
19 | : QDialog(0, 0, true ) { | 108 | : QDialog(0, 0, true ) { |
109 | QVBoxLayout* lay = new QVBoxLayout(this); | ||
110 | m_view = new QListView( this ); | ||
111 | m_view->addColumn( tr("Template Names") ); | ||
112 | lay->addWidget( m_view ); | ||
113 | |||
114 | QHBox* box = new QHBox( this ); | ||
115 | lay->addWidget( box ); | ||
116 | |||
117 | QPushButton* b = new QPushButton( box ); | ||
118 | b->setText(tr("&Add") ); | ||
119 | connect( b, SIGNAL(clicked() ), this, SLOT(slotAdd() ) ); | ||
120 | |||
121 | b = new QPushButton( box ); | ||
122 | b->setText(tr("&Edit") ); | ||
123 | connect( b, SIGNAL(clicked() ), this, SLOT(slotEdit() ) ); | ||
124 | |||
125 | b = new QPushButton( box ); | ||
126 | b->setText(tr("&Rename") ); | ||
127 | connect(b, SIGNAL(clicked() ), this, SLOT(slotRename() ) ); | ||
128 | |||
129 | b = new QPushButton( box ); | ||
130 | b->setText(tr("Re&move") ); | ||
131 | connect(b, SIGNAL(clicked() ), this, SLOT(slotRemove() ) ); | ||
132 | |||
133 | init( man ); | ||
134 | m_edit = edit; | ||
20 | } | 135 | } |
21 | TemplateDialog::~TemplateDialog() { | 136 | TemplateDialog::~TemplateDialog() { |
22 | } | 137 | } |
138 | void TemplateDialog::slotAdd() { | ||
139 | if ( m_edit->newEvent( QDate::currentDate() ) ) { | ||
140 | (void)new TemplateItem( m_view, tr("New Template"), m_edit->event() ); | ||
141 | } | ||
142 | } | ||
143 | void TemplateDialog::slotEdit() { | ||
144 | TemplateItem* item = static_cast<TemplateItem*>( m_view->currentItem() ); | ||
145 | if (!item) return; | ||
146 | |||
147 | if (m_edit->edit( item->event() ) ) | ||
148 | item->setEvent( m_edit->event() ); | ||
149 | |||
150 | } | ||
151 | void TemplateDialog::slotRemove() { | ||
152 | QListViewItem* item = m_view->currentItem(); | ||
153 | if (!item) return; | ||
154 | |||
155 | m_view->takeItem( item ); | ||
156 | delete item; | ||
157 | } | ||
158 | void TemplateDialog::slotRename() { | ||
159 | TemplateItem* item = static_cast<TemplateItem*>( m_view->currentItem() ); | ||
160 | if (!item) return; | ||
161 | |||
162 | InputDialog dlg( item->text() ); | ||
163 | dlg.setCaption( tr("Rename") ); | ||
164 | if ( dlg.exec() == QDialog::Accepted ) | ||
165 | item->setText( dlg.text() ); | ||
166 | |||
167 | } | ||
23 | TemplateManager TemplateDialog::manager()const { | 168 | TemplateManager TemplateDialog::manager()const { |
24 | return TemplateManager(); | 169 | TemplateManager manager; |
170 | |||
171 | QListViewItemIterator it(m_view); | ||
172 | while ( it.current() ) { | ||
173 | TemplateItem* item = static_cast<TemplateItem*>( it.current() ); | ||
174 | manager.add( item->text(), item->event() ); | ||
175 | ++it; | ||
176 | } | ||
177 | return manager; | ||
178 | } | ||
179 | void TemplateDialog::init( const TemplateManager& man ) { | ||
180 | QStringList list = man.names(); | ||
181 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | ||
182 | (void)new TemplateItem( m_view, (*it), man.value( (*it) ) ); | ||
183 | } | ||
25 | } | 184 | } |
diff --git a/core/pim/datebook2/templatemanager.h b/core/pim/datebook2/templatemanager.h index f885677..91d8b2e 100644 --- a/core/pim/datebook2/templatemanager.h +++ b/core/pim/datebook2/templatemanager.h | |||
@@ -1,36 +1,48 @@ | |||
1 | #ifndef OPIE_DATEBOOK_TEMPLATE_MANAGER_ZECKE_H_RANDOM_CAUSE_BJARNE | 1 | #ifndef OPIE_DATEBOOK_TEMPLATE_MANAGER_ZECKE_H_RANDOM_CAUSE_BJARNE |
2 | #define OPIE_DATEBOOK_TEMPLATE_MANAGER_ZECKE_H_RANDOM_CAUSE_BJARNE | 2 | #define OPIE_DATEBOOK_TEMPLATE_MANAGER_ZECKE_H_RANDOM_CAUSE_BJARNE |
3 | 3 | ||
4 | #include <qobject.h> | 4 | #include <qobject.h> |
5 | 5 | ||
6 | #include <opie/oevent.h> | 6 | #include <opie/oevent.h> |
7 | 7 | ||
8 | #include "managertemplate.h" | 8 | #include "managertemplate.h" |
9 | 9 | ||
10 | class QListView; | ||
10 | namespace Datebook { | 11 | namespace Datebook { |
11 | /** | 12 | /** |
12 | * The OEvent Template Manager | 13 | * The OEvent Template Manager |
13 | */ | 14 | */ |
15 | class Editor; | ||
14 | class TemplateManager : public ManagerTemplate<OEvent> { | 16 | class TemplateManager : public ManagerTemplate<OEvent> { |
15 | public: | 17 | public: |
16 | TemplateManager(); | 18 | TemplateManager(); |
17 | ~TemplateManager(); | 19 | ~TemplateManager(); |
18 | 20 | ||
19 | private: | 21 | bool save(); |
20 | virtual bool doSave(); | 22 | bool load(); |
21 | virtual bool doLoad(); | ||
22 | }; | 23 | }; |
23 | /** | 24 | /** |
24 | * a QDialog for editing it | 25 | * a QDialog for editing it |
25 | */ | 26 | */ |
26 | class TemplateDialog : public QDialog { | 27 | class TemplateDialog : public QDialog { |
27 | Q_OBJECT | 28 | Q_OBJECT |
28 | public: | 29 | public: |
29 | TemplateDialog(const TemplateManager& man); | 30 | TemplateDialog(const TemplateManager& man, Editor*); |
30 | ~TemplateDialog(); | 31 | ~TemplateDialog(); |
31 | 32 | ||
32 | virtual TemplateManager manager()const; | 33 | TemplateManager manager()const; |
34 | |||
35 | private slots: | ||
36 | void init( const TemplateManager& ); | ||
37 | void slotAdd(); | ||
38 | void slotEdit(); | ||
39 | void slotRename(); | ||
40 | void slotRemove(); | ||
41 | |||
42 | private: | ||
43 | QListView* m_view; | ||
44 | Editor* m_edit; | ||
33 | }; | 45 | }; |
34 | } | 46 | } |
35 | 47 | ||
36 | #endif | 48 | #endif |
diff --git a/core/pim/datebook2/view.h b/core/pim/datebook2/view.h index e2312a3..2236aad 100644 --- a/core/pim/datebook2/view.h +++ b/core/pim/datebook2/view.h | |||
@@ -1,133 +1,143 @@ | |||
1 | #ifndef OPIE_DATE_BOOK_VIEW_H | 1 | #ifndef OPIE_DATE_BOOK_VIEW_H |
2 | #define OPIE_DATE_BOOK_VIEW_H | 2 | #define OPIE_DATE_BOOK_VIEW_H |
3 | 3 | ||
4 | #include <qpixmap.h> | 4 | #include <qpixmap.h> |
5 | #include <qwidget.h> | 5 | #include <qwidget.h> |
6 | 6 | ||
7 | #include <opie/oevent.h> | 7 | #include <opie/oevent.h> |
8 | #include <opie/odatebookaccess.h> | 8 | #include <opie/odatebookaccess.h> |
9 | 9 | ||
10 | class Config; | 10 | class Config; |
11 | namespace Datebook { | 11 | namespace Datebook { |
12 | class MainWindow; | 12 | class MainWindow; |
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(); | 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 ); |
20 | 20 | ||
21 | virtual QPixmap pixmap()const = 0; | 21 | virtual QPixmap pixmap()const = 0; |
22 | |||
23 | /** | ||
24 | * non translatable name or type | ||
25 | */ | ||
26 | virtual QCString type()const = 0; | ||
27 | |||
28 | /** | ||
29 | * shown to the user | ||
30 | */ | ||
31 | virtual QString name()const = 0; | ||
22 | virtual QString description()const = 0; | 32 | virtual QString description()const = 0; |
23 | 33 | ||
24 | /** | 34 | /** |
25 | * return the uid of the current item or 0 | 35 | * return the uid of the current item or 0 |
26 | */ | 36 | */ |
27 | virtual int currentItem()const = 0; | 37 | virtual int currentItem()const = 0; |
28 | 38 | ||
29 | /** | 39 | /** |
30 | * loadConfig | 40 | * loadConfig |
31 | * saveConfig | 41 | * saveConfig |
32 | */ | 42 | */ |
33 | void loadConfig( Config* ); | 43 | void loadConfig( Config* ); |
34 | void saveConfig( Config* ); | 44 | void saveConfig( Config* ); |
35 | 45 | ||
36 | /** | 46 | /** |
37 | * the current range | 47 | * the current range |
38 | * @param src Where to write the start datetime | 48 | * @param src Where to write the start datetime |
39 | * @param dest Where to write the end datetime | 49 | * @param dest Where to write the end datetime |
40 | */ | 50 | */ |
41 | virtual void currentRange( const QDateTime& src, const QDateTime& from) = 0; | 51 | virtual void currentRange( const QDateTime& src, const QDateTime& from) = 0; |
42 | 52 | ||
43 | /** | 53 | /** |
44 | * the clock format changed | 54 | * the clock format changed |
45 | */ | 55 | */ |
46 | virtual void clockChanged() = 0; | 56 | virtual void clockChanged() = 0; |
47 | 57 | ||
48 | /** | 58 | /** |
49 | * the day change means that either | 59 | * the day change means that either |
50 | * monday or sunday is the week start | 60 | * monday or sunday is the week start |
51 | */ | 61 | */ |
52 | virtual void dayChanged() = 0; | 62 | virtual void dayChanged() = 0; |
53 | 63 | ||
54 | /** | 64 | /** |
55 | * show date in your view!! | 65 | * show date in your view!! |
56 | * make the date visible in the current view | 66 | * make the date visible in the current view |
57 | */ | 67 | */ |
58 | virtual void showDay( const QDate& date ) = 0; | 68 | virtual void showDay( const QDate& date ) = 0; |
59 | 69 | ||
60 | /** | 70 | /** |
61 | * return the widget | 71 | * return the widget |
62 | */ | 72 | */ |
63 | virtual QWidget* widget() = 0; | 73 | virtual QWidget* widget() = 0; |
64 | 74 | ||
65 | /** | 75 | /** |
66 | * the view needs an update! | 76 | * the view needs an update! |
67 | */ | 77 | */ |
68 | virtual void reschedule() = 0; | 78 | virtual void reschedule() = 0; |
69 | protected: | 79 | protected: |
70 | void popup( int uid); | 80 | void popup( int uid); |
71 | QString toShortText(const OEffectiveEvent& eff)const; | 81 | QString toShortText(const OEffectiveEvent& eff)const; |
72 | QString toText(const OEffectiveEvent& eff)const; | 82 | QString toText(const OEffectiveEvent& eff)const; |
73 | virtual void doLoadConfig( Config* ) = 0; | 83 | virtual void doLoadConfig( Config* ) = 0; |
74 | virtual void doSaveConfig( Config* ) = 0; | 84 | virtual void doSaveConfig( Config* ) = 0; |
75 | 85 | ||
76 | /** | 86 | /** |
77 | * create a new event starting | 87 | * create a new event starting |
78 | * on start | 88 | * on start |
79 | */ | 89 | */ |
80 | void add( const QDate& start ); | 90 | void add( const QDate& start ); |
81 | 91 | ||
82 | /** | 92 | /** |
83 | * create a new event in a given range | 93 | * create a new event in a given range |
84 | */ | 94 | */ |
85 | void add( const QDateTime& start, const QDateTime& end ); | 95 | void add( const QDateTime& start, const QDateTime& end ); |
86 | 96 | ||
87 | /** | 97 | /** |
88 | * will make the MainWindow to open the editor | 98 | * will make the MainWindow to open the editor |
89 | */ | 99 | */ |
90 | void edit( int uid ); | 100 | void edit( int uid ); |
91 | 101 | ||
92 | /** | 102 | /** |
93 | * remove item with uid | 103 | * remove item with uid |
94 | */ | 104 | */ |
95 | void remove( int uid ); | 105 | void remove( int uid ); |
96 | 106 | ||
97 | /** | 107 | /** |
98 | * give access to all events | 108 | * give access to all events |
99 | */ | 109 | */ |
100 | ODateBookAccess::List allEvents()const; | 110 | ODateBookAccess::List allEvents()const; |
101 | 111 | ||
102 | /** | 112 | /** |
103 | * return events | 113 | * return events |
104 | */ | 114 | */ |
105 | OEffectiveEvent::ValueList events( const QDate& start, const QDate& end ); | 115 | OEffectiveEvent::ValueList events( const QDate& start, const QDate& end ); |
106 | 116 | ||
107 | /** | 117 | /** |
108 | * return an Event | 118 | * return an Event |
109 | */ | 119 | */ |
110 | OEvent event( int uid )const; | 120 | OEvent event( int uid )const; |
111 | 121 | ||
112 | /** | 122 | /** |
113 | * Is the clock AP/PM or 24h? | 123 | * Is the clock AP/PM or 24h? |
114 | */ | 124 | */ |
115 | bool isAP()const; | 125 | bool isAP()const; |
116 | 126 | ||
117 | /** | 127 | /** |
118 | * if the week starts on monday? | 128 | * if the week starts on monday? |
119 | */ | 129 | */ |
120 | bool weekStartOnMonday()const; | 130 | bool weekStartOnMonday()const; |
121 | 131 | ||
122 | /** | 132 | /** |
123 | * return related records for days | 133 | * return related records for days |
124 | */ | 134 | */ |
125 | QList<OPimRecord> records( const QDate& on ); | 135 | QList<OPimRecord> records( const QDate& on ); |
126 | QList<OPimRecord> records( const QDate& start, const QDate& to ); | 136 | QList<OPimRecord> records( const QDate& start, const QDate& to ); |
127 | 137 | ||
128 | private: | 138 | private: |
129 | MainWindow* m_win; | 139 | MainWindow* m_win; |
130 | }; | 140 | }; |
131 | } | 141 | } |
132 | 142 | ||
133 | #endif | 143 | #endif |