summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp52
-rw-r--r--core/pim/todo/mainwindow.h1
-rw-r--r--core/pim/todo/todo.pro2
3 files changed, 48 insertions, 7 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index c9c43d4..2994915 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,89 +1,93 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = General Public License along with 21  -_. . .   )=.  = General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include <unistd.h>
30
29#include <qmenubar.h> 31#include <qmenubar.h>
30#include <qmessagebox.h> 32#include <qmessagebox.h>
31#include <qtoolbar.h> 33#include <qtoolbar.h>
32#include <qpopupmenu.h> 34#include <qpopupmenu.h>
33#include <qwidgetstack.h> 35#include <qwidgetstack.h>
34#include <qaction.h> 36#include <qaction.h>
35#include <qtimer.h> 37#include <qtimer.h>
36 38
39#include <qpe/applnk.h>
37#include <qpe/config.h> 40#include <qpe/config.h>
38#include <qpe/ir.h> 41#include <qpe/ir.h>
39#include <qpe/resource.h> 42#include <qpe/resource.h>
40#include <qpe/qpemessagebox.h> 43#include <qpe/qpemessagebox.h>
41 44
45#include <opie/otodoaccessvcal.h>
42 46
43#include "todotemplatemanager.h" 47#include "todotemplatemanager.h"
44#include "templateeditor.h" 48#include "templateeditor.h"
45#include "todoentryimpl.h" 49#include "todoentryimpl.h"
46#include "tableview.h" 50#include "tableview.h"
47 51
48#include "textviewshow.h" 52#include "textviewshow.h"
49#include "todoeditor.h" 53#include "todoeditor.h"
50#include "mainwindow.h" 54#include "mainwindow.h"
51 55
52 56
53using namespace Todo; 57using namespace Todo;
54 58
55MainWindow::MainWindow( QWidget* parent, 59MainWindow::MainWindow( QWidget* parent,
56 const char* name ) { 60 const char* name ) {
57 61
58 m_syncing = false; 62 m_syncing = false;
59 m_counter = 0; 63 m_counter = 0;
60 m_tempManager = new TemplateManager(); 64 m_tempManager = new TemplateManager();
61 m_tempManager->load(); 65 m_tempManager->load();
62 66
63 initUI(); 67 initUI();
64 initConfig(); 68 initConfig();
65 initViews(); 69 initViews();
66 initActions(); 70 initActions();
67 initEditor(); 71 initEditor();
68 initShow(); 72 initShow();
69 initTemplate(); 73 initTemplate();
70 74
71 populateTemplates(); 75 populateTemplates();
72 raiseCurrentView(); 76 raiseCurrentView();
73 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 77 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
74} 78}
75void MainWindow::initTemplate() { 79void MainWindow::initTemplate() {
76 m_curTempEd = new TemplateEditor( this, templateManager() ); 80 m_curTempEd = new TemplateEditor( this, templateManager() );
77} 81}
78void MainWindow::initActions() { 82void MainWindow::initActions() {
79 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), 83 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ),
80 QString::null, 0, this, 0 ); 84 QString::null, 0, this, 0 );
81 connect(a, SIGNAL( activated() ), 85 connect(a, SIGNAL( activated() ),
82 this, SLOT( slotNew() ) ); 86 this, SLOT( slotNew() ) );
83 a->addTo(m_tool ); 87 a->addTo(m_tool );
84 a->addTo(m_edit ); 88 a->addTo(m_edit );
85 89
86 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), 90 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ),
87 QString::null, 0, this, 0 ); 91 QString::null, 0, this, 0 );
88 connect(a, SIGNAL(activated() ), 92 connect(a, SIGNAL(activated() ),
89 this, SLOT( slotEdit() ) ); 93 this, SLOT( slotEdit() ) );
@@ -483,104 +487,140 @@ void MainWindow::slotDeleteCompleted() {
483 // FIXME 487 // FIXME
484 //m_todoMgr.remove( currentView()->completed() ); 488 //m_todoMgr.remove( currentView()->completed() );
485 currentView()->updateView( ); 489 currentView()->updateView( );
486} 490}
487void MainWindow::slotFind() { 491void MainWindow::slotFind() {
488 492
489} 493}
490void MainWindow::slotEdit() { 494void MainWindow::slotEdit() {
491 slotEdit( currentView()->current() ); 495 slotEdit( currentView()->current() );
492} 496}
493/* 497/*
494 * set the category 498 * set the category
495 */ 499 */
496void MainWindow::setCategory( int c) { 500void MainWindow::setCategory( int c) {
497 if ( c <= 0 ) return; 501 if ( c <= 0 ) return;
498 502
499 503
500 qWarning("Iterating over cats %d", c ); 504 qWarning("Iterating over cats %d", c );
501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 505 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
502 m_catMenu->setItemChecked(i, c == (int)i ); 506 m_catMenu->setItemChecked(i, c == (int)i );
503 507
504 if (c == 1 ) { 508 if (c == 1 ) {
505 m_curCat = QString::null; 509 m_curCat = QString::null;
506 setCaption( tr("Todo") + " - " + tr("All Categories" ) ); 510 setCaption( tr("Todo") + " - " + tr("All Categories" ) );
507 511
508 }else if ( c == (int)m_catMenu->count() - 1 ) { 512 }else if ( c == (int)m_catMenu->count() - 1 ) {
509 m_curCat = tr("Unfiled"); 513 m_curCat = tr("Unfiled");
510 setCaption( tr("Todo") + " - " + tr("Unfiled") ); 514 setCaption( tr("Todo") + " - " + tr("Unfiled") );
511 }else { 515 }else {
512 m_curCat = m_todoMgr.categories()[c-2]; 516 m_curCat = m_todoMgr.categories()[c-2];
513 setCaption( tr("Todo") + " - " + m_curCat ); 517 setCaption( tr("Todo") + " - " + m_curCat );
514 } 518 }
515 m_catMenu->setItemChecked( c, true ); 519 m_catMenu->setItemChecked( c, true );
516 520
517 currentView()->setShowCategory( m_curCat ); 521 currentView()->setShowCategory( m_curCat );
518 raiseCurrentView(); 522 raiseCurrentView();
519} 523}
520void MainWindow::slotShowDeadLine( bool dead) { 524void MainWindow::slotShowDeadLine( bool dead) {
521 m_deadline = dead; 525 m_deadline = dead;
522 currentView()->setShowDeadline( dead ); 526 currentView()->setShowDeadline( dead );
523} 527}
524void MainWindow::slotShowCompleted( bool show) { 528void MainWindow::slotShowCompleted( bool show) {
525 m_completed = show; 529 m_completed = show;
526 currentView()->setShowCompleted( m_completed ); 530 currentView()->setShowCompleted( m_completed );
527} 531}
528bool MainWindow::showOverDue()const { 532bool MainWindow::showOverDue()const {
529 return m_overdue; 533 return m_overdue;
530} 534}
531void MainWindow::setDocument( const QString& ) { 535void MainWindow::setDocument( const QString& fi) {
532 536 DocLnk doc(fi);
537 if (doc.isValid() )
538 receiveFile(doc.file() );
539 else
540 receiveFile(fi );
533} 541}
534void MainWindow::slotBeam() {
535
536}
537void MainWindow::beamDone( Ir* ) {
538 542
543static const char *beamfile = "/tmp/opie-todo.vcs";
544void MainWindow::slotBeam() {
545 ::unlink( beamfile );
546 OTodo todo = event( currentView()->current() );
547 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) );
548 OTodoAccess acc( cal );
549 acc.load();
550 acc.add( todo );
551 acc.save();
552 Ir* ir = new Ir(this );
553 connect(ir, SIGNAL(done(Ir*) ),
554 this, SLOT(beamDone(Ir*) ) );
555 ir->send( beamfile, todo.summary(), "text/x-vCalendar" );
556
557}
558void MainWindow::beamDone( Ir* ir) {
559 delete ir;
560 ::unlink( beamfile );
561}
562void MainWindow::receiveFile( const QString& filename ) {
563 OTodoAccessVCal* cal = new OTodoAccessVCal(filename );
564 OTodoAccess acc( cal );
565 acc.load();
566 OTodoAccess::List list = acc.allRecords();
567
568 QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
569
570 if ( QMessageBox::information(this, tr("New Tasks"),
571 message, QMessageBox::Ok,
572 QMessageBox::Cancel ) == QMessageBox::Ok ) {
573 OTodoAccess::List::Iterator it;
574 for ( it = list.begin(); it != list.end(); ++it )
575 m_todoMgr.add( (*it) );
576
577 currentView()->updateView();
578 }
539} 579}
540 580
541void MainWindow::slotFlush() { 581void MainWindow::slotFlush() {
542 m_syncing = FALSE; 582 m_syncing = FALSE;
543 m_todoMgr.save(); 583 m_todoMgr.save();
544} 584}
545void MainWindow::slotShowDetails() { 585void MainWindow::slotShowDetails() {
546 slotShow( currentView()->current() ); 586 slotShow( currentView()->current() );
547} 587}
548/* 588/*
549 * populate the Categories 589 * populate the Categories
550 * Menu 590 * Menu
551 */ 591 */
552void MainWindow::populateCategories() { 592void MainWindow::populateCategories() {
553 m_todoMgr.load(); 593 m_todoMgr.load();
554 594
555 m_catMenu->clear(); 595 m_catMenu->clear();
556 int id, rememberId; 596 int id, rememberId;
557 id = 1; 597 id = 1;
558 rememberId = 1; 598 rememberId = 1;
559 599
560 m_catMenu->insertItem( tr( "All Categories" ), id++ ); 600 m_catMenu->insertItem( tr( "All Categories" ), id++ );
561 m_catMenu->insertSeparator(); 601 m_catMenu->insertSeparator();
562 QStringList categories = m_todoMgr.categories(); 602 QStringList categories = m_todoMgr.categories();
563 categories.append( tr( "Unfiled" ) ); 603 categories.append( tr( "Unfiled" ) );
564 for ( QStringList::Iterator it = categories.begin(); 604 for ( QStringList::Iterator it = categories.begin();
565 it != categories.end(); ++it ) { 605 it != categories.end(); ++it ) {
566 m_catMenu->insertItem( *it, id ); 606 m_catMenu->insertItem( *it, id );
567 if ( *it == currentCategory() ) 607 if ( *it == currentCategory() )
568 rememberId = id; 608 rememberId = id;
569 ++id; 609 ++id;
570 } 610 }
571 setCategory( rememberId ); 611 setCategory( rememberId );
572} 612}
573bool MainWindow::showCompleted()const { 613bool MainWindow::showCompleted()const {
574 return m_completed; 614 return m_completed;
575} 615}
576bool MainWindow::showDeadline()const { 616bool MainWindow::showDeadline()const {
577 return m_deadline; 617 return m_deadline;
578} 618}
579QString MainWindow::currentCategory()const { 619QString MainWindow::currentCategory()const {
580 return m_curCat; 620 return m_curCat;
581} 621}
582int MainWindow::currentCatId() { 622int MainWindow::currentCatId() {
583 return m_todoMgr.catId( m_curCat ); 623 return m_todoMgr.catId( m_curCat );
584} 624}
585ViewBase* MainWindow::currentView() { 625ViewBase* MainWindow::currentView() {
586 return m_curView; 626 return m_curView;
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
index 598c3af..8d0c29f 100644
--- a/core/pim/todo/mainwindow.h
+++ b/core/pim/todo/mainwindow.h
@@ -51,96 +51,97 @@ namespace Todo {
51 typedef TodoView View; 51 typedef TodoView View;
52 class TemplateManager; 52 class TemplateManager;
53 class Editor; 53 class Editor;
54 class TodoShow; 54 class TodoShow;
55 class TemplateEditor; 55 class TemplateEditor;
56 56
57 class MainWindow : public QMainWindow { 57 class MainWindow : public QMainWindow {
58 Q_OBJECT 58 Q_OBJECT
59 public: 59 public:
60 MainWindow( QWidget *parent = 0, 60 MainWindow( QWidget *parent = 0,
61 const char* name = 0 ); 61 const char* name = 0 );
62 ~MainWindow(); 62 ~MainWindow();
63 63
64 /** return a context menu for an OTodo */ 64 /** return a context menu for an OTodo */
65 QPopupMenu* contextMenu(int uid ); 65 QPopupMenu* contextMenu(int uid );
66 QPopupMenu* options(); 66 QPopupMenu* options();
67 QPopupMenu* edit(); 67 QPopupMenu* edit();
68 QPopupMenu* view(); 68 QPopupMenu* view();
69 QToolBar* toolbar(); 69 QToolBar* toolbar();
70 70
71 71
72 void updateList(); 72 void updateList();
73 OTodoAccess::List list()const; 73 OTodoAccess::List list()const;
74 OTodoAccess::List sorted( bool asc, int sortOrder ); 74 OTodoAccess::List sorted( bool asc, int sortOrder );
75 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); 75 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter );
76 76
77 OTodo event(int uid ); 77 OTodo event(int uid );
78 78
79 bool isSyncing()const; 79 bool isSyncing()const;
80 bool showCompleted()const; 80 bool showCompleted()const;
81 bool showDeadline()const; 81 bool showDeadline()const;
82 bool showOverDue()const; 82 bool showOverDue()const;
83 QString currentCategory()const; 83 QString currentCategory()const;
84 int currentCatId(); 84 int currentCatId();
85 TemplateManager* templateManager(); 85 TemplateManager* templateManager();
86 86
87 void updateTodo( const OTodo& ); 87 void updateTodo( const OTodo& );
88 void populateTemplates(); 88 void populateTemplates();
89 Editor* currentEditor(); 89 Editor* currentEditor();
90private slots: 90private slots:
91 void populateCategories(); 91 void populateCategories();
92 void slotReload(); 92 void slotReload();
93 void slotFlush(); 93 void slotFlush();
94 94
95 protected: 95 protected:
96 void closeEvent( QCloseEvent* e ); 96 void closeEvent( QCloseEvent* e );
97 97
98 private: 98 private:
99 void receiveFile( const QString& filename );
99 void connectBase( ViewBase* ); 100 void connectBase( ViewBase* );
100 void initUI(); 101 void initUI();
101 void initActions(); 102 void initActions();
102 void initConfig(); 103 void initConfig();
103 void initViews(); 104 void initViews();
104 void initEditor(); 105 void initEditor();
105 void initShow(); 106 void initShow();
106 void initTemplate(); 107 void initTemplate();
107 void raiseCurrentView(); 108 void raiseCurrentView();
108 ViewBase* currentView(); 109 ViewBase* currentView();
109 ViewBase* m_curView; 110 ViewBase* m_curView;
110 Editor* m_curEdit; 111 Editor* m_curEdit;
111 TodoShow* currentShow(); 112 TodoShow* currentShow();
112 TodoShow* m_curShow; 113 TodoShow* m_curShow;
113 TemplateEditor* currentTemplateEditor(); 114 TemplateEditor* currentTemplateEditor();
114 TemplateEditor* m_curTempEd; 115 TemplateEditor* m_curTempEd;
115 116
116 QMenuBar* m_bar; 117 QMenuBar* m_bar;
117 QToolBar* m_tool; 118 QToolBar* m_tool;
118 QAction* m_editAction, 119 QAction* m_editAction,
119 *m_deleteAction, 120 *m_deleteAction,
120 *m_findAction, 121 *m_findAction,
121 *m_completedAction, 122 *m_completedAction,
122 *m_showDeadLineAction, 123 *m_showDeadLineAction,
123 *m_deleteAllAction, 124 *m_deleteAllAction,
124 *m_deleteCompleteAction, 125 *m_deleteCompleteAction,
125 *m_duplicateAction, 126 *m_duplicateAction,
126 *m_showOverDueAction, 127 *m_showOverDueAction,
127 *m_effectiveAction; 128 *m_effectiveAction;
128 QWidgetStack *m_stack; 129 QWidgetStack *m_stack;
129 QPopupMenu* m_catMenu, 130 QPopupMenu* m_catMenu,
130 *m_edit, 131 *m_edit,
131 *m_options, 132 *m_options,
132 *m_view, 133 *m_view,
133 *m_template; 134 *m_template;
134 135
135 bool m_syncing:1; 136 bool m_syncing:1;
136 bool m_deadline:1; 137 bool m_deadline:1;
137 bool m_completed:1; 138 bool m_completed:1;
138 bool m_overdue:1; 139 bool m_overdue:1;
139 TodoManager m_todoMgr; 140 TodoManager m_todoMgr;
140 QString m_curCat; 141 QString m_curCat;
141 QList<ViewBase> m_views; 142 QList<ViewBase> m_views;
142 uint m_counter; 143 uint m_counter;
143 TemplateManager* m_tempManager; 144 TemplateManager* m_tempManager;
144 145
145 private slots: 146 private slots:
146 void slotShow(int); 147 void slotShow(int);
diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro
index 3ff78f5..f26acee 100644
--- a/core/pim/todo/todo.pro
+++ b/core/pim/todo/todo.pro
@@ -1,50 +1,50 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on debug 2 CONFIG = qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin 3 DESTDIR = $(OPIEDIR)/bin
4 4
5 HEADERS= smalltodo.h \ 5 HEADERS= smalltodo.h \
6 todomanager.h \ 6 todomanager.h \
7 mainwindow.h \ 7 mainwindow.h \
8 todoview.h \ 8 todoview.h \
9 todoentryimpl.h \ 9 todoentryimpl.h \
10 tableview.h \ 10 tableview.h \
11 tableitems.h \ 11 tableitems.h \
12 todotemplatemanager.h \ 12 todotemplatemanager.h \
13 todoeditor.h \ 13 todoeditor.h \
14 todoshow.h \ 14 todoshow.h \
15 textviewshow.h \ 15 textviewshow.h \
16 templateeditor.h \ 16 templateeditor.h \
17 templatedialog.h \ 17 templatedialog.h \
18 templatedialogimpl.h 18 templatedialogimpl.h
19 19
20 SOURCES= smalltodo.cpp \ 20 SOURCES= smalltodo.cpp \
21 todomanager.cpp \ 21 todomanager.cpp \
22 mainwindow.cpp \ 22 mainwindow.cpp \
23 main.cpp \ 23 main.cpp \
24 todoentryimpl.cpp \ 24 todoentryimpl.cpp \
25 tableview.cpp \ 25 tableview.cpp \
26 tableitems.cpp \ 26 tableitems.cpp \
27 todoview.cpp \ 27 todoview.cpp \
28 todotemplatemanager.cpp \ 28 todotemplatemanager.cpp \
29 todoeditor.cpp \ 29 todoeditor.cpp \
30 todoshow.cpp \ 30 todoshow.cpp \
31 textviewshow.cpp \ 31 textviewshow.cpp \
32 templateeditor.cpp \ 32 templateeditor.cpp \
33 templatedialog.cpp \ 33 templatedialog.cpp \
34 templatedialogimpl.cpp 34 templatedialogimpl.cpp
35 35
36 INTERFACES= todoentry.ui 36 INTERFACES= todoentry.ui
37 TARGET = todolist 37 TARGET = todolist
38INCLUDEPATH += $(OPIEDIR)/include 38INCLUDEPATH += $(OPIEDIR)/include
39 DEPENDPATH+= $(OPIEDIR)/include 39 DEPENDPATH+= $(OPIEDIR)/include
40LIBS += -lqpe -lopie 40LIBS += -lqpe -lopie
41 41
42TRANSLATIONS = ../../../i18n/de/todolist.ts \ 42TRANSLATIONS = ../../../i18n/de/todolist.ts \
43 ../../../i18n/en/todolist.ts \ 43 ../../../i18n/en/todolist.ts \
44 ../../../i18n/es/todolist.ts \ 44 ../../../i18n/es/todolist.ts \
45 ../../../i18n/fr/todolist.ts \ 45 ../../../i18n/fr/todolist.ts \
46 ../../../i18n/hu/todolist.ts \ 46 ../../../i18n/hu/todolist.ts \
47 ../../../i18n/ja/todolist.ts \ 47 ../../../i18n/ja/todolist.ts \
48 ../../../i18n/ko/todolist.ts \ 48 ../../../i18n/ko/todolist.ts \
49 ../../../i18n/no/todolist.ts \ 49 ../../../i18n/no/todolist.ts \
50 ../../../i18n/pl/todolist.ts \ 50 ../../../i18n/pl/todolist.ts \