author | zecke <zecke> | 2002-11-30 11:20:47 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-11-30 11:20:47 (UTC) |
commit | fdda15344fdf7f71fd9e1e4db15ecc5e12224ddb (patch) (unidiff) | |
tree | 32e68b5b483dd3ce8041542e7d95f0b6d8dbf644 | |
parent | bd692f7ebe04e23151cce39baf311b925ccf91b1 (diff) | |
download | opie-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
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 213 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 24 | ||||
-rw-r--r-- | core/pim/todo/otaskeditor.cpp | 35 | ||||
-rw-r--r-- | core/pim/todo/otaskeditor.h | 5 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 27 | ||||
-rw-r--r-- | core/pim/todo/taskeditoradvanced.ui | 8 | ||||
-rw-r--r-- | core/pim/todo/taskeditoroverviewimpl.cpp | 55 | ||||
-rw-r--r-- | core/pim/todo/taskeditoroverviewimpl.h | 1 | ||||
-rw-r--r-- | core/pim/todo/todo.pro | 6 | ||||
-rw-r--r-- | core/pim/todo/todomanager.cpp | 7 | ||||
-rw-r--r-- | core/pim/todo/todomanager.h | 7 | ||||
-rw-r--r-- | core/pim/todo/todoview.cpp | 55 | ||||
-rw-r--r-- | core/pim/todo/todoview.h | 82 |
13 files changed, 310 insertions, 215 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 | |||
@@ -39,32 +39,35 @@ | |||
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 | ||
59 | using namespace Todo; | 60 | using namespace Todo; |
60 | 61 | ||
61 | MainWindow::MainWindow( QWidget* parent, | 62 | MainWindow::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(); |
@@ -172,23 +175,20 @@ void MainWindow::initActions() { | |||
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 */ |
194 | void MainWindow::initConfig() { | 194 | void MainWindow::initConfig() { |
@@ -215,17 +215,16 @@ void MainWindow::initUI() { | |||
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) ) ); |
@@ -249,46 +248,45 @@ void MainWindow::initEditor() { | |||
249 | void MainWindow::initShow() { | 248 | void 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 | } |
253 | MainWindow::~MainWindow() { | 252 | MainWindow::~MainWindow() { |
254 | delete templateManager(); | 253 | delete templateManager(); |
255 | } | 254 | } |
256 | void MainWindow::connectBase( ViewBase* base) { | 255 | void 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, | 258 | QPopupMenu* 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 | } | ||
267 | QPopupMenu* 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 | } |
277 | QPopupMenu* MainWindow::options() { | 278 | QPopupMenu* MainWindow::options() { |
278 | qWarning("Options"); | 279 | qWarning("Options"); |
279 | return m_options; | 280 | return m_options; |
280 | } | 281 | } |
281 | QPopupMenu* MainWindow::edit() { | 282 | QPopupMenu* MainWindow::edit() { |
282 | return m_edit; | 283 | return m_edit; |
283 | } | 284 | } |
284 | QPopupMenu* MainWindow::view() { | ||
285 | return m_view; | ||
286 | } | ||
287 | QToolBar* MainWindow::toolbar() { | 285 | QToolBar* MainWindow::toolbar() { |
288 | return m_tool; | 286 | return m_tool; |
289 | } | 287 | } |
290 | OTodoAccess::List MainWindow::list()const { | 288 | OTodoAccess::List MainWindow::list()const { |
291 | return m_todoMgr.list(); | 289 | return m_todoMgr.list(); |
292 | } | 290 | } |
293 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 291 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
294 | int cat = 0; | 292 | int cat = 0; |
@@ -408,38 +406,17 @@ void MainWindow::slotNewFromTemplate( int id ) { | |||
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 | } |
415 | void MainWindow::slotNew() { | 413 | void 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 | } |
439 | void MainWindow::slotDuplicate() { | 416 | void 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() ); |
@@ -469,17 +446,16 @@ void MainWindow::slotDelete() { | |||
469 | } | 446 | } |
470 | void MainWindow::slotDeleteAll() { | 447 | void 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(); |
@@ -489,18 +465,18 @@ void MainWindow::slotDeleteCompleted() { | |||
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 | } |
501 | void MainWindow::slotFind() { | 477 | void MainWindow::slotFind() { |
502 | 478 | ||
503 | } | 479 | } |
504 | void MainWindow::slotEdit() { | 480 | void MainWindow::slotEdit() { |
505 | slotEdit( currentView()->current() ); | 481 | slotEdit( currentView()->current() ); |
506 | } | 482 | } |
@@ -547,28 +523,17 @@ void MainWindow::setDocument( const QString& 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 | ||
553 | static const char *beamfile = "/tmp/opie-todo.vcs"; | 529 | static const char *beamfile = "/tmp/opie-todo.vcs"; |
554 | void MainWindow::slotBeam() { | 530 | void 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 | } |
568 | void MainWindow::beamDone( Ir* ir) { | 533 | void MainWindow::beamDone( Ir* ir) { |
569 | delete ir; | 534 | delete ir; |
570 | ::unlink( beamfile ); | 535 | ::unlink( beamfile ); |
571 | } | 536 | } |
572 | void MainWindow::receiveFile( const QString& filename ) { | 537 | void 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 ); |
@@ -699,8 +664,142 @@ void MainWindow::slotQuickEntered() { | |||
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 | } |
704 | QuickEditBase* MainWindow::quickEditor() { | 669 | QuickEditBase* MainWindow::quickEditor() { |
705 | return m_curQuick; | 670 | return m_curQuick; |
706 | } | 671 | } |
672 | void MainWindow::slotComplete( int uid ) { | ||
673 | slotComplete( event(uid) ); | ||
674 | } | ||
675 | void 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 | } | ||
727 | void MainWindow::flush() { | ||
728 | slotFlush(); | ||
729 | } | ||
730 | void MainWindow::reload() { | ||
731 | slotReload(); | ||
732 | } | ||
733 | int 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... */ | ||
762 | bool MainWindow::remove( int uid ) { | ||
763 | if (m_syncing) return false; | ||
764 | |||
765 | return m_todoMgr.remove( uid ); | ||
766 | } | ||
767 | void 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 | } | ||
780 | void MainWindow::show( int uid ) { | ||
781 | slotShow( uid ); | ||
782 | } | ||
783 | void MainWindow::edit( int uid ) { | ||
784 | slotEdit( uid ); | ||
785 | } | ||
786 | void 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 | */ | ||
803 | OPimRecord* 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 | |||
@@ -25,20 +25,20 @@ | |||
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 | ||
43 | class QPopupMenu; | 43 | class QPopupMenu; |
44 | class QMenuBar; | 44 | class QMenuBar; |
@@ -51,28 +51,28 @@ class QVBox; | |||
51 | namespace Todo { | 51 | namespace 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 | ||
@@ -131,17 +131,16 @@ private slots: | |||
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; |
@@ -156,21 +155,23 @@ private slots: | |||
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); |
164 | private 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 ); |
@@ -180,12 +181,23 @@ private slots: | |||
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,17 +1,18 @@ | |||
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 | ||
14 | OTaskEditor::OTaskEditor(int cur) | 15 | OTaskEditor::OTaskEditor(int cur) |
15 | : QDialog(0, 0, TRUE ) { | 16 | : QDialog(0, 0, TRUE ) { |
16 | init(); | 17 | init(); |
17 | init( cur ); | 18 | init( cur ); |
@@ -35,57 +36,65 @@ void OTaskEditor::init( const OTodo& to ) { | |||
35 | load( to ); | 36 | load( to ); |
36 | m_uid = to.uid(); | 37 | m_uid = to.uid(); |
37 | } | 38 | } |
38 | OTodo OTaskEditor::todo()const{ | 39 | OTodo 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 | } |
47 | void OTaskEditor::load(const OTodo& to) { | 49 | void 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 | } |
51 | void OTaskEditor::init() { | 54 | void 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 | |||
@@ -2,17 +2,17 @@ | |||
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 | ||
9 | class TaskEditorOverViewImpl; | 9 | class TaskEditorOverViewImpl; |
10 | class TaskEditorAdvanced; | 10 | class TaskEditorAdvancedImpl; |
11 | class TaskEditorAlarms; | 11 | class TaskEditorAlarms; |
12 | class ORecurranceWidget; | 12 | class ORecurranceWidget; |
13 | class QMultiLineEdit; | 13 | class QMultiLineEdit; |
14 | class OTaskEditor : public QDialog { | 14 | class OTaskEditor : public QDialog { |
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | public: | 16 | public: |
17 | OTaskEditor(int cur); | 17 | OTaskEditor(int cur); |
18 | OTaskEditor( const OTodo& todo ); | 18 | OTaskEditor( const OTodo& todo ); |
@@ -27,18 +27,17 @@ public: | |||
27 | 27 | ||
28 | OTodo todo()const; | 28 | OTodo todo()const; |
29 | private: | 29 | private: |
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 | |||
@@ -30,16 +30,18 @@ | |||
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 | ||
42 | using namespace Todo; | 44 | using namespace Todo; |
43 | 45 | ||
44 | namespace { | 46 | namespace { |
45 | static const int BoxSize = 14; | 47 | static const int BoxSize = 14; |
@@ -115,42 +117,43 @@ TableView::TableView( MainWindow* window, QWidget* wid ) | |||
115 | void TableView::newDay() { | 117 | void TableView::newDay() { |
116 | clear(); | 118 | clear(); |
117 | updateView(); | 119 | updateView(); |
118 | } | 120 | } |
119 | TableView::~TableView() { | 121 | TableView::~TableView() { |
120 | 122 | ||
121 | } | 123 | } |
122 | void TableView::slotShowMenu() { | 124 | void 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 | } |
127 | QString TableView::type() const { | 129 | QString TableView::type() const { |
128 | return QString::fromLatin1( tr("Table View") ); | 130 | return QString::fromLatin1( tr("Table View") ); |
129 | } | 131 | } |
130 | int TableView::current() { | 132 | int 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 | } |
135 | QString TableView::currentRepresentation() { | 137 | QString 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 */ |
139 | void TableView::showOverDue( bool ) { | 142 | void TableView::showOverDue( bool ) { |
140 | clear(); | 143 | clear(); |
141 | updateView(); | 144 | updateView(); |
142 | } | 145 | } |
143 | 146 | ||
144 | void TableView::updateView( ) { | 147 | void 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(); |
@@ -237,20 +240,17 @@ void TableView::slotClicked(int row, int col, int, | |||
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: { |
@@ -364,17 +364,17 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool | |||
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()) { |
@@ -457,17 +457,17 @@ void TableView::slotPriority() { | |||
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 | */ |
464 | void TableView::timerEvent( QTimerEvent* ev ) { | 464 | void 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]; |
@@ -508,20 +508,17 @@ void TableView::timerEvent( QTimerEvent* ev ) { | |||
508 | */ | 508 | */ |
509 | void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { | 509 | void 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() ); | 517 | return; |
518 | TodoView::update( todo.uid(), todo ); | ||
519 | updateView(); | ||
520 | return; | ||
521 | } | 518 | } |
522 | QTable::contentsMouseReleaseEvent( e ); | 519 | QTable::contentsMouseReleaseEvent( e ); |
523 | } | 520 | } |
524 | void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { | 521 | void 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 | |||
@@ -6,17 +6,17 @@ | |||
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> |
@@ -190,16 +190,22 @@ | |||
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> |
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 | |||
@@ -2,70 +2,107 @@ | |||
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 | ||
16 | TaskEditorOverViewImpl::TaskEditorOverViewImpl( QWidget* parent, const char* name ) | 18 | TaskEditorOverViewImpl::TaskEditorOverViewImpl( QWidget* parent, const char* name ) |
17 | : TaskEditorOverView( parent, name ) { | 19 | : TaskEditorOverView( parent, name ) { |
18 | init(); | 20 | init(); |
19 | } | 21 | } |
20 | TaskEditorOverViewImpl::~TaskEditorOverViewImpl() { | 22 | TaskEditorOverViewImpl::~TaskEditorOverViewImpl() { |
21 | } | 23 | } |
22 | void TaskEditorOverViewImpl::load( const OTodo& todo) { | 24 | void 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() ); |
38 | btnStart->setText( str ); | 42 | |
39 | 43 | ||
40 | ckbComp->setChecked( FALSE ); | 44 | ckbStart->setChecked( todo.hasStartDate() ); |
41 | btnComp->setText( str ); | 45 | btnStart->setEnabled( todo.hasStartDate() ); |
46 | if ( todo.hasStartDate() ) { | ||
47 | m_start = todo.startDate(); | ||
48 | btnStart->setText( TimeString::longDateString( m_start ) ); | ||
49 | } else | ||
50 | btnStart->setText( str ); | ||
51 | |||
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 | ||
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 | } |
57 | void TaskEditorOverViewImpl::save( OTodo& to) { | 75 | void 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 ); |
@@ -131,21 +168,23 @@ void TaskEditorOverViewImpl::slotStartChecked() { | |||
131 | btnStart->setEnabled( ckbStart->isChecked() ); | 168 | btnStart->setEnabled( ckbStart->isChecked() ); |
132 | } | 169 | } |
133 | void TaskEditorOverViewImpl::slotStartChanged(int y, int m, int d) { | 170 | void 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 | } |
137 | void TaskEditorOverViewImpl::slotDueChecked() { | 174 | void 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 | } |
141 | void TaskEditorOverViewImpl::slotDueChanged(int y, int m, int d ) { | 179 | void 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 | } |
145 | void TaskEditorOverViewImpl::slotCompletedChecked() { | 184 | void TaskEditorOverViewImpl::slotCompletedChecked() { |
146 | btnComp->setEnabled( ckbComp->isChecked() ); | 185 | btnComp->setEnabled( ckbComp->isChecked() ); |
147 | qWarning("slotCompletedChecked"); | 186 | qWarning("slotCompletedChecked"); |
148 | } | 187 | } |
149 | void TaskEditorOverViewImpl::slotCompletedChanged(int y, int m, int d) { | 188 | void 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 ) ); |
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 | |||
@@ -15,16 +15,17 @@ class TaskEditorOverViewImpl : public TaskEditorOverView { | |||
15 | public: | 15 | public: |
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& ); |
21 | signals: | 21 | signals: |
22 | void recurranceEnabled( bool ); | 22 | void recurranceEnabled( bool ); |
23 | void dueDateChanged( const QDate& date ); | ||
23 | 24 | ||
24 | private: | 25 | private: |
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; |
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 | |||
@@ -13,17 +13,18 @@ HEADERS = smalltodo.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 \ |
@@ -32,17 +33,18 @@ SOURCES = smalltodo.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 |
44 | INCLUDEPATH += $(OPIEDIR)/include | 46 | INCLUDEPATH += $(OPIEDIR)/include |
45 | DEPENDPATH+= $(OPIEDIR)/include | 47 | DEPENDPATH+= $(OPIEDIR)/include |
46 | LIBS += -lqpe -lopie | 48 | LIBS += -lqpe -lopie |
47 | 49 | ||
48 | TRANSLATIONS = ../../../i18n/de/todolist.ts \ | 50 | TRANSLATIONS = ../../../i18n/de/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 | |||
@@ -80,22 +80,25 @@ void TodoManager::add( const OTodo& ev ) { | |||
80 | m_db->add( ev ); | 80 | m_db->add( ev ); |
81 | } | 81 | } |
82 | void TodoManager::update( int, const SmallTodo& ) { | 82 | void TodoManager::update( int, const SmallTodo& ) { |
83 | 83 | ||
84 | } | 84 | } |
85 | void TodoManager::update( int, const OTodo& ev) { | 85 | void TodoManager::update( int, const OTodo& ev) { |
86 | m_db->replace( ev ); | 86 | m_db->replace( ev ); |
87 | } | 87 | } |
88 | void TodoManager::remove( int uid ) { | 88 | bool TodoManager::remove( int uid ) { |
89 | m_db->remove( uid ); | 89 | return m_db->remove( uid ); |
90 | } | 90 | } |
91 | void TodoManager::removeAll() { | 91 | void TodoManager::removeAll() { |
92 | m_db->clear(); | 92 | m_db->clear(); |
93 | } | 93 | } |
94 | void TodoManager::removeCompleted() { | ||
95 | m_db->removeAllCompleted(); | ||
96 | } | ||
94 | void TodoManager::save() { | 97 | void TodoManager::save() { |
95 | m_db->save(); | 98 | m_db->save(); |
96 | } | 99 | } |
97 | bool TodoManager::saveAll() { | 100 | bool TodoManager::saveAll() { |
98 | return m_db->save(); | 101 | return m_db->save(); |
99 | } | 102 | } |
100 | void TodoManager::reload() { | 103 | void TodoManager::reload() { |
101 | m_db->reload(); | 104 | m_db->reload(); |
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 | |||
@@ -77,18 +77,23 @@ namespace Todo { | |||
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; |
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,60 +1,32 @@ | |||
1 | #include "mainwindow.h" | 1 | #include "mainwindow.h" |
2 | 2 | ||
3 | #include "todoview.h" | 3 | #include "todoview.h" |
4 | 4 | ||
5 | using namespace Todo; | 5 | using namespace Todo; |
6 | 6 | ||
7 | |||
8 | |||
9 | |||
7 | TodoView::TodoView( MainWindow* win ) | 10 | TodoView::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 | } |
14 | TodoView::~TodoView() { | 16 | TodoView::~TodoView() { |
15 | delete hack; | ||
16 | }; | 17 | }; |
17 | |||
18 | void TodoView::connectShow(QObject* obj, | ||
19 | const char* slot ) { | ||
20 | QObject::connect( hack, SIGNAL(showTodo(int) ), | ||
21 | obj, slot ); | ||
22 | } | ||
23 | void TodoView::connectEdit( QObject* obj, | ||
24 | const char* slot ) { | ||
25 | QObject::connect( hack, SIGNAL(edit(int) ), | ||
26 | obj, slot ); | ||
27 | } | ||
28 | void TodoView::connectUpdateSmall( QObject* obj, | ||
29 | const char* slot ) { | ||
30 | QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ), | ||
31 | obj, slot ); | ||
32 | } | ||
33 | void TodoView::connectUpdateBig( QObject* obj, | ||
34 | const char* slot ) { | ||
35 | QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ), | ||
36 | obj, slot ); | ||
37 | } | ||
38 | void TodoView::connectUpdateView( QObject* obj, | ||
39 | const char* slot ) { | ||
40 | QObject::connect( hack, SIGNAL(update(QWidget*) ), | ||
41 | obj, slot ); | ||
42 | } | ||
43 | void TodoView::connectRemove( QObject* obj, | ||
44 | const char* slot ) { | ||
45 | QObject::connect( hack, SIGNAL(remove(int) ), | ||
46 | obj, slot ); | ||
47 | } | ||
48 | MainWindow* TodoView::todoWindow() { | 18 | MainWindow* TodoView::todoWindow() { |
49 | return m_main; | 19 | return m_main; |
50 | } | 20 | } |
51 | 21 | ||
52 | OTodo TodoView::event(int uid ) { return m_main->event( uid ); } | 22 | OTodo TodoView::event(int uid ) { |
23 | return m_main->event( uid ); | ||
24 | } | ||
53 | OTodoAccess::List TodoView::list(){ | 25 | OTodoAccess::List TodoView::list(){ |
54 | todoWindow()->updateList(); | 26 | todoWindow()->updateList(); |
55 | return todoWindow()->list(); | 27 | return todoWindow()->list(); |
56 | } | 28 | } |
57 | OTodoAccess::List TodoView::sorted()const{ | 29 | OTodoAccess::List TodoView::sorted()const{ |
58 | return m_sort; | 30 | return m_sort; |
59 | } | 31 | } |
60 | void TodoView::sort() { | 32 | void TodoView::sort() { |
@@ -72,8 +44,23 @@ void TodoView::setAscending( bool b ) { | |||
72 | m_asc = b; | 44 | m_asc = b; |
73 | } | 45 | } |
74 | void TodoView::update(int, const SmallTodo& ) { | 46 | void TodoView::update(int, const SmallTodo& ) { |
75 | //m_main->slotUpate1( uid, to ); | 47 | //m_main->slotUpate1( uid, to ); |
76 | } | 48 | } |
77 | void TodoView::update(int , const OTodo& ev ) { | 49 | void TodoView::update(int , const OTodo& ev ) { |
78 | m_main->updateTodo( ev ); | 50 | m_main->updateTodo( ev ); |
79 | } | 51 | } |
52 | void TodoView::showTodo( int uid ) { | ||
53 | m_main->slotShow( uid ); | ||
54 | } | ||
55 | void TodoView::edit( int uid ) { | ||
56 | m_main->slotEdit( uid ); | ||
57 | } | ||
58 | void TodoView::remove( int uid ) { | ||
59 | m_main->m_todoMgr.remove( uid ); | ||
60 | } | ||
61 | void TodoView::complete( int uid ) { | ||
62 | m_main->slotComplete( uid ); | ||
63 | } | ||
64 | void 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 | |||
@@ -35,59 +35,22 @@ | |||
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 | ||
42 | namespace Todo { | 42 | namespace 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 | /* |
@@ -97,26 +60,17 @@ namespace Todo { | |||
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 |
@@ -133,56 +87,38 @@ namespace Todo { | |||
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: | 108 | */ |
170 | */ | 109 | void showTodo( int uid ); |
171 | protected: | 110 | void edit( int uid ); |
172 | void showTodo( int uid ) { hack->emitShow(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 |