summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp213
-rw-r--r--core/pim/todo/mainwindow.h24
-rw-r--r--core/pim/todo/otaskeditor.cpp35
-rw-r--r--core/pim/todo/otaskeditor.h5
-rw-r--r--core/pim/todo/tableview.cpp27
-rw-r--r--core/pim/todo/taskeditoradvanced.ui8
-rw-r--r--core/pim/todo/taskeditoroverviewimpl.cpp55
-rw-r--r--core/pim/todo/taskeditoroverviewimpl.h1
-rw-r--r--core/pim/todo/todo.pro6
-rw-r--r--core/pim/todo/todomanager.cpp7
-rw-r--r--core/pim/todo/todomanager.h7
-rw-r--r--core/pim/todo/todoview.cpp55
-rw-r--r--core/pim/todo/todoview.h82
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
@@ -44,6 +44,7 @@
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"
@@ -59,7 +60,9 @@
59using namespace Todo; 60using namespace Todo;
60 61
61MainWindow::MainWindow( QWidget* parent, 62MainWindow::MainWindow( QWidget* parent,
62 const char* name ) { 63 const char* name )
64 : OPimMainWindow("Todolist")
65{
63 66
64 m_syncing = false; 67 m_syncing = false;
65 m_counter = 0; 68 m_counter = 0;
@@ -177,13 +180,10 @@ void MainWindow::initActions() {
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,
@@ -220,7 +220,6 @@ void MainWindow::initUI() {
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
@@ -254,24 +253,26 @@ MainWindow::~MainWindow() {
254 delete templateManager(); 253 delete templateManager();
255} 254}
256void MainWindow::connectBase( ViewBase* base) { 255void MainWindow::connectBase( ViewBase* base) {
257 base->connectShow( this, SLOT(slotShow(int) ) ); 256 // once templates and signals mix we'll use it again
258 base->connectEdit( this, SLOT(slotEdit(int) ) ); 257}
259 base->connectUpdateSmall( this, 258QPopupMenu* MainWindow::contextMenu( int , bool recur ) {
260 SLOT(slotUpate1(int, const Todo::SmallTodo&) ));
261 base->connectUpdateBig( this,
262 SLOT(slotUpate2(int, const OTodo& ) ) );
263 base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ;
264 base->connectRemove(&m_todoMgr,
265 SLOT(remove(int)) );
266}
267QPopupMenu* MainWindow::contextMenu( int uid ) {
268 QPopupMenu* menu = new QPopupMenu(); 259 QPopupMenu* menu = new QPopupMenu();
269 260
270 m_editAction->addTo( menu ); 261 m_editAction->addTo( menu );
271 m_deleteAction->addTo( menu ); 262 m_deleteAction->addTo( menu );
272 m_duplicateAction->addTo( menu ); 263 m_duplicateAction->addTo( menu );
264
273 menu->insertSeparator(); 265 menu->insertSeparator();
274 266
267 /*
268 * if this event recurs we allow
269 * to detach it.
270 * remove all
271 */
272 if ( recur ) {
273 ; // FIXME
274 }
275
275 return menu; 276 return menu;
276} 277}
277QPopupMenu* MainWindow::options() { 278QPopupMenu* MainWindow::options() {
@@ -281,9 +282,6 @@ QPopupMenu* MainWindow::options() {
281QPopupMenu* MainWindow::edit() { 282QPopupMenu* MainWindow::edit() {
282 return m_edit; 283 return m_edit;
283} 284}
284QPopupMenu* MainWindow::view() {
285 return m_view;
286}
287QToolBar* MainWindow::toolbar() { 285QToolBar* MainWindow::toolbar() {
288 return m_tool; 286 return m_tool;
289} 287}
@@ -413,28 +411,7 @@ void MainWindow::slotNewFromTemplate( int id ) {
413 } 411 }
414} 412}
415void MainWindow::slotNew() { 413void MainWindow::slotNew() {
416 if(m_syncing) { 414 create();
417 QMessageBox::warning(this, tr("Todo"),
418 tr("Can not edit data, currently syncing"));
419 return;
420 }
421
422
423 OTodo todo = currentEditor()->newTodo( currentCatId(),
424 this );
425
426 if ( currentEditor()->accepted() ) {
427 //todo.assignUid();
428 m_todoMgr.add( todo );
429 currentView()->addEvent( todo );
430
431
432 // I'm afraid we must call this every time now, otherwise
433 // spend expensive time comparing all these strings...
434 // but only call if we changed something -zecke
435 populateCategories();
436 }
437 raiseCurrentView( );
438} 415}
439void MainWindow::slotDuplicate() { 416void MainWindow::slotDuplicate() {
440 if(m_syncing) { 417 if(m_syncing) {
@@ -474,7 +451,6 @@ void MainWindow::slotDeleteAll() {
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;
@@ -494,8 +470,8 @@ void MainWindow::slotDeleteCompleted() {
494 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) 470 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) )
495 return; 471 return;
496 472
497 // FIXME 473
498 //m_todoMgr.remove( currentView()->completed() ); 474 m_todoMgr.removeCompleted();
499 currentView()->updateView( ); 475 currentView()->updateView( );
500} 476}
501void MainWindow::slotFind() { 477void MainWindow::slotFind() {
@@ -552,18 +528,7 @@ void MainWindow::setDocument( const QString& fi) {
552 528
553static const char *beamfile = "/tmp/opie-todo.vcs"; 529static const char *beamfile = "/tmp/opie-todo.vcs";
554void MainWindow::slotBeam() { 530void MainWindow::slotBeam() {
555 ::unlink( beamfile ); 531 beam( currentView()->current() );
556 OTodo todo = event( currentView()->current() );
557 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) );
558 OTodoAccess acc( cal );
559 acc.load();
560 acc.add( todo );
561 acc.save();
562 Ir* ir = new Ir(this );
563 connect(ir, SIGNAL(done(Ir*) ),
564 this, SLOT(beamDone(Ir*) ) );
565 ir->send( beamfile, todo.summary(), "text/x-vCalendar" );
566
567} 532}
568void MainWindow::beamDone( Ir* ir) { 533void MainWindow::beamDone( Ir* ir) {
569 delete ir; 534 delete ir;
@@ -704,3 +669,137 @@ void MainWindow::slotQuickEntered() {
704QuickEditBase* MainWindow::quickEditor() { 669QuickEditBase* MainWindow::quickEditor() {
705 return m_curQuick; 670 return m_curQuick;
706} 671}
672void MainWindow::slotComplete( int uid ) {
673 slotComplete( event(uid) );
674}
675void MainWindow::slotComplete( const OTodo& todo ) {
676 OTodo to = todo;
677 to.setCompleted( !to.isCompleted() );
678 to.setCompletedDate( QDate::currentDate() );
679
680 /*
681 * if the item does recur
682 * we need to spin it off
683 * and update the items duedate to the next
684 * possible recurrance of this item...
685 * the spinned off one will loose the
686 */
687 if ( to.recurrence().doesRecur() && to.isCompleted() ) {
688 OTodo to2( to );
689
690 /* the spinned off one won't recur anymore */
691 to.setRecurrence( ORecur() );
692
693 ORecur rec = to2.recurrence();
694 rec.setStart( to.dueDate() );
695 to2.setRecurrence( rec );
696 /*
697 * if there is a next occurence
698 * from the duedate of the last recurrance
699 */
700 QDate date;
701 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) {
702 QDate inval;
703 /* generate a new uid for the old record */
704 to.setUid( 1 );
705
706 /* add the old one cause it has a new UID here cause it was spin off */
707 m_todoMgr.add( to );
708
709 /*
710 * update the due date
711 * start date
712 * and complete date
713 */
714 to2.setDueDate( date );
715 to2.setStartDate( inval );
716 to2.setCompletedDate( inval );
717 to2.setCompleted( false );
718 updateTodo( to2 );
719 }else
720 updateTodo( to );
721 }else
722 updateTodo( to );
723
724 currentView()->updateView();
725 raiseCurrentView();
726}
727void MainWindow::flush() {
728 slotFlush();
729}
730void MainWindow::reload() {
731 slotReload();
732}
733int MainWindow::create() {
734 int uid = 0;
735 if(m_syncing) {
736 QMessageBox::warning(this, tr("Todo"),
737 tr("Can not edit data, currently syncing"));
738 return uid;
739 }
740
741
742 OTodo todo = currentEditor()->newTodo( currentCatId(),
743 this );
744
745 if ( currentEditor()->accepted() ) {
746 //todo.assignUid();
747 uid = todo.uid();
748 m_todoMgr.add( todo );
749 currentView()->addEvent( todo );
750
751
752 // I'm afraid we must call this every time now, otherwise
753 // spend expensive time comparing all these strings...
754 // but only call if we changed something -zecke
755 populateCategories();
756 }
757 raiseCurrentView( );
758
759 return uid;
760}
761/* delete it silently... */
762bool MainWindow::remove( int uid ) {
763 if (m_syncing) return false;
764
765 return m_todoMgr.remove( uid );
766}
767void MainWindow::beam( int uid, int ) {
768 ::unlink( beamfile );
769 OTodo todo = event( uid );
770 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) );
771 OTodoAccess acc( cal );
772 acc.load();
773 acc.add( todo );
774 acc.save();
775 Ir* ir = new Ir(this );
776 connect(ir, SIGNAL(done(Ir*) ),
777 this, SLOT(beamDone(Ir*) ) );
778 ir->send( beamfile, todo.summary(), "text/x-vCalendar" );
779}
780void MainWindow::show( int uid ) {
781 slotShow( uid );
782}
783void MainWindow::edit( int uid ) {
784 slotEdit( uid );
785}
786void MainWindow::add( const OPimRecord& rec) {
787 if ( rec.rtti() != OTodo::rtti() ) return;
788
789 const OTodo& todo = static_cast<const OTodo&>(rec);
790
791 m_todoMgr.add(todo );
792 currentView()->addEvent( todo );
793
794
795 // I'm afraid we must call this every time now, otherwise
796 // spend expensive time comparing all these strings...
797 // but only call if we changed something -zecke
798 populateCategories();
799}
800/* todo does not have the QDataStream<< and >> operators implemented :(
801 * FIXME
802 */
803OPimRecord* MainWindow::record( int rtti, const QByteArray& ) {
804 return 0l;
805}
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
index 270cbd1..14cfa82 100644
--- a/core/pim/todo/mainwindow.h
+++ b/core/pim/todo/mainwindow.h
@@ -30,10 +30,10 @@
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"
@@ -56,18 +56,18 @@ namespace Todo {
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
@@ -136,7 +136,6 @@ private slots:
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
@@ -161,11 +160,13 @@ private slots:
161 private slots: 160 private slots:
162 void slotShow(int); 161 void slotShow(int);
163 void slotEdit(int); 162 void slotEdit(int);
164private slots:
165 void slotUpdate3( QWidget* ); 163 void slotUpdate3( QWidget* );
164 void slotComplete( int uid );
165 void slotComplete( const OTodo& ev );
166 void slotNewFromTemplate(int id ); 166 void slotNewFromTemplate(int id );
167 void slotNew(); 167 void slotNew();
168 void slotDuplicate(); 168 void slotDuplicate();
169
169 void slotDelete(); 170 void slotDelete();
170 void slotDeleteAll(); 171 void slotDeleteAll();
171 void slotDeleteCompleted(); 172 void slotDeleteCompleted();
@@ -185,6 +186,17 @@ private slots:
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
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
@@ -2,11 +2,12 @@
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"
@@ -40,32 +41,36 @@ OTodo OTaskEditor::todo()const{
40 OTodo to; 41 OTodo to;
41 to.setUid(m_uid ); 42 to.setUid(m_uid );
42 m_overView->save( to ); 43 m_overView->save( to );
43 to.setDescription( m_line->text() ); 44 m_adv->save( to );
45 to.setRecurrence( m_rec->recurrence() );
44 46
45 return to; 47 return to;
46} 48}
47void OTaskEditor::load(const OTodo& to) { 49void OTaskEditor::load(const OTodo& to) {
48 m_overView->load( to ); 50 m_overView->load( to );
49 m_line->setText( to.description() ); 51 m_adv->load( to );
52 m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() );
50} 53}
51void OTaskEditor::init() { 54void OTaskEditor::init() {
52 QVBoxLayout* lay = new QVBoxLayout(this); 55 QVBoxLayout* lay = new QVBoxLayout(this );
56 QScrollView* view = new QScrollView( this );
57 view->setResizePolicy( QScrollView::AutoOneFit );
58 lay->addWidget( view );
59
53 setCaption("Task Editor"); 60 setCaption("Task Editor");
54 m_tab = new OTabWidget(this); 61 QWidget* container = new QWidget( view->viewport() );
62 view->addChild( container );
55 63
64 QVBoxLayout* layo = new QVBoxLayout( container );
65 m_tab = new OTabWidget(container );
66 layo->addWidget( m_tab );
56 /* 67 /*
57 * Add the Widgets 68 * Add the Widgets
58 */ 69 */
59 m_overView = new TaskEditorOverViewImpl(m_tab ); 70 m_overView = new TaskEditorOverViewImpl(m_tab );
60 m_tab->addTab( m_overView, QString::null, tr("Overview") ); 71 m_tab->addTab( m_overView, QString::null, tr("Overview") );
61 72
62 m_adv = new TaskEditorAdvanced( m_tab ); 73 m_adv = new TaskEditorAdvancedImpl( m_tab );
63 m_line = new QMultiLineEdit(m_adv );
64 m_line->setWordWrap( QMultiLineEdit::WidgetWidth );
65 QLabel* label = new QLabel(m_adv );
66 label->setText( tr("Description") );
67 ((QGridLayout*) m_adv->layout() )->addWidget( label,3, 0 );
68 ((QGridLayout*) m_adv->layout())->addWidget( m_line,4,0 );
69 m_tab->addTab( m_adv, QString::null, tr("Advanced") ); 74 m_tab->addTab( m_adv, QString::null, tr("Advanced") );
70 75
71 m_alarm = new TaskEditorAlarms( m_tab ); 76 m_alarm = new TaskEditorAlarms( m_tab );
@@ -81,11 +86,15 @@ void OTaskEditor::init() {
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
@@ -7,7 +7,7 @@
7#include <opie/otabwidget.h> 7#include <opie/otabwidget.h>
8 8
9class TaskEditorOverViewImpl; 9class TaskEditorOverViewImpl;
10class TaskEditorAdvanced; 10class TaskEditorAdvancedImpl;
11class TaskEditorAlarms; 11class TaskEditorAlarms;
12class ORecurranceWidget; 12class ORecurranceWidget;
13class QMultiLineEdit; 13class QMultiLineEdit;
@@ -32,11 +32,10 @@ private:
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};
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
@@ -35,6 +35,8 @@
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"
@@ -120,7 +122,7 @@ TableView::~TableView() {
120 122
121} 123}
122void TableView::slotShowMenu() { 124void TableView::slotShowMenu() {
123 QPopupMenu *menu = todoWindow()->contextMenu( current() ); 125 QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() );
124 menu->exec(QCursor::pos() ); 126 menu->exec(QCursor::pos() );
125 delete menu; 127 delete menu;
126} 128}
@@ -129,11 +131,12 @@ QString TableView::type() const {
129} 131}
130int TableView::current() { 132int TableView::current() {
131 int uid = sorted().uidAt(currentRow() ); 133 int uid = sorted().uidAt(currentRow() );
132 qWarning("uid %d", uid ); 134
133 return uid; 135 return uid;
134} 136}
135QString TableView::currentRepresentation() { 137QString TableView::currentRepresentation() {
136 return text( currentRow(), 2); 138 OTodo to = sorted()[currentRow()];
139 return to.summary().isEmpty() ? to.description().left(20) : to.summary() ;
137} 140}
138/* show overdue */ 141/* show overdue */
139void TableView::showOverDue( bool ) { 142void TableView::showOverDue( bool ) {
@@ -145,7 +148,7 @@ 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
@@ -242,10 +245,7 @@ void TableView::slotClicked(int row, int col, int,
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;
@@ -369,7 +369,7 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
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 }
@@ -462,7 +462,7 @@ void TableView::slotPriority() {
462 * 462 *
463 */ 463 */
464void TableView::timerEvent( QTimerEvent* ev ) { 464void TableView::timerEvent( QTimerEvent* ev ) {
465 qWarning("sorted %d", sorted().count() ); 465// qWarning("sorted %d", sorted().count() );
466 if (sorted().count() == 0 ) 466 if (sorted().count() == 0 )
467 return; 467 return;
468 468
@@ -513,11 +513,8 @@ void TableView::contentsMouseReleaseEvent( QMouseEvent* e) {
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}
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
@@ -11,7 +11,7 @@
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>
@@ -195,6 +195,12 @@
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>
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
@@ -7,6 +7,8 @@
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/*
@@ -20,7 +22,7 @@ TaskEditorOverViewImpl::TaskEditorOverViewImpl( QWidget* parent, const char* nam
20TaskEditorOverViewImpl::~TaskEditorOverViewImpl() { 22TaskEditorOverViewImpl::~TaskEditorOverViewImpl() {
21} 23}
22void TaskEditorOverViewImpl::load( const OTodo& todo) { 24void TaskEditorOverViewImpl::load( const OTodo& todo) {
23 /* 25 /*
24 * now that we're 'preloaded' we 26 * now that we're 'preloaded' we
25 * need to disable the buttons 27 * need to disable the buttons
26 * holding the dat 28 * holding the dat
@@ -29,16 +31,31 @@ void TaskEditorOverViewImpl::load( const OTodo& todo) {
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 );
@@ -47,6 +64,7 @@ void TaskEditorOverViewImpl::load( const OTodo& todo) {
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() );
@@ -55,12 +73,31 @@ void TaskEditorOverViewImpl::load( const OTodo& todo) {
55 73
56} 74}
57void TaskEditorOverViewImpl::save( OTodo& to) { 75void TaskEditorOverViewImpl::save( OTodo& to) {
58 qWarning("save it now"); 76 /* a invalid date */
77 QDate inval;
78 /* save our info back */
79
80 /* due date */
59 if ( ckbDue->isChecked() ) { 81 if ( ckbDue->isChecked() ) {
60 to.setDueDate( m_due ); 82 to.setDueDate( m_due );
61 to.setHasDueDate( true ); 83 to.setHasDueDate( true );
62 }else 84 }else
63 to.setHasDueDate( false ); 85 to.setHasDueDate( false );
86
87 /* start date */
88 if ( ckbStart->isChecked() ) {
89 to.setStartDate( m_start );
90 }else
91 to.setStartDate( inval );
92
93 /* comp date */
94 if ( ckbComp->isChecked() ) {
95 qWarning("completed checked");
96 to.setCompletedDate( m_comp );
97 }else
98 to.setCompletedDate( inval );
99
100
64 if ( comboCategory->currentCategory() != -1 ) { 101 if ( comboCategory->currentCategory() != -1 ) {
65 QArray<int> arr = comboCategory->currentCategories(); 102 QArray<int> arr = comboCategory->currentCategories();
66 to.setCategories( arr ); 103 to.setCategories( arr );
@@ -136,11 +173,13 @@ void TaskEditorOverViewImpl::slotStartChanged(int y, int m, int d) {
136} 173}
137void TaskEditorOverViewImpl::slotDueChecked() { 174void TaskEditorOverViewImpl::slotDueChecked() {
138 btnDue->setEnabled( ckbDue->isChecked() ); 175 btnDue->setEnabled( ckbDue->isChecked() );
176 emit dueDateChanged( m_due );
139 qWarning("slotDueChecked"); 177 qWarning("slotDueChecked");
140} 178}
141void TaskEditorOverViewImpl::slotDueChanged(int y, int m, int d ) { 179void TaskEditorOverViewImpl::slotDueChanged(int y, int m, int d ) {
142 m_due.setYMD(y, m, d ); 180 m_due.setYMD(y, m, d );
143 btnDue->setText( TimeString::longDateString( m_due ) ); 181 btnDue->setText( TimeString::longDateString( m_due ) );
182 emit dueDateChanged( m_due );
144} 183}
145void TaskEditorOverViewImpl::slotCompletedChecked() { 184void TaskEditorOverViewImpl::slotCompletedChecked() {
146 btnComp->setEnabled( ckbComp->isChecked() ); 185 btnComp->setEnabled( ckbComp->isChecked() );
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
@@ -20,6 +20,7 @@ public:
20 void save( OTodo& ); 20 void save( OTodo& );
21signals: 21signals:
22 void recurranceEnabled( bool ); 22 void recurranceEnabled( bool );
23 void dueDateChanged( const QDate& date );
23 24
24private: 25private:
25 void init(); 26 void init();
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
@@ -18,7 +18,8 @@ HEADERS = smalltodo.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 \
@@ -37,7 +38,8 @@ SOURCES = smalltodo.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
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
@@ -85,12 +85,15 @@ void TodoManager::update( int, const SmallTodo& ) {
85void TodoManager::update( int, const OTodo& ev) { 85void TodoManager::update( int, const OTodo& ev) {
86 m_db->replace( ev ); 86 m_db->replace( ev );
87} 87}
88void TodoManager::remove( int uid ) { 88bool TodoManager::remove( int uid ) {
89 m_db->remove( uid ); 89 return m_db->remove( uid );
90} 90}
91void TodoManager::removeAll() { 91void TodoManager::removeAll() {
92 m_db->clear(); 92 m_db->clear();
93} 93}
94void TodoManager::removeCompleted() {
95 m_db->removeAllCompleted();
96}
94void TodoManager::save() { 97void TodoManager::save() {
95 m_db->save(); 98 m_db->save();
96} 99}
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
@@ -82,8 +82,13 @@ namespace Todo {
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();
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
@@ -4,52 +4,24 @@
4 4
5using namespace Todo; 5using namespace Todo;
6 6
7
8
9
7TodoView::TodoView( MainWindow* win ) 10TodoView::TodoView( MainWindow* win )
8 : m_main( win ) 11 : m_main( win )
9{ 12{
10 hack = new InternQtHack;
11 m_asc = false; 13 m_asc = false;
12 m_sortOrder = -1; 14 m_sortOrder = -1;
13} 15}
14TodoView::~TodoView() { 16TodoView::~TodoView() {
15 delete hack;
16}; 17};
17
18void TodoView::connectShow(QObject* obj,
19 const char* slot ) {
20 QObject::connect( hack, SIGNAL(showTodo(int) ),
21 obj, slot );
22}
23void TodoView::connectEdit( QObject* obj,
24 const char* slot ) {
25 QObject::connect( hack, SIGNAL(edit(int) ),
26 obj, slot );
27}
28void TodoView::connectUpdateSmall( QObject* obj,
29 const char* slot ) {
30 QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ),
31 obj, slot );
32}
33void TodoView::connectUpdateBig( QObject* obj,
34 const char* slot ) {
35 QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ),
36 obj, slot );
37}
38void TodoView::connectUpdateView( QObject* obj,
39 const char* slot ) {
40 QObject::connect( hack, SIGNAL(update(QWidget*) ),
41 obj, slot );
42}
43void TodoView::connectRemove( QObject* obj,
44 const char* slot ) {
45 QObject::connect( hack, SIGNAL(remove(int) ),
46 obj, slot );
47}
48MainWindow* TodoView::todoWindow() { 18MainWindow* TodoView::todoWindow() {
49 return m_main; 19 return m_main;
50} 20}
51 21
52OTodo TodoView::event(int uid ) { return m_main->event( uid ); } 22OTodo TodoView::event(int uid ) {
23 return m_main->event( uid );
24}
53OTodoAccess::List TodoView::list(){ 25OTodoAccess::List TodoView::list(){
54 todoWindow()->updateList(); 26 todoWindow()->updateList();
55 return todoWindow()->list(); 27 return todoWindow()->list();
@@ -77,3 +49,18 @@ void TodoView::update(int, const SmallTodo& ) {
77void TodoView::update(int , const OTodo& ev ) { 49void TodoView::update(int , const OTodo& ev ) {
78 m_main->updateTodo( ev ); 50 m_main->updateTodo( ev );
79} 51}
52void TodoView::showTodo( int uid ) {
53 m_main->slotShow( uid );
54}
55void TodoView::edit( int uid ) {
56 m_main->slotEdit( uid );
57}
58void TodoView::remove( int uid ) {
59 m_main->m_todoMgr.remove( uid );
60}
61void TodoView::complete( int uid ) {
62 m_main->slotComplete( uid );
63}
64void TodoView::complete( const OTodo& ev ) {
65 m_main->slotComplete( ev );
66}
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h
index e5c77f9..e73e808 100644
--- a/core/pim/todo/todoview.h
+++ b/core/pim/todo/todoview.h
@@ -40,49 +40,12 @@
40 40
41 41
42namespace Todo { 42namespace Todo {
43
44 /**
45 * According to tronical it's not possible
46 * to have Q_OBJECT in a template at all
47 * so this is a hack widget not meant
48 * to be public
49 */
50 class InternQtHack : public QObject {
51 Q_OBJECT
52 public:
53 InternQtHack() : QObject() {};
54 void emitShow(int uid) { emit showTodo(uid); }
55 void emitEdit(int uid) { emit edit(uid ); }
56 void emitUpdate( int uid,
57 const SmallTodo& to) {
58 emit update(uid, to );
59 }
60 void emitUpdate( int uid,
61 const OTodo& ev ){
62 emit update(uid, ev );
63 }
64 void emitRemove( int uid ) {
65 emit remove( uid );
66 }
67 void emitUpdate( QWidget* wid ) {
68 emit update( wid );
69 }
70 signals:
71 void showTodo(int uid );
72 void edit(int uid );
73 void update( int uid, const Todo::SmallTodo& );
74 void update( int uid, const OTodo& );
75 /* sorry you need to cast */;
76 void update( QWidget* wid );
77 void remove( int uid );
78
79 };
80 class MainWindow; 43 class MainWindow;
81 44
82 /** 45 /**
83 * due to inheretince problems we need this base class 46 * due to inheretince problems we need this base class
84 */ 47 */
85 class ViewBase { 48 struct ViewBase {
86 public: 49 public:
87 virtual QWidget* widget() = 0; 50 virtual QWidget* widget() = 0;
88 virtual QString type()const = 0; 51 virtual QString type()const = 0;
@@ -102,16 +65,7 @@ namespace Todo {
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 /**
@@ -138,21 +92,6 @@ namespace Todo {
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 );
@@ -164,20 +103,17 @@ namespace Todo {
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;