summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-13 19:09:09 (UTC)
committer zecke <zecke>2002-10-13 19:09:09 (UTC)
commit0762b201f248b9eaf3a08601b04484bec9a6d9a1 (patch) (unidiff)
tree5f386485a6b3b3e5c6edeeefdd26ef98ff924a34
parent34c1199becdb2f9b0447553e66c85d8f6770558f (diff)
downloadopie-0762b201f248b9eaf3a08601b04484bec9a6d9a1.zip
opie-0762b201f248b9eaf3a08601b04484bec9a6d9a1.tar.gz
opie-0762b201f248b9eaf3a08601b04484bec9a6d9a1.tar.bz2
Implement beaming and adding of todos. Use the vCal resource for that
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp52
-rw-r--r--core/pim/todo/mainwindow.h1
-rw-r--r--core/pim/todo/todo.pro2
3 files changed, 48 insertions, 7 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index c9c43d4..2994915 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,169 +1,173 @@
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>
30
29#include <qmenubar.h> 31#include <qmenubar.h>
30#include <qmessagebox.h> 32#include <qmessagebox.h>
31#include <qtoolbar.h> 33#include <qtoolbar.h>
32#include <qpopupmenu.h> 34#include <qpopupmenu.h>
33#include <qwidgetstack.h> 35#include <qwidgetstack.h>
34#include <qaction.h> 36#include <qaction.h>
35#include <qtimer.h> 37#include <qtimer.h>
36 38
39#include <qpe/applnk.h>
37#include <qpe/config.h> 40#include <qpe/config.h>
38#include <qpe/ir.h> 41#include <qpe/ir.h>
39#include <qpe/resource.h> 42#include <qpe/resource.h>
40#include <qpe/qpemessagebox.h> 43#include <qpe/qpemessagebox.h>
41 44
45#include <opie/otodoaccessvcal.h>
42 46
43#include "todotemplatemanager.h" 47#include "todotemplatemanager.h"
44#include "templateeditor.h" 48#include "templateeditor.h"
45#include "todoentryimpl.h" 49#include "todoentryimpl.h"
46#include "tableview.h" 50#include "tableview.h"
47 51
48#include "textviewshow.h" 52#include "textviewshow.h"
49#include "todoeditor.h" 53#include "todoeditor.h"
50#include "mainwindow.h" 54#include "mainwindow.h"
51 55
52 56
53using namespace Todo; 57using namespace Todo;
54 58
55MainWindow::MainWindow( QWidget* parent, 59MainWindow::MainWindow( QWidget* parent,
56 const char* name ) { 60 const char* name ) {
57 61
58 m_syncing = false; 62 m_syncing = false;
59 m_counter = 0; 63 m_counter = 0;
60 m_tempManager = new TemplateManager(); 64 m_tempManager = new TemplateManager();
61 m_tempManager->load(); 65 m_tempManager->load();
62 66
63 initUI(); 67 initUI();
64 initConfig(); 68 initConfig();
65 initViews(); 69 initViews();
66 initActions(); 70 initActions();
67 initEditor(); 71 initEditor();
68 initShow(); 72 initShow();
69 initTemplate(); 73 initTemplate();
70 74
71 populateTemplates(); 75 populateTemplates();
72 raiseCurrentView(); 76 raiseCurrentView();
73 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 77 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
74} 78}
75void MainWindow::initTemplate() { 79void MainWindow::initTemplate() {
76 m_curTempEd = new TemplateEditor( this, templateManager() ); 80 m_curTempEd = new TemplateEditor( this, templateManager() );
77} 81}
78void MainWindow::initActions() { 82void MainWindow::initActions() {
79 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), 83 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ),
80 QString::null, 0, this, 0 ); 84 QString::null, 0, this, 0 );
81 connect(a, SIGNAL( activated() ), 85 connect(a, SIGNAL( activated() ),
82 this, SLOT( slotNew() ) ); 86 this, SLOT( slotNew() ) );
83 a->addTo(m_tool ); 87 a->addTo(m_tool );
84 a->addTo(m_edit ); 88 a->addTo(m_edit );
85 89
86 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), 90 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ),
87 QString::null, 0, this, 0 ); 91 QString::null, 0, this, 0 );
88 connect(a, SIGNAL(activated() ), 92 connect(a, SIGNAL(activated() ),
89 this, SLOT( slotEdit() ) ); 93 this, SLOT( slotEdit() ) );
90 a->addTo( m_tool ); 94 a->addTo( m_tool );
91 a->addTo( m_edit ); 95 a->addTo( m_edit );
92 m_editAction = a; 96 m_editAction = a;
93 97
94 a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); 98 a = new QAction( QString::null, tr("View Task"), 0, this, 0 );
95 connect(a, SIGNAL( activated() ), 99 connect(a, SIGNAL( activated() ),
96 this, SLOT( slotShowDetails() ) ); 100 this, SLOT( slotShowDetails() ) );
97 a->addTo( m_edit ); 101 a->addTo( m_edit );
98 102
99 m_edit->insertSeparator(); 103 m_edit->insertSeparator();
100 104
101 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), 105 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ),
102 QString::null, 0, this, 0 ); 106 QString::null, 0, this, 0 );
103 connect(a, SIGNAL(activated() ), 107 connect(a, SIGNAL(activated() ),
104 this, SLOT(slotDelete() ) ); 108 this, SLOT(slotDelete() ) );
105 a->addTo( m_tool ); 109 a->addTo( m_tool );
106 a->addTo( m_edit ); 110 a->addTo( m_edit );
107 m_deleteAction = a; 111 m_deleteAction = a;
108 112
109 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); 113 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 );
110 connect(a, SIGNAL( activated() ), 114 connect(a, SIGNAL( activated() ),
111 this, SLOT( slotDeleteAll() ) ); 115 this, SLOT( slotDeleteAll() ) );
112 a->addTo(m_edit ); 116 a->addTo(m_edit );
113 m_deleteAllAction = a; 117 m_deleteAllAction = a;
114 118
115 a = new QAction( QString::null, tr("Delete completed"), 119 a = new QAction( QString::null, tr("Delete completed"),
116 0, this, 0 ); 120 0, this, 0 );
117 connect(a, SIGNAL( activated() ), 121 connect(a, SIGNAL( activated() ),
118 this, SLOT( slotDeleteCompleted() ) ); 122 this, SLOT( slotDeleteCompleted() ) );
119 a->addTo(m_edit ); 123 a->addTo(m_edit );
120 a->setEnabled( TRUE ); 124 a->setEnabled( TRUE );
121 m_deleteCompleteAction = a; 125 m_deleteCompleteAction = a;
122 126
123 m_edit->insertSeparator(); 127 m_edit->insertSeparator();
124 128
125 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); 129 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 );
126 connect(a, SIGNAL( activated() ), 130 connect(a, SIGNAL( activated() ),
127 this, SLOT( slotDuplicate() ) ); 131 this, SLOT( slotDuplicate() ) );
128 a->addTo(m_edit ); 132 a->addTo(m_edit );
129 m_duplicateAction = a; 133 m_duplicateAction = a;
130 134
131 m_edit->insertSeparator(); 135 m_edit->insertSeparator();
132 136
133 if ( Ir::supported() ) { 137 if ( Ir::supported() ) {
134 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), 138 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
135 QString::null, 0, this, 0 ); 139 QString::null, 0, this, 0 );
136 connect( a, SIGNAL( activated() ), 140 connect( a, SIGNAL( activated() ),
137 this, SLOT( slotBeam() ) ); 141 this, SLOT( slotBeam() ) );
138 a->addTo( m_edit ); 142 a->addTo( m_edit );
139 a->addTo( m_tool ); 143 a->addTo( m_tool );
140 } 144 }
141 145
142 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), 146 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ),
143 QString::null, 0, this, 0 ); 147 QString::null, 0, this, 0 );
144 connect(a, SIGNAL( activated() ), 148 connect(a, SIGNAL( activated() ),
145 this, SLOT( slotFind() ) ); 149 this, SLOT( slotFind() ) );
146 a->addTo( m_options ); 150 a->addTo( m_options );
147 m_findAction = a; 151 m_findAction = a;
148 152
149 m_options->insertSeparator(); 153 m_options->insertSeparator();
150 154
151 m_completedAction = new QAction( QString::null, tr("Completed tasks"), 155 m_completedAction = new QAction( QString::null, tr("Completed tasks"),
152 0, this, 0, TRUE ); 156 0, this, 0, TRUE );
153 m_completedAction->addTo( m_options ); 157 m_completedAction->addTo( m_options );
154 m_completedAction->setOn( showCompleted() ); 158 m_completedAction->setOn( showCompleted() );
155 connect(m_completedAction, SIGNAL( toggled(bool) ), 159 connect(m_completedAction, SIGNAL( toggled(bool) ),
156 this, SLOT(slotShowCompleted(bool) ) ); 160 this, SLOT(slotShowCompleted(bool) ) );
157 161
158 m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), 162 m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"),
159 0, this, 0, TRUE ); 163 0, this, 0, TRUE );
160 m_showDeadLineAction->addTo( m_options ); 164 m_showDeadLineAction->addTo( m_options );
161 m_showDeadLineAction->setOn( showDeadline() ); 165 m_showDeadLineAction->setOn( showDeadline() );
162 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), 166 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ),
163 this, SLOT( slotShowDeadLine( bool ) ) ); 167 this, SLOT( slotShowDeadLine( bool ) ) );
164 168
165 m_options->insertSeparator(); 169 m_options->insertSeparator();
166 170
167 m_bar->insertItem( tr("Data") ,m_edit ); 171 m_bar->insertItem( tr("Data") ,m_edit );
168 m_bar->insertItem( tr("Category"), m_catMenu ); 172 m_bar->insertItem( tr("Category"), m_catMenu );
169 m_bar->insertItem( tr("Options"), m_options ); 173 m_bar->insertItem( tr("Options"), m_options );
@@ -403,237 +407,273 @@ void MainWindow::slotNew() {
403 if(m_syncing) { 407 if(m_syncing) {
404 QMessageBox::warning(this, tr("Todo"), 408 QMessageBox::warning(this, tr("Todo"),
405 tr("Can not edit data, currently syncing")); 409 tr("Can not edit data, currently syncing"));
406 return; 410 return;
407 } 411 }
408 412
409 413
410 OTodo todo = currentEditor()->newTodo( currentCatId(), 414 OTodo todo = currentEditor()->newTodo( currentCatId(),
411 this ); 415 this );
412 416
413 if ( currentEditor()->accepted() ) { 417 if ( currentEditor()->accepted() ) {
414 //todo.assignUid(); 418 //todo.assignUid();
415 currentView()->addEvent( todo ); 419 currentView()->addEvent( todo );
416 m_todoMgr.add( todo ); 420 m_todoMgr.add( todo );
417 421
418 // I'm afraid we must call this every time now, otherwise 422 // I'm afraid we must call this every time now, otherwise
419 // spend expensive time comparing all these strings... 423 // spend expensive time comparing all these strings...
420 // but only call if we changed something -zecke 424 // but only call if we changed something -zecke
421 populateCategories(); 425 populateCategories();
422 } 426 }
423 raiseCurrentView( ); 427 raiseCurrentView( );
424} 428}
425void MainWindow::slotDuplicate() { 429void MainWindow::slotDuplicate() {
426 if(m_syncing) { 430 if(m_syncing) {
427 QMessageBox::warning(this, tr("Todo"), 431 QMessageBox::warning(this, tr("Todo"),
428 tr("Can not edit data, currently syncing")); 432 tr("Can not edit data, currently syncing"));
429 return; 433 return;
430 } 434 }
431 OTodo ev = m_todoMgr.event( currentView()->current() ); 435 OTodo ev = m_todoMgr.event( currentView()->current() );
432 /* let's generate a new uid */ 436 /* let's generate a new uid */
433 ev.setUid(-1); 437 ev.setUid(-1);
434 m_todoMgr.add( ev ); 438 m_todoMgr.add( ev );
435 439
436 currentView()->addEvent( ev ); 440 currentView()->addEvent( ev );
437 raiseCurrentView(); 441 raiseCurrentView();
438} 442}
439void MainWindow::slotDelete() { 443void MainWindow::slotDelete() {
440 if (!currentView()->current() ) 444 if (!currentView()->current() )
441 return; 445 return;
442 446
443 if(m_syncing) { 447 if(m_syncing) {
444 QMessageBox::warning(this, tr("Todo"), 448 QMessageBox::warning(this, tr("Todo"),
445 tr("Can not edit data, currently syncing")); 449 tr("Can not edit data, currently syncing"));
446 return; 450 return;
447 } 451 }
448 QString strName = currentView()->currentRepresentation(); 452 QString strName = currentView()->currentRepresentation();
449 if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) 453 if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) )
450 return; 454 return;
451 455
452 m_todoMgr.remove( currentView()->current() ); 456 m_todoMgr.remove( currentView()->current() );
453 currentView()->removeEvent( currentView()->current() ); 457 currentView()->removeEvent( currentView()->current() );
454 raiseCurrentView(); 458 raiseCurrentView();
455} 459}
456void MainWindow::slotDeleteAll() { 460void MainWindow::slotDeleteAll() {
457 if(m_syncing) { 461 if(m_syncing) {
458 QMessageBox::warning(this, tr("Todo"), 462 QMessageBox::warning(this, tr("Todo"),
459 tr("Can not edit data, currently syncing")); 463 tr("Can not edit data, currently syncing"));
460 return; 464 return;
461 } 465 }
462 466
463 //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); 467 //QString strName = table->text( table->currentRow(), 2 ).left( 30 );
464 468
465 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) 469 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) )
466 return; 470 return;
467 471
468 m_todoMgr.removeAll(); 472 m_todoMgr.removeAll();
469 currentView()->clear(); 473 currentView()->clear();
470 474
471 raiseCurrentView(); 475 raiseCurrentView();
472} 476}
473void MainWindow::slotDeleteCompleted() { 477void MainWindow::slotDeleteCompleted() {
474 if(m_syncing) { 478 if(m_syncing) {
475 QMessageBox::warning(this, tr("Todo"), 479 QMessageBox::warning(this, tr("Todo"),
476 tr("Can not edit data, currently syncing")); 480 tr("Can not edit data, currently syncing"));
477 return; 481 return;
478 } 482 }
479 483
480 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) 484 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) )
481 return; 485 return;
482 486
483 // FIXME 487 // FIXME
484 //m_todoMgr.remove( currentView()->completed() ); 488 //m_todoMgr.remove( currentView()->completed() );
485 currentView()->updateView( ); 489 currentView()->updateView( );
486} 490}
487void MainWindow::slotFind() { 491void MainWindow::slotFind() {
488 492
489} 493}
490void MainWindow::slotEdit() { 494void MainWindow::slotEdit() {
491 slotEdit( currentView()->current() ); 495 slotEdit( currentView()->current() );
492} 496}
493/* 497/*
494 * set the category 498 * set the category
495 */ 499 */
496void MainWindow::setCategory( int c) { 500void MainWindow::setCategory( int c) {
497 if ( c <= 0 ) return; 501 if ( c <= 0 ) return;
498 502
499 503
500 qWarning("Iterating over cats %d", c ); 504 qWarning("Iterating over cats %d", c );
501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 505 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
502 m_catMenu->setItemChecked(i, c == (int)i ); 506 m_catMenu->setItemChecked(i, c == (int)i );
503 507
504 if (c == 1 ) { 508 if (c == 1 ) {
505 m_curCat = QString::null; 509 m_curCat = QString::null;
506 setCaption( tr("Todo") + " - " + tr("All Categories" ) ); 510 setCaption( tr("Todo") + " - " + tr("All Categories" ) );
507 511
508 }else if ( c == (int)m_catMenu->count() - 1 ) { 512 }else if ( c == (int)m_catMenu->count() - 1 ) {
509 m_curCat = tr("Unfiled"); 513 m_curCat = tr("Unfiled");
510 setCaption( tr("Todo") + " - " + tr("Unfiled") ); 514 setCaption( tr("Todo") + " - " + tr("Unfiled") );
511 }else { 515 }else {
512 m_curCat = m_todoMgr.categories()[c-2]; 516 m_curCat = m_todoMgr.categories()[c-2];
513 setCaption( tr("Todo") + " - " + m_curCat ); 517 setCaption( tr("Todo") + " - " + m_curCat );
514 } 518 }
515 m_catMenu->setItemChecked( c, true ); 519 m_catMenu->setItemChecked( c, true );
516 520
517 currentView()->setShowCategory( m_curCat ); 521 currentView()->setShowCategory( m_curCat );
518 raiseCurrentView(); 522 raiseCurrentView();
519} 523}
520void MainWindow::slotShowDeadLine( bool dead) { 524void MainWindow::slotShowDeadLine( bool dead) {
521 m_deadline = dead; 525 m_deadline = dead;
522 currentView()->setShowDeadline( dead ); 526 currentView()->setShowDeadline( dead );
523} 527}
524void MainWindow::slotShowCompleted( bool show) { 528void MainWindow::slotShowCompleted( bool show) {
525 m_completed = show; 529 m_completed = show;
526 currentView()->setShowCompleted( m_completed ); 530 currentView()->setShowCompleted( m_completed );
527} 531}
528bool MainWindow::showOverDue()const { 532bool MainWindow::showOverDue()const {
529 return m_overdue; 533 return m_overdue;
530} 534}
531void MainWindow::setDocument( const QString& ) { 535void MainWindow::setDocument( const QString& fi) {
532 536 DocLnk doc(fi);
537 if (doc.isValid() )
538 receiveFile(doc.file() );
539 else
540 receiveFile(fi );
533} 541}
534void MainWindow::slotBeam() {
535
536}
537void MainWindow::beamDone( Ir* ) {
538 542
543static const char *beamfile = "/tmp/opie-todo.vcs";
544void MainWindow::slotBeam() {
545 ::unlink( beamfile );
546 OTodo todo = event( currentView()->current() );
547 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) );
548 OTodoAccess acc( cal );
549 acc.load();
550 acc.add( todo );
551 acc.save();
552 Ir* ir = new Ir(this );
553 connect(ir, SIGNAL(done(Ir*) ),
554 this, SLOT(beamDone(Ir*) ) );
555 ir->send( beamfile, todo.summary(), "text/x-vCalendar" );
556
557}
558void MainWindow::beamDone( Ir* ir) {
559 delete ir;
560 ::unlink( beamfile );
561}
562void MainWindow::receiveFile( const QString& filename ) {
563 OTodoAccessVCal* cal = new OTodoAccessVCal(filename );
564 OTodoAccess acc( cal );
565 acc.load();
566 OTodoAccess::List list = acc.allRecords();
567
568 QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
569
570 if ( QMessageBox::information(this, tr("New Tasks"),
571 message, QMessageBox::Ok,
572 QMessageBox::Cancel ) == QMessageBox::Ok ) {
573 OTodoAccess::List::Iterator it;
574 for ( it = list.begin(); it != list.end(); ++it )
575 m_todoMgr.add( (*it) );
576
577 currentView()->updateView();
578 }
539} 579}
540 580
541void MainWindow::slotFlush() { 581void MainWindow::slotFlush() {
542 m_syncing = FALSE; 582 m_syncing = FALSE;
543 m_todoMgr.save(); 583 m_todoMgr.save();
544} 584}
545void MainWindow::slotShowDetails() { 585void MainWindow::slotShowDetails() {
546 slotShow( currentView()->current() ); 586 slotShow( currentView()->current() );
547} 587}
548/* 588/*
549 * populate the Categories 589 * populate the Categories
550 * Menu 590 * Menu
551 */ 591 */
552void MainWindow::populateCategories() { 592void MainWindow::populateCategories() {
553 m_todoMgr.load(); 593 m_todoMgr.load();
554 594
555 m_catMenu->clear(); 595 m_catMenu->clear();
556 int id, rememberId; 596 int id, rememberId;
557 id = 1; 597 id = 1;
558 rememberId = 1; 598 rememberId = 1;
559 599
560 m_catMenu->insertItem( tr( "All Categories" ), id++ ); 600 m_catMenu->insertItem( tr( "All Categories" ), id++ );
561 m_catMenu->insertSeparator(); 601 m_catMenu->insertSeparator();
562 QStringList categories = m_todoMgr.categories(); 602 QStringList categories = m_todoMgr.categories();
563 categories.append( tr( "Unfiled" ) ); 603 categories.append( tr( "Unfiled" ) );
564 for ( QStringList::Iterator it = categories.begin(); 604 for ( QStringList::Iterator it = categories.begin();
565 it != categories.end(); ++it ) { 605 it != categories.end(); ++it ) {
566 m_catMenu->insertItem( *it, id ); 606 m_catMenu->insertItem( *it, id );
567 if ( *it == currentCategory() ) 607 if ( *it == currentCategory() )
568 rememberId = id; 608 rememberId = id;
569 ++id; 609 ++id;
570 } 610 }
571 setCategory( rememberId ); 611 setCategory( rememberId );
572} 612}
573bool MainWindow::showCompleted()const { 613bool MainWindow::showCompleted()const {
574 return m_completed; 614 return m_completed;
575} 615}
576bool MainWindow::showDeadline()const { 616bool MainWindow::showDeadline()const {
577 return m_deadline; 617 return m_deadline;
578} 618}
579QString MainWindow::currentCategory()const { 619QString MainWindow::currentCategory()const {
580 return m_curCat; 620 return m_curCat;
581} 621}
582int MainWindow::currentCatId() { 622int MainWindow::currentCatId() {
583 return m_todoMgr.catId( m_curCat ); 623 return m_todoMgr.catId( m_curCat );
584} 624}
585ViewBase* MainWindow::currentView() { 625ViewBase* MainWindow::currentView() {
586 return m_curView; 626 return m_curView;
587} 627}
588void MainWindow::raiseCurrentView() { 628void MainWindow::raiseCurrentView() {
589 m_stack->raiseWidget( m_curView->widget() ); 629 m_stack->raiseWidget( m_curView->widget() );
590} 630}
591void MainWindow::slotShowDue(bool ov) { 631void MainWindow::slotShowDue(bool ov) {
592 m_overdue = ov; 632 m_overdue = ov;
593 currentView()->showOverDue( ov ); 633 currentView()->showOverDue( ov );
594 raiseCurrentView(); 634 raiseCurrentView();
595} 635}
596void MainWindow::slotShow( int uid ) { 636void MainWindow::slotShow( int uid ) {
597 qWarning("slotShow"); 637 qWarning("slotShow");
598 currentShow()->slotShow( event( uid ) ); 638 currentShow()->slotShow( event( uid ) );
599 m_stack->raiseWidget( currentShow()->widget() ); 639 m_stack->raiseWidget( currentShow()->widget() );
600} 640}
601void MainWindow::slotEdit( int uid ) { 641void MainWindow::slotEdit( int uid ) {
602 if(m_syncing) { 642 if(m_syncing) {
603 QMessageBox::warning(this, tr("Todo"), 643 QMessageBox::warning(this, tr("Todo"),
604 tr("Can not edit data, currently syncing")); 644 tr("Can not edit data, currently syncing"));
605 return; 645 return;
606 } 646 }
607 647
608 OTodo todo = m_todoMgr.event( uid ); 648 OTodo todo = m_todoMgr.event( uid );
609 649
610 todo = currentEditor()->edit(this, todo ); 650 todo = currentEditor()->edit(this, todo );
611 651
612 /* if completed */ 652 /* if completed */
613 if ( currentEditor()->accepted() ) { 653 if ( currentEditor()->accepted() ) {
614 qWarning("Replacing now" ); 654 qWarning("Replacing now" );
615 m_todoMgr.update( todo.uid(), todo ); 655 m_todoMgr.update( todo.uid(), todo );
616 currentView()->replaceEvent( todo ); 656 currentView()->replaceEvent( todo );
617 /* a Category might have changed */ 657 /* a Category might have changed */
618 populateCategories(); 658 populateCategories();
619 } 659 }
620 660
621 raiseCurrentView(); 661 raiseCurrentView();
622} 662}
623/* 663/*
624void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 664void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
625 m_todoMgr.update( uid, ev ); 665 m_todoMgr.update( uid, ev );
626} 666}
627*/ 667*/
628void MainWindow::updateTodo( const OTodo& ev) { 668void MainWindow::updateTodo( const OTodo& ev) {
629 m_todoMgr.update( ev.uid() , ev ); 669 m_todoMgr.update( ev.uid() , ev );
630} 670}
631/* The view changed it's configuration 671/* The view changed it's configuration
632 * update the view menu 672 * update the view menu
633 */ 673 */
634void MainWindow::slotUpdate3( QWidget* ) { 674void MainWindow::slotUpdate3( QWidget* ) {
635 675
636} 676}
637void MainWindow::updateList() { 677void MainWindow::updateList() {
638 m_todoMgr.updateList(); 678 m_todoMgr.updateList();
639} 679}
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
index 598c3af..8d0c29f 100644
--- a/core/pim/todo/mainwindow.h
+++ b/core/pim/todo/mainwindow.h
@@ -1,175 +1,176 @@
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 Holger Freyther <zecke@handhelds.org> 3             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
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  -_. . .   )=.  = 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#include <qmainwindow.h> 33#include <qmainwindow.h>
34 34
35#include <opie/otodoaccess.h> 35#include <opie/otodoaccess.h>
36#include <opie/otodo.h> 36#include <opie/otodo.h>
37 37
38#include "smalltodo.h" 38#include "smalltodo.h"
39#include "todoview.h" 39#include "todoview.h"
40#include "todomanager.h" 40#include "todomanager.h"
41 41
42class QPopupMenu; 42class QPopupMenu;
43class QMenuBar; 43class QMenuBar;
44class QToolBar; 44class QToolBar;
45class QAction; 45class QAction;
46class QWidgetStack; 46class QWidgetStack;
47class Ir; 47class Ir;
48 48
49 49
50namespace Todo { 50namespace Todo {
51 typedef TodoView View; 51 typedef TodoView View;
52 class TemplateManager; 52 class TemplateManager;
53 class Editor; 53 class Editor;
54 class TodoShow; 54 class TodoShow;
55 class TemplateEditor; 55 class TemplateEditor;
56 56
57 class MainWindow : public QMainWindow { 57 class MainWindow : public QMainWindow {
58 Q_OBJECT 58 Q_OBJECT
59 public: 59 public:
60 MainWindow( QWidget *parent = 0, 60 MainWindow( QWidget *parent = 0,
61 const char* name = 0 ); 61 const char* name = 0 );
62 ~MainWindow(); 62 ~MainWindow();
63 63
64 /** return a context menu for an OTodo */ 64 /** return a context menu for an OTodo */
65 QPopupMenu* contextMenu(int uid ); 65 QPopupMenu* contextMenu(int uid );
66 QPopupMenu* options(); 66 QPopupMenu* options();
67 QPopupMenu* edit(); 67 QPopupMenu* edit();
68 QPopupMenu* view(); 68 QPopupMenu* view();
69 QToolBar* toolbar(); 69 QToolBar* toolbar();
70 70
71 71
72 void updateList(); 72 void updateList();
73 OTodoAccess::List list()const; 73 OTodoAccess::List list()const;
74 OTodoAccess::List sorted( bool asc, int sortOrder ); 74 OTodoAccess::List sorted( bool asc, int sortOrder );
75 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); 75 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter );
76 76
77 OTodo event(int uid ); 77 OTodo event(int uid );
78 78
79 bool isSyncing()const; 79 bool isSyncing()const;
80 bool showCompleted()const; 80 bool showCompleted()const;
81 bool showDeadline()const; 81 bool showDeadline()const;
82 bool showOverDue()const; 82 bool showOverDue()const;
83 QString currentCategory()const; 83 QString currentCategory()const;
84 int currentCatId(); 84 int currentCatId();
85 TemplateManager* templateManager(); 85 TemplateManager* templateManager();
86 86
87 void updateTodo( const OTodo& ); 87 void updateTodo( const OTodo& );
88 void populateTemplates(); 88 void populateTemplates();
89 Editor* currentEditor(); 89 Editor* currentEditor();
90private slots: 90private slots:
91 void populateCategories(); 91 void populateCategories();
92 void slotReload(); 92 void slotReload();
93 void slotFlush(); 93 void slotFlush();
94 94
95 protected: 95 protected:
96 void closeEvent( QCloseEvent* e ); 96 void closeEvent( QCloseEvent* e );
97 97
98 private: 98 private:
99 void receiveFile( const QString& filename );
99 void connectBase( ViewBase* ); 100 void connectBase( ViewBase* );
100 void initUI(); 101 void initUI();
101 void initActions(); 102 void initActions();
102 void initConfig(); 103 void initConfig();
103 void initViews(); 104 void initViews();
104 void initEditor(); 105 void initEditor();
105 void initShow(); 106 void initShow();
106 void initTemplate(); 107 void initTemplate();
107 void raiseCurrentView(); 108 void raiseCurrentView();
108 ViewBase* currentView(); 109 ViewBase* currentView();
109 ViewBase* m_curView; 110 ViewBase* m_curView;
110 Editor* m_curEdit; 111 Editor* m_curEdit;
111 TodoShow* currentShow(); 112 TodoShow* currentShow();
112 TodoShow* m_curShow; 113 TodoShow* m_curShow;
113 TemplateEditor* currentTemplateEditor(); 114 TemplateEditor* currentTemplateEditor();
114 TemplateEditor* m_curTempEd; 115 TemplateEditor* m_curTempEd;
115 116
116 QMenuBar* m_bar; 117 QMenuBar* m_bar;
117 QToolBar* m_tool; 118 QToolBar* m_tool;
118 QAction* m_editAction, 119 QAction* m_editAction,
119 *m_deleteAction, 120 *m_deleteAction,
120 *m_findAction, 121 *m_findAction,
121 *m_completedAction, 122 *m_completedAction,
122 *m_showDeadLineAction, 123 *m_showDeadLineAction,
123 *m_deleteAllAction, 124 *m_deleteAllAction,
124 *m_deleteCompleteAction, 125 *m_deleteCompleteAction,
125 *m_duplicateAction, 126 *m_duplicateAction,
126 *m_showOverDueAction, 127 *m_showOverDueAction,
127 *m_effectiveAction; 128 *m_effectiveAction;
128 QWidgetStack *m_stack; 129 QWidgetStack *m_stack;
129 QPopupMenu* m_catMenu, 130 QPopupMenu* m_catMenu,
130 *m_edit, 131 *m_edit,
131 *m_options, 132 *m_options,
132 *m_view, 133 *m_view,
133 *m_template; 134 *m_template;
134 135
135 bool m_syncing:1; 136 bool m_syncing:1;
136 bool m_deadline:1; 137 bool m_deadline:1;
137 bool m_completed:1; 138 bool m_completed:1;
138 bool m_overdue:1; 139 bool m_overdue:1;
139 TodoManager m_todoMgr; 140 TodoManager m_todoMgr;
140 QString m_curCat; 141 QString m_curCat;
141 QList<ViewBase> m_views; 142 QList<ViewBase> m_views;
142 uint m_counter; 143 uint m_counter;
143 TemplateManager* m_tempManager; 144 TemplateManager* m_tempManager;
144 145
145 private slots: 146 private slots:
146 void slotShow(int); 147 void slotShow(int);
147 void slotEdit(int); 148 void slotEdit(int);
148private slots: 149private slots:
149 void slotUpdate3( QWidget* ); 150 void slotUpdate3( QWidget* );
150 void slotNewFromTemplate(int id ); 151 void slotNewFromTemplate(int id );
151 void slotNew(); 152 void slotNew();
152 void slotDuplicate(); 153 void slotDuplicate();
153 void slotDelete(); 154 void slotDelete();
154 void slotDeleteAll(); 155 void slotDeleteAll();
155 void slotDeleteCompleted(); 156 void slotDeleteCompleted();
156 157
157 void slotEdit(); 158 void slotEdit();
158 void slotFind(); 159 void slotFind();
159 160
160 void setCategory( int ); 161 void setCategory( int );
161 162
162 void slotShowDeadLine( bool ); 163 void slotShowDeadLine( bool );
163 void slotShowCompleted( bool ); 164 void slotShowCompleted( bool );
164 165
165 void setDocument( const QString& ); 166 void setDocument( const QString& );
166 167
167 168
168 void slotBeam(); 169 void slotBeam();
169 void beamDone( Ir* ); 170 void beamDone( Ir* );
170 void slotShowDetails(); 171 void slotShowDetails();
171 void slotShowDue( bool ); 172 void slotShowDue( bool );
172 }; 173 };
173}; 174};
174 175
175#endif 176#endif
diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro
index 3ff78f5..f26acee 100644
--- a/core/pim/todo/todo.pro
+++ b/core/pim/todo/todo.pro
@@ -1,55 +1,55 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on debug 2 CONFIG = qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin 3 DESTDIR = $(OPIEDIR)/bin
4 4
5 HEADERS= smalltodo.h \ 5 HEADERS= smalltodo.h \
6 todomanager.h \ 6 todomanager.h \
7 mainwindow.h \ 7 mainwindow.h \
8 todoview.h \ 8 todoview.h \
9 todoentryimpl.h \ 9 todoentryimpl.h \
10 tableview.h \ 10 tableview.h \
11 tableitems.h \ 11 tableitems.h \
12 todotemplatemanager.h \ 12 todotemplatemanager.h \
13 todoeditor.h \ 13 todoeditor.h \
14 todoshow.h \ 14 todoshow.h \
15 textviewshow.h \ 15 textviewshow.h \
16 templateeditor.h \ 16 templateeditor.h \
17 templatedialog.h \ 17 templatedialog.h \
18 templatedialogimpl.h 18 templatedialogimpl.h
19 19
20 SOURCES= smalltodo.cpp \ 20 SOURCES= smalltodo.cpp \
21 todomanager.cpp \ 21 todomanager.cpp \
22 mainwindow.cpp \ 22 mainwindow.cpp \
23 main.cpp \ 23 main.cpp \
24 todoentryimpl.cpp \ 24 todoentryimpl.cpp \
25 tableview.cpp \ 25 tableview.cpp \
26 tableitems.cpp \ 26 tableitems.cpp \
27 todoview.cpp \ 27 todoview.cpp \
28 todotemplatemanager.cpp \ 28 todotemplatemanager.cpp \
29 todoeditor.cpp \ 29 todoeditor.cpp \
30 todoshow.cpp \ 30 todoshow.cpp \
31 textviewshow.cpp \ 31 textviewshow.cpp \
32 templateeditor.cpp \ 32 templateeditor.cpp \
33 templatedialog.cpp \ 33 templatedialog.cpp \
34 templatedialogimpl.cpp 34 templatedialogimpl.cpp
35 35
36 INTERFACES= todoentry.ui 36 INTERFACES= todoentry.ui
37 TARGET = todolist 37 TARGET = todolist
38INCLUDEPATH += $(OPIEDIR)/include 38INCLUDEPATH += $(OPIEDIR)/include
39 DEPENDPATH+= $(OPIEDIR)/include 39 DEPENDPATH+= $(OPIEDIR)/include
40LIBS += -lqpe -lopie 40LIBS += -lqpe -lopie
41 41
42TRANSLATIONS = ../../../i18n/de/todolist.ts \ 42TRANSLATIONS = ../../../i18n/de/todolist.ts \
43 ../../../i18n/en/todolist.ts \ 43 ../../../i18n/en/todolist.ts \
44 ../../../i18n/es/todolist.ts \ 44 ../../../i18n/es/todolist.ts \
45 ../../../i18n/fr/todolist.ts \ 45 ../../../i18n/fr/todolist.ts \
46 ../../../i18n/hu/todolist.ts \ 46 ../../../i18n/hu/todolist.ts \
47 ../../../i18n/ja/todolist.ts \ 47 ../../../i18n/ja/todolist.ts \
48 ../../../i18n/ko/todolist.ts \ 48 ../../../i18n/ko/todolist.ts \
49 ../../../i18n/no/todolist.ts \ 49 ../../../i18n/no/todolist.ts \
50 ../../../i18n/pl/todolist.ts \ 50 ../../../i18n/pl/todolist.ts \
51 ../../../i18n/pt/todolist.ts \ 51 ../../../i18n/pt/todolist.ts \
52 ../../../i18n/pt_BR/todolist.ts \ 52 ../../../i18n/pt_BR/todolist.ts \
53 ../../../i18n/sl/todolist.ts \ 53 ../../../i18n/sl/todolist.ts \
54 ../../../i18n/zh_CN/todolist.ts \ 54 ../../../i18n/zh_CN/todolist.ts \
55 ../../../i18n/zh_TW/todolist.ts 55 ../../../i18n/zh_TW/todolist.ts