Diffstat (limited to 'core/pim/todo/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index ecb4e40..ad7899f 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -32,68 +32,72 @@ | |||
32 | #include <qmessagebox.h> | 32 | #include <qmessagebox.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qwidgetstack.h> | 36 | #include <qwidgetstack.h> |
37 | #include <qaction.h> | 37 | #include <qaction.h> |
38 | #include <qtimer.h> | 38 | #include <qtimer.h> |
39 | #include <qvbox.h> | 39 | #include <qvbox.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
42 | #include <qwhatsthis.h> | 42 | #include <qwhatsthis.h> |
43 | 43 | ||
44 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
45 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
46 | #include <qpe/ir.h> | 46 | #include <qpe/ir.h> |
47 | #include <qpe/resource.h> | 47 | #include <qpe/resource.h> |
48 | #include <qpe/qpemessagebox.h> | 48 | #include <qpe/qpemessagebox.h> |
49 | #include <qpe/alarmserver.h> | 49 | #include <qpe/alarmserver.h> |
50 | #include <qpe/timestring.h> | 50 | #include <qpe/timestring.h> |
51 | #include <qpe/qpeapplication.h> | 51 | #include <qpe/qpeapplication.h> |
52 | 52 | ||
53 | #include <opie/orecur.h> | 53 | #include <opie/orecur.h> |
54 | #include <opie/opimnotifymanager.h> | 54 | #include <opie/opimnotifymanager.h> |
55 | #include <opie/otodoaccessvcal.h> | 55 | #include <opie/otodoaccessvcal.h> |
56 | #include <opie/owidgetstack.h> | ||
56 | 57 | ||
57 | #include <opie/oapplicationfactory.h> | 58 | #include <opie/oapplicationfactory.h> |
58 | 59 | ||
59 | #include "quickeditimpl.h" | 60 | #include "quickeditimpl.h" |
60 | #include "todotemplatemanager.h" | 61 | #include "todotemplatemanager.h" |
61 | #include "templateeditor.h" | 62 | #include "templateeditor.h" |
62 | #include "tableview.h" | 63 | #include "tableview.h" |
63 | 64 | ||
64 | #include "textviewshow.h" | 65 | #include "textviewshow.h" |
65 | #include "todoeditor.h" | 66 | #include "todoeditor.h" |
66 | #include "mainwindow.h" | 67 | #include "mainwindow.h" |
67 | 68 | ||
68 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) | 69 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) |
69 | 70 | ||
70 | using namespace Todo; | 71 | using namespace Todo; |
71 | 72 | ||
72 | MainWindow::MainWindow( QWidget* parent, | 73 | MainWindow::MainWindow( QWidget* parent, |
73 | const char* name, WFlags ) | 74 | const char* name, WFlags ) |
74 | : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) | 75 | : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) |
75 | { | 76 | { |
77 | if (!name) | ||
78 | setName("todo window"); | ||
79 | |||
76 | m_syncing = false; | 80 | m_syncing = false; |
77 | m_showing = false; | 81 | m_showing = false; |
78 | m_counter = 0; | 82 | m_counter = 0; |
79 | m_tempManager = new TemplateManager(); | 83 | m_tempManager = new TemplateManager(); |
80 | m_tempManager->load(); | 84 | m_tempManager->load(); |
81 | 85 | ||
82 | initUI(); | 86 | initUI(); |
83 | initConfig(); | 87 | initConfig(); |
84 | initViews(); | 88 | initViews(); |
85 | initActions(); | 89 | initActions(); |
86 | initEditor(); | 90 | initEditor(); |
87 | initShow(); | 91 | initShow(); |
88 | initTemplate(); | 92 | initTemplate(); |
89 | 93 | ||
90 | populateTemplates(); | 94 | populateTemplates(); |
91 | raiseCurrentView(); | 95 | raiseCurrentView(); |
92 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); | 96 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); |
93 | } | 97 | } |
94 | void MainWindow::initTemplate() { | 98 | void MainWindow::initTemplate() { |
95 | m_curTempEd = new TemplateEditor( this, templateManager() ); | 99 | m_curTempEd = new TemplateEditor( this, templateManager() ); |
96 | } | 100 | } |
97 | void MainWindow::initActions() { | 101 | void MainWindow::initActions() { |
98 | 102 | ||
99 | // Data menu | 103 | // Data menu |
@@ -203,49 +207,49 @@ void MainWindow::initActions() { | |||
203 | 207 | ||
204 | m_options->insertSeparator(); | 208 | m_options->insertSeparator(); |
205 | 209 | ||
206 | m_bar->insertItem( QWidget::tr("Data") ,m_edit ); | 210 | m_bar->insertItem( QWidget::tr("Data") ,m_edit ); |
207 | m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); | 211 | m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); |
208 | m_bar->insertItem( QWidget::tr("Options"), m_options ); | 212 | m_bar->insertItem( QWidget::tr("Options"), m_options ); |
209 | 213 | ||
210 | m_curQuick = new QuickEditImpl( this, m_quicktask ); | 214 | m_curQuick = new QuickEditImpl( this, m_quicktask ); |
211 | addToolBar( (QPEToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); | 215 | addToolBar( (QPEToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); |
212 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); | 216 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); |
213 | 217 | ||
214 | } | 218 | } |
215 | /* m_curCat from Config */ | 219 | /* m_curCat from Config */ |
216 | void MainWindow::initConfig() { | 220 | void MainWindow::initConfig() { |
217 | Config config( "todo" ); | 221 | Config config( "todo" ); |
218 | config.setGroup( "View" ); | 222 | config.setGroup( "View" ); |
219 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); | 223 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); |
220 | m_curCat = config.readEntry( "Category", QString::null ); | 224 | m_curCat = config.readEntry( "Category", QString::null ); |
221 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); | 225 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); |
222 | m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); | 226 | m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); |
223 | m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); | 227 | m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); |
224 | } | 228 | } |
225 | void MainWindow::initUI() { | 229 | void MainWindow::initUI() { |
226 | 230 | ||
227 | m_stack = new QWidgetStack(this, "main stack"); | 231 | m_stack = new OWidgetStack(this, "main stack"); |
228 | 232 | ||
229 | setCentralWidget( m_stack ); | 233 | setCentralWidget( m_stack ); |
230 | 234 | ||
231 | setToolBarsMovable( FALSE ); | 235 | setToolBarsMovable( FALSE ); |
232 | 236 | ||
233 | QToolBar *menubarholder = new QToolBar( this ); | 237 | QToolBar *menubarholder = new QToolBar( this ); |
234 | menubarholder->setHorizontalStretchable( TRUE ); | 238 | menubarholder->setHorizontalStretchable( TRUE ); |
235 | m_bar = new QMenuBar( menubarholder ); | 239 | m_bar = new QMenuBar( menubarholder ); |
236 | 240 | ||
237 | m_tool = new QToolBar( this ); | 241 | m_tool = new QToolBar( this ); |
238 | 242 | ||
239 | /** QPopupMenu */ | 243 | /** QPopupMenu */ |
240 | m_edit = new QPopupMenu( this ); | 244 | m_edit = new QPopupMenu( this ); |
241 | m_options = new QPopupMenu( this ); | 245 | m_options = new QPopupMenu( this ); |
242 | m_catMenu = new QPopupMenu( this ); | 246 | m_catMenu = new QPopupMenu( this ); |
243 | m_template = new QPopupMenu( this ); | 247 | m_template = new QPopupMenu( this ); |
244 | 248 | ||
245 | m_catMenu->setCheckable( TRUE ); | 249 | m_catMenu->setCheckable( TRUE ); |
246 | m_template->setCheckable( TRUE ); | 250 | m_template->setCheckable( TRUE ); |
247 | 251 | ||
248 | connect(m_catMenu, SIGNAL(activated(int) ), | 252 | connect(m_catMenu, SIGNAL(activated(int) ), |
249 | this, SLOT(setCategory(int) ) ); | 253 | this, SLOT(setCategory(int) ) ); |
250 | connect(m_template, SIGNAL(activated(int) ), | 254 | connect(m_template, SIGNAL(activated(int) ), |
251 | this, SLOT(slotNewFromTemplate(int) ) ); | 255 | this, SLOT(slotNewFromTemplate(int) ) ); |
@@ -384,48 +388,49 @@ void MainWindow::closeEvent( QCloseEvent* e ) { | |||
384 | "Free up some space\n" | 388 | "Free up some space\n" |
385 | "and try again.\n" | 389 | "and try again.\n" |
386 | "\nQuit Anyway?"), | 390 | "\nQuit Anyway?"), |
387 | QMessageBox::Yes|QMessageBox::Escape, | 391 | QMessageBox::Yes|QMessageBox::Escape, |
388 | QMessageBox::No|QMessageBox::Default) | 392 | QMessageBox::No|QMessageBox::Default) |
389 | != QMessageBox::No ) { | 393 | != QMessageBox::No ) { |
390 | e->accept(); | 394 | e->accept(); |
391 | quit = true; | 395 | quit = true; |
392 | }else | 396 | }else |
393 | e->ignore(); | 397 | e->ignore(); |
394 | 398 | ||
395 | } | 399 | } |
396 | 400 | ||
397 | if (quit ) { | 401 | if (quit ) { |
398 | Config config( "todo" ); | 402 | Config config( "todo" ); |
399 | config.setGroup( "View" ); | 403 | config.setGroup( "View" ); |
400 | config.writeEntry( "ShowComplete", showCompleted() ); | 404 | config.writeEntry( "ShowComplete", showCompleted() ); |
401 | config.writeEntry( "Category", currentCategory() ); | 405 | config.writeEntry( "Category", currentCategory() ); |
402 | config.writeEntry( "ShowDeadLine", showDeadline()); | 406 | config.writeEntry( "ShowDeadLine", showDeadline()); |
403 | config.writeEntry( "ShowOverDue", showOverDue() ); | 407 | config.writeEntry( "ShowOverDue", showOverDue() ); |
404 | config.writeEntry( "ShowQuickTask", showQuickTask() ); | 408 | config.writeEntry( "ShowQuickTask", showQuickTask() ); |
405 | /* save templates */ | 409 | /* save templates */ |
406 | templateManager()->save(); | 410 | templateManager()->save(); |
407 | e->accept(); | 411 | e->accept(); |
412 | qApp->quit(); | ||
408 | } | 413 | } |
409 | } | 414 | } |
410 | void MainWindow::populateTemplates() { | 415 | void MainWindow::populateTemplates() { |
411 | m_template->clear(); | 416 | m_template->clear(); |
412 | QStringList list = templateManager()->templates(); | 417 | QStringList list = templateManager()->templates(); |
413 | QStringList::Iterator it; | 418 | QStringList::Iterator it; |
414 | for ( it = list.begin(); it != list.end(); ++it ) { | 419 | for ( it = list.begin(); it != list.end(); ++it ) { |
415 | m_template->insertItem( (*it) ); | 420 | m_template->insertItem( (*it) ); |
416 | } | 421 | } |
417 | } | 422 | } |
418 | /* | 423 | /* |
419 | * slotNewFromTemplate | 424 | * slotNewFromTemplate |
420 | * We use the edit widget to do | 425 | * We use the edit widget to do |
421 | * the config but we setUid(1) | 426 | * the config but we setUid(1) |
422 | * to get a new uid | 427 | * to get a new uid |
423 | */ | 428 | */ |
424 | /* | 429 | /* |
425 | * first we get the name of the template | 430 | * first we get the name of the template |
426 | * then we will use the TemplateManager | 431 | * then we will use the TemplateManager |
427 | */ | 432 | */ |
428 | void MainWindow::slotNewFromTemplate( int id ) { | 433 | void MainWindow::slotNewFromTemplate( int id ) { |
429 | QString name = m_template->text( id ); | 434 | QString name = m_template->text( id ); |
430 | 435 | ||
431 | OTodo event = templateManager()->templateEvent( name ); | 436 | OTodo event = templateManager()->templateEvent( name ); |