summaryrefslogtreecommitdiff
path: root/core/pim
authorzecke <zecke>2002-11-30 11:20:47 (UTC)
committer zecke <zecke>2002-11-30 11:20:47 (UTC)
commitfdda15344fdf7f71fd9e1e4db15ecc5e12224ddb (patch) (unidiff)
tree32e68b5b483dd3ce8041542e7d95f0b6d8dbf644 /core/pim
parentbd692f7ebe04e23151cce39baf311b925ccf91b1 (diff)
downloadopie-fdda15344fdf7f71fd9e1e4db15ecc5e12224ddb.zip
opie-fdda15344fdf7f71fd9e1e4db15ecc5e12224ddb.tar.gz
opie-fdda15344fdf7f71fd9e1e4db15ecc5e12224ddb.tar.bz2
Back from hospital with new power
This versions clean up m failure on templates with Qt... in todoview Implements Recurrance( backends to not safe it yet ) OPimState and Maintainer mode in some ways and much more This one also implements the OPimMainWindow specs and has a small Memu replacement to get the toolbar in one line
Diffstat (limited to 'core/pim') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp213
-rw-r--r--core/pim/todo/mainwindow.h24
-rw-r--r--core/pim/todo/otaskeditor.cpp33
-rw-r--r--core/pim/todo/otaskeditor.h5
-rw-r--r--core/pim/todo/tableview.cpp25
-rw-r--r--core/pim/todo/taskeditoradvanced.ui8
-rw-r--r--core/pim/todo/taskeditoroverviewimpl.cpp49
-rw-r--r--core/pim/todo/taskeditoroverviewimpl.h1
-rw-r--r--core/pim/todo/todo.pro6
-rw-r--r--core/pim/todo/todomanager.cpp7
-rw-r--r--core/pim/todo/todomanager.h7
-rw-r--r--core/pim/todo/todoview.cpp55
-rw-r--r--core/pim/todo/todoview.h80
13 files changed, 304 insertions, 209 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 9b2423b..b2b3b8f 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -35,40 +35,43 @@
35#include <qwidgetstack.h> 35#include <qwidgetstack.h>
36#include <qaction.h> 36#include <qaction.h>
37#include <qtimer.h> 37#include <qtimer.h>
38#include <qvbox.h> 38#include <qvbox.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40 40
41#include <qpe/applnk.h> 41#include <qpe/applnk.h>
42#include <qpe/config.h> 42#include <qpe/config.h>
43#include <qpe/ir.h> 43#include <qpe/ir.h>
44#include <qpe/resource.h> 44#include <qpe/resource.h>
45#include <qpe/qpemessagebox.h> 45#include <qpe/qpemessagebox.h>
46 46
47#include <opie/orecur.h>
47#include <opie/otodoaccessvcal.h> 48#include <opie/otodoaccessvcal.h>
48 49
49#include "quickeditimpl.h" 50#include "quickeditimpl.h"
50#include "todotemplatemanager.h" 51#include "todotemplatemanager.h"
51#include "templateeditor.h" 52#include "templateeditor.h"
52#include "tableview.h" 53#include "tableview.h"
53 54
54#include "textviewshow.h" 55#include "textviewshow.h"
55#include "todoeditor.h" 56#include "todoeditor.h"
56#include "mainwindow.h" 57#include "mainwindow.h"
57 58
58 59
59using namespace Todo; 60using namespace Todo;
60 61
61MainWindow::MainWindow( QWidget* parent, 62MainWindow::MainWindow( QWidget* parent,
62 const char* name ) { 63 const char* name )
64 : OPimMainWindow("Todolist")
65{
63 66
64 m_syncing = false; 67 m_syncing = false;
65 m_counter = 0; 68 m_counter = 0;
66 m_tempManager = new TemplateManager(); 69 m_tempManager = new TemplateManager();
67 m_tempManager->load(); 70 m_tempManager->load();
68 71
69 initUI(); 72 initUI();
70 initConfig(); 73 initConfig();
71 initViews(); 74 initViews();
72 initActions(); 75 initActions();
73 initEditor(); 76 initEditor();
74 initShow(); 77 initShow();
@@ -168,31 +171,28 @@ void MainWindow::initActions() {
168 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), 171 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ),
169 this, SLOT( slotShowDeadLine( bool ) ) ); 172 this, SLOT( slotShowDeadLine( bool ) ) );
170 173
171 m_options->insertSeparator(); 174 m_options->insertSeparator();
172 175
173 m_bar->insertItem( tr("Data") ,m_edit ); 176 m_bar->insertItem( tr("Data") ,m_edit );
174 m_bar->insertItem( tr("Category"), m_catMenu ); 177 m_bar->insertItem( tr("Category"), m_catMenu );
175 m_bar->insertItem( tr("Options"), m_options ); 178 m_bar->insertItem( tr("Options"), m_options );
176 179
177 /* initialize the view menu */ 180 /* initialize the view menu */
178 a = new QAction( QString::null, tr("Show only over due"), 181 a = new QAction( QString::null, tr("Show only over due"),
179 0, this, 0, TRUE ); 182 0, this, 0, TRUE );
180 a->addTo( m_view ); 183 a->addTo( m_options );
181 a->setOn( showOverDue() ); 184 a->setOn( showOverDue() );
182 connect(a, SIGNAL(toggled(bool)), 185 connect(a, SIGNAL(toggled(bool)),
183 this, SLOT(slotShowDue(bool) ) ); 186 this, SLOT(slotShowDue(bool) ) );
184 m_view->insertSeparator();
185
186 m_bar->insertItem( tr("View"), m_view );
187 187
188 /* templates */ 188 /* templates */
189 m_edit->insertItem(tr("New from template"), m_template, 189 m_edit->insertItem(tr("New from template"), m_template,
190 -1, 0 ); 190 -1, 0 );
191 191
192} 192}
193/* m_curCat from Config */ 193/* m_curCat from Config */
194void MainWindow::initConfig() { 194void MainWindow::initConfig() {
195 Config config( "todo" ); 195 Config config( "todo" );
196 config.setGroup( "View" ); 196 config.setGroup( "View" );
197 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 197 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
198 m_curCat = config.readEntry( "Category", QString::null ); 198 m_curCat = config.readEntry( "Category", QString::null );
@@ -211,25 +211,24 @@ void MainWindow::initUI() {
211 setCentralWidget( m_mainBox ); 211 setCentralWidget( m_mainBox );
212 212
213 setToolBarsMovable( FALSE ); 213 setToolBarsMovable( FALSE );
214 214
215 m_tool = new QToolBar( this ); 215 m_tool = new QToolBar( this );
216 m_tool->setHorizontalStretchable( TRUE ); 216 m_tool->setHorizontalStretchable( TRUE );
217 217
218 m_bar = new QMenuBar( m_tool ); 218 m_bar = new QMenuBar( m_tool );
219 219
220 /** QPopupMenu */ 220 /** QPopupMenu */
221 m_edit = new QPopupMenu( this ); 221 m_edit = new QPopupMenu( this );
222 m_options = new QPopupMenu( this ); 222 m_options = new QPopupMenu( this );
223 m_view = new QPopupMenu( this );
224 m_catMenu = new QPopupMenu( this ); 223 m_catMenu = new QPopupMenu( this );
225 m_template = new QPopupMenu( this ); 224 m_template = new QPopupMenu( this );
226 225
227 m_catMenu->setCheckable( TRUE ); 226 m_catMenu->setCheckable( TRUE );
228 m_template->setCheckable( TRUE ); 227 m_template->setCheckable( TRUE );
229 228
230 connect(m_catMenu, SIGNAL(activated(int) ), 229 connect(m_catMenu, SIGNAL(activated(int) ),
231 this, SLOT(setCategory(int) ) ); 230 this, SLOT(setCategory(int) ) );
232 connect(m_template, SIGNAL(activated(int) ), 231 connect(m_template, SIGNAL(activated(int) ),
233 this, SLOT(slotNewFromTemplate(int) ) ); 232 this, SLOT(slotNewFromTemplate(int) ) );
234} 233}
235void MainWindow::initViews() { 234void MainWindow::initViews() {
@@ -245,54 +244,53 @@ void MainWindow::initViews() {
245} 244}
246void MainWindow::initEditor() { 245void MainWindow::initEditor() {
247 m_curEdit = new Editor(); 246 m_curEdit = new Editor();
248} 247}
249void MainWindow::initShow() { 248void MainWindow::initShow() {
250 m_curShow = new TextViewShow(this); 249 m_curShow = new TextViewShow(this);
251 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 250 m_stack->addWidget( m_curShow->widget() , m_counter++ );
252} 251}
253MainWindow::~MainWindow() { 252MainWindow::~MainWindow() {
254 delete templateManager(); 253 delete templateManager();
255} 254}
256void MainWindow::connectBase( ViewBase* base) { 255void MainWindow::connectBase( ViewBase* base) {
257 base->connectShow( this, SLOT(slotShow(int) ) ); 256 // once templates and signals mix we'll use it again
258 base->connectEdit( this, SLOT(slotEdit(int) ) ); 257}
259 base->connectUpdateSmall( this, 258QPopupMenu* MainWindow::contextMenu( int , bool recur ) {
260 SLOT(slotUpate1(int, const Todo::SmallTodo&) ));
261 base->connectUpdateBig( this,
262 SLOT(slotUpate2(int, const OTodo& ) ) );
263 base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ;
264 base->connectRemove(&m_todoMgr,
265 SLOT(remove(int)) );
266}
267QPopupMenu* MainWindow::contextMenu( int uid ) {
268 QPopupMenu* menu = new QPopupMenu(); 259 QPopupMenu* menu = new QPopupMenu();
269 260
270 m_editAction->addTo( menu ); 261 m_editAction->addTo( menu );
271 m_deleteAction->addTo( menu ); 262 m_deleteAction->addTo( menu );
272 m_duplicateAction->addTo( menu ); 263 m_duplicateAction->addTo( menu );
264
273 menu->insertSeparator(); 265 menu->insertSeparator();
274 266
267 /*
268 * if this event recurs we allow
269 * to detach it.
270 * remove all
271 */
272 if ( recur ) {
273 ; // FIXME
274 }
275
275 return menu; 276 return menu;
276} 277}
277QPopupMenu* MainWindow::options() { 278QPopupMenu* MainWindow::options() {
278 qWarning("Options"); 279 qWarning("Options");
279 return m_options; 280 return m_options;
280} 281}
281QPopupMenu* MainWindow::edit() { 282QPopupMenu* MainWindow::edit() {
282 return m_edit; 283 return m_edit;
283} 284}
284QPopupMenu* MainWindow::view() {
285 return m_view;
286}
287QToolBar* MainWindow::toolbar() { 285QToolBar* MainWindow::toolbar() {
288 return m_tool; 286 return m_tool;
289} 287}
290OTodoAccess::List MainWindow::list()const { 288OTodoAccess::List MainWindow::list()const {
291 return m_todoMgr.list(); 289 return m_todoMgr.list();
292} 290}
293OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 291OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
294 int cat = 0; 292 int cat = 0;
295 if ( m_curCat != tr("All Categories") ) 293 if ( m_curCat != tr("All Categories") )
296 cat = currentCatId(); 294 cat = currentCatId();
297 295
298 int filter = 1; 296 int filter = 1;
@@ -404,46 +402,25 @@ void MainWindow::slotNewFromTemplate( int id ) {
404 event ); 402 event );
405 403
406 if ( currentEditor()->accepted() ) { 404 if ( currentEditor()->accepted() ) {
407 /* assign new todo */ 405 /* assign new todo */
408 event.setUid( -1 ); 406 event.setUid( -1 );
409 currentView()->addEvent( event ); 407 currentView()->addEvent( event );
410 m_todoMgr.add( event ); 408 m_todoMgr.add( event );
411 409
412 populateCategories(); 410 populateCategories();
413 } 411 }
414} 412}
415void MainWindow::slotNew() { 413void MainWindow::slotNew() {
416 if(m_syncing) { 414 create();
417 QMessageBox::warning(this, tr("Todo"),
418 tr("Can not edit data, currently syncing"));
419 return;
420 }
421
422
423 OTodo todo = currentEditor()->newTodo( currentCatId(),
424 this );
425
426 if ( currentEditor()->accepted() ) {
427 //todo.assignUid();
428 m_todoMgr.add( todo );
429 currentView()->addEvent( todo );
430
431
432 // I'm afraid we must call this every time now, otherwise
433 // spend expensive time comparing all these strings...
434 // but only call if we changed something -zecke
435 populateCategories();
436 }
437 raiseCurrentView( );
438} 415}
439void MainWindow::slotDuplicate() { 416void MainWindow::slotDuplicate() {
440 if(m_syncing) { 417 if(m_syncing) {
441 QMessageBox::warning(this, tr("Todo"), 418 QMessageBox::warning(this, tr("Todo"),
442 tr("Can not edit data, currently syncing")); 419 tr("Can not edit data, currently syncing"));
443 return; 420 return;
444 } 421 }
445 OTodo ev = m_todoMgr.event( currentView()->current() ); 422 OTodo ev = m_todoMgr.event( currentView()->current() );
446 /* let's generate a new uid */ 423 /* let's generate a new uid */
447 ev.setUid(-1); 424 ev.setUid(-1);
448 m_todoMgr.add( ev ); 425 m_todoMgr.add( ev );
449 426
@@ -465,46 +442,45 @@ void MainWindow::slotDelete() {
465 442
466 m_todoMgr.remove( currentView()->current() ); 443 m_todoMgr.remove( currentView()->current() );
467 currentView()->removeEvent( currentView()->current() ); 444 currentView()->removeEvent( currentView()->current() );
468 raiseCurrentView(); 445 raiseCurrentView();
469} 446}
470void MainWindow::slotDeleteAll() { 447void MainWindow::slotDeleteAll() {
471 if(m_syncing) { 448 if(m_syncing) {
472 QMessageBox::warning(this, tr("Todo"), 449 QMessageBox::warning(this, tr("Todo"),
473 tr("Can not edit data, currently syncing")); 450 tr("Can not edit data, currently syncing"));
474 return; 451 return;
475 } 452 }
476 453
477 //QString strName = table->text( table->currentRow(), 2 ).left( 30 );
478 454
479 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) 455 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) )
480 return; 456 return;
481 457
482 m_todoMgr.removeAll(); 458 m_todoMgr.removeAll();
483 currentView()->clear(); 459 currentView()->clear();
484 460
485 raiseCurrentView(); 461 raiseCurrentView();
486} 462}
487void MainWindow::slotDeleteCompleted() { 463void MainWindow::slotDeleteCompleted() {
488 if(m_syncing) { 464 if(m_syncing) {
489 QMessageBox::warning(this, tr("Todo"), 465 QMessageBox::warning(this, tr("Todo"),
490 tr("Can not edit data, currently syncing")); 466 tr("Can not edit data, currently syncing"));
491 return; 467 return;
492 } 468 }
493 469
494 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) 470 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) )
495 return; 471 return;
496 472
497 // FIXME 473
498 //m_todoMgr.remove( currentView()->completed() ); 474 m_todoMgr.removeCompleted();
499 currentView()->updateView( ); 475 currentView()->updateView( );
500} 476}
501void MainWindow::slotFind() { 477void MainWindow::slotFind() {
502 478
503} 479}
504void MainWindow::slotEdit() { 480void MainWindow::slotEdit() {
505 slotEdit( currentView()->current() ); 481 slotEdit( currentView()->current() );
506} 482}
507/* 483/*
508 * set the category 484 * set the category
509 */ 485 */
510void MainWindow::setCategory( int c) { 486void MainWindow::setCategory( int c) {
@@ -543,36 +519,25 @@ bool MainWindow::showOverDue()const {
543 return m_overdue; 519 return m_overdue;
544} 520}
545void MainWindow::setDocument( const QString& fi) { 521void MainWindow::setDocument( const QString& fi) {
546 DocLnk doc(fi); 522 DocLnk doc(fi);
547 if (doc.isValid() ) 523 if (doc.isValid() )
548 receiveFile(doc.file() ); 524 receiveFile(doc.file() );
549 else 525 else
550 receiveFile(fi ); 526 receiveFile(fi );
551} 527}
552 528
553static const char *beamfile = "/tmp/opie-todo.vcs"; 529static const char *beamfile = "/tmp/opie-todo.vcs";
554void MainWindow::slotBeam() { 530void MainWindow::slotBeam() {
555 ::unlink( beamfile ); 531 beam( currentView()->current() );
556 OTodo todo = event( currentView()->current() );
557 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) );
558 OTodoAccess acc( cal );
559 acc.load();
560 acc.add( todo );
561 acc.save();
562 Ir* ir = new Ir(this );
563 connect(ir, SIGNAL(done(Ir*) ),
564 this, SLOT(beamDone(Ir*) ) );
565 ir->send( beamfile, todo.summary(), "text/x-vCalendar" );
566
567} 532}
568void MainWindow::beamDone( Ir* ir) { 533void MainWindow::beamDone( Ir* ir) {
569 delete ir; 534 delete ir;
570 ::unlink( beamfile ); 535 ::unlink( beamfile );
571} 536}
572void MainWindow::receiveFile( const QString& filename ) { 537void MainWindow::receiveFile( const QString& filename ) {
573 OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); 538 OTodoAccessVCal* cal = new OTodoAccessVCal(filename );
574 OTodoAccess acc( cal ); 539 OTodoAccess acc( cal );
575 acc.load(); 540 acc.load();
576 OTodoAccess::List list = acc.allRecords(); 541 OTodoAccess::List list = acc.allRecords();
577 542
578 QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); 543 QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
@@ -695,12 +660,146 @@ void MainWindow::slotQuickEntered() {
695 qWarning("entered"); 660 qWarning("entered");
696 OTodo todo = quickEditor()->todo(); 661 OTodo todo = quickEditor()->todo();
697 if (todo.isEmpty() ) 662 if (todo.isEmpty() )
698 return; 663 return;
699 664
700 m_todoMgr.add( todo ); 665 m_todoMgr.add( todo );
701 currentView()->addEvent( todo ); 666 currentView()->addEvent( todo );
702 raiseCurrentView(); 667 raiseCurrentView();
703} 668}
704QuickEditBase* MainWindow::quickEditor() { 669QuickEditBase* MainWindow::quickEditor() {
705 return m_curQuick; 670 return m_curQuick;
706} 671}
672void MainWindow::slotComplete( int uid ) {
673 slotComplete( event(uid) );
674}
675void MainWindow::slotComplete( const OTodo& todo ) {
676 OTodo to = todo;
677 to.setCompleted( !to.isCompleted() );
678 to.setCompletedDate( QDate::currentDate() );
679
680 /*
681 * if the item does recur
682 * we need to spin it off
683 * and update the items duedate to the next
684 * possible recurrance of this item...
685 * the spinned off one will loose the
686 */
687 if ( to.recurrence().doesRecur() && to.isCompleted() ) {
688 OTodo to2( to );
689
690 /* the spinned off one won't recur anymore */
691 to.setRecurrence( ORecur() );
692
693 ORecur rec = to2.recurrence();
694 rec.setStart( to.dueDate() );
695 to2.setRecurrence( rec );
696 /*
697 * if there is a next occurence
698 * from the duedate of the last recurrance
699 */
700 QDate date;
701 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) {
702 QDate inval;
703 /* generate a new uid for the old record */
704 to.setUid( 1 );
705
706 /* add the old one cause it has a new UID here cause it was spin off */
707 m_todoMgr.add( to );
708
709 /*
710 * update the due date
711 * start date
712 * and complete date
713 */
714 to2.setDueDate( date );
715 to2.setStartDate( inval );
716 to2.setCompletedDate( inval );
717 to2.setCompleted( false );
718 updateTodo( to2 );
719 }else
720 updateTodo( to );
721 }else
722 updateTodo( to );
723
724 currentView()->updateView();
725 raiseCurrentView();
726}
727void MainWindow::flush() {
728 slotFlush();
729}
730void MainWindow::reload() {
731 slotReload();
732}
733int MainWindow::create() {
734 int uid = 0;
735 if(m_syncing) {
736 QMessageBox::warning(this, tr("Todo"),
737 tr("Can not edit data, currently syncing"));
738 return uid;
739 }
740
741
742 OTodo todo = currentEditor()->newTodo( currentCatId(),
743 this );
744
745 if ( currentEditor()->accepted() ) {
746 //todo.assignUid();
747 uid = todo.uid();
748 m_todoMgr.add( todo );
749 currentView()->addEvent( todo );
750
751
752 // I'm afraid we must call this every time now, otherwise
753 // spend expensive time comparing all these strings...
754 // but only call if we changed something -zecke
755 populateCategories();
756 }
757 raiseCurrentView( );
758
759 return uid;
760}
761/* delete it silently... */
762bool MainWindow::remove( int uid ) {
763 if (m_syncing) return false;
764
765 return m_todoMgr.remove( uid );
766}
767void MainWindow::beam( int uid, int ) {
768 ::unlink( beamfile );
769 OTodo todo = event( uid );
770 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) );
771 OTodoAccess acc( cal );
772 acc.load();
773 acc.add( todo );
774 acc.save();
775 Ir* ir = new Ir(this );
776 connect(ir, SIGNAL(done(Ir*) ),
777 this, SLOT(beamDone(Ir*) ) );
778 ir->send( beamfile, todo.summary(), "text/x-vCalendar" );
779}
780void MainWindow::show( int uid ) {
781 slotShow( uid );
782}
783void MainWindow::edit( int uid ) {
784 slotEdit( uid );
785}
786void MainWindow::add( const OPimRecord& rec) {
787 if ( rec.rtti() != OTodo::rtti() ) return;
788
789 const OTodo& todo = static_cast<const OTodo&>(rec);
790
791 m_todoMgr.add(todo );
792 currentView()->addEvent( todo );
793
794
795 // I'm afraid we must call this every time now, otherwise
796 // spend expensive time comparing all these strings...
797 // but only call if we changed something -zecke
798 populateCategories();
799}
800/* todo does not have the QDataStream<< and >> operators implemented :(
801 * FIXME
802 */
803OPimRecord* MainWindow::record( int rtti, const QByteArray& ) {
804 return 0l;
805}
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
index 270cbd1..14cfa82 100644
--- a/core/pim/todo/mainwindow.h
+++ b/core/pim/todo/mainwindow.h
@@ -21,62 +21,62 @@
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>
34 33
35#include <opie/otodoaccess.h> 34#include <opie/otodoaccess.h>
36#include <opie/otodo.h> 35#include <opie/otodo.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;
50 50
51namespace Todo { 51namespace Todo {
52 typedef TodoView View; 52 typedef TodoView View;
53 class TemplateManager; 53 class TemplateManager;
54 class Editor; 54 class Editor;
55 class TodoShow; 55 class TodoShow;
56 class TemplateEditor; 56 class TemplateEditor;
57 struct QuickEditBase; 57 struct QuickEditBase;
58 58
59 class MainWindow : public QMainWindow { 59 class MainWindow : public OPimMainWindow {
60 Q_OBJECT 60 Q_OBJECT
61 friend class TodoView; // avoid QObject here....
61 public: 62 public:
62 MainWindow( QWidget *parent = 0, 63 MainWindow( QWidget *parent = 0,
63 const char* name = 0 ); 64 const char* name = 0 );
64 ~MainWindow(); 65 ~MainWindow();
65 66
66 /** return a context menu for an OTodo */ 67 /** return a context menu for an OTodo */
67 QPopupMenu* contextMenu(int uid ); 68 QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE );
68 QPopupMenu* options(); 69 QPopupMenu* options();
69 QPopupMenu* edit(); 70 QPopupMenu* edit();
70 QPopupMenu* view();
71 QToolBar* toolbar(); 71 QToolBar* toolbar();
72 72
73 73
74 void updateList(); 74 void updateList();
75 OTodoAccess::List list()const; 75 OTodoAccess::List list()const;
76 OTodoAccess::List sorted( bool asc, int sortOrder ); 76 OTodoAccess::List sorted( bool asc, int sortOrder );
77 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); 77 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter );
78 78
79 OTodo event(int uid ); 79 OTodo event(int uid );
80 80
81 bool isSyncing()const; 81 bool isSyncing()const;
82 bool showCompleted()const; 82 bool showCompleted()const;
@@ -127,65 +127,77 @@ private slots:
127 *m_findAction, 127 *m_findAction,
128 *m_completedAction, 128 *m_completedAction,
129 *m_showDeadLineAction, 129 *m_showDeadLineAction,
130 *m_deleteAllAction, 130 *m_deleteAllAction,
131 *m_deleteCompleteAction, 131 *m_deleteCompleteAction,
132 *m_duplicateAction, 132 *m_duplicateAction,
133 *m_showOverDueAction, 133 *m_showOverDueAction,
134 *m_effectiveAction; 134 *m_effectiveAction;
135 QWidgetStack *m_stack; 135 QWidgetStack *m_stack;
136 QPopupMenu* m_catMenu, 136 QPopupMenu* m_catMenu,
137 *m_edit, 137 *m_edit,
138 *m_options, 138 *m_options,
139 *m_view,
140 *m_template; 139 *m_template;
141 /* box with two rows 140 /* box with two rows
142 * top will be the quick edit 141 * top will be the quick edit
143 * this will bite my ass once 142 * this will bite my ass once
144 * we want to have all parts 143 * we want to have all parts
145 * exchangeable 144 * exchangeable
146 */ 145 */
147 QVBox* m_mainBox; 146 QVBox* m_mainBox;
148 147
149 bool m_syncing:1; 148 bool m_syncing:1;
150 bool m_deadline:1; 149 bool m_deadline:1;
151 bool m_completed:1; 150 bool m_completed:1;
152 bool m_overdue:1; 151 bool m_overdue:1;
153 TodoManager m_todoMgr; 152 TodoManager m_todoMgr;
154 QString m_curCat; 153 QString m_curCat;
155 QList<ViewBase> m_views; 154 QList<ViewBase> m_views;
156 QList<QuickEditBase> m_quickEdit; 155 QList<QuickEditBase> m_quickEdit;
157 uint m_counter; 156 uint m_counter;
158 TemplateManager* m_tempManager; 157 TemplateManager* m_tempManager;
159 158
160 159
161 private slots: 160 private slots:
162 void slotShow(int); 161 void slotShow(int);
163 void slotEdit(int); 162 void slotEdit(int);
164private slots:
165 void slotUpdate3( QWidget* ); 163 void slotUpdate3( QWidget* );
164 void slotComplete( int uid );
165 void slotComplete( const OTodo& ev );
166 void slotNewFromTemplate(int id ); 166 void slotNewFromTemplate(int id );
167 void slotNew(); 167 void slotNew();
168 void slotDuplicate(); 168 void slotDuplicate();
169
169 void slotDelete(); 170 void slotDelete();
170 void slotDeleteAll(); 171 void slotDeleteAll();
171 void slotDeleteCompleted(); 172 void slotDeleteCompleted();
172 173
173 void slotEdit(); 174 void slotEdit();
174 void slotFind(); 175 void slotFind();
175 176
176 void setCategory( int ); 177 void setCategory( int );
177 178
178 void slotShowDeadLine( bool ); 179 void slotShowDeadLine( bool );
179 void slotShowCompleted( bool ); 180 void slotShowCompleted( bool );
180 181
181 void setDocument( const QString& ); 182 void setDocument( const QString& );
182 183
183 184
184 void slotBeam(); 185 void slotBeam();
185 void beamDone( Ir* ); 186 void beamDone( Ir* );
186 void slotShowDetails(); 187 void slotShowDetails();
187 void slotShowDue( bool ); 188 void slotShowDue( bool );
189 /* reimplementation from opimmainwindow */
190 protected slots:
191 void flush();
192 void reload();
193 int create();
194 bool remove( int uid );
195 void beam(int uid, int transport = IrDa );
196 void show( int uid );
197 void edit( int uid );
198 void add( const OPimRecord& );
199 OPimRecord* record( int rtti, const QByteArray& );
188 }; 200 };
189}; 201};
190 202
191#endif 203#endif
diff --git a/core/pim/todo/otaskeditor.cpp b/core/pim/todo/otaskeditor.cpp
index 8b261de..eeb3c0c 100644
--- a/core/pim/todo/otaskeditor.cpp
+++ b/core/pim/todo/otaskeditor.cpp
@@ -1,21 +1,22 @@
1#include <qdatetime.h> 1#include <qdatetime.h>
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qmultilineedit.h> 4#include <qmultilineedit.h>
5#include <qscrollview.h>
5 6
6#include <opie/orecurrancewidget.h> 7#include <opie/orecurrancewidget.h>
7 8
8#include "taskeditoroverviewimpl.h" 9#include "taskeditoroverviewimpl.h"
9#include "taskeditoradvanced.h" 10#include "taskeditoradvancedimpl.h"
10#include "taskeditoralarms.h" 11#include "taskeditoralarms.h"
11 12
12#include "otaskeditor.h" 13#include "otaskeditor.h"
13 14
14OTaskEditor::OTaskEditor(int cur) 15OTaskEditor::OTaskEditor(int cur)
15 : QDialog(0, 0, TRUE ) { 16 : QDialog(0, 0, TRUE ) {
16 init(); 17 init();
17 init( cur ); 18 init( cur );
18} 19}
19OTaskEditor::OTaskEditor( const OTodo& to) 20OTaskEditor::OTaskEditor( const OTodo& to)
20 : QDialog(0, 0, TRUE ) { 21 : QDialog(0, 0, TRUE ) {
21 init(); 22 init();
@@ -31,61 +32,69 @@ void OTaskEditor::init( int cur ) {
31 load(to); 32 load(to);
32 m_uid = 1; // generate a new one 33 m_uid = 1; // generate a new one
33} 34}
34void OTaskEditor::init( const OTodo& to ) { 35void OTaskEditor::init( const OTodo& to ) {
35 load( to ); 36 load( to );
36 m_uid = to.uid(); 37 m_uid = to.uid();
37} 38}
38OTodo OTaskEditor::todo()const{ 39OTodo OTaskEditor::todo()const{
39 qWarning("saving!"); 40 qWarning("saving!");
40 OTodo to; 41 OTodo to;
41 to.setUid(m_uid ); 42 to.setUid(m_uid );
42 m_overView->save( to ); 43 m_overView->save( to );
43 to.setDescription( m_line->text() ); 44 m_adv->save( to );
45 to.setRecurrence( m_rec->recurrence() );
44 46
45 return to; 47 return to;
46} 48}
47void OTaskEditor::load(const OTodo& to) { 49void OTaskEditor::load(const OTodo& to) {
48 m_overView->load( to ); 50 m_overView->load( to );
49 m_line->setText( to.description() ); 51 m_adv->load( to );
52 m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() );
50} 53}
51void OTaskEditor::init() { 54void OTaskEditor::init() {
52 QVBoxLayout* lay = new QVBoxLayout(this); 55 QVBoxLayout* lay = new QVBoxLayout(this);
56 QScrollView* view = new QScrollView( this );
57 view->setResizePolicy( QScrollView::AutoOneFit );
58 lay->addWidget( view );
59
53 setCaption("Task Editor"); 60 setCaption("Task Editor");
54 m_tab = new OTabWidget(this); 61 QWidget* container = new QWidget( view->viewport() );
62 view->addChild( container );
55 63
64 QVBoxLayout* layo = new QVBoxLayout( container );
65 m_tab = new OTabWidget(container );
66 layo->addWidget( m_tab );
56 /* 67 /*
57 * Add the Widgets 68 * Add the Widgets
58 */ 69 */
59 m_overView = new TaskEditorOverViewImpl(m_tab ); 70 m_overView = new TaskEditorOverViewImpl(m_tab );
60 m_tab->addTab( m_overView, QString::null, tr("Overview") ); 71 m_tab->addTab( m_overView, QString::null, tr("Overview") );
61 72
62 m_adv = new TaskEditorAdvanced( m_tab ); 73 m_adv = new TaskEditorAdvancedImpl( m_tab );
63 m_line = new QMultiLineEdit(m_adv );
64 m_line->setWordWrap( QMultiLineEdit::WidgetWidth );
65 QLabel* label = new QLabel(m_adv );
66 label->setText( tr("Description") );
67 ((QGridLayout*) m_adv->layout() )->addWidget( label,3, 0 );
68 ((QGridLayout*) m_adv->layout())->addWidget( m_line,4,0 );
69 m_tab->addTab( m_adv, QString::null, tr("Advanced") ); 74 m_tab->addTab( m_adv, QString::null, tr("Advanced") );
70 75
71 m_alarm = new TaskEditorAlarms( m_tab ); 76 m_alarm = new TaskEditorAlarms( m_tab );
72 m_tab->addTab( m_alarm, QString::null, tr("Alarms") ); 77 m_tab->addTab( m_alarm, QString::null, tr("Alarms") );
73 78
74 m_remind = new TaskEditorAlarms( m_tab ); 79 m_remind = new TaskEditorAlarms( m_tab );
75 m_tab->addTab( m_remind, QString::null, tr("Reminders") ); 80 m_tab->addTab( m_remind, QString::null, tr("Reminders") );
76 81
77 QLabel* lbl = new QLabel(m_tab ); 82 QLabel* lbl = new QLabel(m_tab );
78 lbl->setText( tr("X-Ref") ); 83 lbl->setText( tr("X-Ref") );
79 m_tab->addTab( lbl, QString::null, tr("X-Ref") ); 84 m_tab->addTab( lbl, QString::null, tr("X-Ref") );
80 85
81 m_rec = new ORecurranceWidget( true, QDate::currentDate(), this ); 86 m_rec = new ORecurranceWidget( true, QDate::currentDate(), this );
82 m_tab->addTab( m_rec, QString::null, tr("Recurrance") ); 87 m_tab->addTab( m_rec, QString::null, tr("Recurrance") );
83 88
84 lay->addWidget(m_tab );
85 89
86 /* signal and slots */ 90 /* signal and slots */
87 connect(m_overView, SIGNAL(recurranceEnabled(bool) ), 91 connect(m_overView, SIGNAL(recurranceEnabled(bool) ),
88 m_rec, SLOT(setEnabled(bool) ) ); 92 m_rec, SLOT(setEnabled(bool) ) );
89 93
94 /* connect due date changed to the recurrence tab */
95 connect(m_overView, SIGNAL(dueDateChanged(const QDate&) ),
96 m_rec, SLOT(setStartDate(const QDate& ) ) );
97
98
90 m_tab->setCurrentTab( m_overView ); 99 m_tab->setCurrentTab( m_overView );
91} 100}
diff --git a/core/pim/todo/otaskeditor.h b/core/pim/todo/otaskeditor.h
index bcbd543..b43abbf 100644
--- a/core/pim/todo/otaskeditor.h
+++ b/core/pim/todo/otaskeditor.h
@@ -1,44 +1,43 @@
1#ifndef OPIE_TASK_EDITOR_H 1#ifndef OPIE_TASK_EDITOR_H
2#define OPIE_TASK_EDITOR_H 2#define OPIE_TASK_EDITOR_H
3 3
4#include <qdialog.h> 4#include <qdialog.h>
5 5
6#include <opie/otodo.h> 6#include <opie/otodo.h>
7#include <opie/otabwidget.h> 7#include <opie/otabwidget.h>
8 8
9class TaskEditorOverViewImpl; 9class TaskEditorOverViewImpl;
10class TaskEditorAdvanced; 10class TaskEditorAdvancedImpl;
11class TaskEditorAlarms; 11class TaskEditorAlarms;
12class ORecurranceWidget; 12class ORecurranceWidget;
13class QMultiLineEdit; 13class QMultiLineEdit;
14class OTaskEditor : public QDialog { 14class OTaskEditor : public QDialog {
15 Q_OBJECT 15 Q_OBJECT
16public: 16public:
17 OTaskEditor(int cur); 17 OTaskEditor(int cur);
18 OTaskEditor( const OTodo& todo ); 18 OTaskEditor( const OTodo& todo );
19 ~OTaskEditor(); 19 ~OTaskEditor();
20 20
21 /* 21 /*
22 * same as the c'tor but this gives us the 22 * same as the c'tor but this gives us the
23 * power to 'preload' the dialog 23 * power to 'preload' the dialog
24 */ 24 */
25 void init( int cur ); 25 void init( int cur );
26 void init( const OTodo& todo ); 26 void init( const OTodo& todo );
27 27
28 OTodo todo()const; 28 OTodo todo()const;
29private: 29private:
30 void load( const OTodo& ); 30 void load( const OTodo& );
31 void init(); 31 void init();
32 32
33 OTabWidget *m_tab; 33 OTabWidget *m_tab;
34 TaskEditorOverViewImpl* m_overView; 34 TaskEditorOverViewImpl* m_overView;
35 TaskEditorAdvanced *m_adv; 35 TaskEditorAdvancedImpl *m_adv;
36 TaskEditorAlarms *m_alarm; 36 TaskEditorAlarms *m_alarm;
37 TaskEditorAlarms* m_remind; 37 TaskEditorAlarms* m_remind;
38 ORecurranceWidget* m_rec; 38 ORecurranceWidget* m_rec;
39 QMultiLineEdit* m_line;
40 int m_uid; 39 int m_uid;
41 40
42}; 41};
43 42
44#endif 43#endif
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index ded2dbd..0f683c9 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -26,24 +26,26 @@
26 26
27*/ 27*/
28#include <stdlib.h> 28#include <stdlib.h>
29#include <cmath> 29#include <cmath>
30 30
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qpoint.h> 33#include <qpoint.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35 35
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38#include <opie/orecur.h>
39
38#include "mainwindow.h" 40#include "mainwindow.h"
39//#include "tableitems.h" 41//#include "tableitems.h"
40#include "tableview.h" 42#include "tableview.h"
41 43
42using namespace Todo; 44using namespace Todo;
43 45
44namespace { 46namespace {
45 static const int BoxSize = 14; 47 static const int BoxSize = 14;
46 static const int RowHeight = 20; 48 static const int RowHeight = 20;
47} 49}
48 50
49 51
@@ -111,50 +113,51 @@ TableView::TableView( MainWindow* window, QWidget* wid )
111} 113}
112/* a new day has started 114/* a new day has started
113 * update the day 115 * update the day
114 */ 116 */
115void TableView::newDay() { 117void TableView::newDay() {
116 clear(); 118 clear();
117 updateView(); 119 updateView();
118} 120}
119TableView::~TableView() { 121TableView::~TableView() {
120 122
121} 123}
122void TableView::slotShowMenu() { 124void TableView::slotShowMenu() {
123 QPopupMenu *menu = todoWindow()->contextMenu( current() ); 125 QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() );
124 menu->exec(QCursor::pos() ); 126 menu->exec(QCursor::pos() );
125 delete menu; 127 delete menu;
126} 128}
127QString TableView::type() const { 129QString TableView::type() const {
128 return QString::fromLatin1( tr("Table View") ); 130 return QString::fromLatin1( tr("Table View") );
129} 131}
130int TableView::current() { 132int TableView::current() {
131 int uid = sorted().uidAt(currentRow() ); 133 int uid = sorted().uidAt(currentRow() );
132 qWarning("uid %d", uid ); 134
133 return uid; 135 return uid;
134} 136}
135QString TableView::currentRepresentation() { 137QString TableView::currentRepresentation() {
136 return text( currentRow(), 2); 138 OTodo to = sorted()[currentRow()];
139 return to.summary().isEmpty() ? to.description().left(20) : to.summary() ;
137} 140}
138/* show overdue */ 141/* show overdue */
139void TableView::showOverDue( bool ) { 142void TableView::showOverDue( bool ) {
140 clear(); 143 clear();
141 updateView(); 144 updateView();
142} 145}
143 146
144void TableView::updateView( ) { 147void TableView::updateView( ) {
145 qWarning("update view"); 148 qWarning("update view");
146 m_row = false; 149 m_row = false;
147 static int id; 150 static int id;
148 id = startTimer(2000 ); 151 id = startTimer(4000 );
149 /* FIXME we want one page to be read! 152 /* FIXME we want one page to be read!
150 * 153 *
151 * Calculate that screensize 154 * Calculate that screensize
152 */ 155 */
153 todoWindow()->setReadAhead( 4 ); 156 todoWindow()->setReadAhead( 4 );
154 sort(); 157 sort();
155 OTodoAccess::List::Iterator it, end; 158 OTodoAccess::List::Iterator it, end;
156 it = sorted().begin(); 159 it = sorted().begin();
157 end = sorted().end(); 160 end = sorted().end();
158 161
159 qWarning("setTodos"); 162 qWarning("setTodos");
160 QTime time; 163 QTime time;
@@ -233,28 +236,25 @@ void TableView::slotClicked(int row, int col, int,
233 236
234 237
235 switch( col ) { 238 switch( col ) {
236 case 0:{ 239 case 0:{
237 int x = point.x() -columnPos( col ); 240 int x = point.x() -columnPos( col );
238 int y = point.y() -rowPos( row ); 241 int y = point.y() -rowPos( row );
239 int w = columnWidth( col ); 242 int w = columnWidth( col );
240 int h = rowHeight( row ); 243 int h = rowHeight( row );
241 if ( x >= ( w - BoxSize ) / 2 && 244 if ( x >= ( w - BoxSize ) / 2 &&
242 x <= ( w - BoxSize ) / 2 + BoxSize && 245 x <= ( w - BoxSize ) / 2 + BoxSize &&
243 y >= ( h - BoxSize ) / 2 && 246 y >= ( h - BoxSize ) / 2 &&
244 y <= ( h - BoxSize ) / 2 + BoxSize ) { 247 y <= ( h - BoxSize ) / 2 + BoxSize ) {
245 OTodo todo = sorted()[row]; 248 TodoView::complete(sorted()[row] );
246 todo.setCompleted( !todo.isCompleted() );
247 TodoView::update( todo.uid(), todo );
248 updateView();
249 } 249 }
250 } 250 }
251 break; 251 break;
252 252
253 case 1: 253 case 1:
254 break; 254 break;
255 255
256 case 2: { 256 case 2: {
257 m_menuTimer->stop(); 257 m_menuTimer->stop();
258 showTodo( ui ); 258 showTodo( ui );
259 break; 259 break;
260 } 260 }
@@ -360,25 +360,25 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
360 break; 360 break;
361 case 1: 361 case 1:
362 // priority field 362 // priority field
363 { 363 {
364 QString text = QString::number(task.priority()); 364 QString text = QString::number(task.priority());
365 p->drawText(2,2 + fm.ascent(), text); 365 p->drawText(2,2 + fm.ascent(), text);
366 } 366 }
367 break; 367 break;
368 case 2: 368 case 2:
369 // description field 369 // description field
370 { 370 {
371 QString text = task.summary().isEmpty() ? 371 QString text = task.summary().isEmpty() ?
372 task.description() : 372 task.description().left(20) :
373 task.summary(); 373 task.summary();
374 p->drawText(2,2 + fm.ascent(), text); 374 p->drawText(2,2 + fm.ascent(), text);
375 } 375 }
376 break; 376 break;
377 case 3: 377 case 3:
378 { 378 {
379 QString text; 379 QString text;
380 if (task.hasDueDate()) { 380 if (task.hasDueDate()) {
381 int off = QDate::currentDate().daysTo( task.dueDate() ); 381 int off = QDate::currentDate().daysTo( task.dueDate() );
382 text = QString::number(off) + tr(" day(s)"); 382 text = QString::number(off) + tr(" day(s)");
383 /* 383 /*
384 * set color if not completed 384 * set color if not completed
@@ -453,25 +453,25 @@ void TableView::setCellContentFromEditor(int row, int col ) {
453} 453}
454void TableView::slotPriority() { 454void TableView::slotPriority() {
455 setCellContentFromEditor( currentRow(), currentColumn() ); 455 setCellContentFromEditor( currentRow(), currentColumn() );
456} 456}
457/* 457/*
458 * We'll use the TimerEvent to read ahead or to keep the cahce always 458 * We'll use the TimerEvent to read ahead or to keep the cahce always
459 * filled enough. 459 * filled enough.
460 * We will try to read ahead 4 items in both ways 460 * We will try to read ahead 4 items in both ways
461 * up and down. On odd or even we will currentRow()+-4 or +-9 461 * up and down. On odd or even we will currentRow()+-4 or +-9
462 * 462 *
463 */ 463 */
464void TableView::timerEvent( QTimerEvent* ev ) { 464void TableView::timerEvent( QTimerEvent* ev ) {
465 qWarning("sorted %d", sorted().count() ); 465// qWarning("sorted %d", sorted().count() );
466 if (sorted().count() == 0 ) 466 if (sorted().count() == 0 )
467 return; 467 return;
468 468
469 int row = currentRow(); 469 int row = currentRow();
470 if ( m_row ) { 470 if ( m_row ) {
471 int ro = row-4; 471 int ro = row-4;
472 if (ro < 0 ) ro = 0; 472 if (ro < 0 ) ro = 0;
473 sorted()[ro]; 473 sorted()[ro];
474 474
475 ro = row+4; 475 ro = row+4;
476 sorted()[ro]; 476 sorted()[ro];
477 } else { 477 } else {
@@ -504,24 +504,21 @@ void TableView::timerEvent( QTimerEvent* ev ) {
504 * in the x coordinate and this way it's able to pass the 504 * in the x coordinate and this way it's able to pass the
505 * m_completeStrokeWidth criteria 505 * m_completeStrokeWidth criteria
506 * WORKAROUND: strike through needs to strike through the same 506 * WORKAROUND: strike through needs to strike through the same
507 * row and two columns! 507 * row and two columns!
508 */ 508 */
509void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { 509void TableView::contentsMouseReleaseEvent( QMouseEvent* e) {
510 int row = rowAt(m_prevP.y()); 510 int row = rowAt(m_prevP.y());
511 int colOld = columnAt(m_prevP.x() ); 511 int colOld = columnAt(m_prevP.x() );
512 int colNew = columnAt(e->x() ); 512 int colNew = columnAt(e->x() );
513 qWarning("colNew: %d colOld: %d", colNew, colOld ); 513 qWarning("colNew: %d colOld: %d", colNew, colOld );
514 if ( row == rowAt( e->y() ) && row != -1 && 514 if ( row == rowAt( e->y() ) && row != -1 &&
515 colOld != colNew ) { 515 colOld != colNew ) {
516 OTodo todo = sorted()[row]; 516 TodoView::complete( sorted()[row] );
517 todo.setCompleted( !todo.isCompleted() );
518 TodoView::update( todo.uid(), todo );
519 updateView();
520 return; 517 return;
521 } 518 }
522 QTable::contentsMouseReleaseEvent( e ); 519 QTable::contentsMouseReleaseEvent( e );
523} 520}
524void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { 521void TableView::contentsMouseMoveEvent( QMouseEvent* e ) {
525 m_menuTimer->stop(); 522 m_menuTimer->stop();
526 QTable::contentsMouseMoveEvent( e ); 523 QTable::contentsMouseMoveEvent( e );
527} 524}
diff --git a/core/pim/todo/taskeditoradvanced.ui b/core/pim/todo/taskeditoradvanced.ui
index 3ea1346..6160712 100644
--- a/core/pim/todo/taskeditoradvanced.ui
+++ b/core/pim/todo/taskeditoradvanced.ui
@@ -2,25 +2,25 @@
2<class>TaskEditorAdvanced</class> 2<class>TaskEditorAdvanced</class>
3<widget> 3<widget>
4 <class>QWidget</class> 4 <class>QWidget</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>TaskEditorAdvanced</cstring> 7 <cstring>TaskEditorAdvanced</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>236</width> 14 <width>232</width>
15 <height>307</height> 15 <height>307</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Form2</string> 20 <string>Form2</string>
21 </property> 21 </property>
22 <property> 22 <property>
23 <name>layoutMargin</name> 23 <name>layoutMargin</name>
24 </property> 24 </property>
25 <property> 25 <property>
26 <name>layoutSpacing</name> 26 <name>layoutSpacing</name>
@@ -186,24 +186,30 @@
186 <cstring>txtMode</cstring> 186 <cstring>txtMode</cstring>
187 </property> 187 </property>
188 <property stdset="1"> 188 <property stdset="1">
189 <name>text</name> 189 <name>text</name>
190 <string>Maintain Mode:</string> 190 <string>Maintain Mode:</string>
191 </property> 191 </property>
192 </widget> 192 </widget>
193 <widget> 193 <widget>
194 <class>QComboBox</class> 194 <class>QComboBox</class>
195 <item> 195 <item>
196 <property> 196 <property>
197 <name>text</name> 197 <name>text</name>
198 <string>Nothing</string>
199 </property>
200 </item>
201 <item>
202 <property>
203 <name>text</name>
198 <string>Responsible</string> 204 <string>Responsible</string>
199 </property> 205 </property>
200 </item> 206 </item>
201 <item> 207 <item>
202 <property> 208 <property>
203 <name>text</name> 209 <name>text</name>
204 <string>Done By</string> 210 <string>Done By</string>
205 </property> 211 </property>
206 </item> 212 </item>
207 <item> 213 <item>
208 <property> 214 <property>
209 <name>text</name> 215 <name>text</name>
diff --git a/core/pim/todo/taskeditoroverviewimpl.cpp b/core/pim/todo/taskeditoroverviewimpl.cpp
index 24b3386..aef3b1d 100644
--- a/core/pim/todo/taskeditoroverviewimpl.cpp
+++ b/core/pim/todo/taskeditoroverviewimpl.cpp
@@ -1,75 +1,112 @@
1#include <qapplication.h> 1#include <qapplication.h>
2#include <qcheckbox.h> 2#include <qcheckbox.h>
3#include <qcombobox.h> 3#include <qcombobox.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5 5
6#include <qpe/datebookmonth.h> 6#include <qpe/datebookmonth.h>
7#include <qpe/categoryselect.h> 7#include <qpe/categoryselect.h>
8#include <qpe/timestring.h> 8#include <qpe/timestring.h>
9 9
10#include <opie/orecur.h>
11
10#include "taskeditoroverviewimpl.h" 12#include "taskeditoroverviewimpl.h"
11 13
12/* 14/*
13 * we need to hack 15 * we need to hack
14 */ 16 */
15 17
16TaskEditorOverViewImpl::TaskEditorOverViewImpl( QWidget* parent, const char* name ) 18TaskEditorOverViewImpl::TaskEditorOverViewImpl( QWidget* parent, const char* name )
17 : TaskEditorOverView( parent, name ) { 19 : TaskEditorOverView( parent, name ) {
18 init(); 20 init();
19} 21}
20TaskEditorOverViewImpl::~TaskEditorOverViewImpl() { 22TaskEditorOverViewImpl::~TaskEditorOverViewImpl() {
21} 23}
22void TaskEditorOverViewImpl::load( const OTodo& todo) { 24void TaskEditorOverViewImpl::load( const OTodo& todo) {
23 /* 25 /*
24 * now that we're 'preloaded' we 26 * now that we're 'preloaded' we
25 * need to disable the buttons 27 * need to disable the buttons
26 * holding the dat 28 * holding the dat
27 */ 29 */
28 btnDue-> setEnabled( FALSE ); 30 btnDue-> setEnabled( FALSE );
29 btnComp-> setEnabled( FALSE ); 31 btnComp-> setEnabled( FALSE );
30 btnStart->setEnabled( FALSE ); 32 btnStart->setEnabled( FALSE );
31 33
32 34 /*
35 * get some basic dateinfos for now
36 */
33 QDate date = QDate::currentDate(); 37 QDate date = QDate::currentDate();
34 QString str = TimeString::longDateString( date ); 38 QString str = TimeString::longDateString( date );
35 39
36 emit recurranceEnabled( FALSE ); 40 CheckBox7->setChecked( todo.recurrence().doesRecur() );
37 ckbStart->setChecked( FALSE ); 41 emit recurranceEnabled( todo.recurrence().doesRecur() );
42
43
44 ckbStart->setChecked( todo.hasStartDate() );
45 btnStart->setEnabled( todo.hasStartDate() );
46 if ( todo.hasStartDate() ) {
47 m_start = todo.startDate();
48 btnStart->setText( TimeString::longDateString( m_start ) );
49 } else
38 btnStart->setText( str ); 50 btnStart->setText( str );
39 51
40 ckbComp->setChecked( FALSE ); 52 ckbComp->setChecked( todo.hasCompletedDate() );
53 btnComp->setEnabled( todo.hasCompletedDate() );
54 if ( todo.hasCompletedDate() ) {
55 m_comp = todo.completedDate();
56 btnComp->setText( TimeString::longDateString( m_comp ) );
57 }else
41 btnComp->setText( str ); 58 btnComp->setText( str );
42 59
43 cmbProgress->setCurrentItem( todo.progress()/20 ); 60 cmbProgress->setCurrentItem( todo.progress()/20 );
44 cmbSum->insertItem( todo.summary(), 0 ); 61 cmbSum->insertItem( todo.summary(), 0 );
45 cmbSum->setCurrentItem( 0 ); 62 cmbSum->setCurrentItem( 0 );
46 63
47 ckbDue->setChecked( todo.hasDueDate() ); 64 ckbDue->setChecked( todo.hasDueDate() );
48 btnDue->setText( TimeString::longDateString( todo.dueDate() ) ); 65 btnDue->setText( TimeString::longDateString( todo.dueDate() ) );
49 btnDue->setEnabled( todo.hasDueDate() ); 66 btnDue->setEnabled( todo.hasDueDate() );
67 m_due = todo.dueDate();
50 68
51 cmbPrio->setCurrentItem( todo.priority() -1 ); 69 cmbPrio->setCurrentItem( todo.priority() -1 );
52 ckbCompleted->setChecked( todo.isCompleted() ); 70 ckbCompleted->setChecked( todo.isCompleted() );
53 71
54 comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") ); 72 comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") );
55 73
56} 74}
57void TaskEditorOverViewImpl::save( OTodo& to) { 75void TaskEditorOverViewImpl::save( OTodo& to) {
58 qWarning("save it now"); 76 /* a invalid date */
77 QDate inval;
78 /* save our info back */
79
80 /* due date */
59 if ( ckbDue->isChecked() ) { 81 if ( ckbDue->isChecked() ) {
60 to.setDueDate( m_due ); 82 to.setDueDate( m_due );
61 to.setHasDueDate( true ); 83 to.setHasDueDate( true );
62 }else 84 }else
63 to.setHasDueDate( false ); 85 to.setHasDueDate( false );
86
87 /* start date */
88 if ( ckbStart->isChecked() ) {
89 to.setStartDate( m_start );
90 }else
91 to.setStartDate( inval );
92
93 /* comp date */
94 if ( ckbComp->isChecked() ) {
95 qWarning("completed checked");
96 to.setCompletedDate( m_comp );
97 }else
98 to.setCompletedDate( inval );
99
100
64 if ( comboCategory->currentCategory() != -1 ) { 101 if ( comboCategory->currentCategory() != -1 ) {
65 QArray<int> arr = comboCategory->currentCategories(); 102 QArray<int> arr = comboCategory->currentCategories();
66 to.setCategories( arr ); 103 to.setCategories( arr );
67 } 104 }
68 to.setPriority( cmbPrio->currentItem() + 1 ); 105 to.setPriority( cmbPrio->currentItem() + 1 );
69 to.setCompleted( ckbCompleted->isChecked() ); 106 to.setCompleted( ckbCompleted->isChecked() );
70 to.setSummary( cmbSum->currentText() ); 107 to.setSummary( cmbSum->currentText() );
71 to.setProgress( cmbProgress->currentItem() * 20 ); 108 to.setProgress( cmbProgress->currentItem() * 20 );
72} 109}
73/* 110/*
74 * here we will init the basic view 111 * here we will init the basic view
75 * one Popup for each Date Button 112 * one Popup for each Date Button
@@ -127,29 +164,31 @@ void TaskEditorOverViewImpl::init() {
127} 164}
128 165
129void TaskEditorOverViewImpl::slotStartChecked() { 166void TaskEditorOverViewImpl::slotStartChecked() {
130 qWarning("slotStartChecked"); 167 qWarning("slotStartChecked");
131 btnStart->setEnabled( ckbStart->isChecked() ); 168 btnStart->setEnabled( ckbStart->isChecked() );
132} 169}
133void TaskEditorOverViewImpl::slotStartChanged(int y, int m, int d) { 170void TaskEditorOverViewImpl::slotStartChanged(int y, int m, int d) {
134 m_start.setYMD( y, m, d ); 171 m_start.setYMD( y, m, d );
135 btnStart->setText( TimeString::longDateString( m_start ) ); 172 btnStart->setText( TimeString::longDateString( m_start ) );
136} 173}
137void TaskEditorOverViewImpl::slotDueChecked() { 174void TaskEditorOverViewImpl::slotDueChecked() {
138 btnDue->setEnabled( ckbDue->isChecked() ); 175 btnDue->setEnabled( ckbDue->isChecked() );
176 emit dueDateChanged( m_due );
139 qWarning("slotDueChecked"); 177 qWarning("slotDueChecked");
140} 178}
141void TaskEditorOverViewImpl::slotDueChanged(int y, int m, int d ) { 179void TaskEditorOverViewImpl::slotDueChanged(int y, int m, int d ) {
142 m_due.setYMD(y, m, d ); 180 m_due.setYMD(y, m, d );
143 btnDue->setText( TimeString::longDateString( m_due ) ); 181 btnDue->setText( TimeString::longDateString( m_due ) );
182 emit dueDateChanged( m_due );
144} 183}
145void TaskEditorOverViewImpl::slotCompletedChecked() { 184void TaskEditorOverViewImpl::slotCompletedChecked() {
146 btnComp->setEnabled( ckbComp->isChecked() ); 185 btnComp->setEnabled( ckbComp->isChecked() );
147 qWarning("slotCompletedChecked"); 186 qWarning("slotCompletedChecked");
148} 187}
149void TaskEditorOverViewImpl::slotCompletedChanged(int y, int m, int d) { 188void TaskEditorOverViewImpl::slotCompletedChanged(int y, int m, int d) {
150 m_comp.setYMD( y, m, d ); 189 m_comp.setYMD( y, m, d );
151 btnComp->setText( TimeString::longDateString( m_comp ) ); 190 btnComp->setText( TimeString::longDateString( m_comp ) );
152} 191}
153/* 192/*
154 * called by a button pressed event... 193 * called by a button pressed event...
155 * three slots to avoid ugly name() tests 194 * three slots to avoid ugly name() tests
diff --git a/core/pim/todo/taskeditoroverviewimpl.h b/core/pim/todo/taskeditoroverviewimpl.h
index 4fab381..5ee985e 100644
--- a/core/pim/todo/taskeditoroverviewimpl.h
+++ b/core/pim/todo/taskeditoroverviewimpl.h
@@ -11,24 +11,25 @@ class DateBookMonth;
11class QPushButton; 11class QPushButton;
12class QPopupMenu; 12class QPopupMenu;
13class TaskEditorOverViewImpl : public TaskEditorOverView { 13class TaskEditorOverViewImpl : public TaskEditorOverView {
14 Q_OBJECT 14 Q_OBJECT
15public: 15public:
16 TaskEditorOverViewImpl(QWidget* parent, const char* name = 0); 16 TaskEditorOverViewImpl(QWidget* parent, const char* name = 0);
17 ~TaskEditorOverViewImpl(); 17 ~TaskEditorOverViewImpl();
18 18
19 void load( const OTodo& ); 19 void load( const OTodo& );
20 void save( OTodo& ); 20 void save( OTodo& );
21signals: 21signals:
22 void recurranceEnabled( bool ); 22 void recurranceEnabled( bool );
23 void dueDateChanged( const QDate& date );
23 24
24private: 25private:
25 void init(); 26 void init();
26 void popup(QPushButton*, QPopupMenu*); 27 void popup(QPushButton*, QPopupMenu*);
27 DateBookMonth* m_dueBook; 28 DateBookMonth* m_dueBook;
28 DateBookMonth* m_startBook; 29 DateBookMonth* m_startBook;
29 DateBookMonth* m_compBook; 30 DateBookMonth* m_compBook;
30 QDate m_start; 31 QDate m_start;
31 QDate m_comp; 32 QDate m_comp;
32 QDate m_due; 33 QDate m_due;
33 QPopupMenu* m_startPop; 34 QPopupMenu* m_startPop;
34 QPopupMenu* m_compPop; 35 QPopupMenu* m_compPop;
diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro
index 8f21416..40a5f28 100644
--- a/core/pim/todo/todo.pro
+++ b/core/pim/todo/todo.pro
@@ -9,44 +9,46 @@ HEADERS = smalltodo.h \
9 tableview.h \ 9 tableview.h \
10 tableitems.h \ 10 tableitems.h \
11 todotemplatemanager.h \ 11 todotemplatemanager.h \
12 todoeditor.h \ 12 todoeditor.h \
13 todoshow.h \ 13 todoshow.h \
14 textviewshow.h \ 14 textviewshow.h \
15 templateeditor.h \ 15 templateeditor.h \
16 templatedialog.h \ 16 templatedialog.h \
17 templatedialogimpl.h \ 17 templatedialogimpl.h \
18 quickedit.h \ 18 quickedit.h \
19 quickeditimpl.h \ 19 quickeditimpl.h \
20 otaskeditor.h \ 20 otaskeditor.h \
21 taskeditoroverviewimpl.h 21 taskeditoroverviewimpl.h \
22 taskeditoradvancedimpl.h
22 23
23 SOURCES= smalltodo.cpp \ 24 SOURCES= smalltodo.cpp \
24 todomanager.cpp \ 25 todomanager.cpp \
25 mainwindow.cpp \ 26 mainwindow.cpp \
26 main.cpp \ 27 main.cpp \
27 tableview.cpp \ 28 tableview.cpp \
28 tableitems.cpp \ 29 tableitems.cpp \
29 todoview.cpp \ 30 todoview.cpp \
30 todotemplatemanager.cpp \ 31 todotemplatemanager.cpp \
31 todoeditor.cpp \ 32 todoeditor.cpp \
32 todoshow.cpp \ 33 todoshow.cpp \
33 textviewshow.cpp \ 34 textviewshow.cpp \
34 templateeditor.cpp \ 35 templateeditor.cpp \
35 templatedialog.cpp \ 36 templatedialog.cpp \
36 templatedialogimpl.cpp \ 37 templatedialogimpl.cpp \
37 quickeditimpl.cpp \ 38 quickeditimpl.cpp \
38 quickedit.cpp \ 39 quickedit.cpp \
39 otaskeditor.cpp \ 40 otaskeditor.cpp \
40 taskeditoroverviewimpl.cpp 41 taskeditoroverviewimpl.cpp \
42 taskeditoradvancedimpl.cpp
41 43
42 INTERFACES= taskeditoradvanced.ui taskeditoralarms.ui taskeditoroverview.ui 44 INTERFACES= taskeditoradvanced.ui taskeditoralarms.ui taskeditoroverview.ui
43 TARGET = todolist 45 TARGET = todolist
44INCLUDEPATH += $(OPIEDIR)/include 46INCLUDEPATH += $(OPIEDIR)/include
45 DEPENDPATH+= $(OPIEDIR)/include 47 DEPENDPATH+= $(OPIEDIR)/include
46LIBS += -lqpe -lopie 48LIBS += -lqpe -lopie
47 49
48TRANSLATIONS = ../../../i18n/de/todolist.ts \ 50TRANSLATIONS = ../../../i18n/de/todolist.ts \
49 ../../../i18n/en/todolist.ts \ 51 ../../../i18n/en/todolist.ts \
50 ../../../i18n/es/todolist.ts \ 52 ../../../i18n/es/todolist.ts \
51 ../../../i18n/fr/todolist.ts \ 53 ../../../i18n/fr/todolist.ts \
52 ../../../i18n/hu/todolist.ts \ 54 ../../../i18n/hu/todolist.ts \
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
index 1f81539..b5b87de 100644
--- a/core/pim/todo/todomanager.cpp
+++ b/core/pim/todo/todomanager.cpp
@@ -76,30 +76,33 @@ OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) {
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}
88void TodoManager::remove( int uid ) { 88bool TodoManager::remove( int uid ) {
89 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() {
95 m_db->removeAllCompleted();
96}
94void TodoManager::save() { 97void TodoManager::save() {
95 m_db->save(); 98 m_db->save();
96} 99}
97bool TodoManager::saveAll() { 100bool TodoManager::saveAll() {
98 return m_db->save(); 101 return m_db->save();
99} 102}
100void TodoManager::reload() { 103void TodoManager::reload() {
101 m_db->reload(); 104 m_db->reload();
102} 105}
103QStringList TodoManager::categories() { 106QStringList TodoManager::categories() {
104 m_cat.load(categoryFileName() ); 107 m_cat.load(categoryFileName() );
105 return m_cat.labels( "Todo List"); 108 return m_cat.labels( "Todo List");
diff --git a/core/pim/todo/todomanager.h b/core/pim/todo/todomanager.h
index b03b598..8544277 100644
--- a/core/pim/todo/todomanager.h
+++ b/core/pim/todo/todomanager.h
@@ -73,26 +73,31 @@ namespace Todo {
73 OTodoAccess* todoDB(); 73 OTodoAccess* todoDB();
74 bool saveAll(); 74 bool saveAll();
75 75
76 76
77 signals: 77 signals:
78 void update(); 78 void update();
79 void updateCategories(); 79 void updateCategories();
80 80
81 public slots: 81 public slots:
82 void add( const OTodo& ); 82 void add( const OTodo& );
83 void update( int uid, const SmallTodo& ); 83 void update( int uid, const SmallTodo& );
84 void update( int uid, const OTodo& ); 84 void update( int uid, const OTodo& );
85 void remove( int uid ); 85 bool remove( int uid );
86 void remove( const QArray<int>& ); 86 void remove( const QArray<int>& );
87
88 /**
89 * remove all completed
90 */
91 void removeCompleted();
87 void removeAll(); 92 void removeAll();
88 void reload(); 93 void reload();
89 void save(); 94 void save();
90 95
91 private: 96 private:
92 OTodoAccess* m_db; 97 OTodoAccess* m_db;
93 OTodoAccess::List m_list; 98 OTodoAccess::List m_list;
94 OTodoAccess::List::Iterator m_it; 99 OTodoAccess::List::Iterator m_it;
95 OTodoAccess::List m_sorted; 100 OTodoAccess::List m_sorted;
96 Categories m_cat; 101 Categories m_cat;
97 int m_ca; 102 int m_ca;
98 /* sort cat */ 103 /* sort cat */
diff --git a/core/pim/todo/todoview.cpp b/core/pim/todo/todoview.cpp
index 4cf7d30..3e808e7 100644
--- a/core/pim/todo/todoview.cpp
+++ b/core/pim/todo/todoview.cpp
@@ -1,64 +1,36 @@
1#include "mainwindow.h" 1#include "mainwindow.h"
2 2
3#include "todoview.h" 3#include "todoview.h"
4 4
5using namespace Todo; 5using namespace Todo;
6 6
7
8
9
7TodoView::TodoView( MainWindow* win ) 10TodoView::TodoView( MainWindow* win )
8 : m_main( win ) 11 : m_main( win )
9{ 12{
10 hack = new InternQtHack;
11 m_asc = false; 13 m_asc = false;
12 m_sortOrder = -1; 14 m_sortOrder = -1;
13} 15}
14TodoView::~TodoView() { 16TodoView::~TodoView() {
15 delete hack;
16}; 17};
17
18void TodoView::connectShow(QObject* obj,
19 const char* slot ) {
20 QObject::connect( hack, SIGNAL(showTodo(int) ),
21 obj, slot );
22}
23void TodoView::connectEdit( QObject* obj,
24 const char* slot ) {
25 QObject::connect( hack, SIGNAL(edit(int) ),
26 obj, slot );
27}
28void TodoView::connectUpdateSmall( QObject* obj,
29 const char* slot ) {
30 QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ),
31 obj, slot );
32}
33void TodoView::connectUpdateBig( QObject* obj,
34 const char* slot ) {
35 QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ),
36 obj, slot );
37}
38void TodoView::connectUpdateView( QObject* obj,
39 const char* slot ) {
40 QObject::connect( hack, SIGNAL(update(QWidget*) ),
41 obj, slot );
42}
43void TodoView::connectRemove( QObject* obj,
44 const char* slot ) {
45 QObject::connect( hack, SIGNAL(remove(int) ),
46 obj, slot );
47}
48MainWindow* TodoView::todoWindow() { 18MainWindow* TodoView::todoWindow() {
49 return m_main; 19 return m_main;
50} 20}
51 21
52OTodo TodoView::event(int uid ) { return m_main->event( uid ); } 22OTodo TodoView::event(int uid ) {
23 return m_main->event( uid );
24}
53OTodoAccess::List TodoView::list(){ 25OTodoAccess::List TodoView::list(){
54 todoWindow()->updateList(); 26 todoWindow()->updateList();
55 return todoWindow()->list(); 27 return todoWindow()->list();
56} 28}
57OTodoAccess::List TodoView::sorted()const{ 29OTodoAccess::List TodoView::sorted()const{
58 return m_sort; 30 return m_sort;
59} 31}
60void TodoView::sort() { 32void TodoView::sort() {
61 m_sort = todoWindow()->sorted(m_asc,m_sortOrder ); 33 m_sort = todoWindow()->sorted(m_asc,m_sortOrder );
62 qWarning("m_sort.count() = %d", m_sort.count() ); 34 qWarning("m_sort.count() = %d", m_sort.count() );
63} 35}
64void TodoView::sort(int sort) { 36void TodoView::sort(int sort) {
@@ -68,12 +40,27 @@ void TodoView::setSortOrder( int order ) {
68 m_sortOrder = order; 40 m_sortOrder = order;
69} 41}
70void TodoView::setAscending( bool b ) { 42void TodoView::setAscending( bool b ) {
71 qWarning("setAscending %d", b ); 43 qWarning("setAscending %d", b );
72 m_asc = b; 44 m_asc = b;
73} 45}
74void TodoView::update(int, const SmallTodo& ) { 46void TodoView::update(int, const SmallTodo& ) {
75 //m_main->slotUpate1( uid, to ); 47 //m_main->slotUpate1( uid, to );
76} 48}
77void TodoView::update(int , const OTodo& ev ) { 49void TodoView::update(int , const OTodo& ev ) {
78 m_main->updateTodo( ev ); 50 m_main->updateTodo( ev );
79} 51}
52void TodoView::showTodo( int uid ) {
53 m_main->slotShow( uid );
54}
55void TodoView::edit( int uid ) {
56 m_main->slotEdit( uid );
57}
58void TodoView::remove( int uid ) {
59 m_main->m_todoMgr.remove( uid );
60}
61void TodoView::complete( int uid ) {
62 m_main->slotComplete( uid );
63}
64void TodoView::complete( const OTodo& ev ) {
65 m_main->slotComplete( ev );
66}
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h
index e5c77f9..e73e808 100644
--- a/core/pim/todo/todoview.h
+++ b/core/pim/todo/todoview.h
@@ -31,96 +31,50 @@
31 31
32#include <qarray.h> 32#include <qarray.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qvaluelist.h> 34#include <qvaluelist.h>
35#include <qwidget.h> 35#include <qwidget.h>
36 36
37#include <opie/otodoaccess.h> 37#include <opie/otodoaccess.h>
38 38
39#include "smalltodo.h" 39#include "smalltodo.h"
40 40
41 41
42namespace Todo { 42namespace Todo {
43
44 /**
45 * According to tronical it's not possible
46 * to have Q_OBJECT in a template at all
47 * so this is a hack widget not meant
48 * to be public
49 */
50 class InternQtHack : public QObject {
51 Q_OBJECT
52 public:
53 InternQtHack() : QObject() {};
54 void emitShow(int uid) { emit showTodo(uid); }
55 void emitEdit(int uid) { emit edit(uid ); }
56 void emitUpdate( int uid,
57 const SmallTodo& to) {
58 emit update(uid, to );
59 }
60 void emitUpdate( int uid,
61 const OTodo& ev ){
62 emit update(uid, ev );
63 }
64 void emitRemove( int uid ) {
65 emit remove( uid );
66 }
67 void emitUpdate( QWidget* wid ) {
68 emit update( wid );
69 }
70 signals:
71 void showTodo(int uid );
72 void edit(int uid );
73 void update( int uid, const Todo::SmallTodo& );
74 void update( int uid, const OTodo& );
75 /* sorry you need to cast */;
76 void update( QWidget* wid );
77 void remove( int uid );
78
79 };
80 class MainWindow; 43 class MainWindow;
81 44
82 /** 45 /**
83 * due to inheretince problems we need this base class 46 * due to inheretince problems we need this base class
84 */ 47 */
85 class ViewBase { 48 struct ViewBase {
86 public: 49 public:
87 virtual QWidget* widget() = 0; 50 virtual QWidget* widget() = 0;
88 virtual QString type()const = 0; 51 virtual QString type()const = 0;
89 virtual int current() = 0; 52 virtual int current() = 0;
90 virtual QString currentRepresentation() = 0; 53 virtual QString currentRepresentation() = 0;
91 virtual void showOverDue( bool ) = 0; 54 virtual void showOverDue( bool ) = 0;
92 55
93 /* 56 /*
94 * update the view 57 * update the view
95 */ 58 */
96 virtual void updateView() = 0; 59 virtual void updateView() = 0;
97 60
98 virtual void addEvent( const OTodo& ) = 0; 61 virtual void addEvent( const OTodo& ) = 0;
99 virtual void replaceEvent( const OTodo& ) = 0; 62 virtual void replaceEvent( const OTodo& ) = 0;
100 virtual void removeEvent( int uid ) = 0; 63 virtual void removeEvent( int uid ) = 0;
101 virtual void setShowCompleted( bool ) = 0; 64 virtual void setShowCompleted( bool ) = 0;
102 virtual void setShowDeadline( bool ) = 0; 65 virtual void setShowDeadline( bool ) = 0;
103 virtual void setShowCategory( const QString& = QString::null ) = 0; 66 virtual void setShowCategory( const QString& = QString::null ) = 0;
104 virtual void clear() = 0; 67 virtual void clear() = 0;
105/* virtual QArray<int> completed() = 0; */
106 virtual void newDay() = 0; 68 virtual void newDay() = 0;
107
108 virtual void connectShow( QObject*, const char* ) = 0;
109 virtual void connectEdit( QObject*, const char* ) = 0;
110 virtual void connectUpdateSmall( QObject*, const char* ) = 0;
111 virtual void connectUpdateBig( QObject*, const char* ) = 0;
112 virtual void connectUpdateView( QObject*, const char*) = 0;
113 virtual void connectRemove( QObject*, const char* ) = 0;
114
115 }; 69 };
116 70
117 /** 71 /**
118 * A base class for all TodoView which are showing 72 * A base class for all TodoView which are showing
119 * a list of todos. 73 * a list of todos.
120 * Either in a QTable, QListView or any other QWidget 74 * Either in a QTable, QListView or any other QWidget
121 * derived class 75 * derived class
122 * Through the MainWindow( dispatcher ) one can access 76 * Through the MainWindow( dispatcher ) one can access
123 * the relevant informations 77 * the relevant informations
124 * 78 *
125 * It's not possible to have signal and slots from within 79 * It's not possible to have signal and slots from within
126 * templates this way you've to register for a signal 80 * templates this way you've to register for a signal
@@ -129,60 +83,42 @@ namespace Todo {
129 83
130 public: 84 public:
131 /** 85 /**
132 * c'tor 86 * c'tor
133 */ 87 */
134 TodoView( MainWindow* win ); 88 TodoView( MainWindow* win );
135 89
136 /** 90 /**
137 *d'tor 91 *d'tor
138 */ 92 */
139 virtual ~TodoView(); 93 virtual ~TodoView();
140 94
141 /* connect to the show signal */
142 void connectShow(QObject* obj,
143 const char* slot );
144
145 /* connect to edit */
146 void connectEdit( QObject* obj,
147 const char* slot );
148 void connectUpdateSmall( QObject* obj,
149 const char* slot );
150 void connectUpdateBig( QObject* obj,
151 const char* slot ) ;
152 void connectUpdateView( QObject* obj,
153 const char* slot );
154 void connectRemove( QObject* obj,
155 const char* slot );
156 protected: 95 protected:
157 MainWindow* todoWindow(); 96 MainWindow* todoWindow();
158 OTodo event(int uid ); 97 OTodo event(int uid );
159 OTodoAccess::List list(); 98 OTodoAccess::List list();
160 OTodoAccess::List sorted()const; 99 OTodoAccess::List sorted()const;
161 void sort(); 100 void sort();
162 void sort(int sort ); 101 void sort(int sort );
163 void setSortOrder( int order ); 102 void setSortOrder( int order );
164 void setAscending( bool ); 103 void setAscending( bool );
165 104
166 /* 105 /*
167 These things needs to be implemented 106 * These things needs to be implemented
168 in a implementation 107 * in a implementation
169 signals:
170 */ 108 */
171 protected: 109 void showTodo( int uid );
172 void showTodo( int uid ) { hack->emitShow(uid); } 110 void edit( int uid );
173 void edit( int uid ) { hack->emitEdit(uid); }
174 void update(int uid, const SmallTodo& to ); 111 void update(int uid, const SmallTodo& to );
175 void update(int uid, const OTodo& ev); 112 void update(int uid, const OTodo& ev);
176 void remove( int uid ) { 113 void remove( int uid );
177 hack->emitRemove( uid ); 114 void complete( int uid );
178 } 115 void complete( const OTodo& ev );
179 private: 116 private:
180 InternQtHack* hack;
181 MainWindow *m_main; 117 MainWindow *m_main;
182 OTodoAccess::List m_sort; 118 OTodoAccess::List m_sort;
183 bool m_asc : 1; 119 bool m_asc : 1;
184 int m_sortOrder; 120 int m_sortOrder;
185 }; 121 };
186}; 122};
187 123
188#endif 124#endif