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
@@ -32,6 +32,7 @@
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>
@@ -45,8 +46,12 @@
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"
@@ -301,6 +306,10 @@ OTodoAccess::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
@@ -316,6 +325,9 @@ OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
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 ) {
@@ -450,6 +462,7 @@ void MainWindow::slotDelete() {
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();
@@ -641,13 +654,14 @@ void MainWindow::slotEdit( int uid ) {
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 */
@@ -766,6 +780,7 @@ int MainWindow::create() {
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
@@ -783,6 +798,9 @@ int MainWindow::create() {
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) {
@@ -821,3 +839,114 @@ void MainWindow::add( const OPimRecord& rec) {
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
@@ -104,6 +104,8 @@ private slots:
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();
@@ -195,7 +197,8 @@ private slots:
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
@@ -42,6 +42,7 @@ OTodo OTaskEditor::todo()const{
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}
@@ -49,6 +50,8 @@ void 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");
@@ -69,12 +72,12 @@ void OTaskEditor::init() {
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") );
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
@@ -25,32 +25,32 @@ QuickEditImpl::QuickEditImpl( QWidget* parent, bool visible )
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}
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
@@ -28,49 +28,211 @@
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,6 +1,6 @@
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
@@ -32,21 +32,41 @@
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
@@ -144,6 +144,7 @@ TaskEditorStatus::TaskEditorStatus( QWidget* parent, const char* name, WFlags f
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." ) );
@@ -152,7 +153,7 @@ TaskEditorStatus::TaskEditorStatus( QWidget* parent, const char* name, WFlags f
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
@@ -165,8 +166,9 @@ TaskEditorStatus::TaskEditorStatus( QWidget* parent, const char* name, WFlags f
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()
@@ -216,11 +218,12 @@ void TaskEditorStatus::load( const OTodo &todo )
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
@@ -260,11 +263,13 @@ void TaskEditorStatus::save( OTodo &todo )
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()
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
@@ -9,10 +9,12 @@
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 );
@@ -22,9 +24,9 @@ TemplateDialog::TemplateDialog( QWidget* widget )
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() ),
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
@@ -9,6 +9,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:
@@ -61,7 +63,7 @@ TemplateDialogImpl::TemplateDialogImpl( MainWindow* win,
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*) ) );
@@ -70,7 +72,7 @@ TemplateDialogImpl::~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 );
@@ -87,9 +89,7 @@ void 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 }
@@ -113,7 +113,7 @@ void 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
@@ -29,11 +29,10 @@ void TemplateEditor::init() {
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
@@ -122,7 +122,6 @@ bool TodoManager::isLoaded()const {
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 }