summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp133
-rw-r--r--core/pim/todo/mainwindow.h5
-rw-r--r--core/pim/todo/otaskeditor.cpp13
-rw-r--r--core/pim/todo/quickeditimpl.cpp20
-rw-r--r--core/pim/todo/taskeditoralarms.cpp190
-rw-r--r--core/pim/todo/taskeditoralarms.h26
-rw-r--r--core/pim/todo/taskeditorstatus.cpp11
-rw-r--r--core/pim/todo/templatedialog.cpp10
-rw-r--r--core/pim/todo/templatedialogimpl.cpp10
-rw-r--r--core/pim/todo/templateeditor.cpp5
-rw-r--r--core/pim/todo/todomanager.cpp1
11 files changed, 373 insertions, 51 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index c5cedc6..5119ae0 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,145 +1,150 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = General Public License along with 21  -_. . .   )=.  = General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include <unistd.h> 29#include <unistd.h>
30 30
31#include <qmenubar.h> 31#include <qmenubar.h>
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 <qwidgetstack.h> 36#include <qwidgetstack.h>
36#include <qaction.h> 37#include <qaction.h>
37#include <qtimer.h> 38#include <qtimer.h>
38#include <qvbox.h> 39#include <qvbox.h>
39#include <qlayout.h> 40#include <qlayout.h>
40#include <qlineedit.h> 41#include <qlineedit.h>
41#include <qwhatsthis.h> 42#include <qwhatsthis.h>
42 43
43#include <qpe/applnk.h> 44#include <qpe/applnk.h>
44#include <qpe/config.h> 45#include <qpe/config.h>
45#include <qpe/ir.h> 46#include <qpe/ir.h>
46#include <qpe/resource.h> 47#include <qpe/resource.h>
47#include <qpe/qpemessagebox.h> 48#include <qpe/qpemessagebox.h>
49#include <qpe/alarmserver.h>
50#include <qpe/timestring.h>
51#include <qpe/qpeapplication.h>
48 52
49#include <opie/orecur.h> 53#include <opie/orecur.h>
54#include <opie/opimnotifymanager.h>
50#include <opie/otodoaccessvcal.h> 55#include <opie/otodoaccessvcal.h>
51 56
52#include "quickeditimpl.h" 57#include "quickeditimpl.h"
53#include "todotemplatemanager.h" 58#include "todotemplatemanager.h"
54#include "templateeditor.h" 59#include "templateeditor.h"
55#include "tableview.h" 60#include "tableview.h"
56 61
57#include "textviewshow.h" 62#include "textviewshow.h"
58#include "todoeditor.h" 63#include "todoeditor.h"
59#include "mainwindow.h" 64#include "mainwindow.h"
60 65
61 66
62using namespace Todo; 67using namespace Todo;
63 68
64MainWindow::MainWindow( QWidget* parent, 69MainWindow::MainWindow( QWidget* parent,
65 const char* name ) 70 const char* name )
66 : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) 71 : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp )
67{ 72{
68 m_syncing = false; 73 m_syncing = false;
69 m_counter = 0; 74 m_counter = 0;
70 m_tempManager = new TemplateManager(); 75 m_tempManager = new TemplateManager();
71 m_tempManager->load(); 76 m_tempManager->load();
72 77
73 initUI(); 78 initUI();
74 initConfig(); 79 initConfig();
75 initViews(); 80 initViews();
76 initActions(); 81 initActions();
77 initEditor(); 82 initEditor();
78 initShow(); 83 initShow();
79 initTemplate(); 84 initTemplate();
80 85
81 populateTemplates(); 86 populateTemplates();
82 raiseCurrentView(); 87 raiseCurrentView();
83 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 88 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
84} 89}
85void MainWindow::initTemplate() { 90void MainWindow::initTemplate() {
86 m_curTempEd = new TemplateEditor( this, templateManager() ); 91 m_curTempEd = new TemplateEditor( this, templateManager() );
87} 92}
88void MainWindow::initActions() { 93void MainWindow::initActions() {
89 94
90 // Data menu 95 // Data menu
91 m_edit->insertItem(QWidget::tr("New from template"), m_template, 96 m_edit->insertItem(QWidget::tr("New from template"), m_template,
92 -1, 0 ); 97 -1, 0 );
93 98
94 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), 99 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ),
95 QString::null, 0, this, 0 ); 100 QString::null, 0, this, 0 );
96 connect(a, SIGNAL( activated() ), 101 connect(a, SIGNAL( activated() ),
97 this, SLOT( slotNew() ) ); 102 this, SLOT( slotNew() ) );
98 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); 103 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) );
99 a->addTo(m_tool ); 104 a->addTo(m_tool );
100 a->addTo(m_edit ); 105 a->addTo(m_edit );
101 106
102 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), 107 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ),
103 QString::null, 0, this, 0 ); 108 QString::null, 0, this, 0 );
104 connect(a, SIGNAL(activated() ), 109 connect(a, SIGNAL(activated() ),
105 this, SLOT( slotEdit() ) ); 110 this, SLOT( slotEdit() ) );
106 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); 111 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) );
107 a->addTo( m_tool ); 112 a->addTo( m_tool );
108 a->addTo( m_edit ); 113 a->addTo( m_edit );
109 m_editAction = a; 114 m_editAction = a;
110 115
111 a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); 116 a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 );
112 connect(a, SIGNAL( activated() ), 117 connect(a, SIGNAL( activated() ),
113 this, SLOT( slotShowDetails() ) ); 118 this, SLOT( slotShowDetails() ) );
114 a->addTo( m_edit ); 119 a->addTo( m_edit );
115 120
116 m_edit->insertSeparator(); 121 m_edit->insertSeparator();
117 122
118 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), 123 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ),
119 QString::null, 0, this, 0 ); 124 QString::null, 0, this, 0 );
120 connect(a, SIGNAL(activated() ), 125 connect(a, SIGNAL(activated() ),
121 this, SLOT(slotDelete() ) ); 126 this, SLOT(slotDelete() ) );
122 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); 127 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) );
123 a->addTo( m_tool ); 128 a->addTo( m_tool );
124 a->addTo( m_edit ); 129 a->addTo( m_edit );
125 m_deleteAction = a; 130 m_deleteAction = a;
126 131
127 a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); 132 a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 );
128 connect(a, SIGNAL( activated() ), 133 connect(a, SIGNAL( activated() ),
129 this, SLOT( slotDeleteAll() ) ); 134 this, SLOT( slotDeleteAll() ) );
130 a->addTo(m_edit ); 135 a->addTo(m_edit );
131 m_deleteAllAction = a; 136 m_deleteAllAction = a;
132 137
133 a = new QAction( QString::null, QWidget::tr("Delete completed"), 138 a = new QAction( QString::null, QWidget::tr("Delete completed"),
134 0, this, 0 ); 139 0, this, 0 );
135 connect(a, SIGNAL( activated() ), 140 connect(a, SIGNAL( activated() ),
136 this, SLOT( slotDeleteCompleted() ) ); 141 this, SLOT( slotDeleteCompleted() ) );
137 a->addTo(m_edit ); 142 a->addTo(m_edit );
138 a->setEnabled( TRUE ); 143 a->setEnabled( TRUE );
139 m_deleteCompleteAction = a; 144 m_deleteCompleteAction = a;
140 145
141 m_edit->insertSeparator(); 146 m_edit->insertSeparator();
142 147
143 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); 148 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 );
144 connect(a, SIGNAL( activated() ), 149 connect(a, SIGNAL( activated() ),
145 this, SLOT( slotDuplicate() ) ); 150 this, SLOT( slotDuplicate() ) );
@@ -208,616 +213,740 @@ void MainWindow::initConfig() {
208 m_curCat = config.readEntry( "Category", QString::null ); 213 m_curCat = config.readEntry( "Category", QString::null );
209 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 214 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
210 m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); 215 m_overdue = config.readBoolEntry("ShowOverDue", FALSE );
211 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); 216 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE);
212} 217}
213void MainWindow::initUI() { 218void MainWindow::initUI() {
214 219
215 m_stack = new QWidgetStack(this, "main stack"); 220 m_stack = new QWidgetStack(this, "main stack");
216 221
217 setCentralWidget( m_stack ); 222 setCentralWidget( m_stack );
218 223
219 setToolBarsMovable( FALSE ); 224 setToolBarsMovable( FALSE );
220 225
221 QToolBar *menubarholder = new QToolBar( this ); 226 QToolBar *menubarholder = new QToolBar( this );
222 menubarholder->setHorizontalStretchable( TRUE ); 227 menubarholder->setHorizontalStretchable( TRUE );
223 m_bar = new QMenuBar( menubarholder ); 228 m_bar = new QMenuBar( menubarholder );
224 229
225 m_tool = new QToolBar( this ); 230 m_tool = new QToolBar( this );
226 231
227 /** QPopupMenu */ 232 /** QPopupMenu */
228 m_edit = new QPopupMenu( this ); 233 m_edit = new QPopupMenu( this );
229 m_options = new QPopupMenu( this ); 234 m_options = new QPopupMenu( this );
230 m_catMenu = new QPopupMenu( this ); 235 m_catMenu = new QPopupMenu( this );
231 m_template = new QPopupMenu( this ); 236 m_template = new QPopupMenu( this );
232 237
233 m_catMenu->setCheckable( TRUE ); 238 m_catMenu->setCheckable( TRUE );
234 m_template->setCheckable( TRUE ); 239 m_template->setCheckable( TRUE );
235 240
236 connect(m_catMenu, SIGNAL(activated(int) ), 241 connect(m_catMenu, SIGNAL(activated(int) ),
237 this, SLOT(setCategory(int) ) ); 242 this, SLOT(setCategory(int) ) );
238 connect(m_template, SIGNAL(activated(int) ), 243 connect(m_template, SIGNAL(activated(int) ),
239 this, SLOT(slotNewFromTemplate(int) ) ); 244 this, SLOT(slotNewFromTemplate(int) ) );
240} 245}
241void MainWindow::initViews() { 246void MainWindow::initViews() {
242 247
243 TableView* tableView = new TableView( this, m_stack ); 248 TableView* tableView = new TableView( this, m_stack );
244 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." ) ); 249 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." ) );
245 m_stack->addWidget( tableView, m_counter++ ); 250 m_stack->addWidget( tableView, m_counter++ );
246 m_views.append( tableView ); 251 m_views.append( tableView );
247 m_curView = tableView; 252 m_curView = tableView;
248 connectBase( tableView ); 253 connectBase( tableView );
249 /* add QString type + QString configname to 254 /* add QString type + QString configname to
250 * the View menu 255 * the View menu
251 * and subdirs for multiple views 256 * and subdirs for multiple views
252 */ 257 */
253} 258}
254void MainWindow::initEditor() { 259void MainWindow::initEditor() {
255 m_curEdit = new Editor(); 260 m_curEdit = new Editor();
256} 261}
257void MainWindow::initShow() { 262void MainWindow::initShow() {
258 m_curShow = new TextViewShow(this, this); 263 m_curShow = new TextViewShow(this, this);
259 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 264 m_stack->addWidget( m_curShow->widget() , m_counter++ );
260} 265}
261MainWindow::~MainWindow() { 266MainWindow::~MainWindow() {
262 delete templateManager(); 267 delete templateManager();
263} 268}
264void MainWindow::connectBase( ViewBase* ) { 269void MainWindow::connectBase( ViewBase* ) {
265 // once templates and signals mix we'll use it again 270 // once templates and signals mix we'll use it again
266} 271}
267QPopupMenu* MainWindow::contextMenu( int , bool recur ) { 272QPopupMenu* MainWindow::contextMenu( int , bool recur ) {
268 QPopupMenu* menu = new QPopupMenu(); 273 QPopupMenu* menu = new QPopupMenu();
269 274
270 m_editAction->addTo( menu ); 275 m_editAction->addTo( menu );
271 m_deleteAction->addTo( menu ); 276 m_deleteAction->addTo( menu );
272 m_duplicateAction->addTo( menu ); 277 m_duplicateAction->addTo( menu );
273 278
274 menu->insertSeparator(); 279 menu->insertSeparator();
275 280
276 /* 281 /*
277 * if this event recurs we allow 282 * if this event recurs we allow
278 * to detach it. 283 * to detach it.
279 * remove all 284 * remove all
280 */ 285 */
281 if ( recur ) { 286 if ( recur ) {
282 ; // FIXME 287 ; // FIXME
283 } 288 }
284 289
285 return menu; 290 return menu;
286} 291}
287QPopupMenu* MainWindow::options() { 292QPopupMenu* MainWindow::options() {
288 qWarning("Options"); 293 qWarning("Options");
289 return m_options; 294 return m_options;
290} 295}
291QPopupMenu* MainWindow::edit() { 296QPopupMenu* MainWindow::edit() {
292 return m_edit; 297 return m_edit;
293} 298}
294QToolBar* MainWindow::toolbar() { 299QToolBar* MainWindow::toolbar() {
295 return m_tool; 300 return m_tool;
296} 301}
297OTodoAccess::List MainWindow::list()const { 302OTodoAccess::List MainWindow::list()const {
298 return m_todoMgr.list(); 303 return m_todoMgr.list();
299} 304}
300OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 305OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
301 int cat = 0; 306 int cat = 0;
302 if ( m_curCat != QWidget::tr("All Categories") ) 307 if ( m_curCat != QWidget::tr("All Categories") )
303 cat = currentCatId(); 308 cat = currentCatId();
309 if ( m_curCat == QWidget::tr("Unfiled") )
310 cat = -1;
311
312 qWarning(" Category %d %s", cat, m_curCat.latin1() );
304 313
305 int filter = 1; 314 int filter = 1;
306 315
307 if (!m_completed ) 316 if (!m_completed )
308 filter |= 4; 317 filter |= 4;
309 if (m_overdue) 318 if (m_overdue)
310 filter |= 2; 319 filter |= 2;
311 320
312 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 321 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
313} 322}
314OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 323OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
315 int cat = 0; 324 int cat = 0;
316 if ( m_curCat != QWidget::tr("All Categories") ) 325 if ( m_curCat != QWidget::tr("All Categories") )
317 cat = currentCatId(); 326 cat = currentCatId();
318 327
328 if ( m_curCat == QWidget::tr("Unfiled") )
329 cat = -1;
330
319 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 331 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
320} 332}
321OTodo MainWindow::event( int uid ) { 333OTodo MainWindow::event( int uid ) {
322 return m_todoMgr.event( uid ); 334 return m_todoMgr.event( uid );
323} 335}
324bool MainWindow::isSyncing()const { 336bool MainWindow::isSyncing()const {
325 return m_syncing; 337 return m_syncing;
326} 338}
327TemplateManager* MainWindow::templateManager() { 339TemplateManager* MainWindow::templateManager() {
328 return m_tempManager; 340 return m_tempManager;
329} 341}
330Editor* MainWindow::currentEditor() { 342Editor* MainWindow::currentEditor() {
331 return m_curEdit; 343 return m_curEdit;
332} 344}
333TodoShow* MainWindow::currentShow() { 345TodoShow* MainWindow::currentShow() {
334 return m_curShow; 346 return m_curShow;
335} 347}
336void MainWindow::slotReload() { 348void MainWindow::slotReload() {
337 m_todoMgr.reload(); 349 m_todoMgr.reload();
338 currentView()->updateView( ); 350 currentView()->updateView( );
339 raiseCurrentView(); 351 raiseCurrentView();
340} 352}
341void MainWindow::closeEvent( QCloseEvent* e ) { 353void MainWindow::closeEvent( QCloseEvent* e ) {
342 if (m_stack->visibleWidget() == currentShow()->widget() ) { 354 if (m_stack->visibleWidget() == currentShow()->widget() ) {
343 raiseCurrentView(); 355 raiseCurrentView();
344 e->ignore(); 356 e->ignore();
345 return; 357 return;
346 } 358 }
347 /* 359 /*
348 * we should have flushed and now we're still saving 360 * we should have flushed and now we're still saving
349 * so there is no need to flush 361 * so there is no need to flush
350 */ 362 */
351 if (m_syncing ) { 363 if (m_syncing ) {
352 e->accept(); 364 e->accept();
353 return; 365 return;
354 } 366 }
355 bool quit = false; 367 bool quit = false;
356 if ( m_todoMgr.saveAll() ){ 368 if ( m_todoMgr.saveAll() ){
357 qWarning("saved"); 369 qWarning("saved");
358 quit = true; 370 quit = true;
359 }else { 371 }else {
360 if ( QMessageBox::critical( this, QWidget::tr("Out of space"), 372 if ( QMessageBox::critical( this, QWidget::tr("Out of space"),
361 QWidget::tr("Todo was unable\n" 373 QWidget::tr("Todo was unable\n"
362 "to save your changes.\n" 374 "to save your changes.\n"
363 "Free up some space\n" 375 "Free up some space\n"
364 "and try again.\n" 376 "and try again.\n"
365 "\nQuit Anyway?"), 377 "\nQuit Anyway?"),
366 QMessageBox::Yes|QMessageBox::Escape, 378 QMessageBox::Yes|QMessageBox::Escape,
367 QMessageBox::No|QMessageBox::Default) 379 QMessageBox::No|QMessageBox::Default)
368 != QMessageBox::No ) { 380 != QMessageBox::No ) {
369 e->accept(); 381 e->accept();
370 quit = true; 382 quit = true;
371 }else 383 }else
372 e->ignore(); 384 e->ignore();
373 385
374 } 386 }
375 387
376 if (quit ) { 388 if (quit ) {
377 Config config( "todo" ); 389 Config config( "todo" );
378 config.setGroup( "View" ); 390 config.setGroup( "View" );
379 config.writeEntry( "ShowComplete", showCompleted() ); 391 config.writeEntry( "ShowComplete", showCompleted() );
380 config.writeEntry( "Category", currentCategory() ); 392 config.writeEntry( "Category", currentCategory() );
381 config.writeEntry( "ShowDeadLine", showDeadline()); 393 config.writeEntry( "ShowDeadLine", showDeadline());
382 config.writeEntry( "ShowOverDue", showOverDue() ); 394 config.writeEntry( "ShowOverDue", showOverDue() );
383 config.writeEntry( "ShowQuickTask", showQuickTask() ); 395 config.writeEntry( "ShowQuickTask", showQuickTask() );
384 /* save templates */ 396 /* save templates */
385 templateManager()->save(); 397 templateManager()->save();
386 e->accept(); 398 e->accept();
387 } 399 }
388} 400}
389void MainWindow::populateTemplates() { 401void MainWindow::populateTemplates() {
390 m_template->clear(); 402 m_template->clear();
391 QStringList list = templateManager()->templates(); 403 QStringList list = templateManager()->templates();
392 QStringList::Iterator it; 404 QStringList::Iterator it;
393 for ( it = list.begin(); it != list.end(); ++it ) { 405 for ( it = list.begin(); it != list.end(); ++it ) {
394 m_template->insertItem( (*it) ); 406 m_template->insertItem( (*it) );
395 } 407 }
396} 408}
397/* 409/*
398 * slotNewFromTemplate 410 * slotNewFromTemplate
399 * We use the edit widget to do 411 * We use the edit widget to do
400 * the config but we setUid(-1) 412 * the config but we setUid(-1)
401 * to get a new uid 413 * to get a new uid
402 */ 414 */
403/* 415/*
404 * first we get the name of the template 416 * first we get the name of the template
405 * then we will use the TemplateManager 417 * then we will use the TemplateManager
406 */ 418 */
407void MainWindow::slotNewFromTemplate( int id ) { 419void MainWindow::slotNewFromTemplate( int id ) {
408 QString name = m_template->text( id ); 420 QString name = m_template->text( id );
409 421
410 OTodo event = templateManager()->templateEvent( name ); 422 OTodo event = templateManager()->templateEvent( name );
411 event = currentEditor()->edit(this, 423 event = currentEditor()->edit(this,
412 event ); 424 event );
413 425
414 if ( currentEditor()->accepted() ) { 426 if ( currentEditor()->accepted() ) {
415 /* assign new todo */ 427 /* assign new todo */
416 event.setUid( -1 ); 428 event.setUid( -1 );
417 currentView()->addEvent( event ); 429 currentView()->addEvent( event );
418 m_todoMgr.add( event ); 430 m_todoMgr.add( event );
419 431
420 populateCategories(); 432 populateCategories();
421 } 433 }
422} 434}
423void MainWindow::slotNew() { 435void MainWindow::slotNew() {
424 create(); 436 create();
425} 437}
426void MainWindow::slotDuplicate() { 438void MainWindow::slotDuplicate() {
427 if(m_syncing) { 439 if(m_syncing) {
428 QMessageBox::warning(this, QWidget::tr("Todo"), 440 QMessageBox::warning(this, QWidget::tr("Todo"),
429 QWidget::tr("Can not edit data, currently syncing")); 441 QWidget::tr("Can not edit data, currently syncing"));
430 return; 442 return;
431 } 443 }
432 OTodo ev = m_todoMgr.event( currentView()->current() ); 444 OTodo ev = m_todoMgr.event( currentView()->current() );
433 /* let's generate a new uid */ 445 /* let's generate a new uid */
434 ev.setUid(-1); 446 ev.setUid(-1);
435 m_todoMgr.add( ev ); 447 m_todoMgr.add( ev );
436 448
437 currentView()->addEvent( ev ); 449 currentView()->addEvent( ev );
438 raiseCurrentView(); 450 raiseCurrentView();
439} 451}
440void MainWindow::slotDelete() { 452void MainWindow::slotDelete() {
441 if (!currentView()->current() ) 453 if (!currentView()->current() )
442 return; 454 return;
443 455
444 if(m_syncing) { 456 if(m_syncing) {
445 QMessageBox::warning(this, QWidget::tr("Todo"), 457 QMessageBox::warning(this, QWidget::tr("Todo"),
446 QWidget::tr("Can not edit data, currently syncing")); 458 QWidget::tr("Can not edit data, currently syncing"));
447 return; 459 return;
448 } 460 }
449 QString strName = currentView()->currentRepresentation(); 461 QString strName = currentView()->currentRepresentation();
450 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) 462 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) )
451 return; 463 return;
452 464
465 handleAlarms( OTodo(), m_todoMgr.event( currentView()->current() ) );
453 m_todoMgr.remove( currentView()->current() ); 466 m_todoMgr.remove( currentView()->current() );
454 currentView()->removeEvent( currentView()->current() ); 467 currentView()->removeEvent( currentView()->current() );
455 raiseCurrentView(); 468 raiseCurrentView();
456} 469}
457void MainWindow::slotDeleteAll() { 470void MainWindow::slotDeleteAll() {
458 if(m_syncing) { 471 if(m_syncing) {
459 QMessageBox::warning(this, QWidget::tr("Todo"), 472 QMessageBox::warning(this, QWidget::tr("Todo"),
460 QWidget::tr("Can not edit data, currently syncing")); 473 QWidget::tr("Can not edit data, currently syncing"));
461 return; 474 return;
462 } 475 }
463 476
464 477
465 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) 478 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) )
466 return; 479 return;
467 480
468 m_todoMgr.removeAll(); 481 m_todoMgr.removeAll();
469 currentView()->clear(); 482 currentView()->clear();
470 483
471 raiseCurrentView(); 484 raiseCurrentView();
472} 485}
473void MainWindow::slotDeleteCompleted() { 486void MainWindow::slotDeleteCompleted() {
474 if(m_syncing) { 487 if(m_syncing) {
475 QMessageBox::warning(this, QWidget::tr("Todo"), 488 QMessageBox::warning(this, QWidget::tr("Todo"),
476 QWidget::tr("Can not edit data, currently syncing")); 489 QWidget::tr("Can not edit data, currently syncing"));
477 return; 490 return;
478 } 491 }
479 492
480 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) 493 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) )
481 return; 494 return;
482 495
483 496
484 m_todoMgr.removeCompleted(); 497 m_todoMgr.removeCompleted();
485 currentView()->updateView( ); 498 currentView()->updateView( );
486} 499}
487void MainWindow::slotFind() { 500void MainWindow::slotFind() {
488 501
489} 502}
490void MainWindow::slotEdit() { 503void MainWindow::slotEdit() {
491 slotEdit( currentView()->current() ); 504 slotEdit( currentView()->current() );
492} 505}
493/* 506/*
494 * set the category 507 * set the category
495 */ 508 */
496void MainWindow::setCategory( int c) { 509void MainWindow::setCategory( int c) {
497 if ( c <= 0 ) return; 510 if ( c <= 0 ) return;
498 511
499 512
500 qWarning("Iterating over cats %d", c ); 513 qWarning("Iterating over cats %d", c );
501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 514 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
502 m_catMenu->setItemChecked(i, c == (int)i ); 515 m_catMenu->setItemChecked(i, c == (int)i );
503 516
504 if (c == 1 ) { 517 if (c == 1 ) {
505 m_curCat = QString::null; 518 m_curCat = QString::null;
506 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); 519 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) );
507 520
508 }else if ( c == (int)m_catMenu->count() - 1 ) { 521 }else if ( c == (int)m_catMenu->count() - 1 ) {
509 m_curCat = QWidget::tr("Unfiled"); 522 m_curCat = QWidget::tr("Unfiled");
510 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); 523 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") );
511 }else { 524 }else {
512 m_curCat = m_todoMgr.categories()[c-2]; 525 m_curCat = m_todoMgr.categories()[c-2];
513 setCaption( QWidget::tr("Todo") + " - " + m_curCat ); 526 setCaption( QWidget::tr("Todo") + " - " + m_curCat );
514 } 527 }
515 m_catMenu->setItemChecked( c, true ); 528 m_catMenu->setItemChecked( c, true );
516 529
517 currentView()->setShowCategory( m_curCat ); 530 currentView()->setShowCategory( m_curCat );
518 raiseCurrentView(); 531 raiseCurrentView();
519} 532}
520void MainWindow::slotShowDeadLine( bool dead) { 533void MainWindow::slotShowDeadLine( bool dead) {
521 m_deadline = dead; 534 m_deadline = dead;
522 currentView()->setShowDeadline( dead ); 535 currentView()->setShowDeadline( dead );
523} 536}
524void MainWindow::slotShowCompleted( bool show) { 537void MainWindow::slotShowCompleted( bool show) {
525 m_completed = show; 538 m_completed = show;
526 currentView()->setShowCompleted( m_completed ); 539 currentView()->setShowCompleted( m_completed );
527} 540}
528void MainWindow::slotShowQuickTask( bool show ) { 541void MainWindow::slotShowQuickTask( bool show ) {
529 m_quicktask = show; 542 m_quicktask = show;
530 if ( m_quicktask ) 543 if ( m_quicktask )
531 m_curQuick->widget()->show(); 544 m_curQuick->widget()->show();
532 else 545 else
533 m_curQuick->widget()->hide(); 546 m_curQuick->widget()->hide();
534} 547}
535bool MainWindow::showOverDue()const { 548bool MainWindow::showOverDue()const {
536 return m_overdue; 549 return m_overdue;
537} 550}
538void MainWindow::setDocument( const QString& fi) { 551void MainWindow::setDocument( const QString& fi) {
539 DocLnk doc(fi); 552 DocLnk doc(fi);
540 if (doc.isValid() ) 553 if (doc.isValid() )
541 receiveFile(doc.file() ); 554 receiveFile(doc.file() );
542 else 555 else
543 receiveFile(fi ); 556 receiveFile(fi );
544} 557}
545 558
546static const char *beamfile = "/tmp/opie-todo.vcs"; 559static const char *beamfile = "/tmp/opie-todo.vcs";
547void MainWindow::slotBeam() { 560void MainWindow::slotBeam() {
548 beam( currentView()->current() ); 561 beam( currentView()->current() );
549} 562}
550void MainWindow::beamDone( Ir* ir) { 563void MainWindow::beamDone( Ir* ir) {
551 delete ir; 564 delete ir;
552 ::unlink( beamfile ); 565 ::unlink( beamfile );
553} 566}
554void MainWindow::receiveFile( const QString& filename ) { 567void MainWindow::receiveFile( const QString& filename ) {
555 OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); 568 OTodoAccessVCal* cal = new OTodoAccessVCal(filename );
556 OTodoAccess acc( cal ); 569 OTodoAccess acc( cal );
557 acc.load(); 570 acc.load();
558 OTodoAccess::List list = acc.allRecords(); 571 OTodoAccess::List list = acc.allRecords();
559 572
560 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); 573 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
561 574
562 if ( QMessageBox::information(this, QWidget::tr("New Tasks"), 575 if ( QMessageBox::information(this, QWidget::tr("New Tasks"),
563 message, QMessageBox::Ok, 576 message, QMessageBox::Ok,
564 QMessageBox::Cancel ) == QMessageBox::Ok ) { 577 QMessageBox::Cancel ) == QMessageBox::Ok ) {
565 OTodoAccess::List::Iterator it; 578 OTodoAccess::List::Iterator it;
566 for ( it = list.begin(); it != list.end(); ++it ) 579 for ( it = list.begin(); it != list.end(); ++it )
567 m_todoMgr.add( (*it) ); 580 m_todoMgr.add( (*it) );
568 581
569 currentView()->updateView(); 582 currentView()->updateView();
570 } 583 }
571} 584}
572 585
573void MainWindow::slotFlush() { 586void MainWindow::slotFlush() {
574 m_syncing = FALSE; 587 m_syncing = FALSE;
575 m_todoMgr.save(); 588 m_todoMgr.save();
576} 589}
577void MainWindow::slotShowDetails() { 590void MainWindow::slotShowDetails() {
578 slotShow( currentView()->current() ); 591 slotShow( currentView()->current() );
579} 592}
580/* 593/*
581 * populate the Categories 594 * populate the Categories
582 * Menu 595 * Menu
583 */ 596 */
584void MainWindow::populateCategories() { 597void MainWindow::populateCategories() {
585 m_todoMgr.load(); 598 m_todoMgr.load();
586 599
587 m_catMenu->clear(); 600 m_catMenu->clear();
588 int id, rememberId; 601 int id, rememberId;
589 id = 1; 602 id = 1;
590 rememberId = 1; 603 rememberId = 1;
591 604
592 m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); 605 m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ );
593 m_catMenu->insertSeparator(); 606 m_catMenu->insertSeparator();
594 QStringList categories = m_todoMgr.categories(); 607 QStringList categories = m_todoMgr.categories();
595 categories.append( QWidget::tr( "Unfiled" ) ); 608 categories.append( QWidget::tr( "Unfiled" ) );
596 for ( QStringList::Iterator it = categories.begin(); 609 for ( QStringList::Iterator it = categories.begin();
597 it != categories.end(); ++it ) { 610 it != categories.end(); ++it ) {
598 m_catMenu->insertItem( *it, id ); 611 m_catMenu->insertItem( *it, id );
599 if ( *it == currentCategory() ) 612 if ( *it == currentCategory() )
600 rememberId = id; 613 rememberId = id;
601 ++id; 614 ++id;
602 } 615 }
603 setCategory( rememberId ); 616 setCategory( rememberId );
604} 617}
605bool MainWindow::showCompleted()const { 618bool MainWindow::showCompleted()const {
606 return m_completed; 619 return m_completed;
607} 620}
608bool MainWindow::showDeadline()const { 621bool MainWindow::showDeadline()const {
609 return m_deadline; 622 return m_deadline;
610} 623}
611bool MainWindow::showQuickTask()const { 624bool MainWindow::showQuickTask()const {
612 return m_quicktask; 625 return m_quicktask;
613} 626}
614QString MainWindow::currentCategory()const { 627QString MainWindow::currentCategory()const {
615 return m_curCat; 628 return m_curCat;
616} 629}
617int MainWindow::currentCatId() { 630int MainWindow::currentCatId() {
618 return m_todoMgr.catId( m_curCat ); 631 return m_todoMgr.catId( m_curCat );
619} 632}
620ViewBase* MainWindow::currentView() { 633ViewBase* MainWindow::currentView() {
621 return m_curView; 634 return m_curView;
622} 635}
623void MainWindow::raiseCurrentView() { 636void MainWindow::raiseCurrentView() {
624 m_stack->raiseWidget( m_curView->widget() ); 637 m_stack->raiseWidget( m_curView->widget() );
625} 638}
626void MainWindow::slotShowDue(bool ov) { 639void MainWindow::slotShowDue(bool ov) {
627 m_overdue = ov; 640 m_overdue = ov;
628 currentView()->showOverDue( ov ); 641 currentView()->showOverDue( ov );
629 raiseCurrentView(); 642 raiseCurrentView();
630} 643}
631void MainWindow::slotShow( int uid ) { 644void MainWindow::slotShow( int uid ) {
632 qWarning("slotShow"); 645 qWarning("slotShow");
633 currentShow()->slotShow( event( uid ) ); 646 currentShow()->slotShow( event( uid ) );
634 m_stack->raiseWidget( currentShow()->widget() ); 647 m_stack->raiseWidget( currentShow()->widget() );
635} 648}
636void MainWindow::slotEdit( int uid ) { 649void MainWindow::slotEdit( int uid ) {
637 if (uid == 1 ) return; 650 if (uid == 1 ) return;
638 if(m_syncing) { 651 if(m_syncing) {
639 QMessageBox::warning(this, QWidget::tr("Todo"), 652 QMessageBox::warning(this, QWidget::tr("Todo"),
640 QWidget::tr("Can not edit data, currently syncing")); 653 QWidget::tr("Can not edit data, currently syncing"));
641 return; 654 return;
642 } 655 }
643 656
644 OTodo todo = m_todoMgr.event( uid ); 657 OTodo old_todo = m_todoMgr.event( uid );
645 658
646 todo = currentEditor()->edit(this, todo ); 659 OTodo todo = currentEditor()->edit(this, old_todo );
647 660
648 /* if completed */ 661 /* if completed */
649 if ( currentEditor()->accepted() ) { 662 if ( currentEditor()->accepted() ) {
650 qWarning("Replacing now" ); 663 qWarning("Replacing now" );
664 handleAlarms( old_todo, todo );
651 m_todoMgr.update( todo.uid(), todo ); 665 m_todoMgr.update( todo.uid(), todo );
652 currentView()->replaceEvent( todo ); 666 currentView()->replaceEvent( todo );
653 /* a Category might have changed */ 667 /* a Category might have changed */
654 populateCategories(); 668 populateCategories();
655 } 669 }
656 670
657 raiseCurrentView(); 671 raiseCurrentView();
658} 672}
659/* 673/*
660void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 674void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
661 m_todoMgr.update( uid, ev ); 675 m_todoMgr.update( uid, ev );
662} 676}
663*/ 677*/
664void MainWindow::updateTodo( const OTodo& ev) { 678void MainWindow::updateTodo( const OTodo& ev) {
665 m_todoMgr.update( ev.uid() , ev ); 679 m_todoMgr.update( ev.uid() , ev );
666} 680}
667/* The view changed it's configuration 681/* The view changed it's configuration
668 * update the view menu 682 * update the view menu
669 */ 683 */
670void MainWindow::slotUpdate3( QWidget* ) { 684void MainWindow::slotUpdate3( QWidget* ) {
671 685
672} 686}
673void MainWindow::updateList() { 687void MainWindow::updateList() {
674 m_todoMgr.updateList(); 688 m_todoMgr.updateList();
675} 689}
676void MainWindow::setReadAhead( uint count ) { 690void MainWindow::setReadAhead( uint count ) {
677 if (m_todoMgr.todoDB() ) 691 if (m_todoMgr.todoDB() )
678 m_todoMgr.todoDB()->setReadAhead( count ); 692 m_todoMgr.todoDB()->setReadAhead( count );
679} 693}
680void MainWindow::slotQuickEntered() { 694void MainWindow::slotQuickEntered() {
681 qWarning("entered"); 695 qWarning("entered");
682 OTodo todo = quickEditor()->todo(); 696 OTodo todo = quickEditor()->todo();
683 if (todo.isEmpty() ) 697 if (todo.isEmpty() )
684 return; 698 return;
685 699
686 m_todoMgr.add( todo ); 700 m_todoMgr.add( todo );
687 currentView()->addEvent( todo ); 701 currentView()->addEvent( todo );
688 raiseCurrentView(); 702 raiseCurrentView();
689} 703}
690QuickEditBase* MainWindow::quickEditor() { 704QuickEditBase* MainWindow::quickEditor() {
691 return m_curQuick; 705 return m_curQuick;
692} 706}
693void MainWindow::slotComplete( int uid ) { 707void MainWindow::slotComplete( int uid ) {
694 slotComplete( event(uid) ); 708 slotComplete( event(uid) );
695} 709}
696void MainWindow::slotComplete( const OTodo& todo ) { 710void MainWindow::slotComplete( const OTodo& todo ) {
697 OTodo to = todo; 711 OTodo to = todo;
698 to.setCompleted( !to.isCompleted() ); 712 to.setCompleted( !to.isCompleted() );
699 to.setCompletedDate( QDate::currentDate() ); 713 to.setCompletedDate( QDate::currentDate() );
700 714
701 /* 715 /*
702 * if the item does recur 716 * if the item does recur
703 * we need to spin it off 717 * we need to spin it off
704 * and update the items duedate to the next 718 * and update the items duedate to the next
705 * possible recurrance of this item... 719 * possible recurrance of this item...
706 * the spinned off one will loose the 720 * the spinned off one will loose the
707 */ 721 */
708 if ( to.hasRecurrence() && to.isCompleted() ) { 722 if ( to.hasRecurrence() && to.isCompleted() ) {
709 OTodo to2( to ); 723 OTodo to2( to );
710 724
711 /* the spinned off one won't recur anymore */ 725 /* the spinned off one won't recur anymore */
712 to.setRecurrence( ORecur() ); 726 to.setRecurrence( ORecur() );
713 727
714 ORecur rec = to2.recurrence(); 728 ORecur rec = to2.recurrence();
715 rec.setStart( to.dueDate() ); 729 rec.setStart( to.dueDate() );
716 to2.setRecurrence( rec ); 730 to2.setRecurrence( rec );
717 /* 731 /*
718 * if there is a next occurence 732 * if there is a next occurence
719 * from the duedate of the last recurrance 733 * from the duedate of the last recurrance
720 */ 734 */
721 QDate date; 735 QDate date;
722 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { 736 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) {
723 QDate inval; 737 QDate inval;
724 /* generate a new uid for the old record */ 738 /* generate a new uid for the old record */
725 to.setUid( 1 ); 739 to.setUid( 1 );
726 740
727 /* add the old one cause it has a new UID here cause it was spin off */ 741 /* add the old one cause it has a new UID here cause it was spin off */
728 m_todoMgr.add( to ); 742 m_todoMgr.add( to );
729 743
730 /* 744 /*
731 * update the due date 745 * update the due date
732 * start date 746 * start date
733 * and complete date 747 * and complete date
734 */ 748 */
735 to2.setDueDate( date ); 749 to2.setDueDate( date );
736 to2.setStartDate( inval ); 750 to2.setStartDate( inval );
737 to2.setCompletedDate( inval ); 751 to2.setCompletedDate( inval );
738 to2.setCompleted( false ); 752 to2.setCompleted( false );
739 updateTodo( to2 ); 753 updateTodo( to2 );
740 }else 754 }else
741 updateTodo( to ); 755 updateTodo( to );
742 }else 756 }else
743 updateTodo( to ); 757 updateTodo( to );
744 758
745 currentView()->updateView(); 759 currentView()->updateView();
746 raiseCurrentView(); 760 raiseCurrentView();
747} 761}
748void MainWindow::flush() { 762void MainWindow::flush() {
749 slotFlush(); 763 slotFlush();
750} 764}
751void MainWindow::reload() { 765void MainWindow::reload() {
752 slotReload(); 766 slotReload();
753} 767}
754int MainWindow::create() { 768int MainWindow::create() {
755 int uid = 0; 769 int uid = 0;
756 if(m_syncing) { 770 if(m_syncing) {
757 QMessageBox::warning(this, QWidget::tr("Todo"), 771 QMessageBox::warning(this, QWidget::tr("Todo"),
758 QWidget::tr("Can not edit data, currently syncing")); 772 QWidget::tr("Can not edit data, currently syncing"));
759 return uid; 773 return uid;
760 } 774 }
761 775
762 776
763 OTodo todo = currentEditor()->newTodo( currentCatId(), 777 OTodo todo = currentEditor()->newTodo( currentCatId(),
764 this ); 778 this );
765 779
766 if ( currentEditor()->accepted() ) { 780 if ( currentEditor()->accepted() ) {
767 //todo.assignUid(); 781 //todo.assignUid();
768 uid = todo.uid(); 782 uid = todo.uid();
783 handleAlarms( OTodo(), todo );
769 m_todoMgr.add( todo ); 784 m_todoMgr.add( todo );
770 currentView()->addEvent( todo ); 785 currentView()->addEvent( todo );
771 786
772 787
773 // I'm afraid we must call this every time now, otherwise 788 // I'm afraid we must call this every time now, otherwise
774 // spend expensive time comparing all these strings... 789 // spend expensive time comparing all these strings...
775 // but only call if we changed something -zecke 790 // but only call if we changed something -zecke
776 populateCategories(); 791 populateCategories();
777 } 792 }
778 raiseCurrentView( ); 793 raiseCurrentView( );
779 794
780 return uid; 795 return uid;
781} 796}
782/* delete it silently... */ 797/* delete it silently... */
783bool MainWindow::remove( int uid ) { 798bool MainWindow::remove( int uid ) {
784 if (m_syncing) return false; 799 if (m_syncing) return false;
785 800
801 /* argh need to get the whole OEvent... to disable alarms -zecke */
802 handleAlarms( OTodo(), m_todoMgr.event( uid ) );
803
786 return m_todoMgr.remove( uid ); 804 return m_todoMgr.remove( uid );
787} 805}
788void MainWindow::beam( int uid) { 806void MainWindow::beam( int uid) {
789 ::unlink( beamfile ); 807 ::unlink( beamfile );
790 OTodo todo = event( uid ); 808 OTodo todo = event( uid );
791 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); 809 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) );
792 OTodoAccess acc( cal ); 810 OTodoAccess acc( cal );
793 acc.load(); 811 acc.load();
794 acc.add( todo ); 812 acc.add( todo );
795 acc.save(); 813 acc.save();
796 Ir* ir = new Ir(this ); 814 Ir* ir = new Ir(this );
797 connect(ir, SIGNAL(done(Ir*) ), 815 connect(ir, SIGNAL(done(Ir*) ),
798 this, SLOT(beamDone(Ir*) ) ); 816 this, SLOT(beamDone(Ir*) ) );
799 ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); 817 ir->send(beamfile, todo.summary(), "text/x-vCalendar" );
800} 818}
801void MainWindow::show( int uid ) { 819void MainWindow::show( int uid ) {
802 slotShow( uid ); 820 slotShow( uid );
803} 821}
804void MainWindow::edit( int uid ) { 822void MainWindow::edit( int uid ) {
805 slotEdit( uid ); 823 slotEdit( uid );
806} 824}
807void MainWindow::add( const OPimRecord& rec) { 825void MainWindow::add( const OPimRecord& rec) {
808 if ( rec.rtti() != OTodo::rtti() ) return; 826 if ( rec.rtti() != OTodo::rtti() ) return;
809 827
810 const OTodo& todo = static_cast<const OTodo&>(rec); 828 const OTodo& todo = static_cast<const OTodo&>(rec);
811 829
812 m_todoMgr.add(todo ); 830 m_todoMgr.add(todo );
813 currentView()->addEvent( todo ); 831 currentView()->addEvent( todo );
814 832
815 833
816 // I'm afraid we must call this every time now, otherwise 834 // I'm afraid we must call this every time now, otherwise
817 // spend expensive time comparing all these strings... 835 // spend expensive time comparing all these strings...
818 // but only call if we changed something -zecke 836 // but only call if we changed something -zecke
819 populateCategories(); 837 populateCategories();
820} 838}
821void MainWindow::slotReturnFromView() { 839void MainWindow::slotReturnFromView() {
822 raiseCurrentView(); 840 raiseCurrentView();
823} 841}
842
843namespace {
844 OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls,
845 const OPimNotifyManager::Alarms& newAls ) {
846 OPimNotifyManager::Alarms nonMatching;
847 OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin();
848 OPimNotifyManager::Alarms::ConstIterator newIt;
849 for ( ; oldIt != oldAls.end(); ++oldIt ) {
850 bool found = false;
851 QDateTime oldDt = (*oldIt).dateTime();
852 for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) {
853 if ( oldDt == (*newIt).dateTime() ) {
854 found = true;
855 break;
856 }
857 }
858 if (!found)
859 nonMatching.append( (*oldIt) );
860 }
861 return nonMatching;
862 }
863 void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
864 OPimNotifyManager::Alarms::ConstIterator it;
865 for ( it = als.begin(); it != als.end(); ++it ) {
866 qWarning("Adding alarm for %s", (*it).dateTime().toString().latin1() );
867 AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
868 }
869
870 }
871 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
872 OPimNotifyManager::Alarms::ConstIterator it;
873 for ( it = als.begin(); it != als.end(); ++it ) {
874 qWarning("Removinf alarm for %s", (*it).dateTime().toString().latin1() );
875 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
876 }
877 }
878}
879
880void MainWindow::handleAlarms( const OTodo& oldTodo, const OTodo& newTodo) {
881 /*
882 * if oldTodo is not empty and has notifiers we need to find the deleted ones
883 */
884 if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) {
885 OPimNotifyManager::Alarms removed;
886 OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms();
887 if (!newTodo.hasNotifiers() )
888 removed = oldAls;
889 else
890 removed = findNonMatching( oldAls, newTodo.notifiers().alarms() );
891
892 removeAlarms( removed, oldTodo.uid() );
893 }
894 if ( newTodo.hasNotifiers() ) {
895 OPimNotifyManager::Alarms added;
896 if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() )
897 added = newTodo.notifiers().alarms();
898 else
899 added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() );
900
901 addAlarms( added, newTodo.uid() );
902 }
903}
904/* we might have not loaded the db */
905void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
906 m_todoMgr.load();
907
908 OTodo todo = m_todoMgr.event( uid );
909 if (!todo.hasNotifiers() ) return;
910
911 /*
912 * let's find the right alarm and find out if silent
913 * then show a richtext widget
914 */
915 bool loud = false;
916 OPimNotifyManager::Alarms als = todo.notifiers().alarms();
917 OPimNotifyManager::Alarms::Iterator it;
918 for ( it = als.begin(); it != als.end(); ++it ) {
919 if ( (*it).dateTime() == dt ) {
920 loud = ( (*it).sound() == OPimAlarm::Loud );
921 break;
922 }
923 }
924 if (loud)
925 startAlarm();
926
927 QDialog dlg(this, 0, TRUE );
928 QVBoxLayout* lay = new QVBoxLayout( &dlg );
929 QTextView* view = new QTextView( &dlg );
930 lay->addWidget( view );
931 QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg );
932 connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) );
933 lay->addWidget( btnOk );
934
935 QString text = tr("<h1>Alarm at %0</h1><br>").arg( TimeString::dateString( dt ) );
936 text += todo.toRichText();
937 view->setText( text );
938
939 dlg.showMaximized();
940 bool needToStay = dlg.exec();
941
942 if (loud)
943 killAlarm();
944
945 if (needToStay) {
946 showMaximized();
947 raise();
948 QPEApplication::setKeepRunning();
949 setActiveWindow();
950 }
951
952}
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
index 434e969..02e2449 100644
--- a/core/pim/todo/mainwindow.h
+++ b/core/pim/todo/mainwindow.h
@@ -11,191 +11,194 @@
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef TODO_MAIN_WINDOW_H 29#ifndef TODO_MAIN_WINDOW_H
30#define TODO_MAIN_WINDOW_H 30#define TODO_MAIN_WINDOW_H
31 31
32#include <qlist.h> 32#include <qlist.h>
33 33
34#include <opie/otodoaccess.h> 34#include <opie/otodoaccess.h>
35#include <opie/otodo.h> 35#include <opie/otodo.h>
36#include <opie/opimmainwindow.h> 36#include <opie/opimmainwindow.h>
37 37
38#include "smalltodo.h" 38#include "smalltodo.h"
39#include "todoview.h" 39#include "todoview.h"
40#include "quickedit.h" 40#include "quickedit.h"
41#include "todomanager.h" 41#include "todomanager.h"
42 42
43class QPopupMenu; 43class QPopupMenu;
44class QMenuBar; 44class QMenuBar;
45class QToolBar; 45class QToolBar;
46class QAction; 46class QAction;
47class QWidgetStack; 47class QWidgetStack;
48class Ir; 48class Ir;
49class QVBox; 49class QVBox;
50class QLineEdit; 50class QLineEdit;
51 51
52namespace Todo { 52namespace Todo {
53 typedef TodoView View; 53 typedef TodoView View;
54 class TemplateManager; 54 class TemplateManager;
55 class Editor; 55 class Editor;
56 class TodoShow; 56 class TodoShow;
57 class TemplateEditor; 57 class TemplateEditor;
58 struct QuickEditBase; 58 struct QuickEditBase;
59 59
60 class MainWindow : public OPimMainWindow { 60 class MainWindow : public OPimMainWindow {
61 Q_OBJECT 61 Q_OBJECT
62 friend class TodoView; // avoid QObject here.... 62 friend class TodoView; // avoid QObject here....
63 friend class TodoShow; // avoid QObject 63 friend class TodoShow; // avoid QObject
64 public: 64 public:
65 MainWindow( QWidget *parent = 0, 65 MainWindow( QWidget *parent = 0,
66 const char* name = 0 ); 66 const char* name = 0 );
67 ~MainWindow(); 67 ~MainWindow();
68 68
69 /** return a context menu for an OTodo */ 69 /** return a context menu for an OTodo */
70 QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE ); 70 QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE );
71 QPopupMenu* options(); 71 QPopupMenu* options();
72 QPopupMenu* edit(); 72 QPopupMenu* edit();
73 QToolBar* toolbar(); 73 QToolBar* toolbar();
74 74
75 75
76 void updateList(); 76 void updateList();
77 OTodoAccess::List list()const; 77 OTodoAccess::List list()const;
78 OTodoAccess::List sorted( bool asc, int sortOrder ); 78 OTodoAccess::List sorted( bool asc, int sortOrder );
79 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); 79 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter );
80 80
81 OTodo event(int uid ); 81 OTodo event(int uid );
82 82
83 bool isSyncing()const; 83 bool isSyncing()const;
84 bool showCompleted()const; 84 bool showCompleted()const;
85 bool showDeadline()const; 85 bool showDeadline()const;
86 bool showOverDue()const; 86 bool showOverDue()const;
87 bool showQuickTask()const; 87 bool showQuickTask()const;
88 QString currentCategory()const; 88 QString currentCategory()const;
89 int currentCatId(); 89 int currentCatId();
90 TemplateManager* templateManager(); 90 TemplateManager* templateManager();
91 QuickEditBase* quickEditor(); 91 QuickEditBase* quickEditor();
92 92
93 void updateTodo( const OTodo& ); 93 void updateTodo( const OTodo& );
94 void populateTemplates(); 94 void populateTemplates();
95 Editor* currentEditor(); 95 Editor* currentEditor();
96 void setReadAhead(uint count ); 96 void setReadAhead(uint count );
97private slots: 97private slots:
98 void slotQuickEntered(); 98 void slotQuickEntered();
99 void populateCategories(); 99 void populateCategories();
100 void slotReload(); 100 void slotReload();
101 void slotFlush(); 101 void slotFlush();
102 102
103 protected: 103 protected:
104 void closeEvent( QCloseEvent* e ); 104 void closeEvent( QCloseEvent* e );
105 105
106 private: 106 private:
107 /* handle setting and removing alarms */
108 void handleAlarms( const OTodo& oldTodo, const OTodo& newTodo );
107 void receiveFile( const QString& filename ); 109 void receiveFile( const QString& filename );
108 void connectBase( ViewBase* ); 110 void connectBase( ViewBase* );
109 void initUI(); 111 void initUI();
110 void initActions(); 112 void initActions();
111 void initConfig(); 113 void initConfig();
112 void initViews(); 114 void initViews();
113 void initEditor(); 115 void initEditor();
114 void initShow(); 116 void initShow();
115 void initTemplate(); 117 void initTemplate();
116 void raiseCurrentView(); 118 void raiseCurrentView();
117 ViewBase* currentView(); 119 ViewBase* currentView();
118 ViewBase* m_curView; 120 ViewBase* m_curView;
119 QuickEditBase* m_curQuick; 121 QuickEditBase* m_curQuick;
120 Editor* m_curEdit; 122 Editor* m_curEdit;
121 TodoShow* currentShow(); 123 TodoShow* currentShow();
122 TodoShow* m_curShow; 124 TodoShow* m_curShow;
123 TemplateEditor* currentTemplateEditor(); 125 TemplateEditor* currentTemplateEditor();
124 TemplateEditor* m_curTempEd; 126 TemplateEditor* m_curTempEd;
125 127
126 QMenuBar* m_bar; 128 QMenuBar* m_bar;
127 QToolBar* m_tool; 129 QToolBar* m_tool;
128 QAction* m_editAction, 130 QAction* m_editAction,
129 *m_deleteAction, 131 *m_deleteAction,
130 *m_findAction, 132 *m_findAction,
131 *m_completedAction, 133 *m_completedAction,
132 *m_showDeadLineAction, 134 *m_showDeadLineAction,
133 *m_deleteAllAction, 135 *m_deleteAllAction,
134 *m_deleteCompleteAction, 136 *m_deleteCompleteAction,
135 *m_duplicateAction, 137 *m_duplicateAction,
136 *m_showOverDueAction, 138 *m_showOverDueAction,
137 *m_showQuickTaskAction, 139 *m_showQuickTaskAction,
138 *m_effectiveAction; 140 *m_effectiveAction;
139 QWidgetStack *m_stack; 141 QWidgetStack *m_stack;
140 QPopupMenu* m_catMenu, 142 QPopupMenu* m_catMenu,
141 *m_edit, 143 *m_edit,
142 *m_options, 144 *m_options,
143 *m_template; 145 *m_template;
144 146
145 bool m_syncing:1; 147 bool m_syncing:1;
146 bool m_deadline:1; 148 bool m_deadline:1;
147 bool m_completed:1; 149 bool m_completed:1;
148 bool m_overdue:1; 150 bool m_overdue:1;
149 bool m_quicktask:1; 151 bool m_quicktask:1;
150 TodoManager m_todoMgr; 152 TodoManager m_todoMgr;
151 QString m_curCat; 153 QString m_curCat;
152 QList<ViewBase> m_views; 154 QList<ViewBase> m_views;
153 uint m_counter; 155 uint m_counter;
154 TemplateManager* m_tempManager; 156 TemplateManager* m_tempManager;
155 157
156 158
157 private slots: 159 private slots:
158 void slotShow(int); 160 void slotShow(int);
159 void slotEdit(int); 161 void slotEdit(int);
160 void slotUpdate3( QWidget* ); 162 void slotUpdate3( QWidget* );
161 void slotComplete( int uid ); 163 void slotComplete( int uid );
162 void slotComplete( const OTodo& ev ); 164 void slotComplete( const OTodo& ev );
163 void slotNewFromTemplate(int id ); 165 void slotNewFromTemplate(int id );
164 void slotNew(); 166 void slotNew();
165 void slotDuplicate(); 167 void slotDuplicate();
166 168
167 void slotDelete(); 169 void slotDelete();
168 void slotDeleteAll(); 170 void slotDeleteAll();
169 void slotDeleteCompleted(); 171 void slotDeleteCompleted();
170 172
171 void slotEdit(); 173 void slotEdit();
172 void slotFind(); 174 void slotFind();
173 175
174 void setCategory( int ); 176 void setCategory( int );
175 177
176 void slotShowDeadLine( bool ); 178 void slotShowDeadLine( bool );
177 void slotShowCompleted( bool ); 179 void slotShowCompleted( bool );
178 void slotShowQuickTask( bool ); 180 void slotShowQuickTask( bool );
179 181
180 void setDocument( const QString& ); 182 void setDocument( const QString& );
181 183
182 184
183 void slotBeam(); 185 void slotBeam();
184 void beamDone( Ir* ); 186 void beamDone( Ir* );
185 void slotShowDetails(); 187 void slotShowDetails();
186 void slotShowDue( bool ); 188 void slotShowDue( bool );
187 void slotReturnFromView(); // for TodoShow... 189 void slotReturnFromView(); // for TodoShow...
188 /* reimplementation from opimmainwindow */ 190 /* reimplementation from opimmainwindow */
189 protected slots: 191 protected slots:
190 void flush(); 192 void flush();
191 void reload(); 193 void reload();
192 int create(); 194 int create();
193 bool remove( int uid ); 195 bool remove( int uid );
194 void beam(int uid); 196 void beam(int uid);
195 void show( int uid ); 197 void show( int uid );
196 void edit( int uid ); 198 void edit( int uid );
197 void add( const OPimRecord& ); 199 void add( const OPimRecord& );
200 void doAlarm( const QDateTime& dt, int uid );
198 }; 201 };
199}; 202}
200 203
201#endif 204#endif
diff --git a/core/pim/todo/otaskeditor.cpp b/core/pim/todo/otaskeditor.cpp
index e26d5e4..84f854f 100644
--- a/core/pim/todo/otaskeditor.cpp
+++ b/core/pim/todo/otaskeditor.cpp
@@ -1,93 +1,96 @@
1#include <qdatetime.h> 1#include <qdatetime.h>
2#include <qlabel.h> 2#include <qlabel.h>
3#include <qlayout.h> 3#include <qlayout.h>
4#include <qmultilineedit.h> 4#include <qmultilineedit.h>
5 5
6#include <opie/orecurrancewidget.h> 6#include <opie/orecurrancewidget.h>
7 7
8#include "taskeditoroverview.h" 8#include "taskeditoroverview.h"
9#include "taskeditorstatus.h" 9#include "taskeditorstatus.h"
10#include "taskeditoralarms.h" 10#include "taskeditoralarms.h"
11 11
12#include "otaskeditor.h" 12#include "otaskeditor.h"
13 13
14OTaskEditor::OTaskEditor(int cur) 14OTaskEditor::OTaskEditor(int cur)
15 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) { 15 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) {
16 init(); 16 init();
17 init( cur ); 17 init( cur );
18} 18}
19OTaskEditor::OTaskEditor( const OTodo& to) 19OTaskEditor::OTaskEditor( const OTodo& to)
20 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) { 20 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) {
21 init(); 21 init();
22 init( to ); 22 init( to );
23} 23}
24OTaskEditor::~OTaskEditor() { 24OTaskEditor::~OTaskEditor() {
25 25
26} 26}
27void OTaskEditor::init( int cur ) { 27void OTaskEditor::init( int cur ) {
28 OTodo to; 28 OTodo to;
29 if ( cur != 0 ) 29 if ( cur != 0 )
30 to.setCategories( cur ); 30 to.setCategories( cur );
31 load(to); 31 load(to);
32 m_uid = 1; // generate a new one 32 m_uid = 1; // generate a new one
33} 33}
34void OTaskEditor::init( const OTodo& to ) { 34void OTaskEditor::init( const OTodo& to ) {
35 load( to ); 35 load( to );
36 m_uid = to.uid(); 36 m_uid = to.uid();
37} 37}
38OTodo OTaskEditor::todo()const{ 38OTodo OTaskEditor::todo()const{
39 qWarning("saving!"); 39 qWarning("saving!");
40 OTodo to; 40 OTodo to;
41 to.setUid(m_uid ); 41 to.setUid(m_uid );
42 m_overView->save( to ); 42 m_overView->save( to );
43 m_stat->save( to ); 43 m_stat->save( to );
44 to.setRecurrence( m_rec->recurrence() ); 44 to.setRecurrence( m_rec->recurrence() );
45 m_alarm->save( to );
45 46
46 return to; 47 return to;
47} 48}
48void OTaskEditor::load(const OTodo& to) { 49void OTaskEditor::load(const OTodo& to) {
49 m_overView->load( to ); 50 m_overView->load( to );
50 m_stat->load( to ); 51 m_stat->load( to );
51 m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() ); 52 m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() );
53 m_alarm->setEnabled( !to.hasRecurrence() );
54 m_alarm->load( to );
52} 55}
53void OTaskEditor::init() { 56void OTaskEditor::init() {
54 setCaption("Task Editor"); 57 setCaption("Task Editor");
55 58
56 QVBoxLayout* layo = new QVBoxLayout( this ); 59 QVBoxLayout* layo = new QVBoxLayout( this );
57 m_tab = new OTabWidget( this ); 60 m_tab = new OTabWidget( this );
58 layo->addWidget( m_tab ); 61 layo->addWidget( m_tab );
59 62
60 /* 63 /*
61 * Add the Widgets 64 * Add the Widgets
62 */ 65 */
63 m_overView = new TaskEditorOverView( m_tab ); 66 m_overView = new TaskEditorOverView( m_tab );
64 m_tab->addTab( m_overView, "todo/info", tr("Information") ); 67 m_tab->addTab( m_overView, "todo/info", tr("Information") );
65 68
66 m_stat = new TaskEditorStatus( m_tab ); 69 m_stat = new TaskEditorStatus( m_tab );
67 m_tab->addTab( m_stat, "todo/TodoList", tr("Status") ); 70 m_tab->addTab( m_stat, "todo/TodoList", tr("Status") );
68 71
69 m_alarm = new TaskEditorAlarms( m_tab ); 72 m_alarm = new TaskEditorAlarms( m_tab );
70 m_tab->addTab( m_alarm, "todo/alarm", tr("Alarms") ); 73 m_tab->addTab( m_alarm, "todo/alarm", tr("Alarms") );
71 74
72 m_remind = new TaskEditorAlarms( m_tab ); 75// m_remind = new TaskEditorAlarms( m_tab );
73 m_tab->addTab( m_remind, "todo/reminder", tr("Reminders") ); 76// m_tab->addTab( m_remind, "todo/reminder", tr("Reminders") );
74 77
75 QLabel* lbl = new QLabel( m_tab ); 78// QLabel* lbl = new QLabel( m_tab );
76 lbl->setText( tr("X-Ref") ); 79// lbl->setText( tr("X-Ref") );
77 m_tab->addTab( lbl, "todo/xref", tr("X-Ref") ); 80// m_tab->addTab( lbl, "todo/xref", tr("X-Ref") );
78 81
79 m_rec = new ORecurranceWidget( true, QDate::currentDate(), this ); 82 m_rec = new ORecurranceWidget( true, QDate::currentDate(), this );
80 m_tab->addTab( m_rec, "repeat", tr("Recurrence") ); 83 m_tab->addTab( m_rec, "repeat", tr("Recurrence") );
81 84
82 85
83 /* signal and slots */ 86 /* signal and slots */
84 connect(m_overView, SIGNAL(recurranceEnabled(bool) ), 87 connect(m_overView, SIGNAL(recurranceEnabled(bool) ),
85 m_rec, SLOT(setEnabled(bool) ) ); 88 m_rec, SLOT(setEnabled(bool) ) );
86 89
87 /* connect due date changed to the recurrence tab */ 90 /* connect due date changed to the recurrence tab */
88 connect(m_stat, SIGNAL(dueDateChanged(const QDate&) ), 91 connect(m_stat, SIGNAL(dueDateChanged(const QDate&) ),
89 m_rec, SLOT(setStartDate(const QDate& ) ) ); 92 m_rec, SLOT(setStartDate(const QDate& ) ) );
90 93
91 94
92 m_tab->setCurrentTab( m_overView ); 95 m_tab->setCurrentTab( m_overView );
93} 96}
diff --git a/core/pim/todo/quickeditimpl.cpp b/core/pim/todo/quickeditimpl.cpp
index 91d3131..f4c7c47 100644
--- a/core/pim/todo/quickeditimpl.cpp
+++ b/core/pim/todo/quickeditimpl.cpp
@@ -1,111 +1,111 @@
1#include <qaction.h> 1#include <qaction.h>
2#include <qlineedit.h> 2#include <qlineedit.h>
3#include <qwhatsthis.h> 3#include <qwhatsthis.h>
4 4
5#include <qpe/resource.h> 5#include <qpe/resource.h>
6 6
7#include <opie/oclickablelabel.h> 7#include <opie/oclickablelabel.h>
8 8
9#include "mainwindow.h" 9#include "mainwindow.h"
10#include "quickeditimpl.h" 10#include "quickeditimpl.h"
11 11
12 12
13QuickEditImpl::QuickEditImpl( QWidget* parent, bool visible ) 13QuickEditImpl::QuickEditImpl( QWidget* parent, bool visible )
14 : QPEToolBar( (QMainWindow *)parent ), Todo::QuickEdit( (Todo::MainWindow *)parent ) { 14 : QPEToolBar( (QMainWindow *)parent ), Todo::QuickEdit( (Todo::MainWindow *)parent ) {
15 setHorizontalStretchable( TRUE ); 15 setHorizontalStretchable( TRUE );
16 16
17 // Load priority icons 17 // Load priority icons
18 // TODO - probably should be done globally somewhere else, 18 // TODO - probably should be done globally somewhere else,
19 // see also tableview.cpp/h, taskeditoroverview.cpp/h 19 // see also tableview.cpp/h, taskeditoroverview.cpp/h
20 priority1 = Resource::loadPixmap( "todo/priority1" ); 20 priority1 = Resource::loadPixmap( "todo/priority1" );
21 priority3 = Resource::loadPixmap( "todo/priority3" ); 21 priority3 = Resource::loadPixmap( "todo/priority3" );
22 priority5 = Resource::loadPixmap( "todo/priority5" ); 22 priority5 = Resource::loadPixmap( "todo/priority5" );
23 23
24 m_lbl = new OClickableLabel( this ); 24 m_lbl = new OClickableLabel( this );
25 m_lbl->setMinimumWidth( 15 ); 25 m_lbl->setMinimumWidth( 15 );
26 m_lbl->setPixmap( priority3 ); 26 m_lbl->setPixmap( priority3 );
27 connect(m_lbl, SIGNAL(clicked() ), this, SLOT(slotPrio()) ); 27 connect(m_lbl, SIGNAL(clicked() ), this, SLOT(slotPrio()) );
28 QWhatsThis::add( m_lbl, tr( "Click here to set the priority of new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 28 QWhatsThis::add( m_lbl, QWidget::tr( "Click here to set the priority of new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
29 29
30 m_edit = new QLineEdit( this ); 30 m_edit = new QLineEdit( this );
31 setStretchableWidget( m_edit ); 31 setStretchableWidget( m_edit );
32 QWhatsThis::add( m_edit, tr( "Enter description of new task here.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 32 QWhatsThis::add( m_edit, QWidget::tr( "Enter description of new task here.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
33 33
34 QAction *a = new QAction( tr( "More" ), Resource::loadPixmap( "todo/more" ), QString::null, 0, this, 0 ); 34 QAction *a = new QAction( QWidget::tr( "More" ), Resource::loadPixmap( "todo/more" ), QString::null, 0, this, 0 );
35 connect( a, SIGNAL( activated() ), this, SLOT( slotMore() ) ); 35 connect( a, SIGNAL( activated() ), this, SLOT( slotMore() ) );
36 a->addTo( this ); 36 a->addTo( this );
37 a->setWhatsThis( tr( "Click here to enter additional information for new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 37 a->setWhatsThis( QWidget::tr( "Click here to enter additional information for new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
38 38
39 a = new QAction( tr( "Enter" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); 39 a = new QAction( QWidget::tr( "Enter" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
40 connect( a, SIGNAL( activated() ), this, SLOT( slotEnter() ) ); 40 connect( a, SIGNAL( activated() ), this, SLOT( slotEnter() ) );
41 a->addTo( this ); 41 a->addTo( this );
42 a->setWhatsThis( tr( "Click here to add new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 42 a->setWhatsThis( QWidget::tr( "Click here to add new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
43 43
44 a = new QAction( tr( "Cancel" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 44 a = new QAction( QWidget::tr( "Cancel" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
45 connect( a, SIGNAL( activated() ), this, SLOT( slotCancel() ) ); 45 connect( a, SIGNAL( activated() ), this, SLOT( slotCancel() ) );
46 a->addTo( this ); 46 a->addTo( this );
47 a->setWhatsThis( tr( "Click here to reset new task information.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 47 a->setWhatsThis( QWidget::tr( "Click here to reset new task information.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
48 48
49 m_visible = visible; 49 m_visible = visible;
50 if ( !m_visible ) { 50 if ( !m_visible ) {
51 hide(); 51 hide();
52 } 52 }
53 53
54 m_menu = 0l; 54 m_menu = 0l;
55 reinit(); 55 reinit();
56} 56}
57QuickEditImpl::~QuickEditImpl() { 57QuickEditImpl::~QuickEditImpl() {
58 58
59} 59}
60OTodo QuickEditImpl::todo()const { 60OTodo QuickEditImpl::todo()const {
61 return m_todo; 61 return m_todo;
62} 62}
63QWidget* QuickEditImpl::widget() { 63QWidget* QuickEditImpl::widget() {
64 return this; 64 return this;
65} 65}
66void QuickEditImpl::slotEnter() { 66void QuickEditImpl::slotEnter() {
67 OTodo todo; 67 OTodo todo;
68 68
69 69
70 if (!m_edit->text().isEmpty() ) { 70 if (!m_edit->text().isEmpty() ) {
71 todo.setUid(1 ); // new uid 71 todo.setUid(1 ); // new uid
72 todo.setPriority( m_state ); 72 todo.setPriority( m_state );
73 todo.setSummary( m_edit->text() ); 73 todo.setSummary( m_edit->text() );
74 if ( ((Todo::MainWindow *)parent())->currentCatId() != 0 ) 74 if ( ((Todo::MainWindow *)parent())->currentCatId() != 0 )
75 todo.setCategories( ((Todo::MainWindow *)parent())->currentCatId() ); 75 todo.setCategories( ((Todo::MainWindow *)parent())->currentCatId() );
76 76
77 m_todo = todo; 77 m_todo = todo;
78 commit(); 78 commit();
79 } 79 }
80 m_todo = todo; 80 m_todo = todo;
81 reinit(); 81 reinit();
82} 82}
83void QuickEditImpl::slotPrio() { 83void QuickEditImpl::slotPrio() {
84 m_state -= 2; 84 m_state -= 2;
85 if ( m_state < 1 ) 85 if ( m_state < 1 )
86 m_state = 5; 86 m_state = 5;
87 87
88 switch( m_state ) { 88 switch( m_state ) {
89 case 1: 89 case 1:
90 m_lbl->setPixmap( priority1 ); 90 m_lbl->setPixmap( priority1 );
91 break; 91 break;
92 case 5: 92 case 5:
93 m_lbl->setPixmap( priority5 ); 93 m_lbl->setPixmap( priority5 );
94 break; 94 break;
95 case 3: 95 case 3:
96 default: 96 default:
97 m_lbl->setPixmap( priority3 ); 97 m_lbl->setPixmap( priority3 );
98 break; 98 break;
99 } 99 }
100} 100}
101void QuickEditImpl::slotMore() { 101void QuickEditImpl::slotMore() {
102 // TODO - implement 102 // TODO - implement
103} 103}
104void QuickEditImpl::slotCancel() { 104void QuickEditImpl::slotCancel() {
105 reinit(); 105 reinit();
106} 106}
107void QuickEditImpl::reinit() { 107void QuickEditImpl::reinit() {
108 m_state = 3; 108 m_state = 3;
109 m_lbl->setPixmap( priority3 ); 109 m_lbl->setPixmap( priority3 );
110 m_edit->clear(); 110 m_edit->clear();
111} 111}
diff --git a/core/pim/todo/taskeditoralarms.cpp b/core/pim/todo/taskeditoralarms.cpp
index 3cb5576..bff3338 100644
--- a/core/pim/todo/taskeditoralarms.cpp
+++ b/core/pim/todo/taskeditoralarms.cpp
@@ -1,76 +1,238 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = General Public License along with 21  -_. . .   )=.  = General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "taskeditoralarms.h" 29#include "taskeditoralarms.h"
30 30
31#include <opie/otodo.h>
32#include <opie/opimnotifymanager.h>
33#include <opie/otimepicker.h>
34
35#include <qpe/datebookmonth.h>
31#include <qpe/resource.h> 36#include <qpe/resource.h>
37#include <qpe/timestring.h>
32 38
39#include <qdatetime.h>
33#include <qlistview.h> 40#include <qlistview.h>
34#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qpopupmenu.h>
35#include <qlayout.h> 43#include <qlayout.h>
36#include <qwhatsthis.h> 44#include <qwhatsthis.h>
37 45
38TaskEditorAlarms::TaskEditorAlarms( QWidget* parent, const char* name, WFlags fl ) 46
47class AlarmItem : public QListViewItem {
48public:
49 AlarmItem( QListView*, const OPimAlarm& );
50 ~AlarmItem();
51
52 OPimAlarm alarm()const;
53 void setAlarm( const OPimAlarm& );
54private:
55 QDateTime m_dt;
56 int m_type;
57};
58AlarmItem::AlarmItem( QListView* view, const OPimAlarm& dt)
59 : QListViewItem(view) {
60 setAlarm( dt );
61}
62void AlarmItem::setAlarm( const OPimAlarm& dt ) {
63 m_dt = dt.dateTime();
64 m_type = dt.sound();
65 setText( 0, TimeString::dateString( m_dt.date() ) );
66 setText( 1, TimeString::timeString( m_dt.time() ) );
67 setText( 2, m_type == 0 ? QObject::tr("silent") : QObject::tr("loud") );
68}
69AlarmItem::~AlarmItem() {
70}
71OPimAlarm AlarmItem::alarm()const{
72 OPimAlarm al( m_type, m_dt );
73
74 return al;
75}
76
77TaskEditorAlarms::TaskEditorAlarms( QWidget* parent, int, const char* name, WFlags fl )
39 : QWidget( parent, name, fl ) 78 : QWidget( parent, name, fl )
40{ 79{
41 QGridLayout *layout = new QGridLayout( this, 2, 3, 4, 4 ); 80 m_date = m_type = m_time = 0;
81 QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 4 );
42 82
43 lstAlarms = new QListView( this ); 83 lstAlarms = new QListView( this );
84 lstAlarms->addColumn( tr("Date") );
85 lstAlarms->addColumn( tr("Time") );
86 lstAlarms->addColumn( tr("Type") );
87
88 connect( lstAlarms, SIGNAL(clicked ( QListViewItem *, const QPoint &, int ) ),
89 this, SLOT(inlineEdit(QListViewItem*, const QPoint&, int ) ) );
90
44 layout->addMultiCellWidget( lstAlarms, 0, 0, 0, 2 ); 91 layout->addMultiCellWidget( lstAlarms, 0, 0, 0, 2 );
45 92
46 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), this ); 93 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), this );
47 //QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); 94 //QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) );
48 //connect( btn, SIGNAL( clicked() ), this, SLOT( slotNew() ) ); 95 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNew() ) );
49 layout->addWidget( btn, 1, 0 ); 96 layout->addWidget( btn, 1, 0 );
50 97/* use when we've reminders too */
98#if 0
51 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), this ); 99 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), this );
52 //QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); 100 //QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) );
53 //connect( btn, SIGNAL( clicked() ), this, SLOT( slotEdit() ) ); 101 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEdit() ) );
54 layout->addWidget( btn, 1, 1 ); 102 layout->addWidget( btn, 1, 1 );
103#endif
55 104
56 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); 105 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this );
57 //QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); 106 //QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) );
58 //connect( btn, SIGNAL( clicked() ), this, SLOT( slotDelete() ) ); 107 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDelete() ) );
59 layout->addWidget( btn, 1, 2 ); 108 layout->addWidget( btn, 1, 2 );
60} 109}
61 110
62TaskEditorAlarms::~TaskEditorAlarms() 111TaskEditorAlarms::~TaskEditorAlarms(){
63{
64} 112}
65 113
66void TaskEditorAlarms::slotNew() 114void TaskEditorAlarms::slotNew(){
67{ 115 (void)new AlarmItem(lstAlarms, OPimAlarm(0, QDateTime::currentDateTime() ) );
68} 116}
69 117
70void TaskEditorAlarms::slotEdit() 118void TaskEditorAlarms::slotEdit(){
71{
72} 119}
73 120
74void TaskEditorAlarms::slotDelete() 121void TaskEditorAlarms::slotDelete(){
75{ 122 QListViewItem* item = lstAlarms->currentItem();
123 if (!item) return;
124
125 lstAlarms->takeItem( item ); delete item;
126
127
128}
129
130void TaskEditorAlarms::load( const OTodo& todo) {
131 lstAlarms->clear();
132 if (!todo.hasNotifiers() ) return;
133
134 OPimNotifyManager::Alarms als = todo.notifiers().alarms();
135
136 if (als.isEmpty() ) return;
137
138 OPimNotifyManager::Alarms::Iterator it = als.begin();
139 for ( ; it != als.end(); ++it )
140 (void)new AlarmItem( lstAlarms, (*it) );
141
142
143}
144void TaskEditorAlarms::save( OTodo& todo ) {
145 if (lstAlarms->childCount() <= 0 ) return;
146
147 OPimNotifyManager::Alarms alarms;
148
149 for ( QListViewItem* item = lstAlarms->firstChild(); item; item = item->nextSibling() ) {
150 AlarmItem *alItem = static_cast<AlarmItem*>(item);
151 alarms.append( alItem->alarm() );
152 }
153
154 OPimNotifyManager& manager = todo.notifiers();
155 manager.setAlarms( alarms );
156}
157void TaskEditorAlarms::inlineEdit( QListViewItem* alarm, const QPoint& p, int col ) {
158 if (!alarm) return;
159
160 AlarmItem* item = static_cast<AlarmItem*>(alarm);
161 switch( col ) {
162 // date
163 case 0:
164 return inlineSetDate( item, p );
165 // time
166 case 1:
167 return inlineSetTime( item );
168 // type
169 case 2:
170 return inlineSetType( item, p );
171 }
172}
173void TaskEditorAlarms::inlineSetDate( AlarmItem* item, const QPoint& p ) {
174 QPopupMenu* pop = popup( 0 );
175 m_dbMonth->setDate( item->alarm().dateTime().date() );
176 pop->exec(p);
177
178 OPimAlarm al = item->alarm();
179 QDateTime dt = al.dateTime();
180 dt.setDate( m_dbMonth->selectedDate() );
181 al.setDateTime( dt );
182 item->setAlarm( al );
183}
184void TaskEditorAlarms::inlineSetType( AlarmItem* item, const QPoint& p ) {
185 int type;
186 QPopupMenu* pop = popup( 2 );
187 switch( pop->exec(p) ) {
188 case 10:
189 type = 1;
190 break;
191 case 20:
192 default:
193 type = 0;
194 }
195 OPimAlarm al = item->alarm();
196 al.setSound( type );
197 item->setAlarm( al );
198}
199void TaskEditorAlarms::inlineSetTime( AlarmItem* item ) {
200 OPimAlarm al = item->alarm();
201 QDateTime dt = al.dateTime();
202
203 OTimePickerDialog dialog;
204 dialog.setTime( dt.time() );
205 if ( dialog.exec() == QDialog::Accepted ) {
206 dt.setTime( dialog.time() );
207 al.setDateTime( dt );
208 item->setAlarm( al );
209 }
210}
211QPopupMenu* TaskEditorAlarms::popup( int column ) {
212 QPopupMenu* pop = 0;
213 switch( column ) {
214 case 0:{
215 if (!m_date) {
216 m_date = new QPopupMenu(this);
217 m_dbMonth = new DateBookMonth(m_date, 0, TRUE);
218 m_date->insertItem(m_dbMonth);
219 }
220 pop = m_date;
221 }
222 break;
223 case 1:
224 break;
225 case 2:{
226 if (!m_type) {
227 m_type = new QPopupMenu(this);
228 m_type->insertItem( QObject::tr("loud"), 10 );
229 m_type->insertItem( QObject::tr("silent"), 20 );
230 }
231 pop = m_type;
232 }
233 break;
234 default:
235 break;
236 }
237 return pop;
76} 238}
diff --git a/core/pim/todo/taskeditoralarms.h b/core/pim/todo/taskeditoralarms.h
index f77ded5..0aa52cc 100644
--- a/core/pim/todo/taskeditoralarms.h
+++ b/core/pim/todo/taskeditoralarms.h
@@ -1,52 +1,72 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002,2003 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = General Public License along with 21  -_. . .   )=.  = General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef TASKEDITORALARMS_H 29#ifndef TASKEDITORALARMS_H
30#define TASKEDITORALARMS_H 30#define TASKEDITORALARMS_H
31 31
32#include <qwidget.h> 32#include <qwidget.h>
33 33
34class QListView; 34class QListView;
35class QListViewItem;
36class OTodo;
35 37
38class AlarmItem;
39class DateBookMonth;
36class TaskEditorAlarms : public QWidget 40class TaskEditorAlarms : public QWidget
37{ 41{
38 Q_OBJECT 42 Q_OBJECT
39 43
40public: 44public:
41 TaskEditorAlarms( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 45 enum Type {
46 Alarm = 0,
47 Reminders
48 };
49 TaskEditorAlarms( QWidget* parent = 0, int type = Alarm, const char* name = 0, WFlags fl = 0 );
42 ~TaskEditorAlarms(); 50 ~TaskEditorAlarms();
51 void load( const OTodo& );
52 void save( OTodo& );
53private:
54 QPopupMenu* popup( int column );
55 void inlineSetDate( AlarmItem*, const QPoint& p );
56 void inlineSetTime( AlarmItem*);
57 void inlineSetType( AlarmItem*, const QPoint& p );
43 58
44 QListView* lstAlarms; 59 QListView* lstAlarms;
60 QPopupMenu* m_date;
61 QPopupMenu* m_time;
62 QPopupMenu* m_type;
63 DateBookMonth* m_dbMonth;
45 64
46protected slots: 65protected slots:
47 void slotNew(); 66 void slotNew();
48 void slotEdit(); 67 void slotEdit();
49 void slotDelete(); 68 void slotDelete();
69 void inlineEdit( QListViewItem*, const QPoint& p, int );
50}; 70};
51 71
52#endif // TASKEDITORALARMS_H 72#endif // TASKEDITORALARMS_H
diff --git a/core/pim/todo/taskeditorstatus.cpp b/core/pim/todo/taskeditorstatus.cpp
index 4331877..0ab4223 100644
--- a/core/pim/todo/taskeditorstatus.cpp
+++ b/core/pim/todo/taskeditorstatus.cpp
@@ -51,251 +51,256 @@ TaskEditorStatus::TaskEditorStatus( QWidget* parent, const char* name, WFlags f
51 : QWidget( parent, name, fl ) 51 : QWidget( parent, name, fl )
52{ 52{
53 QDate curDate = QDate::currentDate(); 53 QDate curDate = QDate::currentDate();
54 m_start = m_comp = m_due = curDate; 54 m_start = m_comp = m_due = curDate;
55 QString curDateStr = TimeString::longDateString( curDate ); 55 QString curDateStr = TimeString::longDateString( curDate );
56 56
57 QVBoxLayout *vb = new QVBoxLayout( this ); 57 QVBoxLayout *vb = new QVBoxLayout( this );
58 58
59 QScrollView *sv = new QScrollView( this ); 59 QScrollView *sv = new QScrollView( this );
60 vb->addWidget( sv ); 60 vb->addWidget( sv );
61 sv->setResizePolicy( QScrollView::AutoOneFit ); 61 sv->setResizePolicy( QScrollView::AutoOneFit );
62 sv->setFrameStyle( QFrame::NoFrame ); 62 sv->setFrameStyle( QFrame::NoFrame );
63 63
64 QWidget *container = new QWidget( sv->viewport() ); 64 QWidget *container = new QWidget( sv->viewport() );
65 sv->addChild( container ); 65 sv->addChild( container );
66 66
67 QGridLayout *layout = new QGridLayout( container, 7, 3, 4, 4 ); 67 QGridLayout *layout = new QGridLayout( container, 7, 3, 4, 4 );
68 68
69 // Status 69 // Status
70 QLabel *label = new QLabel( tr( "Status:" ), container ); 70 QLabel *label = new QLabel( tr( "Status:" ), container );
71 layout->addWidget( label, 0, 0 ); 71 layout->addWidget( label, 0, 0 );
72 QWhatsThis::add( label, tr( "Click here to set the current status of this task." ) ); 72 QWhatsThis::add( label, tr( "Click here to set the current status of this task." ) );
73 cmbStatus = new QComboBox( FALSE, container ); 73 cmbStatus = new QComboBox( FALSE, container );
74 cmbStatus->insertItem( tr( "Started" ) ); 74 cmbStatus->insertItem( tr( "Started" ) );
75 cmbStatus->insertItem( tr( "Postponed" ) ); 75 cmbStatus->insertItem( tr( "Postponed" ) );
76 cmbStatus->insertItem( tr( "Finished" ) ); 76 cmbStatus->insertItem( tr( "Finished" ) );
77 cmbStatus->insertItem( tr( "Not started" ) ); 77 cmbStatus->insertItem( tr( "Not started" ) );
78 layout->addMultiCellWidget( cmbStatus, 0, 0, 1, 2 ); 78 layout->addMultiCellWidget( cmbStatus, 0, 0, 1, 2 );
79 QWhatsThis::add( cmbStatus, tr( "Click here to set the current status of this task." ) ); 79 QWhatsThis::add( cmbStatus, tr( "Click here to set the current status of this task." ) );
80 80
81 // Progress 81 // Progress
82 label = new QLabel( tr( "Progress:" ), container ); 82 label = new QLabel( tr( "Progress:" ), container );
83 layout->addWidget( label, 1, 0 ); 83 layout->addWidget( label, 1, 0 );
84 QWhatsThis::add( label, tr( "Select progress made on this task here." ) ); 84 QWhatsThis::add( label, tr( "Select progress made on this task here." ) );
85 cmbProgress = new QComboBox( FALSE, container ); 85 cmbProgress = new QComboBox( FALSE, container );
86 cmbProgress->insertItem( tr( "0 %" ) ); 86 cmbProgress->insertItem( tr( "0 %" ) );
87 cmbProgress->insertItem( tr( "20 %" ) ); 87 cmbProgress->insertItem( tr( "20 %" ) );
88 cmbProgress->insertItem( tr( "40 %" ) ); 88 cmbProgress->insertItem( tr( "40 %" ) );
89 cmbProgress->insertItem( tr( "60 %" ) ); 89 cmbProgress->insertItem( tr( "60 %" ) );
90 cmbProgress->insertItem( tr( "80 %" ) ); 90 cmbProgress->insertItem( tr( "80 %" ) );
91 cmbProgress->insertItem( tr( "100 %" ) ); 91 cmbProgress->insertItem( tr( "100 %" ) );
92 layout->addMultiCellWidget( cmbProgress, 1, 1, 1, 2 ); 92 layout->addMultiCellWidget( cmbProgress, 1, 1, 1, 2 );
93 QWhatsThis::add( cmbProgress, tr( "Select progress made on this task here." ) ); 93 QWhatsThis::add( cmbProgress, tr( "Select progress made on this task here." ) );
94 94
95 // Start date 95 // Start date
96 ckbStart = new QCheckBox( tr( "Start Date:" ), container ); 96 ckbStart = new QCheckBox( tr( "Start Date:" ), container );
97 layout->addWidget( ckbStart, 2, 0 ); 97 layout->addWidget( ckbStart, 2, 0 );
98 QWhatsThis::add( ckbStart, tr( "Click here to set the date this task was started." ) ); 98 QWhatsThis::add( ckbStart, tr( "Click here to set the date this task was started." ) );
99 connect( ckbStart, SIGNAL( clicked() ), this, SLOT( slotStartChecked() ) ); 99 connect( ckbStart, SIGNAL( clicked() ), this, SLOT( slotStartChecked() ) );
100 btnStart = new QPushButton( curDateStr, container ); 100 btnStart = new QPushButton( curDateStr, container );
101 btnStart->setEnabled( FALSE ); 101 btnStart->setEnabled( FALSE );
102 layout->addMultiCellWidget( btnStart, 2, 2, 1, 2 ); 102 layout->addMultiCellWidget( btnStart, 2, 2, 1, 2 );
103 QWhatsThis::add( btnStart, tr( "Click here to set the date this task was started." ) ); 103 QWhatsThis::add( btnStart, tr( "Click here to set the date this task was started." ) );
104 QPopupMenu *popup = new QPopupMenu( this ); 104 QPopupMenu *popup = new QPopupMenu( this );
105 m_startBook = new DateBookMonth( popup, 0, TRUE ); 105 m_startBook = new DateBookMonth( popup, 0, TRUE );
106 popup->insertItem( m_startBook ); 106 popup->insertItem( m_startBook );
107 btnStart->setPopup( popup ); 107 btnStart->setPopup( popup );
108 connect( m_startBook, SIGNAL( dateClicked( int, int, int ) ), 108 connect( m_startBook, SIGNAL( dateClicked( int, int, int ) ),
109 this, SLOT( slotStartChanged( int, int, int ) ) ); 109 this, SLOT( slotStartChanged( int, int, int ) ) );
110 110
111 // Due date 111 // Due date
112 ckbDue = new QCheckBox( tr( "Due Date:" ), container ); 112 ckbDue = new QCheckBox( tr( "Due Date:" ), container );
113 layout->addWidget( ckbDue, 3, 0 ); 113 layout->addWidget( ckbDue, 3, 0 );
114 QWhatsThis::add( ckbDue, tr( "Click here to set the date this task needs to be completed by." ) ); 114 QWhatsThis::add( ckbDue, tr( "Click here to set the date this task needs to be completed by." ) );
115 connect( ckbDue, SIGNAL( clicked() ), this, SLOT( slotDueChecked() ) ); 115 connect( ckbDue, SIGNAL( clicked() ), this, SLOT( slotDueChecked() ) );
116 btnDue = new QPushButton( curDateStr, container ); 116 btnDue = new QPushButton( curDateStr, container );
117 btnDue->setEnabled( FALSE ); 117 btnDue->setEnabled( FALSE );
118 layout->addMultiCellWidget( btnDue, 3, 3, 1, 2 ); 118 layout->addMultiCellWidget( btnDue, 3, 3, 1, 2 );
119 QWhatsThis::add( btnDue, tr( "Click here to set the date this task needs to be completed by." ) ); 119 QWhatsThis::add( btnDue, tr( "Click here to set the date this task needs to be completed by." ) );
120 popup = new QPopupMenu( this ); 120 popup = new QPopupMenu( this );
121 m_dueBook = new DateBookMonth( popup, 0, TRUE ); 121 m_dueBook = new DateBookMonth( popup, 0, TRUE );
122 popup->insertItem( m_dueBook ); 122 popup->insertItem( m_dueBook );
123 btnDue->setPopup( popup ); 123 btnDue->setPopup( popup );
124 connect( m_dueBook, SIGNAL( dateClicked( int, int, int ) ), 124 connect( m_dueBook, SIGNAL( dateClicked( int, int, int ) ),
125 this, SLOT( slotDueChanged( int, int, int ) ) ); 125 this, SLOT( slotDueChanged( int, int, int ) ) );
126 126
127 // Completed 127 // Completed
128 ckbComp = new QCheckBox( tr( "Completed:" ), container ); 128 ckbComp = new QCheckBox( tr( "Completed:" ), container );
129 layout->addWidget( ckbComp, 4, 0 ); 129 layout->addWidget( ckbComp, 4, 0 );
130 QWhatsThis::add( ckbComp, tr( "Click here to mark this task as completed." ) ); 130 QWhatsThis::add( ckbComp, tr( "Click here to mark this task as completed." ) );
131 connect( ckbComp, SIGNAL( clicked() ), this, SLOT( slotCompChecked() ) ); 131 connect( ckbComp, SIGNAL( clicked() ), this, SLOT( slotCompChecked() ) );
132 btnComp = new QPushButton( curDateStr, container ); 132 btnComp = new QPushButton( curDateStr, container );
133 btnComp->setEnabled( FALSE ); 133 btnComp->setEnabled( FALSE );
134 layout->addMultiCellWidget( btnComp, 4, 4, 1, 2 ); 134 layout->addMultiCellWidget( btnComp, 4, 4, 1, 2 );
135 QWhatsThis::add( btnComp, tr( "Click here to set the date this task was completed." ) ); 135 QWhatsThis::add( btnComp, tr( "Click here to set the date this task was completed." ) );
136 popup = new QPopupMenu( this ); 136 popup = new QPopupMenu( this );
137 m_compBook = new DateBookMonth( popup, 0, TRUE ); 137 m_compBook = new DateBookMonth( popup, 0, TRUE );
138 popup->insertItem( m_compBook ); 138 popup->insertItem( m_compBook );
139 btnComp->setPopup( popup ); 139 btnComp->setPopup( popup );
140 connect( m_compBook, SIGNAL( dateClicked( int, int, int ) ), 140 connect( m_compBook, SIGNAL( dateClicked( int, int, int ) ),
141 this, SLOT( slotCompChanged( int, int, int ) ) ); 141 this, SLOT( slotCompChanged( int, int, int ) ) );
142 142
143 QSpacerItem *spacer = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ); 143 QSpacerItem *spacer = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding );
144 layout->addItem( spacer, 5, 0 ); 144 layout->addItem( spacer, 5, 0 );
145 145
146 // Maintainer mode 146 // Maintainer mode
147#if 0
147 label = new QLabel( tr( "Maintainer Mode:" ), container ); 148 label = new QLabel( tr( "Maintainer Mode:" ), container );
148 layout->addWidget( label, 6, 0 ); 149 layout->addWidget( label, 6, 0 );
149 QWhatsThis::add( label, tr( "Click here to set the maintainer's role." ) ); 150 QWhatsThis::add( label, tr( "Click here to set the maintainer's role." ) );
150 cmbMaintMode = new QComboBox( FALSE, container ); 151 cmbMaintMode = new QComboBox( FALSE, container );
151 cmbMaintMode->insertItem( tr( "Nothing" ) ); 152 cmbMaintMode->insertItem( tr( "Nothing" ) );
152 cmbMaintMode->insertItem( tr( "Responsible" ) ); 153 cmbMaintMode->insertItem( tr( "Responsible" ) );
153 cmbMaintMode->insertItem( tr( "Done By" ) ); 154 cmbMaintMode->insertItem( tr( "Done By" ) );
154 cmbMaintMode->insertItem( tr( "Coordinating" ) ); 155 cmbMaintMode->insertItem( tr( "Coordinating" ) );
155 layout->addMultiCellWidget( cmbMaintMode, 6, 6, 1, 2 ); 156// layout->addMultiCellWidget( cmbMaintMode, 6, 6, 1, 2 );
156 QWhatsThis::add( cmbMaintMode, tr( "Click here to set the maintainer's role." ) ); 157 QWhatsThis::add( cmbMaintMode, tr( "Click here to set the maintainer's role." ) );
157 158
158 // Maintainer 159 // Maintainer
159 label = new QLabel( tr( "Maintainer:" ), container ); 160 label = new QLabel( tr( "Maintainer:" ), container );
160 layout->addWidget( label, 7, 0 ); 161 layout->addWidget( label, 7, 0 );
161 QWhatsThis::add( label, tr( "This is the name of the current task maintainer." ) ); 162 QWhatsThis::add( label, tr( "This is the name of the current task maintainer." ) );
162 txtMaintainer = new QLabel( tr( "test" ), container ); 163 txtMaintainer = new QLabel( tr( "test" ), container );
163 txtMaintainer->setTextFormat( QLabel::RichText ); 164 txtMaintainer->setTextFormat( QLabel::RichText );
164 layout->addWidget( txtMaintainer, 7, 1 ); 165 layout->addWidget( txtMaintainer, 7, 1 );
165 QWhatsThis::add( txtMaintainer, tr( "This is the name of the current task maintainer." ) ); 166 QWhatsThis::add( txtMaintainer, tr( "This is the name of the current task maintainer." ) );
166 tbtMaintainer = new QToolButton( container ); 167 tbtMaintainer = new QToolButton( container );
167 tbtMaintainer->setPixmap( Resource::loadPixmap( "todo/more" ) ); 168 tbtMaintainer->setPixmap( Resource::loadPixmap( "todo/more" ) );
168 layout->addWidget( tbtMaintainer, 7, 2 ); 169// layout->addWidget( tbtMaintainer, 7, 2 );
169 QWhatsThis::add( tbtMaintainer, tr( "Click here to select the task maintainer." ) ); 170 QWhatsThis::add( tbtMaintainer, tr( "Click here to select the task maintainer." ) );
171#endif
170} 172}
171 173
172TaskEditorStatus::~TaskEditorStatus() 174TaskEditorStatus::~TaskEditorStatus()
173{ 175{
174} 176}
175 177
176void TaskEditorStatus::load( const OTodo &todo ) 178void TaskEditorStatus::load( const OTodo &todo )
177{ 179{
178 QDate date = QDate::currentDate(); 180 QDate date = QDate::currentDate();
179 QString str = TimeString::longDateString( date ); 181 QString str = TimeString::longDateString( date );
180 182
181 // Status 183 // Status
182 int state = todo.hasState()? todo.state().state() : OPimState::NotStarted; 184 int state = todo.hasState()? todo.state().state() : OPimState::NotStarted;
183 if ( state == OPimState::Undefined ) 185 if ( state == OPimState::Undefined )
184 state = OPimState::NotStarted; 186 state = OPimState::NotStarted;
185 cmbStatus->setCurrentItem( state ); 187 cmbStatus->setCurrentItem( state );
186 188
187 // Progress 189 // Progress
188 cmbProgress->setCurrentItem( todo.progress() / 20 ); 190 cmbProgress->setCurrentItem( todo.progress() / 20 );
189 191
190 // Start date 192 // Start date
191 ckbStart->setChecked( todo.hasStartDate() ); 193 ckbStart->setChecked( todo.hasStartDate() );
192 btnStart->setEnabled( todo.hasStartDate() ); 194 btnStart->setEnabled( todo.hasStartDate() );
193 if ( todo.hasStartDate() ) 195 if ( todo.hasStartDate() )
194 { 196 {
195 m_start = todo.startDate(); 197 m_start = todo.startDate();
196 btnStart->setText( TimeString::longDateString( m_start ) ); 198 btnStart->setText( TimeString::longDateString( m_start ) );
197 } 199 }
198 else 200 else
199 btnStart->setText( str ); 201 btnStart->setText( str );
200 202
201 // Due date 203 // Due date
202 ckbDue->setChecked( todo.hasDueDate() ); 204 ckbDue->setChecked( todo.hasDueDate() );
203 btnDue->setText( TimeString::longDateString( todo.dueDate() ) ); 205 btnDue->setText( TimeString::longDateString( todo.dueDate() ) );
204 btnDue->setEnabled( todo.hasDueDate() ); 206 btnDue->setEnabled( todo.hasDueDate() );
205 m_due = todo.dueDate(); 207 m_due = todo.dueDate();
206 208
207 // Completed 209 // Completed
208 ckbComp->setChecked( todo.isCompleted() ); 210 ckbComp->setChecked( todo.isCompleted() );
209 btnComp->setEnabled( todo.hasCompletedDate() ); 211 btnComp->setEnabled( todo.hasCompletedDate() );
210 if ( todo.hasCompletedDate() ) 212 if ( todo.hasCompletedDate() )
211 { 213 {
212 m_comp = todo.completedDate(); 214 m_comp = todo.completedDate();
213 btnComp->setText( TimeString::longDateString( m_comp ) ); 215 btnComp->setText( TimeString::longDateString( m_comp ) );
214 } 216 }
215 else 217 else
216 btnComp->setText( str ); 218 btnComp->setText( str );
217 219
218 // Maintainer Mode 220 // Maintainer Mode
221#if 0
219 state = todo.hasMaintainer() ? todo.maintainer().mode() : OPimMaintainer::Nothing; 222 state = todo.hasMaintainer() ? todo.maintainer().mode() : OPimMaintainer::Nothing;
220 if ( state == OPimMaintainer::Undefined ) 223 if ( state == OPimMaintainer::Undefined )
221 state = OPimMaintainer::Nothing; 224 state = OPimMaintainer::Nothing;
222 cmbMaintMode->setCurrentItem( state ); 225 cmbMaintMode->setCurrentItem( state );
223 226#endif
224 // Maintainer - not implemented yet 227 // Maintainer - not implemented yet
225} 228}
226 229
227void TaskEditorStatus::save( OTodo &todo ) 230void TaskEditorStatus::save( OTodo &todo )
228{ 231{
229 QDate inval; 232 QDate inval;
230 233
231 // Status 234 // Status
232 todo.setState( OPimState( cmbStatus->currentItem() ) ); 235 todo.setState( OPimState( cmbStatus->currentItem() ) );
233 236
234 // Progress 237 // Progress
235 todo.setProgress( cmbProgress->currentItem() * 20 ); 238 todo.setProgress( cmbProgress->currentItem() * 20 );
236 239
237 // Start date 240 // Start date
238 if ( ckbStart->isChecked() ) 241 if ( ckbStart->isChecked() )
239 { 242 {
240 todo.setStartDate( m_start ); 243 todo.setStartDate( m_start );
241 } 244 }
242 else 245 else
243 todo.setStartDate( inval ); 246 todo.setStartDate( inval );
244 247
245 // Due date 248 // Due date
246 if ( ckbDue->isChecked() ) 249 if ( ckbDue->isChecked() )
247 { 250 {
248 todo.setDueDate( m_due ); 251 todo.setDueDate( m_due );
249 todo.setHasDueDate( true ); 252 todo.setHasDueDate( true );
250 } 253 }
251 else 254 else
252 todo.setHasDueDate( false ); 255 todo.setHasDueDate( false );
253 256
254 // Completed 257 // Completed
255 todo.setCompleted( ckbComp->isChecked() ); 258 todo.setCompleted( ckbComp->isChecked() );
256 if ( ckbComp->isChecked() ) 259 if ( ckbComp->isChecked() )
257 { 260 {
258 todo.setCompletedDate( m_comp ); 261 todo.setCompletedDate( m_comp );
259 } 262 }
260 else 263 else
261 todo.setCompletedDate( inval ); 264 todo.setCompletedDate( inval );
262 265
266#if 0
263 // Maintainer mode - not implemented yet 267 // Maintainer mode - not implemented yet
264 268
265 // Maintainer 269 // Maintainer
266 /* TODO - resolve name to uid.....*/ 270 /* TODO - resolve name to uid.....*/
267 todo.setMaintainer( OPimMaintainer( cmbMaintMode->currentItem(), -10 ) ); 271 todo.setMaintainer( OPimMaintainer( cmbMaintMode->currentItem(), -10 ) );
272#endif
268} 273}
269 274
270void TaskEditorStatus::slotStartChecked() 275void TaskEditorStatus::slotStartChecked()
271{ 276{
272 btnStart->setEnabled( ckbStart->isChecked() ); 277 btnStart->setEnabled( ckbStart->isChecked() );
273} 278}
274 279
275void TaskEditorStatus::slotCompChecked() 280void TaskEditorStatus::slotCompChecked()
276{ 281{
277 btnComp->setEnabled( ckbComp->isChecked() ); 282 btnComp->setEnabled( ckbComp->isChecked() );
278} 283}
279 284
280void TaskEditorStatus::slotDueChecked() 285void TaskEditorStatus::slotDueChecked()
281{ 286{
282 btnDue->setEnabled( ckbDue->isChecked() ); 287 btnDue->setEnabled( ckbDue->isChecked() );
283} 288}
284 289
285void TaskEditorStatus::slotStartChanged(int y, int m, int d) 290void TaskEditorStatus::slotStartChanged(int y, int m, int d)
286{ 291{
287 m_start.setYMD( y, m, d ); 292 m_start.setYMD( y, m, d );
288 btnStart->setText( TimeString::longDateString( m_start ) ); 293 btnStart->setText( TimeString::longDateString( m_start ) );
289} 294}
290 295
291void TaskEditorStatus::slotCompChanged(int y, int m, int d) 296void TaskEditorStatus::slotCompChanged(int y, int m, int d)
292{ 297{
293 m_comp.setYMD( y, m, d ); 298 m_comp.setYMD( y, m, d );
294 btnComp->setText( TimeString::longDateString( m_comp ) ); 299 btnComp->setText( TimeString::longDateString( m_comp ) );
295} 300}
296 301
297void TaskEditorStatus::slotDueChanged(int y, int m, int d) 302void TaskEditorStatus::slotDueChanged(int y, int m, int d)
298{ 303{
299 m_due.setYMD( y, m, d ); 304 m_due.setYMD( y, m, d );
300 btnDue->setText( TimeString::longDateString( m_due ) ); 305 btnDue->setText( TimeString::longDateString( m_due ) );
301} 306}
diff --git a/core/pim/todo/templatedialog.cpp b/core/pim/todo/templatedialog.cpp
index c94f69c..8dfbd0b 100644
--- a/core/pim/todo/templatedialog.cpp
+++ b/core/pim/todo/templatedialog.cpp
@@ -1,60 +1,62 @@
1#include <qpushbutton.h> 1#include <qpushbutton.h>
2#include <qhbox.h> 2#include <qhbox.h>
3#include <qlayout.h> 3#include <qlayout.h>
4#include <qlistview.h> 4#include <qlistview.h>
5#include <qlineedit.h> 5#include <qlineedit.h>
6 6
7#include "templatedialog.h" 7#include "templatedialog.h"
8 8
9 9
10using namespace Todo; 10using namespace Todo;
11 11
12/* TRANSLATOR Todo::TemplateDialog */
13
12TemplateDialog::TemplateDialog( QWidget* widget ) 14TemplateDialog::TemplateDialog( QWidget* widget )
13 : QDialog( widget, "TemplateDialog", TRUE ) 15 : QDialog( widget, "TemplateDialog", TRUE )
14{ 16{
15 setCaption( tr("Template Editor") ); 17 setCaption( QWidget::tr("Template Editor") );
16 m_main = new QVBoxLayout(this ); 18 m_main = new QVBoxLayout(this );
17 19
18 m_list = new QListView( this ); 20 m_list = new QListView( this );
19 m_main->addWidget( m_list, 100 ); 21 m_main->addWidget( m_list, 100 );
20 22
21 m_lne = new QLineEdit( this ); 23 m_lne = new QLineEdit( this );
22 m_main->addWidget( m_lne ); 24 m_main->addWidget( m_lne );
23 25
24 m_btnBar = new QHBox( this ); 26 m_btnBar = new QHBox( this );
25 m_add = new QPushButton( tr("Add"), m_btnBar ); 27 m_add = new QPushButton( QWidget::tr("Add"), m_btnBar );
26 m_edit = new QPushButton( tr("Edit"), m_btnBar ); 28 m_edit = new QPushButton( QWidget::tr("Edit"), m_btnBar );
27 m_rem = new QPushButton( tr("Remove"), m_btnBar ); 29 m_rem = new QPushButton( QWidget::tr("Remove"), m_btnBar );
28 m_main->addWidget( m_btnBar ); 30 m_main->addWidget( m_btnBar );
29 31
30 connect(m_add, SIGNAL(clicked() ), 32 connect(m_add, SIGNAL(clicked() ),
31 this, SLOT(slotAdd() ) ); 33 this, SLOT(slotAdd() ) );
32 connect(m_edit, SIGNAL(clicked() ), 34 connect(m_edit, SIGNAL(clicked() ),
33 this, SLOT(slotEdit() ) ); 35 this, SLOT(slotEdit() ) );
34 connect(m_rem, SIGNAL(clicked() ), 36 connect(m_rem, SIGNAL(clicked() ),
35 this, SLOT(slotRemove() ) ); 37 this, SLOT(slotRemove() ) );
36 connect(m_lne, SIGNAL(returnPressed() ), 38 connect(m_lne, SIGNAL(returnPressed() ),
37 this, SLOT(slotReturn() ) ); 39 this, SLOT(slotReturn() ) );
38 40
39} 41}
40TemplateDialog::~TemplateDialog() { 42TemplateDialog::~TemplateDialog() {
41 // Qt does delete our widgets 43 // Qt does delete our widgets
42} 44}
43QListView* TemplateDialog::listView() { 45QListView* TemplateDialog::listView() {
44 return m_list; 46 return m_list;
45} 47}
46QLineEdit* TemplateDialog::edit() { 48QLineEdit* TemplateDialog::edit() {
47 return m_lne; 49 return m_lne;
48} 50}
49void TemplateDialog::slotAdd() { 51void TemplateDialog::slotAdd() {
50 qWarning("Not Implemented here"); 52 qWarning("Not Implemented here");
51} 53}
52void TemplateDialog::slotRemove() { 54void TemplateDialog::slotRemove() {
53 qWarning("Not Implemented here"); 55 qWarning("Not Implemented here");
54} 56}
55void TemplateDialog::slotEdit() { 57void TemplateDialog::slotEdit() {
56 qWarning("Not Implemented here"); 58 qWarning("Not Implemented here");
57} 59}
58void TemplateDialog::slotReturn() { 60void TemplateDialog::slotReturn() {
59 qWarning("Not Implemented here"); 61 qWarning("Not Implemented here");
60} 62}
diff --git a/core/pim/todo/templatedialogimpl.cpp b/core/pim/todo/templatedialogimpl.cpp
index 77c5363..fed92f0 100644
--- a/core/pim/todo/templatedialogimpl.cpp
+++ b/core/pim/todo/templatedialogimpl.cpp
@@ -1,119 +1,119 @@
1#include <qlistview.h> 1#include <qlistview.h>
2#include <qlineedit.h> 2#include <qlineedit.h>
3 3
4#include "mainwindow.h" 4#include "mainwindow.h"
5#include "todoeditor.h" 5#include "todoeditor.h"
6#include "todotemplatemanager.h" 6#include "todotemplatemanager.h"
7#include "templatedialogimpl.h" 7#include "templatedialogimpl.h"
8 8
9 9
10using namespace Todo; 10using namespace Todo;
11 11
12/* TRANSLATOR Todo::TemplateDialogImpl */
13
12namespace { 14namespace {
13 class TemplateListItem : public QListViewItem { 15 class TemplateListItem : public QListViewItem {
14 public: 16 public:
15 TemplateListItem( QListView*, 17 TemplateListItem( QListView*,
16 const QString& name, 18 const QString& name,
17 const OTodo& ); 19 const OTodo& );
18 ~TemplateListItem(); 20 ~TemplateListItem();
19 21
20 OTodo event()const; 22 OTodo event()const;
21 QString text()const; 23 QString text()const;
22 void setText(const QString& str ); 24 void setText(const QString& str );
23 void setEvent( const OTodo& ); 25 void setEvent( const OTodo& );
24 private: 26 private:
25 QString m_name; 27 QString m_name;
26 OTodo m_ev; 28 OTodo m_ev;
27 }; 29 };
28 30
29 /* implementation */ 31 /* implementation */
30 TemplateListItem::TemplateListItem( QListView* view, 32 TemplateListItem::TemplateListItem( QListView* view,
31 const QString& text, 33 const QString& text,
32 const OTodo& ev ) 34 const OTodo& ev )
33 : QListViewItem( view ), m_name( text ), m_ev( ev ) 35 : QListViewItem( view ), m_name( text ), m_ev( ev )
34 { 36 {
35 QListViewItem::setText(0, m_name ); 37 QListViewItem::setText(0, m_name );
36 } 38 }
37 TemplateListItem::~TemplateListItem() {} 39 TemplateListItem::~TemplateListItem() {}
38 OTodo TemplateListItem::event() const { 40 OTodo TemplateListItem::event() const {
39 return m_ev; 41 return m_ev;
40 } 42 }
41 QString TemplateListItem::text()const { 43 QString TemplateListItem::text()const {
42 return m_name; 44 return m_name;
43 } 45 }
44 void TemplateListItem::setText( const QString& str ) { 46 void TemplateListItem::setText( const QString& str ) {
45 QListViewItem::setText(0, str ); 47 QListViewItem::setText(0, str );
46 m_name = str; 48 m_name = str;
47 } 49 }
48 void TemplateListItem::setEvent( const OTodo& ev) { 50 void TemplateListItem::setEvent( const OTodo& ev) {
49 m_ev = ev; 51 m_ev = ev;
50 } 52 }
51} 53}
52 54
53TemplateDialogImpl::TemplateDialogImpl( MainWindow* win, 55TemplateDialogImpl::TemplateDialogImpl( MainWindow* win,
54 TemplateManager* man ) 56 TemplateManager* man )
55 : TemplateDialog( win ), m_win( win), m_man( man ) 57 : TemplateDialog( win ), m_win( win), m_man( man )
56{ 58{
57 /* fill the listview */ 59 /* fill the listview */
58 /* not the fastest way.... */ 60 /* not the fastest way.... */
59 QStringList list = man->templates(); 61 QStringList list = man->templates();
60 for (QStringList::Iterator it = list.begin(); 62 for (QStringList::Iterator it = list.begin();
61 it != list.end(); ++it ) { 63 it != list.end(); ++it ) {
62 new TemplateListItem( listView(), (*it), man->templateEvent( (*it) ) ); 64 new TemplateListItem( listView(), (*it), man->templateEvent( (*it) ) );
63 } 65 }
64 listView()->addColumn( tr("Name") ); 66 listView()->addColumn( QWidget::tr("Name") );
65 67
66 connect( listView(), SIGNAL(clicked(QListViewItem*) ), 68 connect( listView(), SIGNAL(clicked(QListViewItem*) ),
67 this, SLOT(slotClicked(QListViewItem*) ) ); 69 this, SLOT(slotClicked(QListViewItem*) ) );
68} 70}
69TemplateDialogImpl::~TemplateDialogImpl() { 71TemplateDialogImpl::~TemplateDialogImpl() {
70 72
71} 73}
72void TemplateDialogImpl::slotAdd() { 74void TemplateDialogImpl::slotAdd() {
73 QString str = tr("New Template %1").arg( listView()->childCount() ); 75 QString str = QWidget::tr("New Template %1").arg( listView()->childCount() );
74 OTodo ev; 76 OTodo ev;
75 m_man->addEvent(str, ev); 77 m_man->addEvent(str, ev);
76 new TemplateListItem( listView(), str, ev ); 78 new TemplateListItem( listView(), str, ev );
77} 79}
78void TemplateDialogImpl::slotRemove() { 80void TemplateDialogImpl::slotRemove() {
79 TemplateListItem* item = (TemplateListItem*) listView()->currentItem(); 81 TemplateListItem* item = (TemplateListItem*) listView()->currentItem();
80 listView()->takeItem( item ); 82 listView()->takeItem( item );
81 83
82 m_man->removeEvent( item->text() ); 84 m_man->removeEvent( item->text() );
83 85
84 delete item; 86 delete item;
85} 87}
86void TemplateDialogImpl::slotEdit() { 88void TemplateDialogImpl::slotEdit() {
87 TemplateListItem* item = (TemplateListItem*)listView()->currentItem(); 89 TemplateListItem* item = (TemplateListItem*)listView()->currentItem();
88 OTodo ev = m_win->currentEditor()->edit( m_win, item->event() ); 90 OTodo ev = m_win->currentEditor()->edit( m_win, item->event() );
89 if ( m_win->currentEditor()->accepted() ) { 91 if ( m_win->currentEditor()->accepted() ) {
90 qWarning("accepted");
91 item->setEvent( ev ); 92 item->setEvent( ev );
92 qWarning("Priority %d", ev.priority() );
93 m_man->removeEvent( item->text() ); 93 m_man->removeEvent( item->text() );
94 m_man->addEvent( item->text(), ev ); 94 m_man->addEvent( item->text(), ev );
95 } 95 }
96} 96}
97/* 97/*
98 * we need to update 98 * we need to update
99 * the text 99 * the text
100 */ 100 */
101 101
102void TemplateDialogImpl::slotReturn() { 102void TemplateDialogImpl::slotReturn() {
103 TemplateListItem* tbl = (TemplateListItem*)listView()->currentItem(); 103 TemplateListItem* tbl = (TemplateListItem*)listView()->currentItem();
104 104
105 if (tbl->text() != edit()->text() ) { 105 if (tbl->text() != edit()->text() ) {
106 m_man->removeEvent( tbl->text() ); 106 m_man->removeEvent( tbl->text() );
107 tbl->setText( edit()->text() ); 107 tbl->setText( edit()->text() );
108 m_man->addEvent( tbl->text(), tbl->event() ); 108 m_man->addEvent( tbl->text(), tbl->event() );
109 } 109 }
110} 110}
111/* update the lineedit when changing */ 111/* update the lineedit when changing */
112void TemplateDialogImpl::slotClicked( QListViewItem* item) { 112void TemplateDialogImpl::slotClicked( QListViewItem* item) {
113 if (!item) 113 if (!item)
114 return; 114 return;
115 115
116 TemplateListItem* tbl = (TemplateListItem*)item; 116 TemplateListItem* tbl = static_cast<TemplateListItem*>(item);
117 edit()->setText( tbl->text() ); 117 edit()->setText( tbl->text() );
118} 118}
119 119
diff --git a/core/pim/todo/templateeditor.cpp b/core/pim/todo/templateeditor.cpp
index 3930428..ca02173 100644
--- a/core/pim/todo/templateeditor.cpp
+++ b/core/pim/todo/templateeditor.cpp
@@ -1,39 +1,38 @@
1#include <qaction.h> 1#include <qaction.h>
2#include <qpopupmenu.h> 2#include <qpopupmenu.h>
3 3
4#include "mainwindow.h" 4#include "mainwindow.h"
5#include "todotemplatemanager.h" 5#include "todotemplatemanager.h"
6 6
7#include "templatedialogimpl.h" 7#include "templatedialogimpl.h"
8#include "templateeditor.h" 8#include "templateeditor.h"
9 9
10using namespace Todo; 10using namespace Todo;
11 11
12TemplateEditor::TemplateEditor( MainWindow* main, 12TemplateEditor::TemplateEditor( MainWindow* main,
13 TemplateManager* manager ) 13 TemplateManager* manager )
14 : QObject( main ), m_main( main ), m_man( manager ) 14 : QObject( main ), m_main( main ), m_man( manager )
15{ 15{
16 init(); 16 init();
17 17
18} 18}
19TemplateEditor::~TemplateEditor() { 19TemplateEditor::~TemplateEditor() {
20 20
21} 21}
22/* ok we add us to the Menubar */ 22/* ok we add us to the Menubar */
23void TemplateEditor::init() { 23void TemplateEditor::init() {
24 QAction* a = new QAction( QString::null, QWidget::tr("Configure Templates"), 24 QAction* a = new QAction( QString::null, QWidget::tr("Configure Templates"),
25 0, this, 0, FALSE ); 25 0, this, 0, FALSE );
26 connect(a, SIGNAL(activated() ), 26 connect(a, SIGNAL(activated() ),
27 this, SLOT(setUp() ) ); 27 this, SLOT(setUp() ) );
28 28
29 a->addTo( m_main->options() ); 29 a->addTo( m_main->options() );
30} 30}
31void TemplateEditor::setUp() { 31void TemplateEditor::setUp() {
32 qWarning("set up");
33 TemplateDialogImpl dlg(m_main, m_man ); 32 TemplateDialogImpl dlg(m_main, m_man );
34 int ret= dlg.exec(); 33 int ret= dlg.exec();
35 if (QDialog::Accepted != ret ) { 34 if (QDialog::Accepted != ret )
36 m_man->load(); 35 m_man->load();
37 }else 36 else
38 m_main->populateTemplates(); 37 m_main->populateTemplates();
39} 38}
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
index b5b87de..df2e711 100644
--- a/core/pim/todo/todomanager.cpp
+++ b/core/pim/todo/todomanager.cpp
@@ -29,101 +29,100 @@
29#include <qpe/categoryselect.h> 29#include <qpe/categoryselect.h>
30 30
31#include "todomanager.h" 31#include "todomanager.h"
32 32
33using namespace Todo; 33using namespace Todo;
34 34
35TodoManager::TodoManager( QObject *obj ) 35TodoManager::TodoManager( QObject *obj )
36 : QObject( obj ) { 36 : QObject( obj ) {
37 m_db = 0l; 37 m_db = 0l;
38 QTime time; 38 QTime time;
39 time.start(); 39 time.start();
40 int el = time.elapsed(); 40 int el = time.elapsed();
41 qWarning("QTimer for loading %d", el/1000 ); 41 qWarning("QTimer for loading %d", el/1000 );
42} 42}
43TodoManager::~TodoManager() { 43TodoManager::~TodoManager() {
44 delete m_db; 44 delete m_db;
45} 45}
46OTodo TodoManager::event(int uid ) { 46OTodo TodoManager::event(int uid ) {
47 return m_db->find( uid ); 47 return m_db->find( uid );
48} 48}
49void TodoManager::updateList() { 49void TodoManager::updateList() {
50 qWarning("update list"); 50 qWarning("update list");
51 m_list = m_db->allRecords(); 51 m_list = m_db->allRecords();
52} 52}
53OTodoAccess::List TodoManager::list() const{ 53OTodoAccess::List TodoManager::list() const{
54 return m_list; 54 return m_list;
55} 55}
56OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { 56OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) {
57 return m_db->sorted( asc, so, f, cat ); 57 return m_db->sorted( asc, so, f, cat );
58} 58}
59OTodoAccess::List::Iterator TodoManager::overDue() { 59OTodoAccess::List::Iterator TodoManager::overDue() {
60 int filter = 2 | 1; 60 int filter = 2 | 1;
61 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); 61 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca );
62 m_it = m_list.begin(); 62 m_it = m_list.begin();
63 return m_it; 63 return m_it;
64} 64}
65OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, 65OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start,
66 const QDate& end ) { 66 const QDate& end ) {
67 m_list = m_db->effectiveToDos( start, end ); 67 m_list = m_db->effectiveToDos( start, end );
68 m_it = m_list.begin(); 68 m_it = m_list.begin();
69 return m_it; 69 return m_it;
70} 70}
71OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) { 71OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) {
72 m_list = m_db->queryByExample( ev, query ); 72 m_list = m_db->queryByExample( ev, query );
73 m_it = m_list.begin(); 73 m_it = m_list.begin();
74 return m_it; 74 return m_it;
75} 75}
76OTodoAccess* TodoManager::todoDB() { 76OTodoAccess* TodoManager::todoDB() {
77 return m_db; 77 return m_db;
78} 78}
79void TodoManager::add( const OTodo& ev ) { 79void TodoManager::add( const OTodo& ev ) {
80 m_db->add( ev ); 80 m_db->add( ev );
81} 81}
82void TodoManager::update( int, const SmallTodo& ) { 82void TodoManager::update( int, const SmallTodo& ) {
83 83
84} 84}
85void TodoManager::update( int, const OTodo& ev) { 85void TodoManager::update( int, const OTodo& ev) {
86 m_db->replace( ev ); 86 m_db->replace( ev );
87} 87}
88bool TodoManager::remove( int uid ) { 88bool TodoManager::remove( int uid ) {
89 return m_db->remove( uid ); 89 return m_db->remove( uid );
90} 90}
91void TodoManager::removeAll() { 91void TodoManager::removeAll() {
92 m_db->clear(); 92 m_db->clear();
93} 93}
94void TodoManager::removeCompleted() { 94void TodoManager::removeCompleted() {
95 m_db->removeAllCompleted(); 95 m_db->removeAllCompleted();
96} 96}
97void TodoManager::save() { 97void TodoManager::save() {
98 m_db->save(); 98 m_db->save();
99} 99}
100bool TodoManager::saveAll() { 100bool TodoManager::saveAll() {
101 return m_db->save(); 101 return m_db->save();
102} 102}
103void TodoManager::reload() { 103void TodoManager::reload() {
104 m_db->reload(); 104 m_db->reload();
105} 105}
106QStringList TodoManager::categories() { 106QStringList TodoManager::categories() {
107 m_cat.load(categoryFileName() ); 107 m_cat.load(categoryFileName() );
108 return m_cat.labels( "Todo List"); 108 return m_cat.labels( "Todo List");
109} 109}
110/* 110/*
111 * we rely on load beeing called from populateCategories 111 * we rely on load beeing called from populateCategories
112 */ 112 */
113int TodoManager::catId( const QString& cats ) { 113int TodoManager::catId( const QString& cats ) {
114 return m_cat.id( "Todo List", cats ); 114 return m_cat.id( "Todo List", cats );
115} 115}
116void TodoManager::remove( const QArray<int>& ids) { 116void TodoManager::remove( const QArray<int>& ids) {
117 for (uint i=0; i < ids.size(); i++ ) 117 for (uint i=0; i < ids.size(); i++ )
118 remove( ids[i] ); 118 remove( ids[i] );
119} 119}
120bool TodoManager::isLoaded()const { 120bool TodoManager::isLoaded()const {
121 return (m_db == 0 ); 121 return (m_db == 0 );
122} 122}
123void TodoManager::load() { 123void TodoManager::load() {
124 if (!m_db) { 124 if (!m_db) {
125 qWarning("loading!");
126 m_db = new OTodoAccess(); 125 m_db = new OTodoAccess();
127 m_db->load(); 126 m_db->load();
128 } 127 }
129} 128}