author | zecke <zecke> | 2002-10-13 19:09:09 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-13 19:09:09 (UTC) |
commit | 0762b201f248b9eaf3a08601b04484bec9a6d9a1 (patch) (unidiff) | |
tree | 5f386485a6b3b3e5c6edeeefdd26ef98ff924a34 | |
parent | 34c1199becdb2f9b0447553e66c85d8f6770558f (diff) | |
download | opie-0762b201f248b9eaf3a08601b04484bec9a6d9a1.zip opie-0762b201f248b9eaf3a08601b04484bec9a6d9a1.tar.gz opie-0762b201f248b9eaf3a08601b04484bec9a6d9a1.tar.bz2 |
Implement beaming and adding of todos. Use the vCal resource for that
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 52 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 1 | ||||
-rw-r--r-- | core/pim/todo/todo.pro | 2 |
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,73 +1,77 @@ | |||
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 | ||
53 | using namespace Todo; | 57 | using namespace Todo; |
54 | 58 | ||
55 | MainWindow::MainWindow( QWidget* parent, | 59 | MainWindow::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() ) ); |
@@ -499,72 +503,108 @@ void MainWindow::setCategory( int c) { | |||
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 | } |
520 | void MainWindow::slotShowDeadLine( bool dead) { | 524 | void MainWindow::slotShowDeadLine( bool dead) { |
521 | m_deadline = dead; | 525 | m_deadline = dead; |
522 | currentView()->setShowDeadline( dead ); | 526 | currentView()->setShowDeadline( dead ); |
523 | } | 527 | } |
524 | void MainWindow::slotShowCompleted( bool show) { | 528 | void MainWindow::slotShowCompleted( bool show) { |
525 | m_completed = show; | 529 | m_completed = show; |
526 | currentView()->setShowCompleted( m_completed ); | 530 | currentView()->setShowCompleted( m_completed ); |
527 | } | 531 | } |
528 | bool MainWindow::showOverDue()const { | 532 | bool MainWindow::showOverDue()const { |
529 | return m_overdue; | 533 | return m_overdue; |
530 | } | 534 | } |
531 | void MainWindow::setDocument( const QString& ) { | 535 | void 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 | } |
534 | void MainWindow::slotBeam() { | ||
535 | |||
536 | } | ||
537 | void MainWindow::beamDone( Ir* ) { | ||
538 | 542 | ||
543 | static const char *beamfile = "/tmp/opie-todo.vcs"; | ||
544 | void 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 | } | ||
558 | void MainWindow::beamDone( Ir* ir) { | ||
559 | delete ir; | ||
560 | ::unlink( beamfile ); | ||
561 | } | ||
562 | void 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 | ||
541 | void MainWindow::slotFlush() { | 581 | void MainWindow::slotFlush() { |
542 | m_syncing = FALSE; | 582 | m_syncing = FALSE; |
543 | m_todoMgr.save(); | 583 | m_todoMgr.save(); |
544 | } | 584 | } |
545 | void MainWindow::slotShowDetails() { | 585 | void 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 | */ |
552 | void MainWindow::populateCategories() { | 592 | void 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 | } |
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 | |||
@@ -67,64 +67,65 @@ namespace Todo { | |||
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(); |
90 | private slots: | 90 | private 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, |
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,34 +1,34 @@ | |||
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 |