Diffstat (limited to 'core/pim/datebook2/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook2/mainwindow.cpp | 97 |
1 files changed, 88 insertions, 9 deletions
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 | |||
@@ -15,2 +15,3 @@ | |||
15 | 15 | ||
16 | #include "editor.h" | ||
16 | #include "show.h" | 17 | #include "show.h" |
@@ -24,3 +25,4 @@ using namespace Datebook; | |||
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" ) ); |
@@ -31,3 +33,2 @@ MainWindow::MainWindow() | |||
31 | 33 | ||
32 | raiseCurrentView(); | ||
33 | QTimer::singleShot(0, this, SLOT(populate() ) ); | 34 | QTimer::singleShot(0, this, SLOT(populate() ) ); |
@@ -43,2 +44,8 @@ MainWindow::MainWindow() | |||
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 | } |
@@ -97,4 +104,8 @@ void MainWindow::initUI() { | |||
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"), |
@@ -132,2 +143,6 @@ void MainWindow::initUI() { | |||
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) ), |
@@ -148,4 +163,8 @@ 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 | } |
@@ -188,11 +207,17 @@ BookManager* MainWindow::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() { |
@@ -204,6 +229,25 @@ void MainWindow::slotAction( QAction* act ) { | |||
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 | } |
@@ -226 +270,36 @@ bool MainWindow::viewStartMonday()const { | |||
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 | } | ||