-rw-r--r-- | core/pim/todo/mainwindow.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 75da27c..9013522 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -56,111 +56,112 @@ _;:, .> :=|. This program is free software; you can | |||
56 | #include "templatedialogimpl.h" | 56 | #include "templatedialogimpl.h" |
57 | #include "tableview.h" | 57 | #include "tableview.h" |
58 | 58 | ||
59 | #include "textviewshow.h" | 59 | #include "textviewshow.h" |
60 | #include "todoeditor.h" | 60 | #include "todoeditor.h" |
61 | #include "newtaskdlg.h" | 61 | #include "newtaskdlg.h" |
62 | #include "mainwindow.h" | 62 | #include "mainwindow.h" |
63 | 63 | ||
64 | using Opie::Core::OApplicationFactory; | 64 | using Opie::Core::OApplicationFactory; |
65 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) | 65 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) |
66 | 66 | ||
67 | using namespace Opie; | 67 | using namespace Opie; |
68 | using namespace Todo; | 68 | using namespace Todo; |
69 | 69 | ||
70 | MainWindow::MainWindow( QWidget* parent, | 70 | MainWindow::MainWindow( QWidget* parent, |
71 | const char* name, WFlags ) | 71 | const char* name, WFlags ) |
72 | : Opie::OPimMainWindow( "Todolist", tr( "Todo List" ), "Todo List", tr( "Task" ), "todo", | 72 | : Opie::OPimMainWindow( "Todolist", "Todo List", tr( "Task" ), "todo", |
73 | parent, name, WType_TopLevel | WStyle_ContextHelp ) | 73 | parent, name, WType_TopLevel | WStyle_ContextHelp ) |
74 | { | 74 | { |
75 | setCaption( tr( "Todo List" ) ); | ||
75 | if (!name) | 76 | if (!name) |
76 | setName("todo window"); | 77 | setName("todo window"); |
77 | 78 | ||
78 | m_syncing = false; | 79 | m_syncing = false; |
79 | m_showing = false; | 80 | m_showing = false; |
80 | m_counter = 0; | 81 | m_counter = 0; |
81 | m_tempManager = new TemplateManager(); | 82 | m_tempManager = new TemplateManager(); |
82 | m_tempManager->load(); | 83 | m_tempManager->load(); |
83 | 84 | ||
84 | initConfig(); | 85 | initConfig(); |
85 | initUI(); | 86 | initUI(); |
86 | initViews(); | 87 | initViews(); |
87 | initActions(); | 88 | initActions(); |
88 | initEditor(); | 89 | initEditor(); |
89 | initShow(); | 90 | initShow(); |
90 | 91 | ||
91 | raiseCurrentView(); | 92 | raiseCurrentView(); |
92 | QTimer::singleShot( 0, this, SLOT(initStuff()) ); | 93 | QTimer::singleShot( 0, this, SLOT(initStuff()) ); |
93 | } | 94 | } |
94 | void MainWindow::initStuff() { | 95 | void MainWindow::initStuff() { |
95 | m_todoMgr.load(); | 96 | m_todoMgr.load(); |
96 | setViewCategory( m_curCat ); | 97 | setViewCategory( m_curCat ); |
97 | setCategory( m_curCat ); | 98 | setCategory( m_curCat ); |
98 | } | 99 | } |
99 | void MainWindow::initActions() { | 100 | void MainWindow::initActions() { |
100 | // Insert Task menu items | 101 | // Insert Task menu items |
101 | QActionGroup *items = new QActionGroup( this, QString::null, false ); | 102 | QActionGroup *items = new QActionGroup( this, QString::null, false ); |
102 | 103 | ||
103 | m_deleteCompleteAction = new QAction( QString::null, QWidget::tr( "Delete completed" ), | 104 | m_deleteCompleteAction = new QAction( QString::null, QWidget::tr( "Delete completed" ), |
104 | 0, items, 0 ); | 105 | 0, items, 0 ); |
105 | connect( m_deleteCompleteAction, SIGNAL(activated()), this, SLOT(slotDeleteCompleted()) ); | 106 | connect( m_deleteCompleteAction, SIGNAL(activated()), this, SLOT(slotDeleteCompleted()) ); |
106 | 107 | ||
107 | insertItemMenuItems( items ); | 108 | insertItemMenuItems( items ); |
108 | 109 | ||
109 | // Insert View menu items | 110 | // Insert View menu items |
110 | items = new QActionGroup( this, QString::null, false ); | 111 | items = new QActionGroup( this, QString::null, false ); |
111 | 112 | ||
112 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), | 113 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), |
113 | 0, items, 0, true ); | 114 | 0, items, 0, true ); |
114 | m_completedAction->setOn( showCompleted() ); | 115 | m_completedAction->setOn( showCompleted() ); |
115 | connect( m_completedAction, SIGNAL(toggled(bool)), this, SLOT(slotShowCompleted(bool)) ); | 116 | connect( m_completedAction, SIGNAL(toggled(bool)), this, SLOT(slotShowCompleted(bool)) ); |
116 | 117 | ||
117 | QAction *a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), | 118 | QAction *a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), |
118 | 0, items, 0, true ); | 119 | 0, items, 0, true ); |
119 | a->setOn( showOverDue() ); | 120 | a->setOn( showOverDue() ); |
120 | connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool)) ); | 121 | connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool)) ); |
121 | 122 | ||
122 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), | 123 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), |
123 | 0, items, 0, true ); | 124 | 0, items, 0, true ); |
124 | m_showDeadLineAction->setOn( showDeadline() ); | 125 | m_showDeadLineAction->setOn( showDeadline() ); |
125 | connect( m_showDeadLineAction, SIGNAL(toggled(bool)), this, SLOT(slotShowDeadLine(bool)) ); | 126 | connect( m_showDeadLineAction, SIGNAL(toggled(bool)), this, SLOT(slotShowDeadLine(bool)) ); |
126 | 127 | ||
127 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), | 128 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), |
128 | 0, items, 0, true ); | 129 | 0, items, 0, true ); |
129 | m_showQuickTaskAction->setOn( showQuickTask() ); | 130 | m_showQuickTaskAction->setOn( showQuickTask() ); |
130 | connect( m_showQuickTaskAction, SIGNAL(toggled(bool)), this, SLOT(slotShowQuickTask(bool)) ); | 131 | connect( m_showQuickTaskAction, SIGNAL(toggled(bool)), this, SLOT(slotShowQuickTask(bool)) ); |
131 | 132 | ||
132 | insertViewMenuItems( items ); | 133 | insertViewMenuItems( items ); |
133 | } | 134 | } |
134 | /* m_curCat from Config */ | 135 | /* m_curCat from Config */ |
135 | void MainWindow::initConfig() { | 136 | void MainWindow::initConfig() { |
136 | Config config( "todo" ); | 137 | Config config( "todo" ); |
137 | config.setGroup( "View" ); | 138 | config.setGroup( "View" ); |
138 | m_completed = config.readBoolEntry( "ShowComplete", true ); | 139 | m_completed = config.readBoolEntry( "ShowComplete", true ); |
139 | m_curCat = config.readEntry( "Category", QString::null ); | 140 | m_curCat = config.readEntry( "Category", QString::null ); |
140 | m_deadline = config.readBoolEntry( "ShowDeadLine", true); | 141 | m_deadline = config.readBoolEntry( "ShowDeadLine", true); |
141 | m_overdue = config.readBoolEntry("ShowOverDue", false ); | 142 | m_overdue = config.readBoolEntry("ShowOverDue", false ); |
142 | m_quicktask = config.readBoolEntry("ShowQuickTask", true); | 143 | m_quicktask = config.readBoolEntry("ShowQuickTask", true); |
143 | } | 144 | } |
144 | void MainWindow::initUI() { | 145 | void MainWindow::initUI() { |
145 | // Create main widget stack | 146 | // Create main widget stack |
146 | m_stack = new Opie::Ui::OWidgetStack(this, "main stack"); | 147 | m_stack = new Opie::Ui::OWidgetStack(this, "main stack"); |
147 | setCentralWidget( m_stack ); | 148 | setCentralWidget( m_stack ); |
148 | connect( this, SIGNAL(categorySelected(const QString&)), | 149 | connect( this, SIGNAL(categorySelected(const QString&)), |
149 | this, SLOT(setCategory(const QString&)) ); | 150 | this, SLOT(setCategory(const QString&)) ); |
150 | 151 | ||
151 | // Create quick task toolbar | 152 | // Create quick task toolbar |
152 | m_curQuick = new QuickEditImpl( this, m_quicktask ); | 153 | m_curQuick = new QuickEditImpl( this, m_quicktask ); |
153 | addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), | 154 | addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), |
154 | QMainWindow::Top, true ); | 155 | QMainWindow::Top, true ); |
155 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered()) ); | 156 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered()) ); |
156 | } | 157 | } |
157 | void MainWindow::initViews() { | 158 | void MainWindow::initViews() { |
158 | 159 | ||
159 | TableView* tableView = new TableView( this, m_stack ); | 160 | TableView* tableView = new TableView( this, m_stack ); |
160 | QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) ); | 161 | QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) ); |
161 | m_stack->addWidget( tableView, m_counter++ ); | 162 | m_stack->addWidget( tableView, m_counter++ ); |
162 | m_views.append( tableView ); | 163 | m_views.append( tableView ); |
163 | m_curView = tableView; | 164 | m_curView = tableView; |
164 | connectBase( tableView ); | 165 | connectBase( tableView ); |
165 | /* add QString type + QString configname to | 166 | /* add QString type + QString configname to |
166 | * the View menu | 167 | * the View menu |
@@ -186,43 +187,43 @@ QPopupMenu* MainWindow::contextMenu( int , bool /*recur*/ ) { | |||
186 | OPimTodoAccess::List MainWindow::list()const { | 187 | OPimTodoAccess::List MainWindow::list()const { |
187 | return m_todoMgr.list(); | 188 | return m_todoMgr.list(); |
188 | } | 189 | } |
189 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 190 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
190 | int cat = 0; | 191 | int cat = 0; |
191 | if ( m_curCat != tr( "All" ) ) | 192 | if ( m_curCat != tr( "All" ) ) |
192 | cat = currentCatId(); | 193 | cat = currentCatId(); |
193 | if ( m_curCat == tr( "Unfiled" ) ) | 194 | if ( m_curCat == tr( "Unfiled" ) ) |
194 | cat = -1; | 195 | cat = -1; |
195 | 196 | ||
196 | int filter = OPimTodoAccess::FilterCategory; | 197 | int filter = OPimTodoAccess::FilterCategory; |
197 | 198 | ||
198 | if (!m_completed ) | 199 | if (!m_completed ) |
199 | filter |= OPimTodoAccess::DoNotShowCompleted; | 200 | filter |= OPimTodoAccess::DoNotShowCompleted; |
200 | if (m_overdue) | 201 | if (m_overdue) |
201 | filter |= OPimTodoAccess::OnlyOverDue; | 202 | filter |= OPimTodoAccess::OnlyOverDue; |
202 | 203 | ||
203 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | 204 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); |
204 | } | 205 | } |
205 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 206 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
206 | int cat = 0; | 207 | int cat = 0; |
207 | if ( m_curCat != tr( "All" ) ) | 208 | if ( m_curCat != tr( "All" ) ) |
208 | cat = currentCatId(); | 209 | cat = currentCatId(); |
209 | 210 | ||
210 | if ( m_curCat == tr( "Unfiled" ) ) | 211 | if ( m_curCat == tr( "Unfiled" ) ) |
211 | cat = -1; | 212 | cat = -1; |
212 | 213 | ||
213 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | 214 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); |
214 | } | 215 | } |
215 | OPimTodo MainWindow::event( int uid ) { | 216 | OPimTodo MainWindow::event( int uid ) { |
216 | return m_todoMgr.event( uid ); | 217 | return m_todoMgr.event( uid ); |
217 | } | 218 | } |
218 | bool MainWindow::isSyncing()const { | 219 | bool MainWindow::isSyncing()const { |
219 | return m_syncing; | 220 | return m_syncing; |
220 | } | 221 | } |
221 | TemplateManager* MainWindow::templateManager() { | 222 | TemplateManager* MainWindow::templateManager() { |
222 | return m_tempManager; | 223 | return m_tempManager; |
223 | } | 224 | } |
224 | Editor* MainWindow::currentEditor() { | 225 | Editor* MainWindow::currentEditor() { |
225 | return m_curEdit; | 226 | return m_curEdit; |
226 | } | 227 | } |
227 | TodoShow* MainWindow::currentShow() { | 228 | TodoShow* MainWindow::currentShow() { |
228 | return m_curShow; | 229 | return m_curShow; |
@@ -285,33 +286,33 @@ void MainWindow::closeEvent( QCloseEvent* e ) { | |||
285 | void MainWindow::slotItemNew() { | 286 | void MainWindow::slotItemNew() { |
286 | NewTaskDlg dlg( templateManager()->templates(), this ); | 287 | NewTaskDlg dlg( templateManager()->templates(), this ); |
287 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { | 288 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { |
288 | QString tempName = dlg.tempSelected(); | 289 | QString tempName = dlg.tempSelected(); |
289 | if ( tempName.isNull() ) | 290 | if ( tempName.isNull() ) |
290 | // Create new, blank task | 291 | // Create new, blank task |
291 | create(); | 292 | create(); |
292 | else { | 293 | else { |
293 | // Create new task from the template selected | 294 | // Create new task from the template selected |
294 | OPimTodo event = templateManager()->templateEvent( tempName ); | 295 | OPimTodo event = templateManager()->templateEvent( tempName ); |
295 | event = currentEditor()->edit( this, event ); | 296 | event = currentEditor()->edit( this, event ); |
296 | if ( currentEditor()->accepted() ) { | 297 | if ( currentEditor()->accepted() ) { |
297 | event.setUid( 1 ); | 298 | event.setUid( 1 ); |
298 | handleAlarms( OPimTodo(), event ); | 299 | handleAlarms( OPimTodo(), event ); |
299 | m_todoMgr.add( event ); | 300 | m_todoMgr.add( event ); |
300 | currentView()->addEvent( event ); | 301 | currentView()->addEvent( event ); |
301 | 302 | ||
302 | reloadCategories(); | 303 | reloadCategories(); |
303 | } | 304 | } |
304 | raiseCurrentView(); | 305 | raiseCurrentView(); |
305 | } | 306 | } |
306 | } | 307 | } |
307 | } | 308 | } |
308 | void MainWindow::slotItemEdit() { | 309 | void MainWindow::slotItemEdit() { |
309 | slotEdit( currentView()->current() ); | 310 | slotEdit( currentView()->current() ); |
310 | } | 311 | } |
311 | void MainWindow::slotItemDuplicate() { | 312 | void MainWindow::slotItemDuplicate() { |
312 | if(m_syncing) { | 313 | if(m_syncing) { |
313 | QMessageBox::warning(this, QWidget::tr("Todo"), | 314 | QMessageBox::warning(this, QWidget::tr("Todo"), |
314 | QWidget::tr("Data can not be edited, currently syncing")); | 315 | QWidget::tr("Data can not be edited, currently syncing")); |
315 | return; | 316 | return; |
316 | } | 317 | } |
317 | OPimTodo ev = m_todoMgr.event( currentView()->current() ); | 318 | OPimTodo ev = m_todoMgr.event( currentView()->current() ); |
@@ -392,33 +393,33 @@ void MainWindow::slotDeleteCompleted() { | |||
392 | } | 393 | } |
393 | 394 | ||
394 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) | 395 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) |
395 | return; | 396 | return; |
396 | 397 | ||
397 | 398 | ||
398 | m_todoMgr.removeCompleted(); | 399 | m_todoMgr.removeCompleted(); |
399 | currentView()->updateView( ); | 400 | currentView()->updateView( ); |
400 | } | 401 | } |
401 | /* | 402 | /* |
402 | * set the category | 403 | * set the category |
403 | */ | 404 | */ |
404 | void MainWindow::setCategory( const QString &category ) { | 405 | void MainWindow::setCategory( const QString &category ) { |
405 | m_curCat = category; | 406 | m_curCat = category; |
406 | if ( m_curCat == tr( "All" ) ) | 407 | if ( m_curCat == tr( "All" ) ) |
407 | m_curCat = QString::null; | 408 | m_curCat = QString::null; |
408 | 409 | ||
409 | currentView()->setShowCategory( m_curCat ); | 410 | currentView()->setShowCategory( m_curCat ); |
410 | raiseCurrentView(); | 411 | raiseCurrentView(); |
411 | } | 412 | } |
412 | void MainWindow::slotShowDeadLine( bool dead) { | 413 | void MainWindow::slotShowDeadLine( bool dead) { |
413 | m_deadline = dead; | 414 | m_deadline = dead; |
414 | currentView()->setShowDeadline( dead ); | 415 | currentView()->setShowDeadline( dead ); |
415 | } | 416 | } |
416 | void MainWindow::slotShowCompleted( bool show) { | 417 | void MainWindow::slotShowCompleted( bool show) { |
417 | m_completed = show; | 418 | m_completed = show; |
418 | currentView()->setShowCompleted( m_completed ); | 419 | currentView()->setShowCompleted( m_completed ); |
419 | } | 420 | } |
420 | void MainWindow::slotShowQuickTask( bool show ) { | 421 | void MainWindow::slotShowQuickTask( bool show ) { |
421 | m_quicktask = show; | 422 | m_quicktask = show; |
422 | if ( m_quicktask ) | 423 | if ( m_quicktask ) |
423 | m_curQuick->widget()->show(); | 424 | m_curQuick->widget()->show(); |
424 | else | 425 | else |