summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-13 02:26:52 (UTC)
committer zecke <zecke>2002-10-13 02:26:52 (UTC)
commite9e5c2346f12f78b42025c70a50ebb4157dbd7ca (patch) (unidiff)
tree310c3a4bb3fc38646b21941e516f6f9f6b4c7fb9
parentd96ce086c617b5b2efc5081cd10a43257a78f488 (diff)
downloadopie-e9e5c2346f12f78b42025c70a50ebb4157dbd7ca.zip
opie-e9e5c2346f12f78b42025c70a50ebb4157dbd7ca.tar.gz
opie-e9e5c2346f12f78b42025c70a50ebb4157dbd7ca.tar.bz2
Speed Speed Speed...
main.cpp disabled messagehandler.. TableView: do not update View from setCategory if category was not changed and if not first setCategory Inline editing is working again current is working too Fixed sorting MainWindow: Show Event and Edit event does work again Try to avoid calling sorted or allRecords unneeded... 10.000 todos on SQL does feel fast I need to get it down some more... maybe tweaking libsqlite a bit ( some compiler switches and disable asserts ) Before I implement new features I want to get down to 2-3 seconds loading of Data The UI will instantly pop up and then load the stuff within seconds
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/main.cpp2
-rw-r--r--core/pim/todo/mainwindow.cpp7
-rw-r--r--core/pim/todo/tableview.cpp97
-rw-r--r--core/pim/todo/tableview.h7
-rw-r--r--core/pim/todo/todomanager.cpp2
-rw-r--r--core/pim/todo/todoview.cpp3
-rw-r--r--core/pim/todo/todoview.h2
7 files changed, 86 insertions, 34 deletions
diff --git a/core/pim/todo/main.cpp b/core/pim/todo/main.cpp
index 58ed45c..aeae794 100644
--- a/core/pim/todo/main.cpp
+++ b/core/pim/todo/main.cpp
@@ -1,49 +1,49 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "mainwindow.h" 21#include "mainwindow.h"
22 22
23 23
24#include <qdatetime.h> 24#include <qdatetime.h>
25 25
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27 27
28void myMessages( QtMsgType, const char* ) { 28void myMessages( QtMsgType, const char* ) {
29 29
30} 30}
31 31
32int main( int argc, char **argv ) 32int main( int argc, char **argv )
33{ 33{
34 qInstallMsgHandler( myMessages ); 34// qInstallMsgHandler( myMessages );
35 QPEApplication a( argc, argv ); 35 QPEApplication a( argc, argv );
36 36
37 QTime time; 37 QTime time;
38 time.start(); 38 time.start();
39 Todo::MainWindow mw; 39 Todo::MainWindow mw;
40 int t = time.elapsed(); 40 int t = time.elapsed();
41 qWarning("QTime %d", t/1000 ); 41 qWarning("QTime %d", t/1000 );
42 mw.setCaption("Opie Todolist"); 42 mw.setCaption("Opie Todolist");
43 QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) ); 43 QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) );
44 QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) ); 44 QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) );
45 45
46 a.showMainWidget(&mw); 46 a.showMainWidget(&mw);
47 47
48 return a.exec(); 48 return a.exec();
49} 49}
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 48954ce..c9c43d4 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -327,312 +327,313 @@ void MainWindow::closeEvent( QCloseEvent* e ) {
327 /* 327 /*
328 * we should have flushed and now we're still saving 328 * we should have flushed and now we're still saving
329 * so there is no need to flush 329 * so there is no need to flush
330 */ 330 */
331 if (m_syncing ) { 331 if (m_syncing ) {
332 e->accept(); 332 e->accept();
333 return; 333 return;
334 } 334 }
335 bool quit = false; 335 bool quit = false;
336 if ( m_todoMgr.saveAll() ){ 336 if ( m_todoMgr.saveAll() ){
337 qWarning("saved"); 337 qWarning("saved");
338 quit = true; 338 quit = true;
339 }else { 339 }else {
340 if ( QMessageBox::critical( this, tr("Out of space"), 340 if ( QMessageBox::critical( this, tr("Out of space"),
341 tr("Todo was unable\n" 341 tr("Todo was unable\n"
342 "to save your changes.\n" 342 "to save your changes.\n"
343 "Free up some space\n" 343 "Free up some space\n"
344 "and try again.\n" 344 "and try again.\n"
345 "\nQuit Anyway?"), 345 "\nQuit Anyway?"),
346 QMessageBox::Yes|QMessageBox::Escape, 346 QMessageBox::Yes|QMessageBox::Escape,
347 QMessageBox::No|QMessageBox::Default) 347 QMessageBox::No|QMessageBox::Default)
348 != QMessageBox::No ) { 348 != QMessageBox::No ) {
349 e->accept(); 349 e->accept();
350 quit = true; 350 quit = true;
351 }else 351 }else
352 e->ignore(); 352 e->ignore();
353 353
354 } 354 }
355 355
356 if (quit ) { 356 if (quit ) {
357 Config config( "todo" ); 357 Config config( "todo" );
358 config.setGroup( "View" ); 358 config.setGroup( "View" );
359 config.writeEntry( "ShowComplete", showCompleted() ); 359 config.writeEntry( "ShowComplete", showCompleted() );
360 config.writeEntry( "Category", currentCategory() ); 360 config.writeEntry( "Category", currentCategory() );
361 config.writeEntry( "ShowDeadLine", showDeadline()); 361 config.writeEntry( "ShowDeadLine", showDeadline());
362 config.writeEntry( "ShowOverDue", showOverDue() ); 362 config.writeEntry( "ShowOverDue", showOverDue() );
363 /* svae templates */ 363 /* svae templates */
364 templateManager()->save(); 364 templateManager()->save();
365 e->accept(); 365 e->accept();
366 } 366 }
367} 367}
368void MainWindow::populateTemplates() { 368void MainWindow::populateTemplates() {
369 m_template->clear(); 369 m_template->clear();
370 QStringList list = templateManager()->templates(); 370 QStringList list = templateManager()->templates();
371 QStringList::Iterator it; 371 QStringList::Iterator it;
372 for ( it = list.begin(); it != list.end(); ++it ) { 372 for ( it = list.begin(); it != list.end(); ++it ) {
373 m_template->insertItem( (*it) ); 373 m_template->insertItem( (*it) );
374 } 374 }
375} 375}
376/* 376/*
377 * slotNewFromTemplate 377 * slotNewFromTemplate
378 * We use the edit widget to do 378 * We use the edit widget to do
379 * the config but we setUid(-1) 379 * the config but we setUid(-1)
380 * to get a new uid 380 * to get a new uid
381 */ 381 */
382/* 382/*
383 * first we get the name of the template 383 * first we get the name of the template
384 * then we will use the TemplateManager 384 * then we will use the TemplateManager
385 */ 385 */
386void MainWindow::slotNewFromTemplate( int id ) { 386void MainWindow::slotNewFromTemplate( int id ) {
387 QString name = m_template->text( id ); 387 QString name = m_template->text( id );
388 388
389 OTodo event = templateManager()->templateEvent( name ); 389 OTodo event = templateManager()->templateEvent( name );
390 event = currentEditor()->edit(this, 390 event = currentEditor()->edit(this,
391 event ); 391 event );
392 392
393 if ( currentEditor()->accepted() ) { 393 if ( currentEditor()->accepted() ) {
394 /* assign new todo */ 394 /* assign new todo */
395 event.setUid( -1 ); 395 event.setUid( -1 );
396 currentView()->addEvent( event ); 396 currentView()->addEvent( event );
397 m_todoMgr.add( event ); 397 m_todoMgr.add( event );
398 398
399 populateCategories(); 399 populateCategories();
400 } 400 }
401} 401}
402void MainWindow::slotNew() { 402void MainWindow::slotNew() {
403 if(m_syncing) { 403 if(m_syncing) {
404 QMessageBox::warning(this, tr("Todo"), 404 QMessageBox::warning(this, tr("Todo"),
405 tr("Can not edit data, currently syncing")); 405 tr("Can not edit data, currently syncing"));
406 return; 406 return;
407 } 407 }
408 408
409 409
410 OTodo todo = currentEditor()->newTodo( currentCatId(), 410 OTodo todo = currentEditor()->newTodo( currentCatId(),
411 this ); 411 this );
412 412
413 if ( currentEditor()->accepted() ) { 413 if ( currentEditor()->accepted() ) {
414 //todo.assignUid(); 414 //todo.assignUid();
415 currentView()->addEvent( todo ); 415 currentView()->addEvent( todo );
416 m_todoMgr.add( todo ); 416 m_todoMgr.add( todo );
417 417
418 // I'm afraid we must call this every time now, otherwise 418 // I'm afraid we must call this every time now, otherwise
419 // spend expensive time comparing all these strings... 419 // spend expensive time comparing all these strings...
420 // but only call if we changed something -zecke 420 // but only call if we changed something -zecke
421 populateCategories(); 421 populateCategories();
422 } 422 }
423
424 raiseCurrentView( ); 423 raiseCurrentView( );
425} 424}
426void MainWindow::slotDuplicate() { 425void MainWindow::slotDuplicate() {
427 if(m_syncing) { 426 if(m_syncing) {
428 QMessageBox::warning(this, tr("Todo"), 427 QMessageBox::warning(this, tr("Todo"),
429 tr("Can not edit data, currently syncing")); 428 tr("Can not edit data, currently syncing"));
430 return; 429 return;
431 } 430 }
432 OTodo ev = m_todoMgr.event( currentView()->current() ); 431 OTodo ev = m_todoMgr.event( currentView()->current() );
433 /* let's generate a new uid */ 432 /* let's generate a new uid */
434 ev.setUid(-1); 433 ev.setUid(-1);
435 m_todoMgr.add( ev ); 434 m_todoMgr.add( ev );
436 435
437 currentView()->addEvent( ev ); 436 currentView()->addEvent( ev );
438 raiseCurrentView(); 437 raiseCurrentView();
439} 438}
440void MainWindow::slotDelete() { 439void MainWindow::slotDelete() {
441 if (!currentView()->current() ) 440 if (!currentView()->current() )
442 return; 441 return;
443 442
444 if(m_syncing) { 443 if(m_syncing) {
445 QMessageBox::warning(this, tr("Todo"), 444 QMessageBox::warning(this, tr("Todo"),
446 tr("Can not edit data, currently syncing")); 445 tr("Can not edit data, currently syncing"));
447 return; 446 return;
448 } 447 }
449 QString strName = currentView()->currentRepresentation(); 448 QString strName = currentView()->currentRepresentation();
450 if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) 449 if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) )
451 return; 450 return;
452 451
453 m_todoMgr.remove( currentView()->current() ); 452 m_todoMgr.remove( currentView()->current() );
454 currentView()->removeEvent( currentView()->current() ); 453 currentView()->removeEvent( currentView()->current() );
455 raiseCurrentView(); 454 raiseCurrentView();
456} 455}
457void MainWindow::slotDeleteAll() { 456void MainWindow::slotDeleteAll() {
458 if(m_syncing) { 457 if(m_syncing) {
459 QMessageBox::warning(this, tr("Todo"), 458 QMessageBox::warning(this, tr("Todo"),
460 tr("Can not edit data, currently syncing")); 459 tr("Can not edit data, currently syncing"));
461 return; 460 return;
462 } 461 }
463 462
464 //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); 463 //QString strName = table->text( table->currentRow(), 2 ).left( 30 );
465 464
466 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) 465 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) )
467 return; 466 return;
468 467
469 m_todoMgr.removeAll(); 468 m_todoMgr.removeAll();
470 currentView()->clear(); 469 currentView()->clear();
471 470
472 raiseCurrentView(); 471 raiseCurrentView();
473} 472}
474void MainWindow::slotDeleteCompleted() { 473void MainWindow::slotDeleteCompleted() {
475 if(m_syncing) { 474 if(m_syncing) {
476 QMessageBox::warning(this, tr("Todo"), 475 QMessageBox::warning(this, tr("Todo"),
477 tr("Can not edit data, currently syncing")); 476 tr("Can not edit data, currently syncing"));
478 return; 477 return;
479 } 478 }
480 479
481 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) 480 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) )
482 return; 481 return;
483 482
484 // FIXME 483 // FIXME
485 //m_todoMgr.remove( currentView()->completed() ); 484 //m_todoMgr.remove( currentView()->completed() );
486 currentView()->updateView( ); 485 currentView()->updateView( );
487} 486}
488void MainWindow::slotFind() { 487void MainWindow::slotFind() {
489 488
490} 489}
491void MainWindow::slotEdit() { 490void MainWindow::slotEdit() {
492 slotEdit( currentView()->current() ); 491 slotEdit( currentView()->current() );
493} 492}
494/* 493/*
495 * set the category 494 * set the category
496 */ 495 */
497void MainWindow::setCategory( int c) { 496void MainWindow::setCategory( int c) {
498 if ( c <= 0 ) return; 497 if ( c <= 0 ) return;
499 498
499
500 qWarning("Iterating over cats %d", c ); 500 qWarning("Iterating over cats %d", c );
501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
502 m_catMenu->setItemChecked(i, c == (int)i ); 502 m_catMenu->setItemChecked(i, c == (int)i );
503 503
504 if (c == 1 ) { 504 if (c == 1 ) {
505 m_curCat = QString::null; 505 m_curCat = QString::null;
506 setCaption( tr("Todo") + " - " + tr("All Categories" ) ); 506 setCaption( tr("Todo") + " - " + tr("All Categories" ) );
507 507
508 }else if ( c == (int)m_catMenu->count() - 1 ) { 508 }else if ( c == (int)m_catMenu->count() - 1 ) {
509 m_curCat = tr("Unfiled"); 509 m_curCat = tr("Unfiled");
510 setCaption( tr("Todo") + " - " + tr("Unfiled") ); 510 setCaption( tr("Todo") + " - " + tr("Unfiled") );
511 }else { 511 }else {
512 m_curCat = m_todoMgr.categories()[c-2]; 512 m_curCat = m_todoMgr.categories()[c-2];
513 setCaption( tr("Todo") + " - " + m_curCat ); 513 setCaption( tr("Todo") + " - " + m_curCat );
514 } 514 }
515 m_catMenu->setItemChecked( c, true ); 515 m_catMenu->setItemChecked( c, true );
516
516 currentView()->setShowCategory( m_curCat ); 517 currentView()->setShowCategory( m_curCat );
517 raiseCurrentView(); 518 raiseCurrentView();
518} 519}
519void MainWindow::slotShowDeadLine( bool dead) { 520void MainWindow::slotShowDeadLine( bool dead) {
520 m_deadline = dead; 521 m_deadline = dead;
521 currentView()->setShowDeadline( dead ); 522 currentView()->setShowDeadline( dead );
522} 523}
523void MainWindow::slotShowCompleted( bool show) { 524void MainWindow::slotShowCompleted( bool show) {
524 m_completed = show; 525 m_completed = show;
525 currentView()->setShowCompleted( m_completed ); 526 currentView()->setShowCompleted( m_completed );
526} 527}
527bool MainWindow::showOverDue()const { 528bool MainWindow::showOverDue()const {
528 return m_overdue; 529 return m_overdue;
529} 530}
530void MainWindow::setDocument( const QString& ) { 531void MainWindow::setDocument( const QString& ) {
531 532
532} 533}
533void MainWindow::slotBeam() { 534void MainWindow::slotBeam() {
534 535
535} 536}
536void MainWindow::beamDone( Ir* ) { 537void MainWindow::beamDone( Ir* ) {
537 538
538} 539}
539 540
540void MainWindow::slotFlush() { 541void MainWindow::slotFlush() {
541 m_syncing = FALSE; 542 m_syncing = FALSE;
542 m_todoMgr.save(); 543 m_todoMgr.save();
543} 544}
544void MainWindow::slotShowDetails() { 545void MainWindow::slotShowDetails() {
545 slotShow( currentView()->current() ); 546 slotShow( currentView()->current() );
546} 547}
547/* 548/*
548 * populate the Categories 549 * populate the Categories
549 * Menu 550 * Menu
550 */ 551 */
551void MainWindow::populateCategories() { 552void MainWindow::populateCategories() {
552 if (m_todoMgr.isLoaded() ) 553 m_todoMgr.load();
553 m_todoMgr.load();
554 554
555 m_catMenu->clear(); 555 m_catMenu->clear();
556 int id, rememberId; 556 int id, rememberId;
557 id = 1; 557 id = 1;
558 rememberId = 1; 558 rememberId = 1;
559 559
560 m_catMenu->insertItem( tr( "All Categories" ), id++ ); 560 m_catMenu->insertItem( tr( "All Categories" ), id++ );
561 m_catMenu->insertSeparator(); 561 m_catMenu->insertSeparator();
562 QStringList categories = m_todoMgr.categories(); 562 QStringList categories = m_todoMgr.categories();
563 categories.append( tr( "Unfiled" ) ); 563 categories.append( tr( "Unfiled" ) );
564 for ( QStringList::Iterator it = categories.begin(); 564 for ( QStringList::Iterator it = categories.begin();
565 it != categories.end(); ++it ) { 565 it != categories.end(); ++it ) {
566 m_catMenu->insertItem( *it, id ); 566 m_catMenu->insertItem( *it, id );
567 if ( *it == currentCategory() ) 567 if ( *it == currentCategory() )
568 rememberId = id; 568 rememberId = id;
569 ++id; 569 ++id;
570 } 570 }
571 setCategory( rememberId ); 571 setCategory( rememberId );
572} 572}
573bool MainWindow::showCompleted()const { 573bool MainWindow::showCompleted()const {
574 return m_completed; 574 return m_completed;
575} 575}
576bool MainWindow::showDeadline()const { 576bool MainWindow::showDeadline()const {
577 return m_deadline; 577 return m_deadline;
578} 578}
579QString MainWindow::currentCategory()const { 579QString MainWindow::currentCategory()const {
580 return m_curCat; 580 return m_curCat;
581} 581}
582int MainWindow::currentCatId() { 582int MainWindow::currentCatId() {
583 return m_todoMgr.catId( m_curCat ); 583 return m_todoMgr.catId( m_curCat );
584} 584}
585ViewBase* MainWindow::currentView() { 585ViewBase* MainWindow::currentView() {
586 return m_curView; 586 return m_curView;
587} 587}
588void MainWindow::raiseCurrentView() { 588void MainWindow::raiseCurrentView() {
589 m_stack->raiseWidget( m_curView->widget() ); 589 m_stack->raiseWidget( m_curView->widget() );
590} 590}
591void MainWindow::slotShowDue(bool ov) { 591void MainWindow::slotShowDue(bool ov) {
592 m_overdue = ov; 592 m_overdue = ov;
593 currentView()->showOverDue( ov ); 593 currentView()->showOverDue( ov );
594 raiseCurrentView(); 594 raiseCurrentView();
595} 595}
596void MainWindow::slotShow( int uid ) { 596void MainWindow::slotShow( int uid ) {
597 qWarning("slotShow"); 597 qWarning("slotShow");
598 currentShow()->slotShow( event( uid ) ); 598 currentShow()->slotShow( event( uid ) );
599 m_stack->raiseWidget( currentShow()->widget() ); 599 m_stack->raiseWidget( currentShow()->widget() );
600} 600}
601void MainWindow::slotEdit( int uid ) { 601void MainWindow::slotEdit( int uid ) {
602 if(m_syncing) { 602 if(m_syncing) {
603 QMessageBox::warning(this, tr("Todo"), 603 QMessageBox::warning(this, tr("Todo"),
604 tr("Can not edit data, currently syncing")); 604 tr("Can not edit data, currently syncing"));
605 return; 605 return;
606 } 606 }
607 607
608 OTodo todo = m_todoMgr.event( uid ); 608 OTodo todo = m_todoMgr.event( uid );
609 609
610 todo = currentEditor()->edit(this, todo ); 610 todo = currentEditor()->edit(this, todo );
611 611
612 /* if completed */ 612 /* if completed */
613 if ( currentEditor()->accepted() ) { 613 if ( currentEditor()->accepted() ) {
614 qWarning("Replacing now" ); 614 qWarning("Replacing now" );
615 m_todoMgr.update( todo.uid(), todo ); 615 m_todoMgr.update( todo.uid(), todo );
616 currentView()->replaceEvent( todo ); 616 currentView()->replaceEvent( todo );
617 /* a Category might have changed */
617 populateCategories(); 618 populateCategories();
618 } 619 }
619 620
620 raiseCurrentView(); 621 raiseCurrentView();
621} 622}
622/* 623/*
623void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 624void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
624 m_todoMgr.update( uid, ev ); 625 m_todoMgr.update( uid, ev );
625} 626}
626*/ 627*/
627void MainWindow::updateTodo( const OTodo& ev) { 628void MainWindow::updateTodo( const OTodo& ev) {
628 m_todoMgr.update( ev.uid() , ev ); 629 m_todoMgr.update( ev.uid() , ev );
629} 630}
630/* The view changed it's configuration 631/* The view changed it's configuration
631 * update the view menu 632 * update the view menu
632 */ 633 */
633void MainWindow::slotUpdate3( QWidget* ) { 634void MainWindow::slotUpdate3( QWidget* ) {
634 635
635} 636}
636void MainWindow::updateList() { 637void MainWindow::updateList() {
637 m_todoMgr.updateList(); 638 m_todoMgr.updateList();
638} 639}
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index 5594b13..5d82eb2 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -1,359 +1,400 @@
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  -_. . .   )=.  = 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#include <qtimer.h> 29#include <qtimer.h>
30#include <qpoint.h> 30#include <qpoint.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32 32
33#include "mainwindow.h" 33#include "mainwindow.h"
34//#include "tableitems.h" 34//#include "tableitems.h"
35#include "tableview.h" 35#include "tableview.h"
36 36
37using namespace Todo; 37using namespace Todo;
38 38
39namespace { 39namespace {
40 static const int BoxSize = 14; 40 static const int BoxSize = 14;
41 static const int RowHeight = 20; 41 static const int RowHeight = 20;
42} 42}
43 43
44 44
45TableView::TableView( MainWindow* window, QWidget* wid ) 45TableView::TableView( MainWindow* window, QWidget* wid )
46 : QTable( wid ), TodoView( window ) { 46 : QTable( wid ), TodoView( window ) {
47 setUpdatesEnabled( false ); 47 setUpdatesEnabled( false );
48 viewport()->setUpdatesEnabled( false ); 48 viewport()->setUpdatesEnabled( false );
49 m_enablePaint = false; 49 m_enablePaint = false;
50 setNumRows(0); 50 setNumRows(0);
51 setNumCols(4); 51 setNumCols(4);
52 52
53 setSorting( TRUE ); 53 setSorting( TRUE );
54 setSelectionMode( NoSelection ); 54 setSelectionMode( NoSelection );
55 setColumnStretchable( 2, TRUE ); 55 setColumnStretchable( 2, TRUE );
56 setColumnWidth(0, 20 ); 56 setColumnWidth(0, 20 );
57 setColumnWidth(1, 35 ); 57 setColumnWidth(1, 35 );
58 58
59 setLeftMargin( 0 ); 59 setLeftMargin( 0 );
60 verticalHeader()->hide(); 60 verticalHeader()->hide();
61 61
62 horizontalHeader()->setLabel(0, tr("C.") ); 62 horizontalHeader()->setLabel(0, tr("C.") );
63 horizontalHeader()->setLabel(1, tr("Prior.") ); 63 horizontalHeader()->setLabel(1, tr("Prior.") );
64 horizontalHeader()->setLabel(2, tr("Description" ) ); 64 horizontalHeader()->setLabel(2, tr("Description" ) );
65 65
66 setColumnStretchable(3, FALSE ); 66 setColumnStretchable(3, FALSE );
67 setColumnWidth(3, 20 ); 67 setColumnWidth(3, 20 );
68 horizontalHeader()->setLabel(3, tr("Deadline") ); 68 horizontalHeader()->setLabel(3, tr("Deadline") );
69 69
70 if ( todoWindow()->showDeadline() ) 70 if ( todoWindow()->showDeadline() )
71 showColumn( 3); 71 showColumn( 3);
72 else 72 else
73 hideColumn(3 ); 73 hideColumn(3 );
74 74
75 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), 75 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ),
76 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); 76 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) );
77 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), 77 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ),
78 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); 78 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) );
79 connect((QTable*)this, SIGNAL(valueChanged(int, int) ), 79 connect((QTable*)this, SIGNAL(valueChanged(int, int) ),
80 this, SLOT( slotValueChanged(int, int) ) ); 80 this, SLOT( slotValueChanged(int, int) ) );
81 connect((QTable*)this, SIGNAL(currentChanged(int, int) ), 81 connect((QTable*)this, SIGNAL(currentChanged(int, int) ),
82 this, SLOT( slotCurrentChanged(int, int) ) ); 82 this, SLOT( slotCurrentChanged(int, int) ) );
83 83
84 m_menuTimer = new QTimer( this ); 84 m_menuTimer = new QTimer( this );
85 connect( m_menuTimer, SIGNAL(timeout()), 85 connect( m_menuTimer, SIGNAL(timeout()),
86 this, SLOT(slotShowMenu()) ); 86 this, SLOT(slotShowMenu()) );
87 87
88 m_enablePaint = true; 88 m_enablePaint = true;
89 setUpdatesEnabled( true ); 89 setUpdatesEnabled( true );
90 viewport()->setUpdatesEnabled( true ); 90 viewport()->setUpdatesEnabled( true );
91 viewport()->update(); 91 viewport()->update();
92 setSortOrder( 0 );
93 setAscending( TRUE );
94 m_first = true;
92} 95}
93/* a new day has started 96/* a new day has started
94 * update the day 97 * update the day
95 */ 98 */
96void TableView::newDay() { 99void TableView::newDay() {
97 clear(); 100 clear();
98 updateView(); 101 updateView();
99} 102}
100TableView::~TableView() { 103TableView::~TableView() {
101 104
102} 105}
103void TableView::slotShowMenu() { 106void TableView::slotShowMenu() {
104 QPopupMenu *menu = todoWindow()->contextMenu( current() ); 107 QPopupMenu *menu = todoWindow()->contextMenu( current() );
105 menu->exec(QCursor::pos() ); 108 menu->exec(QCursor::pos() );
106 delete menu; 109 delete menu;
107} 110}
108QString TableView::type() const { 111QString TableView::type() const {
109 return QString::fromLatin1( tr("Table View") ); 112 return QString::fromLatin1( tr("Table View") );
110} 113}
111int TableView::current() { 114int TableView::current() {
112 int cur = 0; 115 int uid = sorted().uidAt(currentRow() );
113 // FIXME 116 qWarning("uid %d", uid );
114 return cur; 117 return uid;
115} 118}
116QString TableView::currentRepresentation() { 119QString TableView::currentRepresentation() {
117 return text( currentRow(), 2); 120 return text( currentRow(), 2);
118} 121}
119/* show overdue */ 122/* show overdue */
120void TableView::showOverDue( bool ) { 123void TableView::showOverDue( bool ) {
121 clear(); 124 clear();
122 updateView(); 125 updateView();
123} 126}
124 127
125void TableView::updateView( ) { 128void TableView::updateView( ) {
126 setSortOrder( 0 );
127 setAscending( true );
128 sort(); 129 sort();
129 OTodoAccess::List::Iterator it, end; 130 OTodoAccess::List::Iterator it, end;
130 it = sorted().begin(); 131 it = sorted().begin();
131 end = sorted().end(); 132 end = sorted().end();
132 133
133 qWarning("setTodos"); 134 qWarning("setTodos");
134 QTime time; 135 QTime time;
135 time.start(); 136 time.start();
136 m_enablePaint = false; 137 m_enablePaint = false;
137 setUpdatesEnabled( false ); 138 setUpdatesEnabled( false );
138 viewport()->setUpdatesEnabled( false ); 139 viewport()->setUpdatesEnabled( false );
139 140
140 QTime t; 141 QTime t;
141 t.start(); 142 t.start();
142 setNumRows( it.count() ); 143 setNumRows( it.count() );
143 int elc = time.elapsed(); 144 int elc = time.elapsed();
144 qWarning("Adding took %d", elc/1000 ); 145 qWarning("Adding took %d", elc/1000 );
145 setUpdatesEnabled( true ); 146 setUpdatesEnabled( true );
146 viewport()->setUpdatesEnabled( true ); 147 viewport()->setUpdatesEnabled( true );
147 viewport()->update(); 148 viewport()->update();
148 149
149 m_enablePaint = true; 150 m_enablePaint = true;
150 int el = time.elapsed(); 151 int el = time.elapsed();
151 qWarning("adding took %d", el/1000 ); 152 qWarning("adding took %d", el/1000 );
152} 153}
153void TableView::setTodo( int, const OTodo&) { 154void TableView::setTodo( int, const OTodo&) {
154 sort(); 155 sort();
155 156
156 /* repaint */ 157 /* repaint */
157 QTable::update(); 158 QTable::update();
158} 159}
159void TableView::addEvent( const OTodo&) { 160void TableView::addEvent( const OTodo&) {
160 sort(); 161 sort();
161 162
162 QTable::update(); 163 QTable::update();
163} 164}
164/* 165/*
165 * find the event 166 * find the event
166 * and then replace the complete row 167 * and then replace the complete row
167 */ 168 */
168void TableView::replaceEvent( const OTodo& ev) { 169void TableView::replaceEvent( const OTodo& ev) {
169 addEvent( ev ); 170 addEvent( ev );
170} 171}
171/* 172/*
172 * re aligning table can be slow too 173 * re aligning table can be slow too
173 * FIXME: look what performs better 174 * FIXME: look what performs better
174 * either this or the old align table 175 * either this or the old align table
175 */ 176 */
176void TableView::removeEvent( int ) { 177void TableView::removeEvent( int ) {
177 updateView(); 178 updateView();
178} 179}
179void TableView::setShowCompleted( bool b) { 180void TableView::setShowCompleted( bool b) {
180 qWarning("Show Completed %d" + b ); 181 qWarning("Show Completed %d" + b );
181 updateView(); 182 updateView();
182} 183}
183void TableView::setShowDeadline( bool b) { 184void TableView::setShowDeadline( bool b) {
184 qWarning("Show DeadLine %d" + b ); 185 qWarning("Show DeadLine %d" + b );
185 if (b) 186 if (b)
186 showColumn(3 ); 187 showColumn(3 );
187 else 188 else
188 hideColumn(3 ); 189 hideColumn(3 );
189} 190}
190void TableView::setShowCategory( const QString& ) { 191void TableView::setShowCategory( const QString& str) {
191 qWarning("setShowCategory"); 192 qWarning("setShowCategory");
192 updateView(); 193 if ( str != m_oleCat || m_first )
194 updateView();
195
196 m_oleCat = str;
197 m_first = false;
198
193} 199}
194void TableView::clear() { 200void TableView::clear() {
195 setNumRows(0); 201 setNumRows(0);
196} 202}
197void TableView::slotClicked(int row, int col, int, 203void TableView::slotClicked(int row, int col, int,
198 const QPoint& point) { 204 const QPoint& point) {
199 if ( !cellGeometry(row, col ).contains(point ) ) 205 if ( !cellGeometry(row, col ).contains(point ) )
200 return; 206 return;
201 int ui=0; // FIXME = uid(row); 207
208 int ui= sorted().uidAt( row );
202 209
203 210
204 switch( col ) { 211 switch( col ) {
205 case 0: { 212 case 0:{
206 // FIXME 213 int x = point.x() -columnPos( col );
207 CheckItem* item = 0l; 214 int y = point.y() -rowPos( row );
208 /* 215 int w = columnWidth( col );
209 * let's see if we centered clicked 216 int h = rowHeight( row );
210 */ 217 if ( x >= ( w - BoxSize ) / 2 &&
211 if ( item ) { 218 x <= ( w - BoxSize ) / 2 + BoxSize &&
212 int x = point.x() -columnPos( col ); 219 y >= ( h - BoxSize ) / 2 &&
213 int y = point.y() -rowPos( row ); 220 y <= ( h - BoxSize ) / 2 + BoxSize ) {
214 int w = columnWidth( col ); 221 OTodo todo = sorted()[row];
215 int h = rowHeight( row ); 222 todo.setCompleted( !todo.isCompleted() );
216 if ( x >= ( w - OCheckItem::BoxSize ) / 2 && 223 TodoView::update( todo.uid(), todo );
217 x <= ( w - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize && 224 updateView();
218 y >= ( h - OCheckItem::BoxSize ) / 2 && 225 }
219 y <= ( h - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize )
220 item->toggle();
221 }
222 } 226 }
223 break; 227 break;
224 228
225 case 1: 229 case 1:
226 break; 230 break;
227 231
228 case 2: { 232 case 2: {
229 m_menuTimer->stop(); 233 m_menuTimer->stop();
230 showTodo( ui ); 234 showTodo( ui );
231 break; 235 break;
232 } 236 }
233 case 3: { 237 case 3: {
234 m_menuTimer->stop(); 238 m_menuTimer->stop();
235 TodoView::edit( ui ); 239 TodoView::edit( ui );
236 break; 240 break;
237 } 241 }
238 } 242 }
239 243
240 244
241} 245}
242void TableView::slotPressed(int row, int col, int, 246void TableView::slotPressed(int row, int col, int,
243 const QPoint& point) { 247 const QPoint& point) {
244 248
245 /* TextColumn column */ 249 /* TextColumn column */
246 if ( col == 2 && cellGeometry( row, col ).contains( point ) ) 250 if ( col == 2 && cellGeometry( row, col ).contains( point ) )
247 m_menuTimer->start( 750, TRUE ); 251 m_menuTimer->start( 750, TRUE );
248} 252}
249void TableView::slotValueChanged( int, int ) { 253void TableView::slotValueChanged( int, int ) {
250 qWarning("Value Changed"); 254 qWarning("Value Changed");
251} 255}
252void TableView::slotCurrentChanged(int, int ) { 256void TableView::slotCurrentChanged(int, int ) {
253 m_menuTimer->stop(); 257 m_menuTimer->stop();
254} 258}
255QWidget* TableView::widget() { 259QWidget* TableView::widget() {
256 return this; 260 return this;
257} 261}
258/* 262/*
259 * We need to overwrite sortColumn 263 * We need to overwrite sortColumn
260 * because we want to sort whole row 264 * because we want to sort whole row
261 * based 265 * based
262 * We event want to set the setOrder 266 * We event want to set the setOrder
263 * to a sort() and update() 267 * to a sort() and update()
264 */ 268 */
265void TableView::sortColumn( int row, bool asc, bool ) { 269void TableView::sortColumn( int col, bool asc, bool ) {
266 QTable::sortColumn( row, asc, TRUE ); 270 qWarning("bool %d", asc );
267 271 setSortOrder( col );
272 setAscending( asc );
273 updateView();
268} 274}
269void TableView::viewportPaintEvent( QPaintEvent* e) { 275void TableView::viewportPaintEvent( QPaintEvent* e) {
270 qWarning("Paint event" ); 276 qWarning("Paint event" );
271 if (m_enablePaint ) 277 if (m_enablePaint )
272 QTable::viewportPaintEvent( e ); 278 QTable::viewportPaintEvent( e );
273} 279}
274/* 280/*
275 * This segment is copyrighted by TT 281 * This segment is copyrighted by TT
276 * it was taken from their todolist 282 * it was taken from their todolist
277 * application this code is GPL 283 * application this code is GPL
278 */ 284 */
279void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { 285void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
280 const QColorGroup &cg = colorGroup(); 286 const QColorGroup &cg = colorGroup();
281 287
282 p->save(); 288 p->save();
283 289
284 OTodo task = sorted()[row]; 290 OTodo task = sorted()[row];
285 291
286 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 292 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
287 293
288 QPen op = p->pen(); 294 QPen op = p->pen();
289 p->setPen(cg.mid()); 295 p->setPen(cg.mid());
290 p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); 296 p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 );
291 p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); 297 p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 );
292 p->setPen(op); 298 p->setPen(op);
293 299
294 QFont f = p->font(); 300 QFont f = p->font();
295 QFontMetrics fm(f); 301 QFontMetrics fm(f);
296 302
297 switch(col) { 303 switch(col) {
298 case 0: 304 case 0:
299 { 305 {
300 // completed field 306 // completed field
301 int marg = ( cr.width() - BoxSize ) / 2; 307 int marg = ( cr.width() - BoxSize ) / 2;
302 int x = 0; 308 int x = 0;
303 int y = ( cr.height() - BoxSize ) / 2; 309 int y = ( cr.height() - BoxSize ) / 2;
304 p->setPen( QPen( cg.text() ) ); 310 p->setPen( QPen( cg.text() ) );
305 p->drawRect( x + marg, y, BoxSize, BoxSize ); 311 p->drawRect( x + marg, y, BoxSize, BoxSize );
306 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); 312 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
307 p->setPen( darkGreen ); 313 p->setPen( darkGreen );
308 x += 1; 314 x += 1;
309 y += 1; 315 y += 1;
310 if ( task.isCompleted() ) { 316 if ( task.isCompleted() ) {
311 QPointArray a( 9*2 ); 317 QPointArray a( 9*2 );
312 int i, xx, yy; 318 int i, xx, yy;
313 xx = x+2+marg; 319 xx = x+2+marg;
314 yy = y+4; 320 yy = y+4;
315 for ( i=0; i<4; i++ ) { 321 for ( i=0; i<4; i++ ) {
316 a.setPoint( 2*i, xx, yy ); 322 a.setPoint( 2*i, xx, yy );
317 a.setPoint( 2*i+1, xx, yy+2 ); 323 a.setPoint( 2*i+1, xx, yy+2 );
318 xx++; yy++; 324 xx++; yy++;
319 } 325 }
320 yy -= 2; 326 yy -= 2;
321 for ( i=4; i<9; i++ ) { 327 for ( i=4; i<9; i++ ) {
322 a.setPoint( 2*i, xx, yy ); 328 a.setPoint( 2*i, xx, yy );
323 a.setPoint( 2*i+1, xx, yy+2 ); 329 a.setPoint( 2*i+1, xx, yy+2 );
324 xx++; yy--; 330 xx++; yy--;
325 } 331 }
326 p->drawLineSegments( a ); 332 p->drawLineSegments( a );
327 } 333 }
328 } 334 }
329 break; 335 break;
330 case 1: 336 case 1:
331 // priority field 337 // priority field
332 { 338 {
333 QString text = QString::number(task.priority()); 339 QString text = QString::number(task.priority());
334 p->drawText(2,2 + fm.ascent(), text); 340 p->drawText(2,2 + fm.ascent(), text);
335 } 341 }
336 break; 342 break;
337 case 2: 343 case 2:
338 // description field 344 // description field
339 { 345 {
340 QString text = task.summary().isEmpty() ? 346 QString text = task.summary().isEmpty() ?
341 task.description() : 347 task.description() :
342 task.summary(); 348 task.summary();
343 p->drawText(2,2 + fm.ascent(), text); 349 p->drawText(2,2 + fm.ascent(), text);
344 } 350 }
345 break; 351 break;
346 case 3: 352 case 3:
347 { 353 {
348 QString text; 354 QString text;
349 if (task.hasDueDate()) { 355 if (task.hasDueDate()) {
350 text = "HAS"; 356 text = "HAS";
351 } else { 357 } else {
352 text = tr("None"); 358 text = tr("None");
353 } 359 }
354 p->drawText(2,2 + fm.ascent(), text); 360 p->drawText(2,2 + fm.ascent(), text);
355 } 361 }
356 break; 362 break;
357 } 363 }
358 p->restore(); 364 p->restore();
359} 365}
366QWidget* TableView::createEditor(int row, int col, bool )const {
367 switch( col ) {
368 case 1: {
369 /* the priority stuff */
370 QComboBox* combo = new QComboBox( viewport() );
371 combo->insertItem( "1" );
372 combo->insertItem( "2" );
373 combo->insertItem( "3" );
374 combo->insertItem( "4" );
375 combo->insertItem( "5" );
376 combo->setCurrentItem( sorted()[row].priority()-1 );
377 return combo;
378 }
379 case 0:
380 default:
381 return 0l;
382 }
383}
384void TableView::setCellContentFromEditor(int row, int col ) {
385 if ( col == 1 ) {
386 QWidget* wid = cellWidget(row, 1 );
387 if ( wid->inherits("QComboBox") ) {
388 int pri = ((QComboBox*)wid)->currentItem() + 1;
389 OTodo todo = sorted()[row];
390 if ( todo.priority() != pri ) {
391 todo.setPriority( pri );
392 TodoView::update( todo.uid(), todo );
393 updateView();
394 }
395 }
396 }
397}
398void TableView::slotPriority() {
399 setCellContentFromEditor( currentRow(), currentColumn() );
400}
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h
index b608204..bf41aea 100644
--- a/core/pim/todo/tableview.h
+++ b/core/pim/todo/tableview.h
@@ -1,93 +1,100 @@
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  -_. . .   )=.  = 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 OPIE_TABLE_VIEW_H 29#ifndef OPIE_TABLE_VIEW_H
30#define OPIE_TABLE_VIEW_H 30#define OPIE_TABLE_VIEW_H
31 31
32#include <qtable.h> 32#include <qtable.h>
33#include <qmap.h> 33#include <qmap.h>
34 34
35#include "tableitems.h" 35#include "tableitems.h"
36#include "todoview.h" 36#include "todoview.h"
37 37
38class QTimer; 38class QTimer;
39 39
40namespace Todo { 40namespace Todo {
41 class CheckItem; 41 class CheckItem;
42 class DueTextItem; 42 class DueTextItem;
43 class TableView : public QTable, public TodoView { 43 class TableView : public QTable, public TodoView {
44 Q_OBJECT 44 Q_OBJECT
45 public: 45 public:
46 TableView( MainWindow*, QWidget* parent ); 46 TableView( MainWindow*, QWidget* parent );
47 ~TableView(); 47 ~TableView();
48 48
49 49
50 QString type()const; 50 QString type()const;
51 int current(); 51 int current();
52 QString currentRepresentation(); 52 QString currentRepresentation();
53 53
54 void clear(); 54 void clear();
55 void showOverDue( bool ); 55 void showOverDue( bool );
56 void updateView(); 56 void updateView();
57 void setTodo( int uid, const OTodo& ); 57 void setTodo( int uid, const OTodo& );
58 void addEvent( const OTodo& event ); 58 void addEvent( const OTodo& event );
59 void replaceEvent( const OTodo& ); 59 void replaceEvent( const OTodo& );
60 void removeEvent( int uid ); 60 void removeEvent( int uid );
61 void setShowCompleted( bool ); 61 void setShowCompleted( bool );
62 void setShowDeadline( bool ); 62 void setShowDeadline( bool );
63 63
64 void setShowCategory(const QString& =QString::null ); 64 void setShowCategory(const QString& =QString::null );
65 void newDay(); 65 void newDay();
66 QWidget* widget(); 66 QWidget* widget();
67 void sortColumn(int, bool, bool ); 67 void sortColumn(int, bool, bool );
68 68
69 /* 69 /*
70 * we do our drawing ourselves 70 * we do our drawing ourselves
71 * because we don't want to have 71 * because we don't want to have
72 * 40.000 QTableItems for 10.000 72 * 40.000 QTableItems for 10.000
73 * OTodos where we only show 10 at a time! 73 * OTodos where we only show 10 at a time!
74 */ 74 */
75 void paintCell(QPainter* p, int row, int col, const QRect&, bool ); 75 void paintCell(QPainter* p, int row, int col, const QRect&, bool );
76 private: 76 private:
77 /* reimplented for internal reasons */ 77 /* reimplented for internal reasons */
78 void viewportPaintEvent( QPaintEvent* ); 78 void viewportPaintEvent( QPaintEvent* );
79 QTimer *m_menuTimer; 79 QTimer *m_menuTimer;
80 bool m_enablePaint:1; 80 bool m_enablePaint:1;
81 QString m_oleCat;
82 bool m_first : 1;
83
84 protected:
85 QWidget* createEditor(int row, int col, bool initFromCell )const;
86 void setCellContentFromEditor( int row, int col );
81 87
82private slots: 88private slots:
83 void slotShowMenu(); 89 void slotShowMenu();
84 void slotClicked(int, int, int, 90 void slotClicked(int, int, int,
85 const QPoint& ); 91 const QPoint& );
86 void slotPressed(int, int, int, 92 void slotPressed(int, int, int,
87 const QPoint& ); 93 const QPoint& );
88 void slotValueChanged(int, int); 94 void slotValueChanged(int, int);
89 void slotCurrentChanged(int, int ); 95 void slotCurrentChanged(int, int );
96 void slotPriority();
90 }; 97 };
91}; 98};
92 99
93#endif 100#endif
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
index ebf9e8a..1f81539 100644
--- a/core/pim/todo/todomanager.cpp
+++ b/core/pim/todo/todomanager.cpp
@@ -1,124 +1,126 @@
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  -_. . .   )=.  = 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#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qpe/categoryselect.h> 29#include <qpe/categoryselect.h>
30 30
31#include "todomanager.h" 31#include "todomanager.h"
32 32
33using namespace Todo; 33using namespace Todo;
34 34
35TodoManager::TodoManager( QObject *obj ) 35TodoManager::TodoManager( QObject *obj )
36 : QObject( obj ) { 36 : QObject( obj ) {
37 m_db = 0l; 37 m_db = 0l;
38 QTime time; 38 QTime time;
39 time.start(); 39 time.start();
40 int el = time.elapsed(); 40 int el = time.elapsed();
41 qWarning("QTimer for loading %d", el/1000 ); 41 qWarning("QTimer for loading %d", el/1000 );
42} 42}
43TodoManager::~TodoManager() { 43TodoManager::~TodoManager() {
44 delete m_db; 44 delete m_db;
45} 45}
46OTodo TodoManager::event(int uid ) { 46OTodo TodoManager::event(int uid ) {
47 return m_db->find( uid ); 47 return m_db->find( uid );
48} 48}
49void TodoManager::updateList() { 49void TodoManager::updateList() {
50 qWarning("update list");
50 m_list = m_db->allRecords(); 51 m_list = m_db->allRecords();
51} 52}
52OTodoAccess::List TodoManager::list() const{ 53OTodoAccess::List TodoManager::list() const{
53 return m_list; 54 return m_list;
54} 55}
55OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { 56OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) {
56 return m_db->sorted( asc, so, f, cat ); 57 return m_db->sorted( asc, so, f, cat );
57} 58}
58OTodoAccess::List::Iterator TodoManager::overDue() { 59OTodoAccess::List::Iterator TodoManager::overDue() {
59 int filter = 2 | 1; 60 int filter = 2 | 1;
60 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); 61 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca );
61 m_it = m_list.begin(); 62 m_it = m_list.begin();
62 return m_it; 63 return m_it;
63} 64}
64OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, 65OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start,
65 const QDate& end ) { 66 const QDate& end ) {
66 m_list = m_db->effectiveToDos( start, end ); 67 m_list = m_db->effectiveToDos( start, end );
67 m_it = m_list.begin(); 68 m_it = m_list.begin();
68 return m_it; 69 return m_it;
69} 70}
70OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) { 71OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) {
71 m_list = m_db->queryByExample( ev, query ); 72 m_list = m_db->queryByExample( ev, query );
72 m_it = m_list.begin(); 73 m_it = m_list.begin();
73 return m_it; 74 return m_it;
74} 75}
75OTodoAccess* TodoManager::todoDB() { 76OTodoAccess* TodoManager::todoDB() {
76 return m_db; 77 return m_db;
77} 78}
78void TodoManager::add( const OTodo& ev ) { 79void TodoManager::add( const OTodo& ev ) {
79 m_db->add( ev ); 80 m_db->add( ev );
80} 81}
81void TodoManager::update( int, const SmallTodo& ) { 82void TodoManager::update( int, const SmallTodo& ) {
82 83
83} 84}
84void TodoManager::update( int, const OTodo& ev) { 85void TodoManager::update( int, const OTodo& ev) {
85 m_db->replace( ev ); 86 m_db->replace( ev );
86} 87}
87void TodoManager::remove( int uid ) { 88void TodoManager::remove( int uid ) {
88 m_db->remove( uid ); 89 m_db->remove( uid );
89} 90}
90void TodoManager::removeAll() { 91void TodoManager::removeAll() {
91 m_db->clear(); 92 m_db->clear();
92} 93}
93void TodoManager::save() { 94void TodoManager::save() {
94 m_db->save(); 95 m_db->save();
95} 96}
96bool TodoManager::saveAll() { 97bool TodoManager::saveAll() {
97 return m_db->save(); 98 return m_db->save();
98} 99}
99void TodoManager::reload() { 100void TodoManager::reload() {
100 m_db->reload(); 101 m_db->reload();
101} 102}
102QStringList TodoManager::categories() { 103QStringList TodoManager::categories() {
103 m_cat.load(categoryFileName() ); 104 m_cat.load(categoryFileName() );
104 return m_cat.labels( "Todo List"); 105 return m_cat.labels( "Todo List");
105} 106}
106/* 107/*
107 * we rely on load beeing called from populateCategories 108 * we rely on load beeing called from populateCategories
108 */ 109 */
109int TodoManager::catId( const QString& cats ) { 110int TodoManager::catId( const QString& cats ) {
110 return m_cat.id( "Todo List", cats ); 111 return m_cat.id( "Todo List", cats );
111} 112}
112void TodoManager::remove( const QArray<int>& ids) { 113void TodoManager::remove( const QArray<int>& ids) {
113 for (uint i=0; i < ids.size(); i++ ) 114 for (uint i=0; i < ids.size(); i++ )
114 remove( ids[i] ); 115 remove( ids[i] );
115} 116}
116bool TodoManager::isLoaded()const { 117bool TodoManager::isLoaded()const {
117 return (m_db == 0 ); 118 return (m_db == 0 );
118} 119}
119void TodoManager::load() { 120void TodoManager::load() {
120 if (!m_db) { 121 if (!m_db) {
122 qWarning("loading!");
121 m_db = new OTodoAccess(); 123 m_db = new OTodoAccess();
122 m_db->load(); 124 m_db->load();
123 } 125 }
124} 126}
diff --git a/core/pim/todo/todoview.cpp b/core/pim/todo/todoview.cpp
index 06eaaa9..639fa66 100644
--- a/core/pim/todo/todoview.cpp
+++ b/core/pim/todo/todoview.cpp
@@ -1,78 +1,79 @@
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
7TodoView::TodoView( MainWindow* win ) 7TodoView::TodoView( MainWindow* win )
8 : m_main( win ) 8 : m_main( win )
9{ 9{
10 hack = new InternQtHack; 10 hack = new InternQtHack;
11 m_asc = false; 11 m_asc = false;
12 m_sortOrder = -1; 12 m_sortOrder = -1;
13} 13}
14TodoView::~TodoView() { 14TodoView::~TodoView() {
15 delete hack; 15 delete hack;
16}; 16};
17 17
18void TodoView::connectShow(QObject* obj, 18void TodoView::connectShow(QObject* obj,
19 const char* slot ) { 19 const char* slot ) {
20 QObject::connect( hack, SIGNAL(showTodo(int) ), 20 QObject::connect( hack, SIGNAL(showTodo(int) ),
21 obj, slot ); 21 obj, slot );
22} 22}
23void TodoView::connectEdit( QObject* obj, 23void TodoView::connectEdit( QObject* obj,
24 const char* slot ) { 24 const char* slot ) {
25 QObject::connect( hack, SIGNAL(edit(int) ), 25 QObject::connect( hack, SIGNAL(edit(int) ),
26 obj, slot ); 26 obj, slot );
27} 27}
28void TodoView::connectUpdateSmall( QObject* obj, 28void TodoView::connectUpdateSmall( QObject* obj,
29 const char* slot ) { 29 const char* slot ) {
30 QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ), 30 QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ),
31 obj, slot ); 31 obj, slot );
32} 32}
33void TodoView::connectUpdateBig( QObject* obj, 33void TodoView::connectUpdateBig( QObject* obj,
34 const char* slot ) { 34 const char* slot ) {
35 QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ), 35 QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ),
36 obj, slot ); 36 obj, slot );
37} 37}
38void TodoView::connectUpdateView( QObject* obj, 38void TodoView::connectUpdateView( QObject* obj,
39 const char* slot ) { 39 const char* slot ) {
40 QObject::connect( hack, SIGNAL(update(QWidget*) ), 40 QObject::connect( hack, SIGNAL(update(QWidget*) ),
41 obj, slot ); 41 obj, slot );
42} 42}
43void TodoView::connectRemove( QObject* obj, 43void TodoView::connectRemove( QObject* obj,
44 const char* slot ) { 44 const char* slot ) {
45 QObject::connect( hack, SIGNAL(remove(int) ), 45 QObject::connect( hack, SIGNAL(remove(int) ),
46 obj, slot ); 46 obj, slot );
47} 47}
48MainWindow* TodoView::todoWindow() { 48MainWindow* TodoView::todoWindow() {
49 return m_main; 49 return m_main;
50} 50}
51 51
52OTodo TodoView::event(int uid ) { return m_main->event( uid ); } 52OTodo TodoView::event(int uid ) { return m_main->event( uid ); }
53OTodoAccess::List TodoView::list(){ 53OTodoAccess::List TodoView::list(){
54 todoWindow()->updateList(); 54 todoWindow()->updateList();
55 return todoWindow()->list(); 55 return todoWindow()->list();
56} 56}
57OTodoAccess::List TodoView::sorted(){ 57OTodoAccess::List TodoView::sorted()const{
58 return m_sort; 58 return m_sort;
59} 59}
60void TodoView::sort() { 60void TodoView::sort() {
61 m_sort = todoWindow()->sorted(m_asc,m_sortOrder ); 61 m_sort = todoWindow()->sorted(m_asc,m_sortOrder );
62 qWarning("m_sort.count() = %d", m_sort.count() ); 62 qWarning("m_sort.count() = %d", m_sort.count() );
63} 63}
64void TodoView::sort(int sort) { 64void TodoView::sort(int sort) {
65 m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort ); 65 m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort );
66} 66}
67void TodoView::setSortOrder( int order ) { 67void TodoView::setSortOrder( int order ) {
68 m_sortOrder = order; 68 m_sortOrder = order;
69} 69}
70void TodoView::setAscending( bool b ) { 70void TodoView::setAscending( bool b ) {
71 qWarning("setAscending %d", b );
71 m_asc = b; 72 m_asc = b;
72} 73}
73void TodoView::update(int uid, const SmallTodo& to ) { 74void TodoView::update(int uid, const SmallTodo& to ) {
74 //m_main->slotUpate1( uid, to ); 75 //m_main->slotUpate1( uid, to );
75} 76}
76void TodoView::update(int uid, const OTodo& ev ) { 77void TodoView::update(int uid, const OTodo& ev ) {
77 m_main->updateTodo( ev ); 78 m_main->updateTodo( ev );
78} 79}
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h
index 9408ef1..e5c77f9 100644
--- a/core/pim/todo/todoview.h
+++ b/core/pim/todo/todoview.h
@@ -64,125 +64,125 @@ namespace Todo {
64 void emitRemove( int uid ) { 64 void emitRemove( int uid ) {
65 emit remove( uid ); 65 emit remove( uid );
66 } 66 }
67 void emitUpdate( QWidget* wid ) { 67 void emitUpdate( QWidget* wid ) {
68 emit update( wid ); 68 emit update( wid );
69 } 69 }
70 signals: 70 signals:
71 void showTodo(int uid ); 71 void showTodo(int uid );
72 void edit(int uid ); 72 void edit(int uid );
73 void update( int uid, const Todo::SmallTodo& ); 73 void update( int uid, const Todo::SmallTodo& );
74 void update( int uid, const OTodo& ); 74 void update( int uid, const OTodo& );
75 /* sorry you need to cast */; 75 /* sorry you need to cast */;
76 void update( QWidget* wid ); 76 void update( QWidget* wid );
77 void remove( int uid ); 77 void remove( int uid );
78 78
79 }; 79 };
80 class MainWindow; 80 class MainWindow;
81 81
82 /** 82 /**
83 * due to inheretince problems we need this base class 83 * due to inheretince problems we need this base class
84 */ 84 */
85 class ViewBase { 85 class ViewBase {
86 public: 86 public:
87 virtual QWidget* widget() = 0; 87 virtual QWidget* widget() = 0;
88 virtual QString type()const = 0; 88 virtual QString type()const = 0;
89 virtual int current() = 0; 89 virtual int current() = 0;
90 virtual QString currentRepresentation() = 0; 90 virtual QString currentRepresentation() = 0;
91 virtual void showOverDue( bool ) = 0; 91 virtual void showOverDue( bool ) = 0;
92 92
93 /* 93 /*
94 * update the view 94 * update the view
95 */ 95 */
96 virtual void updateView() = 0; 96 virtual void updateView() = 0;
97 97
98 virtual void addEvent( const OTodo& ) = 0; 98 virtual void addEvent( const OTodo& ) = 0;
99 virtual void replaceEvent( const OTodo& ) = 0; 99 virtual void replaceEvent( const OTodo& ) = 0;
100 virtual void removeEvent( int uid ) = 0; 100 virtual void removeEvent( int uid ) = 0;
101 virtual void setShowCompleted( bool ) = 0; 101 virtual void setShowCompleted( bool ) = 0;
102 virtual void setShowDeadline( bool ) = 0; 102 virtual void setShowDeadline( bool ) = 0;
103 virtual void setShowCategory( const QString& = QString::null ) = 0; 103 virtual void setShowCategory( const QString& = QString::null ) = 0;
104 virtual void clear() = 0; 104 virtual void clear() = 0;
105/* virtual QArray<int> completed() = 0; */ 105/* virtual QArray<int> completed() = 0; */
106 virtual void newDay() = 0; 106 virtual void newDay() = 0;
107 107
108 virtual void connectShow( QObject*, const char* ) = 0; 108 virtual void connectShow( QObject*, const char* ) = 0;
109 virtual void connectEdit( QObject*, const char* ) = 0; 109 virtual void connectEdit( QObject*, const char* ) = 0;
110 virtual void connectUpdateSmall( QObject*, const char* ) = 0; 110 virtual void connectUpdateSmall( QObject*, const char* ) = 0;
111 virtual void connectUpdateBig( QObject*, const char* ) = 0; 111 virtual void connectUpdateBig( QObject*, const char* ) = 0;
112 virtual void connectUpdateView( QObject*, const char*) = 0; 112 virtual void connectUpdateView( QObject*, const char*) = 0;
113 virtual void connectRemove( QObject*, const char* ) = 0; 113 virtual void connectRemove( QObject*, const char* ) = 0;
114 114
115 }; 115 };
116 116
117 /** 117 /**
118 * A base class for all TodoView which are showing 118 * A base class for all TodoView which are showing
119 * a list of todos. 119 * a list of todos.
120 * Either in a QTable, QListView or any other QWidget 120 * Either in a QTable, QListView or any other QWidget
121 * derived class 121 * derived class
122 * Through the MainWindow( dispatcher ) one can access 122 * Through the MainWindow( dispatcher ) one can access
123 * the relevant informations 123 * the relevant informations
124 * 124 *
125 * It's not possible to have signal and slots from within 125 * It's not possible to have signal and slots from within
126 * templates this way you've to register for a signal 126 * templates this way you've to register for a signal
127 */ 127 */
128 class TodoView : public ViewBase{ 128 class TodoView : public ViewBase{
129 129
130 public: 130 public:
131 /** 131 /**
132 * c'tor 132 * c'tor
133 */ 133 */
134 TodoView( MainWindow* win ); 134 TodoView( MainWindow* win );
135 135
136 /** 136 /**
137 *d'tor 137 *d'tor
138 */ 138 */
139 virtual ~TodoView(); 139 virtual ~TodoView();
140 140
141 /* connect to the show signal */ 141 /* connect to the show signal */
142 void connectShow(QObject* obj, 142 void connectShow(QObject* obj,
143 const char* slot ); 143 const char* slot );
144 144
145 /* connect to edit */ 145 /* connect to edit */
146 void connectEdit( QObject* obj, 146 void connectEdit( QObject* obj,
147 const char* slot ); 147 const char* slot );
148 void connectUpdateSmall( QObject* obj, 148 void connectUpdateSmall( QObject* obj,
149 const char* slot ); 149 const char* slot );
150 void connectUpdateBig( QObject* obj, 150 void connectUpdateBig( QObject* obj,
151 const char* slot ) ; 151 const char* slot ) ;
152 void connectUpdateView( QObject* obj, 152 void connectUpdateView( QObject* obj,
153 const char* slot ); 153 const char* slot );
154 void connectRemove( QObject* obj, 154 void connectRemove( QObject* obj,
155 const char* slot ); 155 const char* slot );
156 protected: 156 protected:
157 MainWindow* todoWindow(); 157 MainWindow* todoWindow();
158 OTodo event(int uid ); 158 OTodo event(int uid );
159 OTodoAccess::List list(); 159 OTodoAccess::List list();
160 OTodoAccess::List sorted(); 160 OTodoAccess::List sorted()const;
161 void sort(); 161 void sort();
162 void sort(int sort ); 162 void sort(int sort );
163 void setSortOrder( int order ); 163 void setSortOrder( int order );
164 void setAscending( bool ); 164 void setAscending( bool );
165 165
166 /* 166 /*
167 These things needs to be implemented 167 These things needs to be implemented
168 in a implementation 168 in a implementation
169 signals: 169 signals:
170 */ 170 */
171 protected: 171 protected:
172 void showTodo( int uid ) { hack->emitShow(uid); } 172 void showTodo( int uid ) { hack->emitShow(uid); }
173 void edit( int uid ) { hack->emitEdit(uid); } 173 void edit( int uid ) { hack->emitEdit(uid); }
174 void update(int uid, const SmallTodo& to ); 174 void update(int uid, const SmallTodo& to );
175 void update(int uid, const OTodo& ev); 175 void update(int uid, const OTodo& ev);
176 void remove( int uid ) { 176 void remove( int uid ) {
177 hack->emitRemove( uid ); 177 hack->emitRemove( uid );
178 } 178 }
179 private: 179 private:
180 InternQtHack* hack; 180 InternQtHack* hack;
181 MainWindow *m_main; 181 MainWindow *m_main;
182 OTodoAccess::List m_sort; 182 OTodoAccess::List m_sort;
183 bool m_asc : 1; 183 bool m_asc : 1;
184 int m_sortOrder; 184 int m_sortOrder;
185 }; 185 };
186}; 186};
187 187
188#endif 188#endif