summaryrefslogtreecommitdiff
authorzecke <zecke>2003-05-12 13:21:59 (UTC)
committer zecke <zecke>2003-05-12 13:21:59 (UTC)
commit9a4c9544a59f8395f2ec5e7c99028570f8bd8bd1 (patch) (unidiff)
tree8af13b984750f743b7f9f06bbf04b531b1a10ff2
parenta4c8b8912c9e87a2fd76103193e6b4f91c2a2c5d (diff)
downloadopie-9a4c9544a59f8395f2ec5e7c99028570f8bd8bd1.zip
opie-9a4c9544a59f8395f2ec5e7c99028570f8bd8bd1.tar.gz
opie-9a4c9544a59f8395f2ec5e7c99028570f8bd8bd1.tar.bz2
Hospital Hacking Session
make more translatable fix up GUI for Opie1.0 in regards what is implemnted implement setting and removing of Alarms!!!! Show Alarms once they got fired...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp133
-rw-r--r--core/pim/todo/mainwindow.h5
-rw-r--r--core/pim/todo/otaskeditor.cpp13
-rw-r--r--core/pim/todo/quickeditimpl.cpp20
-rw-r--r--core/pim/todo/taskeditoralarms.cpp190
-rw-r--r--core/pim/todo/taskeditoralarms.h26
-rw-r--r--core/pim/todo/taskeditorstatus.cpp11
-rw-r--r--core/pim/todo/templatedialog.cpp10
-rw-r--r--core/pim/todo/templatedialogimpl.cpp10
-rw-r--r--core/pim/todo/templateeditor.cpp5
-rw-r--r--core/pim/todo/todomanager.cpp1
11 files changed, 373 insertions, 51 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index c5cedc6..5119ae0 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -27,31 +27,36 @@
27*/ 27*/
28 28
29#include <unistd.h> 29#include <unistd.h>
30 30
31#include <qmenubar.h> 31#include <qmenubar.h>
32#include <qmessagebox.h> 32#include <qmessagebox.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qpushbutton.h>
35#include <qwidgetstack.h> 36#include <qwidgetstack.h>
36#include <qaction.h> 37#include <qaction.h>
37#include <qtimer.h> 38#include <qtimer.h>
38#include <qvbox.h> 39#include <qvbox.h>
39#include <qlayout.h> 40#include <qlayout.h>
40#include <qlineedit.h> 41#include <qlineedit.h>
41#include <qwhatsthis.h> 42#include <qwhatsthis.h>
42 43
43#include <qpe/applnk.h> 44#include <qpe/applnk.h>
44#include <qpe/config.h> 45#include <qpe/config.h>
45#include <qpe/ir.h> 46#include <qpe/ir.h>
46#include <qpe/resource.h> 47#include <qpe/resource.h>
47#include <qpe/qpemessagebox.h> 48#include <qpe/qpemessagebox.h>
49#include <qpe/alarmserver.h>
50#include <qpe/timestring.h>
51#include <qpe/qpeapplication.h>
48 52
49#include <opie/orecur.h> 53#include <opie/orecur.h>
54#include <opie/opimnotifymanager.h>
50#include <opie/otodoaccessvcal.h> 55#include <opie/otodoaccessvcal.h>
51 56
52#include "quickeditimpl.h" 57#include "quickeditimpl.h"
53#include "todotemplatemanager.h" 58#include "todotemplatemanager.h"
54#include "templateeditor.h" 59#include "templateeditor.h"
55#include "tableview.h" 60#include "tableview.h"
56 61
57#include "textviewshow.h" 62#include "textviewshow.h"
@@ -296,31 +301,38 @@ QToolBar* MainWindow::toolbar() {
296} 301}
297OTodoAccess::List MainWindow::list()const { 302OTodoAccess::List MainWindow::list()const {
298 return m_todoMgr.list(); 303 return m_todoMgr.list();
299} 304}
300OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 305OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
301 int cat = 0; 306 int cat = 0;
302 if ( m_curCat != QWidget::tr("All Categories") ) 307 if ( m_curCat != QWidget::tr("All Categories") )
303 cat = currentCatId(); 308 cat = currentCatId();
309 if ( m_curCat == QWidget::tr("Unfiled") )
310 cat = -1;
311
312 qWarning(" Category %d %s", cat, m_curCat.latin1() );
304 313
305 int filter = 1; 314 int filter = 1;
306 315
307 if (!m_completed ) 316 if (!m_completed )
308 filter |= 4; 317 filter |= 4;
309 if (m_overdue) 318 if (m_overdue)
310 filter |= 2; 319 filter |= 2;
311 320
312 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 321 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
313} 322}
314OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 323OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
315 int cat = 0; 324 int cat = 0;
316 if ( m_curCat != QWidget::tr("All Categories") ) 325 if ( m_curCat != QWidget::tr("All Categories") )
317 cat = currentCatId(); 326 cat = currentCatId();
318 327
328 if ( m_curCat == QWidget::tr("Unfiled") )
329 cat = -1;
330
319 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 331 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
320} 332}
321OTodo MainWindow::event( int uid ) { 333OTodo MainWindow::event( int uid ) {
322 return m_todoMgr.event( uid ); 334 return m_todoMgr.event( uid );
323} 335}
324bool MainWindow::isSyncing()const { 336bool MainWindow::isSyncing()const {
325 return m_syncing; 337 return m_syncing;
326} 338}
@@ -445,16 +457,17 @@ void MainWindow::slotDelete() {
445 QMessageBox::warning(this, QWidget::tr("Todo"), 457 QMessageBox::warning(this, QWidget::tr("Todo"),
446 QWidget::tr("Can not edit data, currently syncing")); 458 QWidget::tr("Can not edit data, currently syncing"));
447 return; 459 return;
448 } 460 }
449 QString strName = currentView()->currentRepresentation(); 461 QString strName = currentView()->currentRepresentation();
450 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) 462 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) )
451 return; 463 return;
452 464
465 handleAlarms( OTodo(), m_todoMgr.event( currentView()->current() ) );
453 m_todoMgr.remove( currentView()->current() ); 466 m_todoMgr.remove( currentView()->current() );
454 currentView()->removeEvent( currentView()->current() ); 467 currentView()->removeEvent( currentView()->current() );
455 raiseCurrentView(); 468 raiseCurrentView();
456} 469}
457void MainWindow::slotDeleteAll() { 470void MainWindow::slotDeleteAll() {
458 if(m_syncing) { 471 if(m_syncing) {
459 QMessageBox::warning(this, QWidget::tr("Todo"), 472 QMessageBox::warning(this, QWidget::tr("Todo"),
460 QWidget::tr("Can not edit data, currently syncing")); 473 QWidget::tr("Can not edit data, currently syncing"));
@@ -636,23 +649,24 @@ void MainWindow::slotShow( int uid ) {
636void MainWindow::slotEdit( int uid ) { 649void MainWindow::slotEdit( int uid ) {
637 if (uid == 1 ) return; 650 if (uid == 1 ) return;
638 if(m_syncing) { 651 if(m_syncing) {
639 QMessageBox::warning(this, QWidget::tr("Todo"), 652 QMessageBox::warning(this, QWidget::tr("Todo"),
640 QWidget::tr("Can not edit data, currently syncing")); 653 QWidget::tr("Can not edit data, currently syncing"));
641 return; 654 return;
642 } 655 }
643 656
644 OTodo todo = m_todoMgr.event( uid ); 657 OTodo old_todo = m_todoMgr.event( uid );
645 658
646 todo = currentEditor()->edit(this, todo ); 659 OTodo todo = currentEditor()->edit(this, old_todo );
647 660
648 /* if completed */ 661 /* if completed */
649 if ( currentEditor()->accepted() ) { 662 if ( currentEditor()->accepted() ) {
650 qWarning("Replacing now" ); 663 qWarning("Replacing now" );
664 handleAlarms( old_todo, todo );
651 m_todoMgr.update( todo.uid(), todo ); 665 m_todoMgr.update( todo.uid(), todo );
652 currentView()->replaceEvent( todo ); 666 currentView()->replaceEvent( todo );
653 /* a Category might have changed */ 667 /* a Category might have changed */
654 populateCategories(); 668 populateCategories();
655 } 669 }
656 670
657 raiseCurrentView(); 671 raiseCurrentView();
658} 672}
@@ -761,16 +775,17 @@ int MainWindow::create() {
761 775
762 776
763 OTodo todo = currentEditor()->newTodo( currentCatId(), 777 OTodo todo = currentEditor()->newTodo( currentCatId(),
764 this ); 778 this );
765 779
766 if ( currentEditor()->accepted() ) { 780 if ( currentEditor()->accepted() ) {
767 //todo.assignUid(); 781 //todo.assignUid();
768 uid = todo.uid(); 782 uid = todo.uid();
783 handleAlarms( OTodo(), todo );
769 m_todoMgr.add( todo ); 784 m_todoMgr.add( todo );
770 currentView()->addEvent( todo ); 785 currentView()->addEvent( todo );
771 786
772 787
773 // I'm afraid we must call this every time now, otherwise 788 // I'm afraid we must call this every time now, otherwise
774 // spend expensive time comparing all these strings... 789 // spend expensive time comparing all these strings...
775 // but only call if we changed something -zecke 790 // but only call if we changed something -zecke
776 populateCategories(); 791 populateCategories();
@@ -778,16 +793,19 @@ int MainWindow::create() {
778 raiseCurrentView( ); 793 raiseCurrentView( );
779 794
780 return uid; 795 return uid;
781} 796}
782/* delete it silently... */ 797/* delete it silently... */
783bool MainWindow::remove( int uid ) { 798bool MainWindow::remove( int uid ) {
784 if (m_syncing) return false; 799 if (m_syncing) return false;
785 800
801 /* argh need to get the whole OEvent... to disable alarms -zecke */
802 handleAlarms( OTodo(), m_todoMgr.event( uid ) );
803
786 return m_todoMgr.remove( uid ); 804 return m_todoMgr.remove( uid );
787} 805}
788void MainWindow::beam( int uid) { 806void MainWindow::beam( int uid) {
789 ::unlink( beamfile ); 807 ::unlink( beamfile );
790 OTodo todo = event( uid ); 808 OTodo todo = event( uid );
791 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); 809 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) );
792 OTodoAccess acc( cal ); 810 OTodoAccess acc( cal );
793 acc.load(); 811 acc.load();
@@ -816,8 +834,119 @@ void MainWindow::add( const OPimRecord& rec) {
816 // I'm afraid we must call this every time now, otherwise 834 // I'm afraid we must call this every time now, otherwise
817 // spend expensive time comparing all these strings... 835 // spend expensive time comparing all these strings...
818 // but only call if we changed something -zecke 836 // but only call if we changed something -zecke
819 populateCategories(); 837 populateCategories();
820} 838}
821void MainWindow::slotReturnFromView() { 839void MainWindow::slotReturnFromView() {
822 raiseCurrentView(); 840 raiseCurrentView();
823} 841}
842
843namespace {
844 OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls,
845 const OPimNotifyManager::Alarms& newAls ) {
846 OPimNotifyManager::Alarms nonMatching;
847 OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin();
848 OPimNotifyManager::Alarms::ConstIterator newIt;
849 for ( ; oldIt != oldAls.end(); ++oldIt ) {
850 bool found = false;
851 QDateTime oldDt = (*oldIt).dateTime();
852 for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) {
853 if ( oldDt == (*newIt).dateTime() ) {
854 found = true;
855 break;
856 }
857 }
858 if (!found)
859 nonMatching.append( (*oldIt) );
860 }
861 return nonMatching;
862 }
863 void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
864 OPimNotifyManager::Alarms::ConstIterator it;
865 for ( it = als.begin(); it != als.end(); ++it ) {
866 qWarning("Adding alarm for %s", (*it).dateTime().toString().latin1() );
867 AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
868 }
869
870 }
871 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
872 OPimNotifyManager::Alarms::ConstIterator it;
873 for ( it = als.begin(); it != als.end(); ++it ) {
874 qWarning("Removinf alarm for %s", (*it).dateTime().toString().latin1() );
875 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
876 }
877 }
878}
879
880void MainWindow::handleAlarms( const OTodo& oldTodo, const OTodo& newTodo) {
881 /*
882 * if oldTodo is not empty and has notifiers we need to find the deleted ones
883 */
884 if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) {
885 OPimNotifyManager::Alarms removed;
886 OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms();
887 if (!newTodo.hasNotifiers() )
888 removed = oldAls;
889 else
890 removed = findNonMatching( oldAls, newTodo.notifiers().alarms() );
891
892 removeAlarms( removed, oldTodo.uid() );
893 }
894 if ( newTodo.hasNotifiers() ) {
895 OPimNotifyManager::Alarms added;
896 if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() )
897 added = newTodo.notifiers().alarms();
898 else
899 added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() );
900
901 addAlarms( added, newTodo.uid() );
902 }
903}
904/* we might have not loaded the db */
905void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
906 m_todoMgr.load();
907
908 OTodo todo = m_todoMgr.event( uid );
909 if (!todo.hasNotifiers() ) return;
910
911 /*
912 * let's find the right alarm and find out if silent
913 * then show a richtext widget
914 */
915 bool loud = false;
916 OPimNotifyManager::Alarms als = todo.notifiers().alarms();
917 OPimNotifyManager::Alarms::Iterator it;
918 for ( it = als.begin(); it != als.end(); ++it ) {
919 if ( (*it).dateTime() == dt ) {
920 loud = ( (*it).sound() == OPimAlarm::Loud );
921 break;
922 }
923 }
924 if (loud)
925 startAlarm();
926
927 QDialog dlg(this, 0, TRUE );
928 QVBoxLayout* lay = new QVBoxLayout( &dlg );
929 QTextView* view = new QTextView( &dlg );
930 lay->addWidget( view );
931 QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg );
932 connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) );
933 lay->addWidget( btnOk );
934
935 QString text = tr("<h1>Alarm at %0</h1><br>").arg( TimeString::dateString( dt ) );
936 text += todo.toRichText();
937 view->setText( text );
938
939 dlg.showMaximized();
940 bool needToStay = dlg.exec();
941
942 if (loud)
943 killAlarm();
944
945 if (needToStay) {
946 showMaximized();
947 raise();
948 QPEApplication::setKeepRunning();
949 setActiveWindow();
950 }
951
952}
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
index 434e969..02e2449 100644
--- a/core/pim/todo/mainwindow.h
+++ b/core/pim/todo/mainwindow.h
@@ -99,16 +99,18 @@ private slots:
99 void populateCategories(); 99 void populateCategories();
100 void slotReload(); 100 void slotReload();
101 void slotFlush(); 101 void slotFlush();
102 102
103 protected: 103 protected:
104 void closeEvent( QCloseEvent* e ); 104 void closeEvent( QCloseEvent* e );
105 105
106 private: 106 private:
107 /* handle setting and removing alarms */
108 void handleAlarms( const OTodo& oldTodo, const OTodo& newTodo );
107 void receiveFile( const QString& filename ); 109 void receiveFile( const QString& filename );
108 void connectBase( ViewBase* ); 110 void connectBase( ViewBase* );
109 void initUI(); 111 void initUI();
110 void initActions(); 112 void initActions();
111 void initConfig(); 113 void initConfig();
112 void initViews(); 114 void initViews();
113 void initEditor(); 115 void initEditor();
114 void initShow(); 116 void initShow();
@@ -190,12 +192,13 @@ private slots:
190 void flush(); 192 void flush();
191 void reload(); 193 void reload();
192 int create(); 194 int create();
193 bool remove( int uid ); 195 bool remove( int uid );
194 void beam(int uid); 196 void beam(int uid);
195 void show( int uid ); 197 void show( int uid );
196 void edit( int uid ); 198 void edit( int uid );
197 void add( const OPimRecord& ); 199 void add( const OPimRecord& );
200 void doAlarm( const QDateTime& dt, int uid );
198 }; 201 };
199}; 202}
200 203
201#endif 204#endif
diff --git a/core/pim/todo/otaskeditor.cpp b/core/pim/todo/otaskeditor.cpp
index e26d5e4..84f854f 100644
--- a/core/pim/todo/otaskeditor.cpp
+++ b/core/pim/todo/otaskeditor.cpp
@@ -37,23 +37,26 @@ void OTaskEditor::init( const OTodo& to ) {
37} 37}
38OTodo OTaskEditor::todo()const{ 38OTodo OTaskEditor::todo()const{
39 qWarning("saving!"); 39 qWarning("saving!");
40 OTodo to; 40 OTodo to;
41 to.setUid(m_uid ); 41 to.setUid(m_uid );
42 m_overView->save( to ); 42 m_overView->save( to );
43 m_stat->save( to ); 43 m_stat->save( to );
44 to.setRecurrence( m_rec->recurrence() ); 44 to.setRecurrence( m_rec->recurrence() );
45 m_alarm->save( to );
45 46
46 return to; 47 return to;
47} 48}
48void OTaskEditor::load(const OTodo& to) { 49void OTaskEditor::load(const OTodo& to) {
49 m_overView->load( to ); 50 m_overView->load( to );
50 m_stat->load( to ); 51 m_stat->load( to );
51 m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() ); 52 m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() );
53 m_alarm->setEnabled( !to.hasRecurrence() );
54 m_alarm->load( to );
52} 55}
53void OTaskEditor::init() { 56void OTaskEditor::init() {
54 setCaption("Task Editor"); 57 setCaption("Task Editor");
55 58
56 QVBoxLayout* layo = new QVBoxLayout( this ); 59 QVBoxLayout* layo = new QVBoxLayout( this );
57 m_tab = new OTabWidget( this ); 60 m_tab = new OTabWidget( this );
58 layo->addWidget( m_tab ); 61 layo->addWidget( m_tab );
59 62
@@ -64,22 +67,22 @@ void OTaskEditor::init() {
64 m_tab->addTab( m_overView, "todo/info", tr("Information") ); 67 m_tab->addTab( m_overView, "todo/info", tr("Information") );
65 68
66 m_stat = new TaskEditorStatus( m_tab ); 69 m_stat = new TaskEditorStatus( m_tab );
67 m_tab->addTab( m_stat, "todo/TodoList", tr("Status") ); 70 m_tab->addTab( m_stat, "todo/TodoList", tr("Status") );
68 71
69 m_alarm = new TaskEditorAlarms( m_tab ); 72 m_alarm = new TaskEditorAlarms( m_tab );
70 m_tab->addTab( m_alarm, "todo/alarm", tr("Alarms") ); 73 m_tab->addTab( m_alarm, "todo/alarm", tr("Alarms") );
71 74
72 m_remind = new TaskEditorAlarms( m_tab ); 75// m_remind = new TaskEditorAlarms( m_tab );
73 m_tab->addTab( m_remind, "todo/reminder", tr("Reminders") ); 76// m_tab->addTab( m_remind, "todo/reminder", tr("Reminders") );
74 77
75 QLabel* lbl = new QLabel( m_tab ); 78// QLabel* lbl = new QLabel( m_tab );
76 lbl->setText( tr("X-Ref") ); 79// lbl->setText( tr("X-Ref") );
77 m_tab->addTab( lbl, "todo/xref", tr("X-Ref") ); 80// m_tab->addTab( lbl, "todo/xref", tr("X-Ref") );
78 81
79 m_rec = new ORecurranceWidget( true, QDate::currentDate(), this ); 82 m_rec = new ORecurranceWidget( true, QDate::currentDate(), this );
80 m_tab->addTab( m_rec, "repeat", tr("Recurrence") ); 83 m_tab->addTab( m_rec, "repeat", tr("Recurrence") );
81 84
82 85
83 /* signal and slots */ 86 /* signal and slots */
84 connect(m_overView, SIGNAL(recurranceEnabled(bool) ), 87 connect(m_overView, SIGNAL(recurranceEnabled(bool) ),
85 m_rec, SLOT(setEnabled(bool) ) ); 88 m_rec, SLOT(setEnabled(bool) ) );
diff --git a/core/pim/todo/quickeditimpl.cpp b/core/pim/todo/quickeditimpl.cpp
index 91d3131..f4c7c47 100644
--- a/core/pim/todo/quickeditimpl.cpp
+++ b/core/pim/todo/quickeditimpl.cpp
@@ -20,42 +20,42 @@ QuickEditImpl::QuickEditImpl( QWidget* parent, bool visible )
20 priority1 = Resource::loadPixmap( "todo/priority1" ); 20 priority1 = Resource::loadPixmap( "todo/priority1" );
21 priority3 = Resource::loadPixmap( "todo/priority3" ); 21 priority3 = Resource::loadPixmap( "todo/priority3" );
22 priority5 = Resource::loadPixmap( "todo/priority5" ); 22 priority5 = Resource::loadPixmap( "todo/priority5" );
23 23
24 m_lbl = new OClickableLabel( this ); 24 m_lbl = new OClickableLabel( this );
25 m_lbl->setMinimumWidth( 15 ); 25 m_lbl->setMinimumWidth( 15 );
26 m_lbl->setPixmap( priority3 ); 26 m_lbl->setPixmap( priority3 );
27 connect(m_lbl, SIGNAL(clicked() ), this, SLOT(slotPrio()) ); 27 connect(m_lbl, SIGNAL(clicked() ), this, SLOT(slotPrio()) );
28 QWhatsThis::add( m_lbl, tr( "Click here to set the priority of new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 28 QWhatsThis::add( m_lbl, QWidget::tr( "Click here to set the priority of new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
29 29
30 m_edit = new QLineEdit( this ); 30 m_edit = new QLineEdit( this );
31 setStretchableWidget( m_edit ); 31 setStretchableWidget( m_edit );
32 QWhatsThis::add( m_edit, tr( "Enter description of new task here.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 32 QWhatsThis::add( m_edit, QWidget::tr( "Enter description of new task here.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
33 33
34 QAction *a = new QAction( tr( "More" ), Resource::loadPixmap( "todo/more" ), QString::null, 0, this, 0 ); 34 QAction *a = new QAction( QWidget::tr( "More" ), Resource::loadPixmap( "todo/more" ), QString::null, 0, this, 0 );
35 connect( a, SIGNAL( activated() ), this, SLOT( slotMore() ) ); 35 connect( a, SIGNAL( activated() ), this, SLOT( slotMore() ) );
36 a->addTo( this ); 36 a->addTo( this );
37 a->setWhatsThis( tr( "Click here to enter additional information for new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 37 a->setWhatsThis( QWidget::tr( "Click here to enter additional information for new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
38 38
39 a = new QAction( tr( "Enter" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); 39 a = new QAction( QWidget::tr( "Enter" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
40 connect( a, SIGNAL( activated() ), this, SLOT( slotEnter() ) ); 40 connect( a, SIGNAL( activated() ), this, SLOT( slotEnter() ) );
41 a->addTo( this ); 41 a->addTo( this );
42 a->setWhatsThis( tr( "Click here to add new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 42 a->setWhatsThis( QWidget::tr( "Click here to add new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
43 43
44 a = new QAction( tr( "Cancel" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 44 a = new QAction( QWidget::tr( "Cancel" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
45 connect( a, SIGNAL( activated() ), this, SLOT( slotCancel() ) ); 45 connect( a, SIGNAL( activated() ), this, SLOT( slotCancel() ) );
46 a->addTo( this ); 46 a->addTo( this );
47 a->setWhatsThis( tr( "Click here to reset new task information.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 47 a->setWhatsThis( QWidget::tr( "Click here to reset new task information.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
48 48
49 m_visible = visible; 49 m_visible = visible;
50 if ( !m_visible ) { 50 if ( !m_visible ) {
51 hide(); 51 hide();
52 } 52 }
53 53
54 m_menu = 0l; 54 m_menu = 0l;
55 reinit(); 55 reinit();
56} 56}
57QuickEditImpl::~QuickEditImpl() { 57QuickEditImpl::~QuickEditImpl() {
58 58
59} 59}
60OTodo QuickEditImpl::todo()const { 60OTodo QuickEditImpl::todo()const {
61 return m_todo; 61 return m_todo;
diff --git a/core/pim/todo/taskeditoralarms.cpp b/core/pim/todo/taskeditoralarms.cpp
index 3cb5576..bff3338 100644
--- a/core/pim/todo/taskeditoralarms.cpp
+++ b/core/pim/todo/taskeditoralarms.cpp
@@ -23,54 +23,216 @@
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "taskeditoralarms.h" 29#include "taskeditoralarms.h"
30 30
31#include <opie/otodo.h>
32#include <opie/opimnotifymanager.h>
33#include <opie/otimepicker.h>
34
35#include <qpe/datebookmonth.h>
31#include <qpe/resource.h> 36#include <qpe/resource.h>
37#include <qpe/timestring.h>
32 38
39#include <qdatetime.h>
33#include <qlistview.h> 40#include <qlistview.h>
34#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qpopupmenu.h>
35#include <qlayout.h> 43#include <qlayout.h>
36#include <qwhatsthis.h> 44#include <qwhatsthis.h>
37 45
38TaskEditorAlarms::TaskEditorAlarms( QWidget* parent, const char* name, WFlags fl ) 46
47class AlarmItem : public QListViewItem {
48public:
49 AlarmItem( QListView*, const OPimAlarm& );
50 ~AlarmItem();
51
52 OPimAlarm alarm()const;
53 void setAlarm( const OPimAlarm& );
54private:
55 QDateTime m_dt;
56 int m_type;
57};
58AlarmItem::AlarmItem( QListView* view, const OPimAlarm& dt)
59 : QListViewItem(view) {
60 setAlarm( dt );
61}
62void AlarmItem::setAlarm( const OPimAlarm& dt ) {
63 m_dt = dt.dateTime();
64 m_type = dt.sound();
65 setText( 0, TimeString::dateString( m_dt.date() ) );
66 setText( 1, TimeString::timeString( m_dt.time() ) );
67 setText( 2, m_type == 0 ? QObject::tr("silent") : QObject::tr("loud") );
68}
69AlarmItem::~AlarmItem() {
70}
71OPimAlarm AlarmItem::alarm()const{
72 OPimAlarm al( m_type, m_dt );
73
74 return al;
75}
76
77TaskEditorAlarms::TaskEditorAlarms( QWidget* parent, int, const char* name, WFlags fl )
39 : QWidget( parent, name, fl ) 78 : QWidget( parent, name, fl )
40{ 79{
41 QGridLayout *layout = new QGridLayout( this, 2, 3, 4, 4 ); 80 m_date = m_type = m_time = 0;
81 QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 4 );
42 82
43 lstAlarms = new QListView( this ); 83 lstAlarms = new QListView( this );
84 lstAlarms->addColumn( tr("Date") );
85 lstAlarms->addColumn( tr("Time") );
86 lstAlarms->addColumn( tr("Type") );
87
88 connect( lstAlarms, SIGNAL(clicked ( QListViewItem *, const QPoint &, int ) ),
89 this, SLOT(inlineEdit(QListViewItem*, const QPoint&, int ) ) );
90
44 layout->addMultiCellWidget( lstAlarms, 0, 0, 0, 2 ); 91 layout->addMultiCellWidget( lstAlarms, 0, 0, 0, 2 );
45 92
46 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), this ); 93 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), this );
47 //QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); 94 //QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) );
48 //connect( btn, SIGNAL( clicked() ), this, SLOT( slotNew() ) ); 95 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNew() ) );
49 layout->addWidget( btn, 1, 0 ); 96 layout->addWidget( btn, 1, 0 );
50 97/* use when we've reminders too */
98#if 0
51 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), this ); 99 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), this );
52 //QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); 100 //QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) );
53 //connect( btn, SIGNAL( clicked() ), this, SLOT( slotEdit() ) ); 101 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEdit() ) );
54 layout->addWidget( btn, 1, 1 ); 102 layout->addWidget( btn, 1, 1 );
103#endif
55 104
56 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); 105 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this );
57 //QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); 106 //QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) );
58 //connect( btn, SIGNAL( clicked() ), this, SLOT( slotDelete() ) ); 107 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDelete() ) );
59 layout->addWidget( btn, 1, 2 ); 108 layout->addWidget( btn, 1, 2 );
60} 109}
61 110
62TaskEditorAlarms::~TaskEditorAlarms() 111TaskEditorAlarms::~TaskEditorAlarms(){
63{
64} 112}
65 113
66void TaskEditorAlarms::slotNew() 114void TaskEditorAlarms::slotNew(){
67{ 115 (void)new AlarmItem(lstAlarms, OPimAlarm(0, QDateTime::currentDateTime() ) );
68} 116}
69 117
70void TaskEditorAlarms::slotEdit() 118void TaskEditorAlarms::slotEdit(){
71{
72} 119}
73 120
74void TaskEditorAlarms::slotDelete() 121void TaskEditorAlarms::slotDelete(){
75{ 122 QListViewItem* item = lstAlarms->currentItem();
123 if (!item) return;
124
125 lstAlarms->takeItem( item ); delete item;
126
127
128}
129
130void TaskEditorAlarms::load( const OTodo& todo) {
131 lstAlarms->clear();
132 if (!todo.hasNotifiers() ) return;
133
134 OPimNotifyManager::Alarms als = todo.notifiers().alarms();
135
136 if (als.isEmpty() ) return;
137
138 OPimNotifyManager::Alarms::Iterator it = als.begin();
139 for ( ; it != als.end(); ++it )
140 (void)new AlarmItem( lstAlarms, (*it) );
141
142
143}
144void TaskEditorAlarms::save( OTodo& todo ) {
145 if (lstAlarms->childCount() <= 0 ) return;
146
147 OPimNotifyManager::Alarms alarms;
148
149 for ( QListViewItem* item = lstAlarms->firstChild(); item; item = item->nextSibling() ) {
150 AlarmItem *alItem = static_cast<AlarmItem*>(item);
151 alarms.append( alItem->alarm() );
152 }
153
154 OPimNotifyManager& manager = todo.notifiers();
155 manager.setAlarms( alarms );
156}
157void TaskEditorAlarms::inlineEdit( QListViewItem* alarm, const QPoint& p, int col ) {
158 if (!alarm) return;
159
160 AlarmItem* item = static_cast<AlarmItem*>(alarm);
161 switch( col ) {
162 // date
163 case 0:
164 return inlineSetDate( item, p );
165 // time
166 case 1:
167 return inlineSetTime( item );
168 // type
169 case 2:
170 return inlineSetType( item, p );
171 }
172}
173void TaskEditorAlarms::inlineSetDate( AlarmItem* item, const QPoint& p ) {
174 QPopupMenu* pop = popup( 0 );
175 m_dbMonth->setDate( item->alarm().dateTime().date() );
176 pop->exec(p);
177
178 OPimAlarm al = item->alarm();
179 QDateTime dt = al.dateTime();
180 dt.setDate( m_dbMonth->selectedDate() );
181 al.setDateTime( dt );
182 item->setAlarm( al );
183}
184void TaskEditorAlarms::inlineSetType( AlarmItem* item, const QPoint& p ) {
185 int type;
186 QPopupMenu* pop = popup( 2 );
187 switch( pop->exec(p) ) {
188 case 10:
189 type = 1;
190 break;
191 case 20:
192 default:
193 type = 0;
194 }
195 OPimAlarm al = item->alarm();
196 al.setSound( type );
197 item->setAlarm( al );
198}
199void TaskEditorAlarms::inlineSetTime( AlarmItem* item ) {
200 OPimAlarm al = item->alarm();
201 QDateTime dt = al.dateTime();
202
203 OTimePickerDialog dialog;
204 dialog.setTime( dt.time() );
205 if ( dialog.exec() == QDialog::Accepted ) {
206 dt.setTime( dialog.time() );
207 al.setDateTime( dt );
208 item->setAlarm( al );
209 }
210}
211QPopupMenu* TaskEditorAlarms::popup( int column ) {
212 QPopupMenu* pop = 0;
213 switch( column ) {
214 case 0:{
215 if (!m_date) {
216 m_date = new QPopupMenu(this);
217 m_dbMonth = new DateBookMonth(m_date, 0, TRUE);
218 m_date->insertItem(m_dbMonth);
219 }
220 pop = m_date;
221 }
222 break;
223 case 1:
224 break;
225 case 2:{
226 if (!m_type) {
227 m_type = new QPopupMenu(this);
228 m_type->insertItem( QObject::tr("loud"), 10 );
229 m_type->insertItem( QObject::tr("silent"), 20 );
230 }
231 pop = m_type;
232 }
233 break;
234 default:
235 break;
236 }
237 return pop;
76} 238}
diff --git a/core/pim/todo/taskeditoralarms.h b/core/pim/todo/taskeditoralarms.h
index f77ded5..0aa52cc 100644
--- a/core/pim/todo/taskeditoralarms.h
+++ b/core/pim/todo/taskeditoralarms.h
@@ -1,11 +1,11 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002,2003 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
@@ -27,26 +27,46 @@
27*/ 27*/
28 28
29#ifndef TASKEDITORALARMS_H 29#ifndef TASKEDITORALARMS_H
30#define TASKEDITORALARMS_H 30#define TASKEDITORALARMS_H
31 31
32#include <qwidget.h> 32#include <qwidget.h>
33 33
34class QListView; 34class QListView;
35class QListViewItem;
36class OTodo;
35 37
38class AlarmItem;
39class DateBookMonth;
36class TaskEditorAlarms : public QWidget 40class TaskEditorAlarms : public QWidget
37{ 41{
38 Q_OBJECT 42 Q_OBJECT
39 43
40public: 44public:
41 TaskEditorAlarms( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 45 enum Type {
46 Alarm = 0,
47 Reminders
48 };
49 TaskEditorAlarms( QWidget* parent = 0, int type = Alarm, const char* name = 0, WFlags fl = 0 );
42 ~TaskEditorAlarms(); 50 ~TaskEditorAlarms();
51 void load( const OTodo& );
52 void save( OTodo& );
53private:
54 QPopupMenu* popup( int column );
55 void inlineSetDate( AlarmItem*, const QPoint& p );
56 void inlineSetTime( AlarmItem*);
57 void inlineSetType( AlarmItem*, const QPoint& p );
43 58
44 QListView* lstAlarms; 59 QListView* lstAlarms;
60 QPopupMenu* m_date;
61 QPopupMenu* m_time;
62 QPopupMenu* m_type;
63 DateBookMonth* m_dbMonth;
45 64
46protected slots: 65protected slots:
47 void slotNew(); 66 void slotNew();
48 void slotEdit(); 67 void slotEdit();
49 void slotDelete(); 68 void slotDelete();
69 void inlineEdit( QListViewItem*, const QPoint& p, int );
50}; 70};
51 71
52#endif // TASKEDITORALARMS_H 72#endif // TASKEDITORALARMS_H
diff --git a/core/pim/todo/taskeditorstatus.cpp b/core/pim/todo/taskeditorstatus.cpp
index 4331877..0ab4223 100644
--- a/core/pim/todo/taskeditorstatus.cpp
+++ b/core/pim/todo/taskeditorstatus.cpp
@@ -139,39 +139,41 @@ TaskEditorStatus::TaskEditorStatus( QWidget* parent, const char* name, WFlags f
139 btnComp->setPopup( popup ); 139 btnComp->setPopup( popup );
140 connect( m_compBook, SIGNAL( dateClicked( int, int, int ) ), 140 connect( m_compBook, SIGNAL( dateClicked( int, int, int ) ),
141 this, SLOT( slotCompChanged( int, int, int ) ) ); 141 this, SLOT( slotCompChanged( int, int, int ) ) );
142 142
143 QSpacerItem *spacer = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ); 143 QSpacerItem *spacer = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding );
144 layout->addItem( spacer, 5, 0 ); 144 layout->addItem( spacer, 5, 0 );
145 145
146 // Maintainer mode 146 // Maintainer mode
147#if 0
147 label = new QLabel( tr( "Maintainer Mode:" ), container ); 148 label = new QLabel( tr( "Maintainer Mode:" ), container );
148 layout->addWidget( label, 6, 0 ); 149 layout->addWidget( label, 6, 0 );
149 QWhatsThis::add( label, tr( "Click here to set the maintainer's role." ) ); 150 QWhatsThis::add( label, tr( "Click here to set the maintainer's role." ) );
150 cmbMaintMode = new QComboBox( FALSE, container ); 151 cmbMaintMode = new QComboBox( FALSE, container );
151 cmbMaintMode->insertItem( tr( "Nothing" ) ); 152 cmbMaintMode->insertItem( tr( "Nothing" ) );
152 cmbMaintMode->insertItem( tr( "Responsible" ) ); 153 cmbMaintMode->insertItem( tr( "Responsible" ) );
153 cmbMaintMode->insertItem( tr( "Done By" ) ); 154 cmbMaintMode->insertItem( tr( "Done By" ) );
154 cmbMaintMode->insertItem( tr( "Coordinating" ) ); 155 cmbMaintMode->insertItem( tr( "Coordinating" ) );
155 layout->addMultiCellWidget( cmbMaintMode, 6, 6, 1, 2 ); 156// layout->addMultiCellWidget( cmbMaintMode, 6, 6, 1, 2 );
156 QWhatsThis::add( cmbMaintMode, tr( "Click here to set the maintainer's role." ) ); 157 QWhatsThis::add( cmbMaintMode, tr( "Click here to set the maintainer's role." ) );
157 158
158 // Maintainer 159 // Maintainer
159 label = new QLabel( tr( "Maintainer:" ), container ); 160 label = new QLabel( tr( "Maintainer:" ), container );
160 layout->addWidget( label, 7, 0 ); 161 layout->addWidget( label, 7, 0 );
161 QWhatsThis::add( label, tr( "This is the name of the current task maintainer." ) ); 162 QWhatsThis::add( label, tr( "This is the name of the current task maintainer." ) );
162 txtMaintainer = new QLabel( tr( "test" ), container ); 163 txtMaintainer = new QLabel( tr( "test" ), container );
163 txtMaintainer->setTextFormat( QLabel::RichText ); 164 txtMaintainer->setTextFormat( QLabel::RichText );
164 layout->addWidget( txtMaintainer, 7, 1 ); 165 layout->addWidget( txtMaintainer, 7, 1 );
165 QWhatsThis::add( txtMaintainer, tr( "This is the name of the current task maintainer." ) ); 166 QWhatsThis::add( txtMaintainer, tr( "This is the name of the current task maintainer." ) );
166 tbtMaintainer = new QToolButton( container ); 167 tbtMaintainer = new QToolButton( container );
167 tbtMaintainer->setPixmap( Resource::loadPixmap( "todo/more" ) ); 168 tbtMaintainer->setPixmap( Resource::loadPixmap( "todo/more" ) );
168 layout->addWidget( tbtMaintainer, 7, 2 ); 169// layout->addWidget( tbtMaintainer, 7, 2 );
169 QWhatsThis::add( tbtMaintainer, tr( "Click here to select the task maintainer." ) ); 170 QWhatsThis::add( tbtMaintainer, tr( "Click here to select the task maintainer." ) );
171#endif
170} 172}
171 173
172TaskEditorStatus::~TaskEditorStatus() 174TaskEditorStatus::~TaskEditorStatus()
173{ 175{
174} 176}
175 177
176void TaskEditorStatus::load( const OTodo &todo ) 178void TaskEditorStatus::load( const OTodo &todo )
177{ 179{
@@ -211,21 +213,22 @@ void TaskEditorStatus::load( const OTodo &todo )
211 { 213 {
212 m_comp = todo.completedDate(); 214 m_comp = todo.completedDate();
213 btnComp->setText( TimeString::longDateString( m_comp ) ); 215 btnComp->setText( TimeString::longDateString( m_comp ) );
214 } 216 }
215 else 217 else
216 btnComp->setText( str ); 218 btnComp->setText( str );
217 219
218 // Maintainer Mode 220 // Maintainer Mode
221#if 0
219 state = todo.hasMaintainer() ? todo.maintainer().mode() : OPimMaintainer::Nothing; 222 state = todo.hasMaintainer() ? todo.maintainer().mode() : OPimMaintainer::Nothing;
220 if ( state == OPimMaintainer::Undefined ) 223 if ( state == OPimMaintainer::Undefined )
221 state = OPimMaintainer::Nothing; 224 state = OPimMaintainer::Nothing;
222 cmbMaintMode->setCurrentItem( state ); 225 cmbMaintMode->setCurrentItem( state );
223 226#endif
224 // Maintainer - not implemented yet 227 // Maintainer - not implemented yet
225} 228}
226 229
227void TaskEditorStatus::save( OTodo &todo ) 230void TaskEditorStatus::save( OTodo &todo )
228{ 231{
229 QDate inval; 232 QDate inval;
230 233
231 // Status 234 // Status
@@ -255,21 +258,23 @@ void TaskEditorStatus::save( OTodo &todo )
255 todo.setCompleted( ckbComp->isChecked() ); 258 todo.setCompleted( ckbComp->isChecked() );
256 if ( ckbComp->isChecked() ) 259 if ( ckbComp->isChecked() )
257 { 260 {
258 todo.setCompletedDate( m_comp ); 261 todo.setCompletedDate( m_comp );
259 } 262 }
260 else 263 else
261 todo.setCompletedDate( inval ); 264 todo.setCompletedDate( inval );
262 265
266#if 0
263 // Maintainer mode - not implemented yet 267 // Maintainer mode - not implemented yet
264 268
265 // Maintainer 269 // Maintainer
266 /* TODO - resolve name to uid.....*/ 270 /* TODO - resolve name to uid.....*/
267 todo.setMaintainer( OPimMaintainer( cmbMaintMode->currentItem(), -10 ) ); 271 todo.setMaintainer( OPimMaintainer( cmbMaintMode->currentItem(), -10 ) );
272#endif
268} 273}
269 274
270void TaskEditorStatus::slotStartChecked() 275void TaskEditorStatus::slotStartChecked()
271{ 276{
272 btnStart->setEnabled( ckbStart->isChecked() ); 277 btnStart->setEnabled( ckbStart->isChecked() );
273} 278}
274 279
275void TaskEditorStatus::slotCompChecked() 280void TaskEditorStatus::slotCompChecked()
diff --git a/core/pim/todo/templatedialog.cpp b/core/pim/todo/templatedialog.cpp
index c94f69c..8dfbd0b 100644
--- a/core/pim/todo/templatedialog.cpp
+++ b/core/pim/todo/templatedialog.cpp
@@ -4,32 +4,34 @@
4#include <qlistview.h> 4#include <qlistview.h>
5#include <qlineedit.h> 5#include <qlineedit.h>
6 6
7#include "templatedialog.h" 7#include "templatedialog.h"
8 8
9 9
10using namespace Todo; 10using namespace Todo;
11 11
12/* TRANSLATOR Todo::TemplateDialog */
13
12TemplateDialog::TemplateDialog( QWidget* widget ) 14TemplateDialog::TemplateDialog( QWidget* widget )
13 : QDialog( widget, "TemplateDialog", TRUE ) 15 : QDialog( widget, "TemplateDialog", TRUE )
14{ 16{
15 setCaption( tr("Template Editor") ); 17 setCaption( QWidget::tr("Template Editor") );
16 m_main = new QVBoxLayout(this ); 18 m_main = new QVBoxLayout(this );
17 19
18 m_list = new QListView( this ); 20 m_list = new QListView( this );
19 m_main->addWidget( m_list, 100 ); 21 m_main->addWidget( m_list, 100 );
20 22
21 m_lne = new QLineEdit( this ); 23 m_lne = new QLineEdit( this );
22 m_main->addWidget( m_lne ); 24 m_main->addWidget( m_lne );
23 25
24 m_btnBar = new QHBox( this ); 26 m_btnBar = new QHBox( this );
25 m_add = new QPushButton( tr("Add"), m_btnBar ); 27 m_add = new QPushButton( QWidget::tr("Add"), m_btnBar );
26 m_edit = new QPushButton( tr("Edit"), m_btnBar ); 28 m_edit = new QPushButton( QWidget::tr("Edit"), m_btnBar );
27 m_rem = new QPushButton( tr("Remove"), m_btnBar ); 29 m_rem = new QPushButton( QWidget::tr("Remove"), m_btnBar );
28 m_main->addWidget( m_btnBar ); 30 m_main->addWidget( m_btnBar );
29 31
30 connect(m_add, SIGNAL(clicked() ), 32 connect(m_add, SIGNAL(clicked() ),
31 this, SLOT(slotAdd() ) ); 33 this, SLOT(slotAdd() ) );
32 connect(m_edit, SIGNAL(clicked() ), 34 connect(m_edit, SIGNAL(clicked() ),
33 this, SLOT(slotEdit() ) ); 35 this, SLOT(slotEdit() ) );
34 connect(m_rem, SIGNAL(clicked() ), 36 connect(m_rem, SIGNAL(clicked() ),
35 this, SLOT(slotRemove() ) ); 37 this, SLOT(slotRemove() ) );
diff --git a/core/pim/todo/templatedialogimpl.cpp b/core/pim/todo/templatedialogimpl.cpp
index 77c5363..fed92f0 100644
--- a/core/pim/todo/templatedialogimpl.cpp
+++ b/core/pim/todo/templatedialogimpl.cpp
@@ -4,16 +4,18 @@
4#include "mainwindow.h" 4#include "mainwindow.h"
5#include "todoeditor.h" 5#include "todoeditor.h"
6#include "todotemplatemanager.h" 6#include "todotemplatemanager.h"
7#include "templatedialogimpl.h" 7#include "templatedialogimpl.h"
8 8
9 9
10using namespace Todo; 10using namespace Todo;
11 11
12/* TRANSLATOR Todo::TemplateDialogImpl */
13
12namespace { 14namespace {
13 class TemplateListItem : public QListViewItem { 15 class TemplateListItem : public QListViewItem {
14 public: 16 public:
15 TemplateListItem( QListView*, 17 TemplateListItem( QListView*,
16 const QString& name, 18 const QString& name,
17 const OTodo& ); 19 const OTodo& );
18 ~TemplateListItem(); 20 ~TemplateListItem();
19 21
@@ -56,45 +58,43 @@ TemplateDialogImpl::TemplateDialogImpl( MainWindow* win,
56{ 58{
57 /* fill the listview */ 59 /* fill the listview */
58 /* not the fastest way.... */ 60 /* not the fastest way.... */
59 QStringList list = man->templates(); 61 QStringList list = man->templates();
60 for (QStringList::Iterator it = list.begin(); 62 for (QStringList::Iterator it = list.begin();
61 it != list.end(); ++it ) { 63 it != list.end(); ++it ) {
62 new TemplateListItem( listView(), (*it), man->templateEvent( (*it) ) ); 64 new TemplateListItem( listView(), (*it), man->templateEvent( (*it) ) );
63 } 65 }
64 listView()->addColumn( tr("Name") ); 66 listView()->addColumn( QWidget::tr("Name") );
65 67
66 connect( listView(), SIGNAL(clicked(QListViewItem*) ), 68 connect( listView(), SIGNAL(clicked(QListViewItem*) ),
67 this, SLOT(slotClicked(QListViewItem*) ) ); 69 this, SLOT(slotClicked(QListViewItem*) ) );
68} 70}
69TemplateDialogImpl::~TemplateDialogImpl() { 71TemplateDialogImpl::~TemplateDialogImpl() {
70 72
71} 73}
72void TemplateDialogImpl::slotAdd() { 74void TemplateDialogImpl::slotAdd() {
73 QString str = tr("New Template %1").arg( listView()->childCount() ); 75 QString str = QWidget::tr("New Template %1").arg( listView()->childCount() );
74 OTodo ev; 76 OTodo ev;
75 m_man->addEvent(str, ev); 77 m_man->addEvent(str, ev);
76 new TemplateListItem( listView(), str, ev ); 78 new TemplateListItem( listView(), str, ev );
77} 79}
78void TemplateDialogImpl::slotRemove() { 80void TemplateDialogImpl::slotRemove() {
79 TemplateListItem* item = (TemplateListItem*) listView()->currentItem(); 81 TemplateListItem* item = (TemplateListItem*) listView()->currentItem();
80 listView()->takeItem( item ); 82 listView()->takeItem( item );
81 83
82 m_man->removeEvent( item->text() ); 84 m_man->removeEvent( item->text() );
83 85
84 delete item; 86 delete item;
85} 87}
86void TemplateDialogImpl::slotEdit() { 88void TemplateDialogImpl::slotEdit() {
87 TemplateListItem* item = (TemplateListItem*)listView()->currentItem(); 89 TemplateListItem* item = (TemplateListItem*)listView()->currentItem();
88 OTodo ev = m_win->currentEditor()->edit( m_win, item->event() ); 90 OTodo ev = m_win->currentEditor()->edit( m_win, item->event() );
89 if ( m_win->currentEditor()->accepted() ) { 91 if ( m_win->currentEditor()->accepted() ) {
90 qWarning("accepted");
91 item->setEvent( ev ); 92 item->setEvent( ev );
92 qWarning("Priority %d", ev.priority() );
93 m_man->removeEvent( item->text() ); 93 m_man->removeEvent( item->text() );
94 m_man->addEvent( item->text(), ev ); 94 m_man->addEvent( item->text(), ev );
95 } 95 }
96} 96}
97/* 97/*
98 * we need to update 98 * we need to update
99 * the text 99 * the text
100 */ 100 */
@@ -108,12 +108,12 @@ void TemplateDialogImpl::slotReturn() {
108 m_man->addEvent( tbl->text(), tbl->event() ); 108 m_man->addEvent( tbl->text(), tbl->event() );
109 } 109 }
110} 110}
111/* update the lineedit when changing */ 111/* update the lineedit when changing */
112void TemplateDialogImpl::slotClicked( QListViewItem* item) { 112void TemplateDialogImpl::slotClicked( QListViewItem* item) {
113 if (!item) 113 if (!item)
114 return; 114 return;
115 115
116 TemplateListItem* tbl = (TemplateListItem*)item; 116 TemplateListItem* tbl = static_cast<TemplateListItem*>(item);
117 edit()->setText( tbl->text() ); 117 edit()->setText( tbl->text() );
118} 118}
119 119
diff --git a/core/pim/todo/templateeditor.cpp b/core/pim/todo/templateeditor.cpp
index 3930428..ca02173 100644
--- a/core/pim/todo/templateeditor.cpp
+++ b/core/pim/todo/templateeditor.cpp
@@ -24,16 +24,15 @@ void TemplateEditor::init() {
24 QAction* a = new QAction( QString::null, QWidget::tr("Configure Templates"), 24 QAction* a = new QAction( QString::null, QWidget::tr("Configure Templates"),
25 0, this, 0, FALSE ); 25 0, this, 0, FALSE );
26 connect(a, SIGNAL(activated() ), 26 connect(a, SIGNAL(activated() ),
27 this, SLOT(setUp() ) ); 27 this, SLOT(setUp() ) );
28 28
29 a->addTo( m_main->options() ); 29 a->addTo( m_main->options() );
30} 30}
31void TemplateEditor::setUp() { 31void TemplateEditor::setUp() {
32 qWarning("set up");
33 TemplateDialogImpl dlg(m_main, m_man ); 32 TemplateDialogImpl dlg(m_main, m_man );
34 int ret= dlg.exec(); 33 int ret= dlg.exec();
35 if (QDialog::Accepted != ret ) { 34 if (QDialog::Accepted != ret )
36 m_man->load(); 35 m_man->load();
37 }else 36 else
38 m_main->populateTemplates(); 37 m_main->populateTemplates();
39} 38}
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
index b5b87de..df2e711 100644
--- a/core/pim/todo/todomanager.cpp
+++ b/core/pim/todo/todomanager.cpp
@@ -117,13 +117,12 @@ void TodoManager::remove( const QArray<int>& ids) {
117 for (uint i=0; i < ids.size(); i++ ) 117 for (uint i=0; i < ids.size(); i++ )
118 remove( ids[i] ); 118 remove( ids[i] );
119} 119}
120bool TodoManager::isLoaded()const { 120bool TodoManager::isLoaded()const {
121 return (m_db == 0 ); 121 return (m_db == 0 );
122} 122}
123void TodoManager::load() { 123void TodoManager::load() {
124 if (!m_db) { 124 if (!m_db) {
125 qWarning("loading!");
126 m_db = new OTodoAccess(); 125 m_db = new OTodoAccess();
127 m_db->load(); 126 m_db->load();
128 } 127 }
129} 128}