summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/TODO27
-rw-r--r--core/pim/todo/main.cpp44
-rw-r--r--core/pim/todo/mainwindow.cpp621
-rw-r--r--core/pim/todo/mainwindow.h175
-rw-r--r--core/pim/todo/opie-todo.control9
-rw-r--r--core/pim/todo/smalltodo.cpp114
-rw-r--r--core/pim/todo/smalltodo.h70
-rw-r--r--core/pim/todo/tableitems.cpp181
-rw-r--r--core/pim/todo/tableitems.h124
-rw-r--r--core/pim/todo/tableview.cpp362
-rw-r--r--core/pim/todo/tableview.h120
-rw-r--r--core/pim/todo/templatedialog.cpp60
-rw-r--r--core/pim/todo/templatedialog.h44
-rw-r--r--core/pim/todo/templatedialogimpl.cpp119
-rw-r--r--core/pim/todo/templatedialogimpl.h33
-rw-r--r--core/pim/todo/templateeditor.cpp39
-rw-r--r--core/pim/todo/templateeditor.h31
-rw-r--r--core/pim/todo/textviewshow.cpp19
-rw-r--r--core/pim/todo/textviewshow.h17
-rw-r--r--core/pim/todo/todo.pro55
-rw-r--r--core/pim/todo/todoeditor.cpp53
-rw-r--r--core/pim/todo/todoeditor.h25
-rw-r--r--core/pim/todo/todoentry.ui481
-rw-r--r--core/pim/todo/todoentryimpl.cpp189
-rw-r--r--core/pim/todo/todoentryimpl.h65
-rw-r--r--core/pim/todo/todomanager.cpp125
-rw-r--r--core/pim/todo/todomanager.h107
-rw-r--r--core/pim/todo/todoshow.cpp9
-rw-r--r--core/pim/todo/todoshow.h53
-rw-r--r--core/pim/todo/todotemplatemanager.cpp75
-rw-r--r--core/pim/todo/todotemplatemanager.h32
-rw-r--r--core/pim/todo/todoview.cpp62
-rw-r--r--core/pim/todo/todoview.h178
33 files changed, 3718 insertions, 0 deletions
diff --git a/core/pim/todo/TODO b/core/pim/todo/TODO
new file mode 100644
index 0000000..a7b430a
--- a/dev/null
+++ b/core/pim/todo/TODO
@@ -0,0 +1,27 @@
105.09.2002
2-Implement a ProjectView
3-Implement Templates
4-Implement Template COnfig
5-Implement MoreConfig
6-Implement beaming again
7-Implement setDocument
8-Implement ViewMenu
9-Implement OFontMenu again
10
11
12
13older
14HI,
15this is the Todo for the TODO Application.
16
17I started a small rewrite of the whole application.
18The idea is to have only the necessary bits
19in memory at once.
20It's meant to be extandable and exchangable.
21I've TodoView as a Baseclass for all Views representationg
22todos. So you could have a QTable or QListView todo
23
24What's missing is:
25Implementation of the views.
26The MainWindow Implementation
27The connection between the Parts \ No newline at end of file
diff --git a/core/pim/todo/main.cpp b/core/pim/todo/main.cpp
new file mode 100644
index 0000000..73977c2
--- a/dev/null
+++ b/core/pim/todo/main.cpp
@@ -0,0 +1,44 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include "mainwindow.h"
22
23
24#include <qdatetime.h>
25
26#include <qpe/qpeapplication.h>
27
28int main( int argc, char **argv )
29{
30 QPEApplication a( argc, argv );
31
32 QTime time;
33 time.start();
34 Todo::MainWindow mw;
35 int t = time.elapsed();
36 qWarning("QTime %d", t/1000 );
37 mw.setCaption("Opie Todolist");
38 QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) );
39 QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) );
40
41 a.showMainWidget(&mw);
42
43 return a.exec();
44}
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
new file mode 100644
index 0000000..a8f4c9c
--- a/dev/null
+++ b/core/pim/todo/mainwindow.cpp
@@ -0,0 +1,621 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include <qmenubar.h>
30#include <qmessagebox.h>
31#include <qtoolbar.h>
32#include <qpopupmenu.h>
33#include <qwidgetstack.h>
34#include <qaction.h>
35#include <qtimer.h>
36
37#include <qpe/config.h>
38#include <qpe/ir.h>
39#include <qpe/resource.h>
40#include <qpe/qpemessagebox.h>
41
42
43#include "todotemplatemanager.h"
44#include "templateeditor.h"
45#include "todoentryimpl.h"
46#include "tableview.h"
47
48#include "textviewshow.h"
49#include "todoeditor.h"
50#include "mainwindow.h"
51
52
53using namespace Todo;
54
55MainWindow::MainWindow( QWidget* parent,
56 const char* name ) {
57
58 m_syncing = false;
59 m_counter = 0;
60 m_tempManager = new TemplateManager();
61 m_tempManager->load();
62
63 initUI();
64 initConfig();
65 initViews();
66 initActions();
67 initEditor();
68 initShow();
69 initTemplate();
70
71 populateTemplates();
72 raiseCurrentView();
73 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
74}
75void MainWindow::initTemplate() {
76 m_curTempEd = new TemplateEditor( this, templateManager() );
77}
78void MainWindow::initActions() {
79 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ),
80 QString::null, 0, this, 0 );
81 connect(a, SIGNAL( activated() ),
82 this, SLOT( slotNew() ) );
83 a->addTo(m_tool );
84 a->addTo(m_edit );
85
86 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ),
87 QString::null, 0, this, 0 );
88 connect(a, SIGNAL(activated() ),
89 this, SLOT( slotEdit() ) );
90 a->addTo( m_tool );
91 a->addTo( m_edit );
92 m_editAction = a;
93
94 a = new QAction( QString::null, tr("View Task"), 0, this, 0 );
95 connect(a, SIGNAL( activated() ),
96 this, SLOT( slotShowDetails() ) );
97 a->addTo( m_edit );
98
99 m_edit->insertSeparator();
100
101 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ),
102 QString::null, 0, this, 0 );
103 connect(a, SIGNAL(activated() ),
104 this, SLOT(slotDelete() ) );
105 a->addTo( m_tool );
106 a->addTo( m_edit );
107 m_deleteAction = a;
108
109 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 );
110 connect(a, SIGNAL( activated() ),
111 this, SLOT( slotDeleteAll() ) );
112 a->addTo(m_edit );
113 m_deleteAllAction = a;
114
115 a = new QAction( QString::null, tr("Delete completed"),
116 0, this, 0 );
117 connect(a, SIGNAL( activated() ),
118 this, SLOT( slotDeleteCompleted() ) );
119 a->addTo(m_edit );
120 a->setEnabled( TRUE );
121 m_deleteCompleteAction = a;
122
123 m_edit->insertSeparator();
124
125 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 );
126 connect(a, SIGNAL( activated() ),
127 this, SLOT( slotDuplicate() ) );
128 a->addTo(m_edit );
129 m_duplicateAction = a;
130
131 m_edit->insertSeparator();
132
133 if ( Ir::supported() ) {
134 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
135 QString::null, 0, this, 0 );
136 connect( a, SIGNAL( activated() ),
137 this, SLOT( slotBeam() ) );
138 a->addTo( m_edit );
139 a->addTo( m_tool );
140 }
141
142 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ),
143 QString::null, 0, this, 0 );
144 connect(a, SIGNAL( activated() ),
145 this, SLOT( slotFind() ) );
146 a->addTo( m_options );
147 m_findAction = a;
148
149 m_options->insertSeparator();
150
151 m_completedAction = new QAction( QString::null, tr("Completed tasks"),
152 0, this, 0, TRUE );
153 m_completedAction->addTo( m_options );
154 m_completedAction->setOn( showCompleted() );
155 connect(m_completedAction, SIGNAL( toggled(bool) ),
156 this, SLOT(slotShowCompleted(bool) ) );
157
158 m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"),
159 0, this, 0, TRUE );
160 m_showDeadLineAction->addTo( m_options );
161 m_showDeadLineAction->setOn( showDeadline() );
162 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ),
163 this, SLOT( slotShowDeadLine( bool ) ) );
164
165 m_options->insertSeparator();
166
167 m_bar->insertItem( tr("Data") ,m_edit );
168 m_bar->insertItem( tr("Category"), m_catMenu );
169 m_bar->insertItem( tr("Options"), m_options );
170
171 /* initialize the view menu */
172 a = new QAction( QString::null, tr("Show over due"),
173 0, this, 0, TRUE );
174 a->addTo( m_view );
175 a->setOn( showOverDue() );
176 connect(a, SIGNAL(toggled(bool)),
177 this, SLOT(slotShowDue(bool) ) );
178 m_view->insertSeparator();
179
180 m_bar->insertItem( tr("View"), m_view );
181
182 /* templates */
183 m_edit->insertItem(tr("New from template"), m_template,
184 -1, 0 );
185
186}
187/* m_curCat from Config */
188void MainWindow::initConfig() {
189 Config config( "todo" );
190 config.setGroup( "View" );
191 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
192 m_curCat = config.readEntry( "Category", QString::null );
193 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
194 m_overdue = config.readBoolEntry("ShowOverDue", TRUE );
195}
196void MainWindow::initUI() {
197 m_stack = new QWidgetStack(this, "main stack");
198 setCentralWidget( m_stack );
199
200 setToolBarsMovable( FALSE );
201
202 m_tool = new QToolBar( this );
203 m_tool->setHorizontalStretchable( TRUE );
204
205 m_bar = new QMenuBar( m_tool );
206
207 /** QPopupMenu */
208 m_edit = new QPopupMenu( this );
209 m_options = new QPopupMenu( this );
210 m_view = new QPopupMenu( this );
211 m_catMenu = new QPopupMenu( this );
212 m_template = new QPopupMenu( this );
213
214 m_catMenu->setCheckable( TRUE );
215 m_template->setCheckable( TRUE );
216
217 connect(m_catMenu, SIGNAL(activated(int) ),
218 this, SLOT(setCategory(int) ) );
219 connect(m_template, SIGNAL(activated(int) ),
220 this, SLOT(slotNewFromTemplate(int) ) );
221}
222void MainWindow::initViews() {
223 TableView* tableView = new TableView( this, this );
224 m_stack->addWidget( tableView, m_counter++ );
225 m_views.append( tableView );
226 m_curView = tableView;
227 connectBase( tableView );
228// tableView->setTodos( begin(), end() ); we call populateCategories
229
230 /* add QString type + QString configname to
231 * the View menu
232 * and subdirs for multiple views
233 */
234}
235void MainWindow::initEditor() {
236 m_curEdit = new Editor();
237}
238void MainWindow::initShow() {
239 m_curShow = new TextViewShow(this);
240 m_stack->addWidget( m_curShow->widget() , m_counter++ );
241}
242MainWindow::~MainWindow() {
243 delete templateManager();
244}
245void MainWindow::connectBase( ViewBase* base) {
246 base->connectShow( this, SLOT(slotShow(int) ) );
247 base->connectEdit( this, SLOT(slotEdit(int) ) );
248 base->connectUpdateSmall( this,
249 SLOT(slotUpate1(int, const Todo::SmallTodo&) ));
250 base->connectUpdateBig( this,
251 SLOT(slotUpate2(int, const OTodo& ) ) );
252 base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ;
253 base->connectRemove(&m_todoMgr,
254 SLOT(remove(int)) );
255}
256QPopupMenu* MainWindow::contextMenu( int uid ) {
257 QPopupMenu* menu = new QPopupMenu();
258
259 m_editAction->addTo( menu );
260 m_deleteAction->addTo( menu );
261 m_duplicateAction->addTo( menu );
262 menu->insertSeparator();
263
264 return menu;
265}
266QPopupMenu* MainWindow::options() {
267 qWarning("Options");
268 return m_options;
269}
270QPopupMenu* MainWindow::edit() {
271 return m_edit;
272}
273QPopupMenu* MainWindow::view() {
274 return m_view;
275}
276QToolBar* MainWindow::toolbar() {
277 return m_tool;
278}
279OTodoAccess::List::Iterator MainWindow::begin() {
280 return m_todoMgr.begin();
281}
282OTodoAccess::List::Iterator MainWindow::end() {
283 return m_todoMgr.end();
284}
285OTodo MainWindow::event( int uid ) {
286 return m_todoMgr.event( uid );
287}
288bool MainWindow::isSyncing()const {
289 return m_syncing;
290}
291TemplateManager* MainWindow::templateManager() {
292 return m_tempManager;
293}
294Editor* MainWindow::currentEditor() {
295 return m_curEdit;
296}
297TodoShow* MainWindow::currentShow() {
298 return m_curShow;
299}
300void MainWindow::slotReload() {
301 m_todoMgr.reload();
302 currentView()->setTodos( begin(), end() );
303 raiseCurrentView();
304}
305void MainWindow::closeEvent( QCloseEvent* e ) {
306 if (m_stack->visibleWidget() == currentShow()->widget() ) {
307 raiseCurrentView();
308 e->ignore();
309 return;
310 }
311 /*
312 * we should have flushed and now we're still saving
313 * so there is no need to flush
314 */
315 if (m_syncing ) {
316 e->accept();
317 return;
318 }
319 bool quit = false;
320 if ( m_todoMgr.saveAll() ){
321 qWarning("saved");
322 quit = true;
323 }else {
324 if ( QMessageBox::critical( this, tr("Out of space"),
325 tr("Todo was unable\n"
326 "to save your changes.\n"
327 "Free up some space\n"
328 "and try again.\n"
329 "\nQuit Anyway?"),
330 QMessageBox::Yes|QMessageBox::Escape,
331 QMessageBox::No|QMessageBox::Default)
332 != QMessageBox::No ) {
333 e->accept();
334 quit = true;
335 }else
336 e->ignore();
337
338 }
339
340 if (quit ) {
341 Config config( "todo" );
342 config.setGroup( "View" );
343 config.writeEntry( "ShowComplete", showCompleted() );
344 config.writeEntry( "Category", currentCategory() );
345 config.writeEntry( "ShowDeadLine", showDeadline());
346 config.writeEntry( "ShowOverDue", showOverDue() );
347 /* svae templates */
348 templateManager()->save();
349 e->accept();
350 }
351}
352void MainWindow::populateTemplates() {
353 m_template->clear();
354 QStringList list = templateManager()->templates();
355 QStringList::Iterator it;
356 for ( it = list.begin(); it != list.end(); ++it ) {
357 m_template->insertItem( (*it) );
358 }
359}
360/*
361 * slotNewFromTemplate
362 * We use the edit widget to do
363 * the config but we setUid(-1)
364 * to get a new uid
365 */
366/*
367 * first we get the name of the template
368 * then we will use the TemplateManager
369 */
370void MainWindow::slotNewFromTemplate( int id ) {
371 QString name = m_template->text( id );
372
373 OTodo event = templateManager()->templateEvent( name );
374 event = currentEditor()->edit(this,
375 event );
376
377 if ( currentEditor()->accepted() ) {
378 /* assign new todo */
379 event.setUid( -1 );
380 currentView()->addEvent( event );
381 m_todoMgr.add( event );
382
383 populateCategories();
384 }
385}
386void MainWindow::slotNew() {
387 if(m_syncing) {
388 QMessageBox::warning(this, tr("Todo"),
389 tr("Can not edit data, currently syncing"));
390 return;
391 }
392
393
394 OTodo todo = currentEditor()->newTodo( currentCatId(),
395 this );
396
397 if ( currentEditor()->accepted() ) {
398 //todo.assignUid();
399 currentView()->addEvent( todo );
400 m_todoMgr.add( todo );
401
402 // I'm afraid we must call this every time now, otherwise
403 // spend expensive time comparing all these strings...
404 // but only call if we changed something -zecke
405 populateCategories();
406 }
407
408 raiseCurrentView( );
409}
410void MainWindow::slotDuplicate() {
411 if(m_syncing) {
412 QMessageBox::warning(this, tr("Todo"),
413 tr("Can not edit data, currently syncing"));
414 return;
415 }
416 OTodo ev = m_todoMgr.event( currentView()->current() );
417 /* let's generate a new uid */
418 ev.setUid(-1);
419 m_todoMgr.add( ev );
420
421 currentView()->addEvent( ev );
422 raiseCurrentView();
423}
424void MainWindow::slotDelete() {
425 if (!currentView()->current() )
426 return;
427
428 if(m_syncing) {
429 QMessageBox::warning(this, tr("Todo"),
430 tr("Can not edit data, currently syncing"));
431 return;
432 }
433 QString strName = currentView()->currentRepresentation();
434 if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) )
435 return;
436
437 m_todoMgr.remove( currentView()->current() );
438 currentView()->removeEvent( currentView()->current() );
439 raiseCurrentView();
440}
441void MainWindow::slotDeleteAll() {
442 if(m_syncing) {
443 QMessageBox::warning(this, tr("Todo"),
444 tr("Can not edit data, currently syncing"));
445 return;
446 }
447
448 //QString strName = table->text( table->currentRow(), 2 ).left( 30 );
449
450 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) )
451 return;
452
453 m_todoMgr.removeAll();
454 currentView()->clear();
455
456 raiseCurrentView();
457}
458void MainWindow::slotDeleteCompleted() {
459 if(m_syncing) {
460 QMessageBox::warning(this, tr("Todo"),
461 tr("Can not edit data, currently syncing"));
462 return;
463 }
464
465 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) )
466 return;
467
468 m_todoMgr.remove( currentView()->completed() );
469 currentView()->setTodos( begin(), end() );
470}
471void MainWindow::slotFind() {
472
473}
474void MainWindow::slotEdit() {
475 slotEdit( currentView()->current() );
476}
477/*
478 * set the category
479 */
480void MainWindow::setCategory( int c) {
481 if ( c <= 0 ) return;
482
483 qWarning("Iterating over cats %d", c );
484 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
485 m_catMenu->setItemChecked(i, c == (int)i );
486
487 if (c == 1 ) {
488 m_curCat = QString::null;
489 setCaption( tr("Todo") + " - " + tr("All Categories" ) );
490
491 }else if ( c == (int)m_catMenu->count() - 1 ) {
492 m_curCat = tr("Unfiled");
493 setCaption( tr("Todo") + " - " + tr("Unfiled") );
494 }else {
495 m_curCat = m_todoMgr.categories()[c-2];
496 setCaption( tr("Todo") + " - " + m_curCat );
497 }
498 m_catMenu->setItemChecked( c, true );
499 currentView()->setShowCategory( m_curCat );
500 raiseCurrentView();
501}
502void MainWindow::slotShowDeadLine( bool dead) {
503 m_deadline = dead;
504 currentView()->setShowDeadline( dead );
505}
506void MainWindow::slotShowCompleted( bool show) {
507 m_completed = show;
508 currentView()->setShowCompleted( m_completed );
509}
510bool MainWindow::showOverDue()const {
511 return m_overdue;
512}
513void MainWindow::setDocument( const QString& ) {
514
515}
516void MainWindow::slotBeam() {
517
518}
519void MainWindow::beamDone( Ir* ) {
520
521}
522
523void MainWindow::slotFlush() {
524 m_syncing = FALSE;
525 m_todoMgr.save();
526}
527void MainWindow::slotShowDetails() {
528 slotShow( currentView()->current() );
529}
530/*
531 * populate the Categories
532 * Menu
533 */
534void MainWindow::populateCategories() {
535 if (m_todoMgr.isLoaded() )
536 m_todoMgr.load();
537
538 m_catMenu->clear();
539 int id, rememberId;
540 id = 1;
541 rememberId = 1;
542
543 m_catMenu->insertItem( tr( "All Categories" ), id++ );
544 m_catMenu->insertSeparator();
545 QStringList categories = m_todoMgr.categories();
546 categories.append( tr( "Unfiled" ) );
547 for ( QStringList::Iterator it = categories.begin();
548 it != categories.end(); ++it ) {
549 m_catMenu->insertItem( *it, id );
550 if ( *it == currentCategory() )
551 rememberId = id;
552 ++id;
553 }
554 setCategory( rememberId );
555}
556bool MainWindow::showCompleted()const {
557 return m_completed;
558}
559bool MainWindow::showDeadline()const {
560 return m_deadline;
561}
562QString MainWindow::currentCategory()const {
563 return m_curCat;
564}
565int MainWindow::currentCatId() {
566 return m_todoMgr.catId( m_curCat );
567}
568ViewBase* MainWindow::currentView() {
569 return m_curView;
570}
571void MainWindow::raiseCurrentView() {
572 m_stack->raiseWidget( m_curView->widget() );
573}
574void MainWindow::slotShowDue(bool ov) {
575 m_overdue = ov;
576 currentView()->showOverDue( ov );
577 raiseCurrentView();
578}
579void MainWindow::slotShow( int uid ) {
580 qWarning("slotShow");
581 currentShow()->slotShow( event( uid ) );
582 m_stack->raiseWidget( currentShow()->widget() );
583}
584void MainWindow::slotEdit( int uid ) {
585 if(m_syncing) {
586 QMessageBox::warning(this, tr("Todo"),
587 tr("Can not edit data, currently syncing"));
588 return;
589 }
590
591 OTodo todo = m_todoMgr.event( uid );
592
593 todo = currentEditor()->edit(this, todo );
594
595 /* if completed */
596 if ( currentEditor()->accepted() ) {
597 qWarning("Replacing now" );
598 m_todoMgr.update( todo.uid(), todo );
599 currentView()->replaceEvent( todo );
600 populateCategories();
601 }
602
603 raiseCurrentView();
604}
605/*
606void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
607 m_todoMgr.update( uid, ev );
608}
609*/
610void MainWindow::updateTodo( const OTodo& ev) {
611 m_todoMgr.update( ev.uid() , ev );
612}
613/* The view changed it's configuration
614 * update the view menu
615 */
616void MainWindow::slotUpdate3( QWidget* ) {
617
618}
619void MainWindow::updateList() {
620 m_todoMgr.updateList();
621}
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
new file mode 100644
index 0000000..43666f0
--- a/dev/null
+++ b/core/pim/todo/mainwindow.h
@@ -0,0 +1,175 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef TODO_MAIN_WINDOW_H
30#define TODO_MAIN_WINDOW_H
31
32#include <qlist.h>
33#include <qmainwindow.h>
34
35#include <opie/otodoaccess.h>
36#include <opie/otodo.h>
37
38#include "smalltodo.h"
39#include "todoview.h"
40#include "todomanager.h"
41
42class QPopupMenu;
43class QMenuBar;
44class QToolBar;
45class QAction;
46class QWidgetStack;
47class Ir;
48
49
50namespace Todo {
51 typedef TodoView View;
52 class TemplateManager;
53 class Editor;
54 class TodoShow;
55 class TemplateEditor;
56
57 class MainWindow : public QMainWindow {
58 Q_OBJECT
59 public:
60 MainWindow( QWidget *parent = 0,
61 const char* name = 0 );
62 ~MainWindow();
63
64 /** return a context menu for an OTodo */
65 QPopupMenu* contextMenu(int uid );
66 QPopupMenu* options();
67 QPopupMenu* edit();
68 QPopupMenu* view();
69 QToolBar* toolbar();
70
71
72 void updateList();
73 OTodoAccess::List::Iterator begin();
74 OTodoAccess::List::Iterator end();
75// OTodoAccess::List::Iterator &iterator();
76
77 OTodo event(int uid );
78
79 bool isSyncing()const;
80 bool showCompleted()const;
81 bool showDeadline()const;
82 bool showOverDue()const;
83 QString currentCategory()const;
84 int currentCatId();
85 TemplateManager* templateManager();
86
87 void updateTodo( const OTodo& );
88 void populateTemplates();
89 Editor* currentEditor();
90private slots:
91 void populateCategories();
92 void slotReload();
93 void slotFlush();
94
95 protected:
96 void closeEvent( QCloseEvent* e );
97
98 private:
99 void connectBase( ViewBase* );
100 void initUI();
101 void initActions();
102 void initConfig();
103 void initViews();
104 void initEditor();
105 void initShow();
106 void initTemplate();
107 void raiseCurrentView();
108 ViewBase* currentView();
109 ViewBase* m_curView;
110 Editor* m_curEdit;
111 TodoShow* currentShow();
112 TodoShow* m_curShow;
113 TemplateEditor* currentTemplateEditor();
114 TemplateEditor* m_curTempEd;
115
116 QMenuBar* m_bar;
117 QToolBar* m_tool;
118 QAction* m_editAction,
119 *m_deleteAction,
120 *m_findAction,
121 *m_completedAction,
122 *m_showDeadLineAction,
123 *m_deleteAllAction,
124 *m_deleteCompleteAction,
125 *m_duplicateAction,
126 *m_showOverDueAction,
127 *m_effectiveAction;
128 QWidgetStack *m_stack;
129 QPopupMenu* m_catMenu,
130 *m_edit,
131 *m_options,
132 *m_view,
133 *m_template;
134
135 bool m_syncing:1;
136 bool m_deadline:1;
137 bool m_completed:1;
138 bool m_overdue:1;
139 TodoManager m_todoMgr;
140 QString m_curCat;
141 QList<ViewBase> m_views;
142 uint m_counter;
143 TemplateManager* m_tempManager;
144
145 private slots:
146 void slotShow(int);
147 void slotEdit(int);
148private slots:
149 void slotUpdate3( QWidget* );
150 void slotNewFromTemplate(int id );
151 void slotNew();
152 void slotDuplicate();
153 void slotDelete();
154 void slotDeleteAll();
155 void slotDeleteCompleted();
156
157 void slotEdit();
158 void slotFind();
159
160 void setCategory( int );
161
162 void slotShowDeadLine( bool );
163 void slotShowCompleted( bool );
164
165 void setDocument( const QString& );
166
167
168 void slotBeam();
169 void beamDone( Ir* );
170 void slotShowDetails();
171 void slotShowDue( bool );
172 };
173};
174
175#endif
diff --git a/core/pim/todo/opie-todo.control b/core/pim/todo/opie-todo.control
new file mode 100644
index 0000000..71929af
--- a/dev/null
+++ b/core/pim/todo/opie-todo.control
@@ -0,0 +1,9 @@
1Files: bin/todolist apps/Applications/todo.desktop
2Priority: optional
3Section: opie/applications
4Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org>
5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION)
8Description: TODO-list manager
9 A Todo-list manager for the Opie environment.
diff --git a/core/pim/todo/smalltodo.cpp b/core/pim/todo/smalltodo.cpp
new file mode 100644
index 0000000..412fe9e
--- a/dev/null
+++ b/core/pim/todo/smalltodo.cpp
@@ -0,0 +1,114 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <zecke@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28#include <qshared.h>
29
30#include "smalltodo.h"
31
32using namespace Todo;
33
34struct SmallTodo::SmallTodoPrivate : public QShared{
35
36 SmallTodoPrivate() : QShared(), uid(-1) {};
37 QString name;
38 QStringList categories; // as real Names
39 int uid;
40 bool complete:1;
41 QDate date;
42
43
44 void deleteSelf() { delete this; };
45};
46
47SmallTodo::SmallTodo(int uid,
48 bool comp,
49 const QDate& date,
50 const QString& name,
51 const QStringList& cats) {
52 d = new SmallTodoPrivate();
53 d->name = name;
54 d->uid = uid;
55 d->categories = cats;
56 d->complete = comp;
57 d->date = date;
58}
59SmallTodo::SmallTodo( const SmallTodo& s ) : d(s.d) {
60 d->ref();
61}
62SmallTodo::~SmallTodo() {
63 /* deref and if last one delete */
64 if ( d->deref() ) {
65 d->deleteSelf();
66 }
67}
68bool SmallTodo::operator==( const SmallTodo& todo ) {
69 if ( d->complete != todo.d->complete ) return false;
70 if ( d->name != todo.d->name ) return false;
71 if ( d->uid != todo.d->uid ) return false;
72 if ( d->categories != todo.d->categories ) return false;
73 if ( d->date != todo.d->date ) return false;
74
75 return true;
76}
77bool SmallTodo::operator==( const SmallTodo& todo ) const{
78 if ( d->complete != todo.d->complete ) return false;
79 if ( d->uid != todo.d->uid ) return false;
80 if ( d->name != todo.d->name ) return false;
81 if ( d->categories != todo.d->categories ) return false;
82 if ( d->date != todo.d->date ) return false;
83
84 return true;
85}
86SmallTodo &SmallTodo::operator=( const SmallTodo& todo ) {
87 todo.d->ref();
88 deref();
89
90 d = todo.d;
91
92 return *this;
93}
94void SmallTodo::deref() {
95 if ( d->deref() ) {
96 delete d;
97 d = 0;
98 }
99}
100QString SmallTodo::name() const {
101 return d->name;
102}
103QStringList SmallTodo::categories()const {
104 return d->categories;
105}
106int SmallTodo::uid()const {
107 return d->uid;
108}
109bool SmallTodo::isCompleted()const {
110 return d->complete;
111}
112QDate SmallTodo::date()const {
113 return d->date;
114}
diff --git a/core/pim/todo/smalltodo.h b/core/pim/todo/smalltodo.h
new file mode 100644
index 0000000..952ed04
--- a/dev/null
+++ b/core/pim/todo/smalltodo.h
@@ -0,0 +1,70 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <zecke@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef TODO_SMALL_TODO_H
30#define TODO_SMALL_TODO_H
31
32#include <qdatetime.h>
33#include <qstring.h>
34#include <qstringlist.h>
35
36
37namespace Todo {
38 /**
39 * SmallTodo holds everything necessary
40 * to represent a OTodo without holding
41 * everything from a OTodo
42 */
43 class SmallTodo {
44 public:
45 SmallTodo(int uid = 0,
46 bool comp = false,
47 const QDate& date = QDate::currentDate(),
48 const QString& = QString::null,
49 const QStringList& = QStringList() );
50 SmallTodo( const SmallTodo& );
51 ~SmallTodo();
52
53 bool operator==( const SmallTodo& );
54 bool operator==( const SmallTodo& ) const;
55
56 SmallTodo &operator=( const SmallTodo& );
57 QString name()const;
58 QStringList categories()const;
59 int uid()const;
60 bool isCompleted()const;
61 QDate date()const;
62
63 private:
64 struct SmallTodoPrivate;
65 SmallTodoPrivate* d;
66 void deref();
67 };
68};
69
70#endif
diff --git a/core/pim/todo/tableitems.cpp b/core/pim/todo/tableitems.cpp
new file mode 100644
index 0000000..ebfefc8
--- a/dev/null
+++ b/core/pim/todo/tableitems.cpp
@@ -0,0 +1,181 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28#include "tableview.h"
29
30#include "tableitems.h"
31#include <string.h>
32
33using namespace Todo;
34
35CheckItem::CheckItem( QTable* t,
36 const QString& sortKey,
37 int uid,
38 const QArray<int>& lis)
39 : OCheckItem(t, sortKey), m_uid(uid ), m_cat( lis )
40{
41}
42CheckItem::~CheckItem() {
43}
44void CheckItem::setChecked( bool b ) {
45 OCheckItem::setChecked(b);
46}
47void CheckItem::toggle() {
48 TableView* view = static_cast<TableView*>( table() );
49 OTodo ev = view->find( view->current() );
50 ev.setCompleted(!isChecked() );
51 view->updateFromTable( ev );
52
53 OCheckItem::toggle();
54 table()->updateCell( row(), col() );
55}
56int CheckItem::uid() const {
57 return m_uid;
58}
59QArray<int> CheckItem::cats() {
60 return m_cat;
61}
62
63/* ComboItem */
64ComboItem::ComboItem( QTable* t, EditType et )
65 : QTableItem( t, et, "3" ), m_cb(0)
66{
67 setReplaceable( FALSE );
68}
69ComboItem::~ComboItem() {
70
71}
72QWidget* ComboItem::createEditor()const {
73 qWarning( "create editor");
74 QString txt = text();
75
76 ( (ComboItem*)this)-> m_cb = new QComboBox( table()->viewport() );
77
78 m_cb->insertItem( "1" );
79 m_cb->insertItem( "2" );
80 m_cb->insertItem( "3" );
81 m_cb->insertItem( "4" );
82 m_cb->insertItem( "5" );
83 m_cb->setCurrentItem( txt.toInt() - 1 );
84
85 return m_cb;
86}
87void ComboItem::setContentFromEditor( QWidget* w) {
88 TableView* view = static_cast<TableView*>( table() );
89 OTodo ev = view->find( view->current() );
90
91 if ( w->inherits( "QComboBox" ) )
92 setText( ( (QComboBox*)w )->currentText() );
93 else
94 QTableItem::setContentFromEditor( w );
95
96 ev.setPriority( text().toInt() );
97 view->updateFromTable( ev );
98}
99void ComboItem::setText( const QString& s ) {
100 if ( m_cb )
101 m_cb->setCurrentItem( s.toInt()-1 );
102
103 QTableItem::setText( s );
104}
105QString ComboItem::text()const {
106 if ( m_cb)
107 return m_cb->currentText();
108
109 return QTableItem::text();
110}
111
112/* TodoTextItem */
113TodoTextItem::~TodoTextItem() {
114
115}
116TodoTextItem::TodoTextItem( QTable* t,
117 const QString& string )
118 : QTableItem( t, QTableItem::Never, string )
119{}
120
121/* DueTextItem */
122DueTextItem::DueTextItem( QTable* t, const OTodo& ev)
123 : QTableItem(t, Never, QString::null )
124{
125 setToDoEvent( ev );
126}
127DueTextItem::~DueTextItem() {
128
129}
130QString DueTextItem::key() const {
131 QString key;
132
133 if( m_hasDate ){
134 if(m_off == 0 ){
135 key.append("b");
136 }else if( m_off > 0 ){
137 key.append("c");
138 }else if( m_off < 0 ){
139 key.append("a");
140 }
141 key.append(QString::number(m_off ) );
142 }else{
143 key.append("d");
144 }
145 return key;
146}
147void DueTextItem::setCompleted( bool comp ) {
148 m_completed = comp;
149 table()->updateCell( row(), col() );
150}
151void DueTextItem::setToDoEvent( const OTodo& ev ) {
152 m_hasDate = ev.hasDueDate();
153 m_completed = ev.isCompleted();
154
155 if( ev.hasDueDate() ){
156 QDate today = QDate::currentDate();
157 m_off = today.daysTo(ev.dueDate() );
158 setText( QString::number(m_off) + " day(s) " );
159 }else{
160 setText("n.d." );
161 m_off = 0;
162 }
163}
164void DueTextItem::paint( QPainter* p, const QColorGroup &cg,
165 const QRect& cr, bool selected ) {
166 QColorGroup cg2(cg);
167
168 QColor text = cg.text();
169 if( m_hasDate && !m_completed ){
170 if( m_off < 0 ){
171 cg2.setColor(QColorGroup::Text, QColor(red ) );
172 }else if( m_off == 0 ){
173 cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined
174 }else if( m_off > 0){
175 cg2.setColor(QColorGroup::Text, QColor(green ) );
176 }
177 }
178 QTableItem::paint(p, cg2, cr, selected );
179 /* restore default color */
180 cg2.setColor(QColorGroup::Text, text );
181}
diff --git a/core/pim/todo/tableitems.h b/core/pim/todo/tableitems.h
new file mode 100644
index 0000000..33ae814
--- a/dev/null
+++ b/core/pim/todo/tableitems.h
@@ -0,0 +1,124 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef OPIE_TODO_TABLE_ITEMS_H
30#define OPIE_TODO_TABLE_ITEMS_H
31
32#include <qarray.h>
33#include <qguardedptr.h>
34#include <qcombobox.h>
35#include <qtable.h>
36
37#include <qpe/stringutil.h>
38
39#include <opie/ocheckitem.h>
40#include <opie/otodo.h>
41
42
43namespace Todo {
44
45 /**
46 * We need to reimplement OCheckItem here
47 * we need to update on change
48 * You can check a checkItem
49 */
50 class CheckItem : public OCheckItem {
51 public:
52 CheckItem( QTable* t, const QString& sortKey,
53 int uid,
54 const QArray<int>& );
55 ~CheckItem();
56 virtual void setChecked( bool b );
57 virtual void toggle();
58 int uid()const;
59 QArray<int> cats();
60 private:
61 int m_uid;
62 QArray<int> m_cat;
63 };
64
65 /**
66 * creates a QComboBox if neccessary
67 * to edit inline
68 */
69 class ComboItem : public QTableItem {
70 public:
71 ComboItem( QTable* t, EditType et );
72 ~ComboItem();
73 QWidget* createEditor()const;
74 void setContentFromEditor( QWidget* w );
75 void setText( const QString& s );
76 int alignment() const;
77
78 QString text()const;
79
80 private:
81 QGuardedPtr<QComboBox> m_cb;
82 };
83
84 /* implement inline */
85 inline int ComboItem::alignment()const {
86 return Qt::AlignCenter;
87 }
88
89 /**
90 * TodoTextItem builds a better specialised
91 * sortkey
92 */
93 class TodoTextItem : public QTableItem {
94 public:
95 TodoTextItem( QTable* t, const QString& str );
96 ~TodoTextItem();
97 QString key()const;
98 };
99
100
101 inline QString TodoTextItem::key() const {
102 return Qtopia::buildSortKey( text() );
103 }
104
105 class DueTextItem : public QTableItem {
106 public:
107 DueTextItem( QTable* t, const OTodo& );
108 ~DueTextItem();
109
110 QString key()const;
111 void setToDoEvent( const OTodo& ev );
112 void setCompleted( bool comp );
113 void paint( QPainter *p, const QColorGroup &cg,
114 const QRect& cr, bool selected );
115 private:
116 int m_off;
117 bool m_hasDate:1;
118 bool m_completed:1;
119 };
120
121
122};
123
124#endif
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
new file mode 100644
index 0000000..39f0d72
--- a/dev/null
+++ b/core/pim/todo/tableview.cpp
@@ -0,0 +1,362 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include <qtimer.h>
30#include <qpoint.h>
31#include <qpopupmenu.h>
32
33#include "mainwindow.h"
34//#include "tableitems.h"
35#include "tableview.h"
36
37using namespace Todo;
38
39
40TableView::TableView( MainWindow* window, QWidget* wid )
41 : QTable( wid ), TodoView( window ) {
42 setUpdatesEnabled( false );
43 viewport()->setUpdatesEnabled( false );
44 m_enablePaint = false;
45 setNumRows(0);
46 setNumCols(4);
47
48 setSorting( TRUE );
49 setSelectionMode( NoSelection );
50 setColumnStretchable( 2, TRUE );
51 setColumnWidth(0, 20 );
52 setColumnWidth(1, 35 );
53
54 setLeftMargin( 0 );
55 verticalHeader()->hide();
56
57 horizontalHeader()->setLabel(0, tr("C.") );
58 horizontalHeader()->setLabel(1, tr("Prior.") );
59 horizontalHeader()->setLabel(2, tr("Description" ) );
60
61 setColumnStretchable(3, FALSE );
62 setColumnWidth(3, 20 );
63 horizontalHeader()->setLabel(3, tr("Deadline") );
64
65 if ( todoWindow()->showDeadline() )
66 showColumn( 3);
67 else
68 hideColumn(3 );
69
70 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ),
71 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) );
72 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ),
73 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) );
74 connect((QTable*)this, SIGNAL(valueChanged(int, int) ),
75 this, SLOT( slotValueChanged(int, int) ) );
76 connect((QTable*)this, SIGNAL(currentChanged(int, int) ),
77 this, SLOT( slotCurrentChanged(int, int) ) );
78
79 m_menuTimer = new QTimer( this );
80 connect( m_menuTimer, SIGNAL(timeout()),
81 this, SLOT(slotShowMenu()) );
82
83 m_enablePaint = true;
84 setUpdatesEnabled( true );
85 viewport()->setUpdatesEnabled( true );
86 viewport()->update();
87}
88/* a new day has started
89 * update the day
90 */
91void TableView::newDay() {
92 clear();
93 setTodos( begin(),end() );
94}
95TableView::~TableView() {
96
97}
98void TableView::slotShowMenu() {
99 QPopupMenu *menu = todoWindow()->contextMenu( current() );
100 menu->exec(QCursor::pos() );
101 delete menu;
102}
103OTodo TableView::find(int uid ) {
104 OTodo ev = TodoView::event( uid );
105 return ev;
106}
107void TableView::updateFromTable( const OTodo& ev, CheckItem* item ) {
108 TodoView::update( ev.uid(), ev );
109
110 /* update the other columns */
111 /* if completed or not we need to update
112 * the table
113 *
114 * We've two cases
115 * either item or !item
116 * this makes cases more easy
117 */
118 if ( !item ) {
119 item = m_cache[ev.uid()];
120 }
121 DueTextItem *due = dueItem( item->row() );
122 due->setCompleted( ev.isCompleted() );
123}
124QString TableView::type() const {
125 return QString::fromLatin1( tr("Table View") );
126}
127int TableView::current() {
128 int cur = 0;
129 CheckItem* i = checkItem( currentRow() );
130 if (i )
131 cur = i->uid();
132
133 return cur;
134}
135QString TableView::currentRepresentation() {
136 return text( currentRow(), 2);
137}
138/* show overdue */
139void TableView::showOverDue( bool ) {
140 clear();
141 setTodos( begin(), end() );
142}
143
144void TableView::setTodos( OTodoAccess::List::Iterator it,
145 OTodoAccess::List::Iterator end ) {
146 qWarning("setTodos");
147 QTime time;
148 time.start();
149 m_enablePaint = false;
150 setUpdatesEnabled( false );
151 viewport()->setUpdatesEnabled( false );
152 clear();
153 QString currentCat = todoWindow()->currentCategory();
154 bool showCompleted = todoWindow()->currentCatId();
155 bool showOverDue = todoWindow()->showOverDue();
156 qWarning( "Current Category:" + todoWindow()->currentCategory() );
157 int id = todoWindow()->currentCatId();
158 QTime t;
159 t.start();
160 setNumRows( it.count() );
161 uint i = 0;
162 for (; it != end; ++it ) {
163 OTodo todo = (*it);
164 /* test if the categories match */
165 if ( !currentCat.isEmpty() &&
166 !todo.categories().contains( id ) ) {
167 continue;
168 }
169 /* the item is completed but we shouldn't show it */
170 if ( !showCompleted && todo.isCompleted() ) {
171 continue;
172 }
173 /* the item is not overdue but we should only show overdue */
174 if ( showOverDue && !todo.isOverdue() ) {
175 continue;
176 }
177 /* now it's fine to add it */
178 insertTodo( todo, i );
179 i++;
180 }
181 setNumRows( i );
182 int elc = time.elapsed();
183 qWarning("Adding took %d", elc/1000 );
184 setUpdatesEnabled( true );
185 viewport()->setUpdatesEnabled( true );
186 viewport()->update();
187 m_enablePaint = true;
188 int el = time.elapsed();
189 qWarning("adding took %d", el/1000 );
190}
191void TableView::setTodo( int uid, const OTodo& ev ) {
192 QMap<int, CheckItem*>::Iterator it = m_cache.find( uid );
193
194 if ( it != m_cache.end() ) {
195 int row = it.data()->row();
196
197 /* update checked */
198 CheckItem* check = checkItem(row );
199 if (check)
200 check->setChecked( ev.isCompleted() );
201
202 /* update the text */
203 QString sum = ev.summary();
204 setText(row, 2, sum.isEmpty() ?
205 ev.description().left(40).simplifyWhiteSpace() :
206 sum );
207
208 /* update priority */
209 setText(row, 1, QString::number( ev.priority() ) );
210
211 /* update DueDate */
212 DueTextItem *due = dueItem( row );
213 due->setToDoEvent( ev );
214 }
215}
216void TableView::addEvent( const OTodo& ev) {
217 int row= numRows();
218 setNumRows( row + 1 );
219 insertTodo( ev, row );
220}
221/*
222 * find the event
223 * and then replace the complete row
224 */
225void TableView::replaceEvent( const OTodo& ev) {
226 setTodo( ev.uid(), ev );
227}
228/*
229 * re aligning table can be slow too
230 * FIXME: look what performs better
231 * either this or the old align table
232 */
233void TableView::removeEvent( int ) {
234 clear();
235 setTodos( begin(), end() );
236}
237void TableView::setShowCompleted( bool b) {
238 qWarning("Show Completed %d" + b );
239 setTodos( begin(), end() );
240}
241void TableView::setShowDeadline( bool b) {
242 qWarning("Show DeadLine %d" + b );
243 if (b)
244 showColumn(3 );
245 else
246 hideColumn(3 );
247}
248void TableView::setShowCategory( const QString& ) {
249 qWarning("setShowCategory");
250 setTodos( begin(), end() );
251}
252void TableView::clear() {
253 m_cache.clear();
254 int rows = numRows();
255 for (int r = 0; r < rows; r++ ) {
256 for (int c = 0; c < numCols(); c++ ) {
257 if ( cellWidget(r, c) )
258 clearCellWidget(r, c );
259 clearCell(r, c);
260 }
261 }
262 setNumRows( 0);
263}
264QArray<int> TableView::completed() {
265 int row = numRows();
266 QArray<int> ids( row );
267
268 int j=0;
269 for (int i = 0; i < row; i++ ) {
270 CheckItem* item = checkItem(i );
271 if (item->isChecked() ) {
272 ids[j] = item->uid();
273 j++;
274 }
275 }
276 ids.resize( j );
277 return ids;
278}
279void TableView::slotClicked(int row, int col, int,
280 const QPoint& point) {
281 if ( !cellGeometry(row, col ).contains(point ) )
282 return;
283
284
285 switch( col ) {
286 case 0: {
287 CheckItem* item = checkItem( row );
288 /*
289 * let's see if we centered clicked
290 */
291 if ( item ) {
292 int x = point.x() -columnPos( col );
293 int y = point.y() -rowPos( row );
294 int w = columnWidth( col );
295 int h = rowHeight( row );
296 if ( x >= ( w - OCheckItem::BoxSize ) / 2 &&
297 x <= ( w - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize &&
298 y >= ( h - OCheckItem::BoxSize ) / 2 &&
299 y <= ( h - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize )
300 item->toggle();
301 }
302 }
303 break;
304
305 case 1:
306 break;
307
308 case 2: {
309 m_menuTimer->stop();
310 showTodo( checkItem(row)->uid() );
311 break;
312 }
313 case 3: {
314 m_menuTimer->stop();
315 TodoView::edit( checkItem(row)->uid() );
316 break;
317 }
318 }
319
320
321}
322void TableView::slotPressed(int row, int col, int,
323 const QPoint& point) {
324
325 /* TextColumn column */
326 if ( col == 2 && cellGeometry( row, col ).contains( point ) )
327 m_menuTimer->start( 750, TRUE );
328}
329void TableView::slotValueChanged( int, int ) {
330 qWarning("Value Changed");
331}
332void TableView::slotCurrentChanged(int, int ) {
333 m_menuTimer->stop();
334}
335/*
336 * hardcode to column 0
337 */
338CheckItem* TableView::checkItem( int row ) {
339 CheckItem *i = static_cast<CheckItem*>( item( row, 0 ) );
340 return i;
341}
342DueTextItem* TableView::dueItem( int row ) {
343 DueTextItem* i = static_cast<DueTextItem*> ( item(row, 3 ) );
344 return i;
345}
346QWidget* TableView::widget() {
347 return this;
348}
349/*
350 * We need to overwrite sortColumn
351 * because we want to sort whole row
352 * based
353 */
354void TableView::sortColumn( int row, bool asc, bool ) {
355 QTable::sortColumn( row, asc, TRUE );
356
357}
358void TableView::viewportPaintEvent( QPaintEvent* e) {
359 qWarning("Paint event" );
360 if (m_enablePaint )
361 QTable::viewportPaintEvent( e );
362}
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h
new file mode 100644
index 0000000..721b40b
--- a/dev/null
+++ b/core/pim/todo/tableview.h
@@ -0,0 +1,120 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef OPIE_TABLE_VIEW_H
30#define OPIE_TABLE_VIEW_H
31
32#include <qtable.h>
33#include <qmap.h>
34
35#include "tableitems.h"
36#include "todoview.h"
37
38class QTimer;
39
40namespace Todo {
41 class CheckItem;
42 class DueTextItem;
43 class TableView : public QTable, public TodoView {
44 Q_OBJECT
45 public:
46 TableView( MainWindow*, QWidget* parent );
47 ~TableView();
48
49 void updateFromTable( const OTodo&, CheckItem* = 0 );
50 OTodo find(int uid);
51
52 QString type()const;
53 int current();
54 QString currentRepresentation();
55
56 void showOverDue( bool );
57 void setTodos( OTodoAccess::List::Iterator it,
58 OTodoAccess::List::Iterator end );
59 void setTodo( int uid, const OTodo& );
60 void addEvent( const OTodo& event );
61 void replaceEvent( const OTodo& );
62 void removeEvent( int uid );
63 void setShowCompleted( bool );
64 void setShowDeadline( bool );
65
66 void setShowCategory(const QString& =QString::null );
67 void clear();
68 void newDay();
69 QArray<int> completed();
70 QWidget* widget();
71 void sortColumn(int, bool, bool );
72 private:
73 /* reimplented for internal reasons */
74 void viewportPaintEvent( QPaintEvent* );
75 inline void insertTodo( const OTodo&, int row );
76 CheckItem* checkItem( int row );
77 DueTextItem* dueItem( int row );
78 QTimer *m_menuTimer;
79 QMap<int, CheckItem*> m_cache;
80 bool m_enablePaint:1;
81
82private slots:
83 void slotShowMenu();
84 void slotClicked(int, int, int,
85 const QPoint& );
86 void slotPressed(int, int, int,
87 const QPoint& );
88 void slotValueChanged(int, int);
89 void slotCurrentChanged(int, int );
90 };
91 inline void TableView::insertTodo( const OTodo& event, int row ) {
92
93
94 QString sortKey = (char) ( (event.isCompleted() ? 'a' : 'A' )
95 + event.priority() )
96 + Qtopia::buildSortKey( event.description() );
97 CheckItem *chk = new CheckItem( this, sortKey, event.uid(), event.categories() );
98 chk->setChecked( event.isCompleted() );
99
100 ComboItem *cmb = new ComboItem(this, QTableItem::WhenCurrent );
101 cmb->setText( QString::number( event.priority() ) );
102
103 QString sum = event.summary();
104 QTableItem* ti = new TodoTextItem( this, sum.isEmpty() ?
105 event.description().left(40).simplifyWhiteSpace() :
106 sum );
107 ti->setReplaceable( FALSE );
108
109 DueTextItem *due = new DueTextItem(this, event );
110
111 setItem( row, 0, chk );
112 setItem( row, 1, cmb );
113 setItem( row, 2, ti );
114 setItem( row, 3, due );
115
116 m_cache.insert( event.uid(), chk );
117 }
118};
119
120#endif
diff --git a/core/pim/todo/templatedialog.cpp b/core/pim/todo/templatedialog.cpp
new file mode 100644
index 0000000..ffcdc24
--- a/dev/null
+++ b/core/pim/todo/templatedialog.cpp
@@ -0,0 +1,60 @@
1#include <qpushbutton.h>
2#include <qhbox.h>
3#include <qlayout.h>
4#include <qlistview.h>
5#include <qlineedit.h>
6
7#include "templatedialog.h"
8
9
10using namespace Todo;
11
12TemplateDialog::TemplateDialog( QWidget* widget )
13 : QDialog( widget, "TemplateDialog", TRUE )
14{
15 setCaption( tr("Template Editor") );
16 m_main = new QVBoxLayout(this );
17
18 m_list = new QListView( this );
19 m_main->addWidget( m_list, 100 );
20
21 m_lne = new QLineEdit( this );
22 m_main->addWidget( m_lne );
23
24 m_btnBar = new QHBox( this );
25 m_add = new QPushButton( tr("Add"), m_btnBar );
26 m_edit = new QPushButton( tr("Edit"), m_btnBar );
27 m_rem = new QPushButton( tr("Remove"), m_btnBar );
28 m_main->addWidget( m_btnBar );
29
30 connect(m_add, SIGNAL(clicked() ),
31 this, SLOT(slotAdd() ) );
32 connect(m_edit, SIGNAL(clicked() ),
33 this, SLOT(slotEdit() ) );
34 connect(m_rem, SIGNAL(clicked() ),
35 this, SLOT(slotEdit() ) );
36 connect(m_lne, SIGNAL(returnPressed() ),
37 this, SLOT(slotReturn() ) );
38
39}
40TemplateDialog::~TemplateDialog() {
41 // Qt does delete our widgets
42}
43QListView* TemplateDialog::listView() {
44 return m_list;
45}
46QLineEdit* TemplateDialog::edit() {
47 return m_lne;
48}
49void TemplateDialog::slotAdd() {
50 qWarning("Not Implemented here");
51}
52void TemplateDialog::slotRemove() {
53 qWarning("Not Implemented here");
54}
55void TemplateDialog::slotEdit() {
56 qWarning("Not Implemented here");
57}
58void TemplateDialog::slotReturn() {
59 qWarning("Not Implemented here");
60}
diff --git a/core/pim/todo/templatedialog.h b/core/pim/todo/templatedialog.h
new file mode 100644
index 0000000..5886c34
--- a/dev/null
+++ b/core/pim/todo/templatedialog.h
@@ -0,0 +1,44 @@
1#ifndef OPIE_TEMPLATE_DIALOG_H
2#define OPIE_TEMPLATE_DIALOG_H
3
4#include <qdialog.h>
5#include <qstring.h>
6
7class QListView;
8class QPushButton;
9class QLabel;
10class QHBox;
11class QVBoxLayout;
12class QLineEdit;
13
14
15namespace Todo {
16 class TemplateDialog : public QDialog {
17 Q_OBJECT
18 public:
19 /* it'll be modal */
20 TemplateDialog( QWidget* parent );
21 virtual ~TemplateDialog();
22
23 protected:
24 QListView* listView();
25 QLineEdit* edit();
26private slots:
27 virtual void slotAdd();
28 virtual void slotRemove();
29 virtual void slotEdit();
30 virtual void slotReturn();
31
32 private:
33 QVBoxLayout* m_main;
34 QHBox* m_btnBar;
35 QListView* m_list;
36 QLineEdit *m_lne;
37 QPushButton* m_add;
38 QPushButton* m_rem;
39 QPushButton* m_edit;
40
41 };
42}
43
44#endif
diff --git a/core/pim/todo/templatedialogimpl.cpp b/core/pim/todo/templatedialogimpl.cpp
new file mode 100644
index 0000000..77c5363
--- a/dev/null
+++ b/core/pim/todo/templatedialogimpl.cpp
@@ -0,0 +1,119 @@
1#include <qlistview.h>
2#include <qlineedit.h>
3
4#include "mainwindow.h"
5#include "todoeditor.h"
6#include "todotemplatemanager.h"
7#include "templatedialogimpl.h"
8
9
10using namespace Todo;
11
12namespace {
13 class TemplateListItem : public QListViewItem {
14 public:
15 TemplateListItem( QListView*,
16 const QString& name,
17 const OTodo& );
18 ~TemplateListItem();
19
20 OTodo event()const;
21 QString text()const;
22 void setText(const QString& str );
23 void setEvent( const OTodo& );
24 private:
25 QString m_name;
26 OTodo m_ev;
27 };
28
29 /* implementation */
30 TemplateListItem::TemplateListItem( QListView* view,
31 const QString& text,
32 const OTodo& ev )
33 : QListViewItem( view ), m_name( text ), m_ev( ev )
34 {
35 QListViewItem::setText(0, m_name );
36 }
37 TemplateListItem::~TemplateListItem() {}
38 OTodo TemplateListItem::event() const {
39 return m_ev;
40 }
41 QString TemplateListItem::text()const {
42 return m_name;
43 }
44 void TemplateListItem::setText( const QString& str ) {
45 QListViewItem::setText(0, str );
46 m_name = str;
47 }
48 void TemplateListItem::setEvent( const OTodo& ev) {
49 m_ev = ev;
50 }
51}
52
53TemplateDialogImpl::TemplateDialogImpl( MainWindow* win,
54 TemplateManager* man )
55 : TemplateDialog( win ), m_win( win), m_man( man )
56{
57 /* fill the listview */
58 /* not the fastest way.... */
59 QStringList list = man->templates();
60 for (QStringList::Iterator it = list.begin();
61 it != list.end(); ++it ) {
62 new TemplateListItem( listView(), (*it), man->templateEvent( (*it) ) );
63 }
64 listView()->addColumn( tr("Name") );
65
66 connect( listView(), SIGNAL(clicked(QListViewItem*) ),
67 this, SLOT(slotClicked(QListViewItem*) ) );
68}
69TemplateDialogImpl::~TemplateDialogImpl() {
70
71}
72void TemplateDialogImpl::slotAdd() {
73 QString str = tr("New Template %1").arg( listView()->childCount() );
74 OTodo ev;
75 m_man->addEvent(str, ev);
76 new TemplateListItem( listView(), str, ev );
77}
78void TemplateDialogImpl::slotRemove() {
79 TemplateListItem* item = (TemplateListItem*) listView()->currentItem();
80 listView()->takeItem( item );
81
82 m_man->removeEvent( item->text() );
83
84 delete item;
85}
86void TemplateDialogImpl::slotEdit() {
87 TemplateListItem* item = (TemplateListItem*)listView()->currentItem();
88 OTodo ev = m_win->currentEditor()->edit( m_win, item->event() );
89 if ( m_win->currentEditor()->accepted() ) {
90 qWarning("accepted");
91 item->setEvent( ev );
92 qWarning("Priority %d", ev.priority() );
93 m_man->removeEvent( item->text() );
94 m_man->addEvent( item->text(), ev );
95 }
96}
97/*
98 * we need to update
99 * the text
100 */
101
102void TemplateDialogImpl::slotReturn() {
103 TemplateListItem* tbl = (TemplateListItem*)listView()->currentItem();
104
105 if (tbl->text() != edit()->text() ) {
106 m_man->removeEvent( tbl->text() );
107 tbl->setText( edit()->text() );
108 m_man->addEvent( tbl->text(), tbl->event() );
109 }
110}
111/* update the lineedit when changing */
112void TemplateDialogImpl::slotClicked( QListViewItem* item) {
113 if (!item)
114 return;
115
116 TemplateListItem* tbl = (TemplateListItem*)item;
117 edit()->setText( tbl->text() );
118}
119
diff --git a/core/pim/todo/templatedialogimpl.h b/core/pim/todo/templatedialogimpl.h
new file mode 100644
index 0000000..f366c9e
--- a/dev/null
+++ b/core/pim/todo/templatedialogimpl.h
@@ -0,0 +1,33 @@
1#ifndef OPIE_TEMPLATE_DIALOG_IMPL_H
2#define OPIE_TEMPLATE_DIALOG_IMPL_H
3
4#include <qlistview.h>
5
6#include <opie/otodo.h>
7
8#include "templatedialog.h"
9
10
11namespace Todo {
12
13 class MainWindow;
14 class TemplateManager;
15 class TemplateDialogImpl : public Todo::TemplateDialog {
16 Q_OBJECT
17 public:
18 TemplateDialogImpl( MainWindow* win, TemplateManager* );
19 ~TemplateDialogImpl();
20
21 private:
22 MainWindow* m_win;
23 TemplateManager* m_man;
24private slots:
25 void slotAdd();
26 void slotRemove();
27 void slotEdit();
28 void slotReturn();
29 void slotClicked(QListViewItem*);
30 };
31};
32
33#endif
diff --git a/core/pim/todo/templateeditor.cpp b/core/pim/todo/templateeditor.cpp
new file mode 100644
index 0000000..1b52d4f
--- a/dev/null
+++ b/core/pim/todo/templateeditor.cpp
@@ -0,0 +1,39 @@
1#include <qaction.h>
2#include <qpopupmenu.h>
3
4#include "mainwindow.h"
5#include "todotemplatemanager.h"
6
7#include "templatedialogimpl.h"
8#include "templateeditor.h"
9
10using namespace Todo;
11
12TemplateEditor::TemplateEditor( MainWindow* main,
13 TemplateManager* manager )
14 : QObject( main ), m_main( main ), m_man( manager )
15{
16 init();
17
18}
19TemplateEditor::~TemplateEditor() {
20
21}
22/* ok we add us to the Menubar */
23void TemplateEditor::init() {
24 QAction* a = new QAction( QString::null, tr("Configure Templates"),
25 0, this, 0, FALSE );
26 connect(a, SIGNAL(activated() ),
27 this, SLOT(setUp() ) );
28
29 a->addTo( m_main->options() );
30}
31void TemplateEditor::setUp() {
32 qWarning("set up");
33 TemplateDialogImpl dlg(m_main, m_man );
34 int ret= dlg.exec();
35 if (QDialog::Accepted != ret ) {
36 m_man->load();
37 }else
38 m_main->populateTemplates();
39}
diff --git a/core/pim/todo/templateeditor.h b/core/pim/todo/templateeditor.h
new file mode 100644
index 0000000..e551328
--- a/dev/null
+++ b/core/pim/todo/templateeditor.h
@@ -0,0 +1,31 @@
1#ifndef OPIE_TEMPLATE_EDITOR_H
2#define OPIE_TEMPLATE_EDITOR_H
3
4#include <qobject.h>
5#include <qdialog.h>
6#include <qstring.h>
7
8namespace Todo {
9
10 class MainWindow;
11 class TemplateManager;
12 class TemplateEditor : public QObject{
13 Q_OBJECT
14 public:
15 TemplateEditor( MainWindow* win,
16 TemplateManager* man);
17 ~TemplateEditor();
18
19 signals:
20 void configChanged();
21 private:
22 void init();
23 MainWindow* m_main;
24 TemplateManager* m_man;
25private slots:
26 void setUp();
27
28 };
29};
30
31#endif
diff --git a/core/pim/todo/textviewshow.cpp b/core/pim/todo/textviewshow.cpp
new file mode 100644
index 0000000..24c8c0e
--- a/dev/null
+++ b/core/pim/todo/textviewshow.cpp
@@ -0,0 +1,19 @@
1#include "textviewshow.h"
2
3using namespace Todo;
4
5TextViewShow::TextViewShow( QWidget* parent)
6 : QTextView( parent ), TodoShow() {
7
8}
9TextViewShow::~TextViewShow() {
10}
11QString TextViewShow::type()const {
12 return QString::fromLatin1("TextViewShow");
13}
14void TextViewShow::slotShow( const OTodo& ev ) {
15 setText( ev.toRichText() );
16}
17QWidget* TextViewShow::widget() {
18 return this;
19}
diff --git a/core/pim/todo/textviewshow.h b/core/pim/todo/textviewshow.h
new file mode 100644
index 0000000..f58026b
--- a/dev/null
+++ b/core/pim/todo/textviewshow.h
@@ -0,0 +1,17 @@
1#include <qtextview.h>
2
3#include "todoshow.h"
4
5namespace Todo {
6
7 class TextViewShow : public QTextView, public TodoShow {
8 public:
9 TextViewShow( QWidget* parent );
10 ~TextViewShow();
11
12 QString type()const;
13 void slotShow( const OTodo& ev );
14 QWidget* widget();
15
16 };
17};
diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro
new file mode 100644
index 0000000..5108951
--- a/dev/null
+++ b/core/pim/todo/todo.pro
@@ -0,0 +1,55 @@
1 TEMPLATE= app
2 CONFIG = qt warn_on debug
3 DESTDIR = $(OPIEDIR)/bin
4
5 HEADERS= smalltodo.h \
6 todomanager.h \
7 mainwindow.h \
8 todoview.h \
9 todoentryimpl.h \
10 tableview.h \
11 tableitems.h \
12 todotemplatemanager.h \
13 todoeditor.h \
14 todoshow.h \
15 textviewshow.h \
16 templateeditor.h \
17 templatedialog.h \
18 templatedialogimpl.h
19
20 SOURCES= smalltodo.cpp \
21 todomanager.cpp \
22 mainwindow.cpp \
23 main.cpp \
24 todoentryimpl.cpp \
25 tableview.cpp \
26 tableitems.cpp \
27 todoview.cpp \
28 todotemplatemanager.cpp \
29 todoeditor.cpp \
30 todoshow.cpp \
31 textviewshow.cpp \
32 templateeditor.cpp \
33 templatedialog.cpp \
34 templatedialogimpl.cpp
35
36 INTERFACES= todoentry.ui
37 TARGET = todolist
38INCLUDEPATH += $(OPIEDIR)/include
39 DEPENDPATH+= $(OPIEDIR)/include
40LIBS += -lqpe -lopie -lopiesql
41
42TRANSLATIONS = ../../../i18n/de/todolist.ts \
43 ../../../i18n/en/todolist.ts \
44 ../../../i18n/es/todolist.ts \
45 ../../../i18n/fr/todolist.ts \
46 ../../../i18n/hu/todolist.ts \
47 ../../../i18n/ja/todolist.ts \
48 ../../../i18n/ko/todolist.ts \
49 ../../../i18n/no/todolist.ts \
50 ../../../i18n/pl/todolist.ts \
51 ../../../i18n/pt/todolist.ts \
52 ../../../i18n/pt_BR/todolist.ts \
53 ../../../i18n/sl/todolist.ts \
54 ../../../i18n/zh_CN/todolist.ts \
55 ../../../i18n/zh_TW/todolist.ts
diff --git a/core/pim/todo/todoeditor.cpp b/core/pim/todo/todoeditor.cpp
new file mode 100644
index 0000000..c9ade20
--- a/dev/null
+++ b/core/pim/todo/todoeditor.cpp
@@ -0,0 +1,53 @@
1
2#include "todoentryimpl.h"
3#include "todoeditor.h"
4
5using namespace Todo;
6
7Editor::Editor() {
8 m_accepted = false;
9}
10Editor::~Editor() {
11}
12OTodo Editor::newTodo( int cur,
13 QWidget* par) {
14
15 NewTaskDialog e( cur, par, 0, TRUE );
16
17
18#if defined(Q_WS_QWS) || defined(_WS_QWS_)
19 e.showMaximized();
20#endif
21
22 int ret = e.exec();
23 if ( QDialog::Accepted == ret ) {
24 m_accepted = true;
25 }else
26 m_accepted = false;
27
28 OTodo ev = e.todoEntry();
29 ev.setUid(1);
30
31 return ev;
32}
33OTodo Editor::edit( QWidget *wid,
34 const OTodo& todo ) {
35 NewTaskDialog e( todo, wid, 0, TRUE );
36 e.setCaption( QObject::tr( "Edit Task" ) );
37
38#if defined(Q_WS_QWS) || defined(_WS_QWS_)
39 e.showMaximized();
40#endif
41 int ret = e.exec();
42
43 OTodo ev = e.todoEntry();
44 if ( ret == QDialog::Accepted )
45 m_accepted = true;
46 else
47 m_accepted = false;
48
49 return ev;
50}
51bool Editor::accepted()const {
52 return m_accepted;
53}
diff --git a/core/pim/todo/todoeditor.h b/core/pim/todo/todoeditor.h
new file mode 100644
index 0000000..bbfdcb5
--- a/dev/null
+++ b/core/pim/todo/todoeditor.h
@@ -0,0 +1,25 @@
1#ifndef OPIE_TODO_EDITOR_H
2#define OPIE_TODO_EDITOR_H
3
4#include <opie/otodo.h>
5
6
7namespace Todo {
8 class Editor {
9 public:
10 Editor();
11 ~Editor();
12
13 OTodo newTodo( int currentCatId,
14 QWidget* par );
15 OTodo edit( QWidget* par,
16 const OTodo& ev = OTodo() );
17
18
19 bool accepted()const;
20 private:
21 bool m_accepted: 1;
22 };
23};
24
25#endif
diff --git a/core/pim/todo/todoentry.ui b/core/pim/todo/todoentry.ui
new file mode 100644
index 0000000..60547f2
--- a/dev/null
+++ b/core/pim/todo/todoentry.ui
@@ -0,0 +1,481 @@
1<!DOCTYPE UI><UI>
2<class>NewTaskDialogBase</class>
3<comment>*********************************************************************
4** Copyright (C) 2000 Trolltech AS. All rights reserved.
5**
6** This file is part of Qtopia Environment.
7**
8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file.
12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17**
18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you.
20**
21*********************************************************************</comment>
22<widget>
23 <class>QDialog</class>
24 <property stdset="1">
25 <name>name</name>
26 <cstring>NewTaskDialogBase</cstring>
27 </property>
28 <property stdset="1">
29 <name>geometry</name>
30 <rect>
31 <x>0</x>
32 <y>0</y>
33 <width>239</width>
34 <height>320</height>
35 </rect>
36 </property>
37 <property stdset="1">
38 <name>caption</name>
39 <string>New Task</string>
40 </property>
41 <property>
42 <name>layoutMargin</name>
43 </property>
44 <property>
45 <name>layoutSpacing</name>
46 </property>
47 <vbox>
48 <property stdset="1">
49 <name>margin</name>
50 <number>4</number>
51 </property>
52 <property stdset="1">
53 <name>spacing</name>
54 <number>4</number>
55 </property>
56 <widget>
57 <class>QLayoutWidget</class>
58 <property stdset="1">
59 <name>name</name>
60 <cstring>Layout19</cstring>
61 </property>
62 <property>
63 <name>layoutSpacing</name>
64 </property>
65 <grid>
66 <property stdset="1">
67 <name>margin</name>
68 <number>0</number>
69 </property>
70 <property stdset="1">
71 <name>spacing</name>
72 <number>4</number>
73 </property>
74 <widget row="3" column="1" >
75 <class>QLayoutWidget</class>
76 <property stdset="1">
77 <name>name</name>
78 <cstring>Layout6</cstring>
79 </property>
80 <property>
81 <name>layoutSpacing</name>
82 </property>
83 <hbox>
84 <property stdset="1">
85 <name>margin</name>
86 <number>0</number>
87 </property>
88 <property stdset="1">
89 <name>spacing</name>
90 <number>4</number>
91 </property>
92 <widget>
93 <class>QComboBox</class>
94 <item>
95 <property>
96 <name>text</name>
97 <string>0%</string>
98 </property>
99 </item>
100 <item>
101 <property>
102 <name>text</name>
103 <string>20%</string>
104 </property>
105 </item>
106 <item>
107 <property>
108 <name>text</name>
109 <string>40%</string>
110 </property>
111 </item>
112 <item>
113 <property>
114 <name>text</name>
115 <string>60%</string>
116 </property>
117 </item>
118 <item>
119 <property>
120 <name>text</name>
121 <string>80%</string>
122 </property>
123 </item>
124 <item>
125 <property>
126 <name>text</name>
127 <string>100%</string>
128 </property>
129 </item>
130 <property stdset="1">
131 <name>name</name>
132 <cstring>cmbProg</cstring>
133 </property>
134 <property stdset="1">
135 <name>sizePolicy</name>
136 <sizepolicy>
137 <hsizetype>7</hsizetype>
138 <vsizetype>0</vsizetype>
139 </sizepolicy>
140 </property>
141 <property stdset="1">
142 <name>maximumSize</name>
143 <size>
144 <width>32767</width>
145 <height>32767</height>
146 </size>
147 </property>
148 </widget>
149 <widget>
150 <class>QCheckBox</class>
151 <property stdset="1">
152 <name>name</name>
153 <cstring>checkCompleted</cstring>
154 </property>
155 <property stdset="1">
156 <name>text</name>
157 <string>&amp;Completed</string>
158 </property>
159 </widget>
160 </hbox>
161 </widget>
162 <widget row="0" column="0" >
163 <class>QLabel</class>
164 <property stdset="1">
165 <name>name</name>
166 <cstring>TextLabel2</cstring>
167 </property>
168 <property stdset="1">
169 <name>text</name>
170 <string>Priority:</string>
171 </property>
172 </widget>
173 <widget row="4" column="1" >
174 <class>QPushButton</class>
175 <property stdset="1">
176 <name>name</name>
177 <cstring>buttonDate</cstring>
178 </property>
179 <property stdset="1">
180 <name>enabled</name>
181 <bool>false</bool>
182 </property>
183 <property stdset="1">
184 <name>text</name>
185 <string>1 Jan 2001</string>
186 </property>
187 </widget>
188 <widget row="3" column="0" >
189 <class>QLabel</class>
190 <property stdset="1">
191 <name>name</name>
192 <cstring>txtProg</cstring>
193 </property>
194 <property stdset="1">
195 <name>frameShape</name>
196 <enum>MShape</enum>
197 </property>
198 <property stdset="1">
199 <name>frameShadow</name>
200 <enum>MShadow</enum>
201 </property>
202 <property stdset="1">
203 <name>text</name>
204 <string>Progress:</string>
205 </property>
206 </widget>
207 <widget row="2" column="1" >
208 <class>QPushButton</class>
209 <property stdset="1">
210 <name>name</name>
211 <cstring>selectGroupButton</cstring>
212 </property>
213 <property stdset="1">
214 <name>text</name>
215 <string>Select</string>
216 </property>
217 </widget>
218 <widget row="2" column="0" >
219 <class>QLabel</class>
220 <property stdset="1">
221 <name>name</name>
222 <cstring>txtProg_2</cstring>
223 </property>
224 <property stdset="1">
225 <name>frameShape</name>
226 <enum>MShape</enum>
227 </property>
228 <property stdset="1">
229 <name>frameShadow</name>
230 <enum>MShadow</enum>
231 </property>
232 <property stdset="1">
233 <name>text</name>
234 <string>Group:</string>
235 </property>
236 </widget>
237 <widget row="4" column="0" >
238 <class>QCheckBox</class>
239 <property stdset="1">
240 <name>name</name>
241 <cstring>checkDate</cstring>
242 </property>
243 <property stdset="1">
244 <name>text</name>
245 <string>D&amp;ue</string>
246 </property>
247 </widget>
248 <widget row="1" column="1" >
249 <class>CategorySelect</class>
250 <property stdset="1">
251 <name>name</name>
252 <cstring>comboCategory</cstring>
253 </property>
254 <property stdset="1">
255 <name>sizePolicy</name>
256 <sizepolicy>
257 <hsizetype>7</hsizetype>
258 <vsizetype>0</vsizetype>
259 </sizepolicy>
260 </property>
261 <property stdset="1">
262 <name>minimumSize</name>
263 <size>
264 <width>60</width>
265 <height>20</height>
266 </size>
267 </property>
268 </widget>
269 <widget row="0" column="1" >
270 <class>QComboBox</class>
271 <item>
272 <property>
273 <name>text</name>
274 <string>1 - Very High</string>
275 </property>
276 </item>
277 <item>
278 <property>
279 <name>text</name>
280 <string>2 - High</string>
281 </property>
282 </item>
283 <item>
284 <property>
285 <name>text</name>
286 <string>3 - Normal</string>
287 </property>
288 </item>
289 <item>
290 <property>
291 <name>text</name>
292 <string>4 - Low</string>
293 </property>
294 </item>
295 <item>
296 <property>
297 <name>text</name>
298 <string>5 - Very Low</string>
299 </property>
300 </item>
301 <property stdset="1">
302 <name>name</name>
303 <cstring>comboPriority</cstring>
304 </property>
305 <property stdset="1">
306 <name>currentItem</name>
307 <number>2</number>
308 </property>
309 </widget>
310 <widget row="5" column="0" >
311 <class>QLabel</class>
312 <property stdset="1">
313 <name>name</name>
314 <cstring>TextLabel1</cstring>
315 </property>
316 <property stdset="1">
317 <name>text</name>
318 <string>Summary:</string>
319 </property>
320 </widget>
321 <widget row="1" column="0" >
322 <class>QLabel</class>
323 <property stdset="1">
324 <name>name</name>
325 <cstring>TextLabel3</cstring>
326 </property>
327 <property stdset="1">
328 <name>frameShape</name>
329 <enum>NoFrame</enum>
330 </property>
331 <property stdset="1">
332 <name>text</name>
333 <string>Category:</string>
334 </property>
335 </widget>
336 <widget row="5" column="1" >
337 <class>QLayoutWidget</class>
338 <property stdset="1">
339 <name>name</name>
340 <cstring>Layout8</cstring>
341 </property>
342 <property>
343 <name>layoutSpacing</name>
344 </property>
345 <hbox>
346 <property stdset="1">
347 <name>margin</name>
348 <number>0</number>
349 </property>
350 <property stdset="1">
351 <name>spacing</name>
352 <number>4</number>
353 </property>
354 <widget>
355 <class>QLineEdit</class>
356 <property stdset="1">
357 <name>name</name>
358 <cstring>lneSum</cstring>
359 </property>
360 </widget>
361 <widget>
362 <class>OClickableLabel</class>
363 <property stdset="1">
364 <name>name</name>
365 <cstring>lblDown</cstring>
366 </property>
367 <property stdset="1">
368 <name>sizePolicy</name>
369 <sizepolicy>
370 <hsizetype>0</hsizetype>
371 <vsizetype>0</vsizetype>
372 </sizepolicy>
373 </property>
374 <property stdset="1">
375 <name>minimumSize</name>
376 <size>
377 <width>20</width>
378 <height>20</height>
379 </size>
380 </property>
381 <property stdset="1">
382 <name>maximumSize</name>
383 <size>
384 <width>20</width>
385 <height>20</height>
386 </size>
387 </property>
388 </widget>
389 </hbox>
390 </widget>
391 </grid>
392 </widget>
393 <widget>
394 <class>QMultiLineEdit</class>
395 <property stdset="1">
396 <name>name</name>
397 <cstring>txtTodo</cstring>
398 </property>
399 <property stdset="1">
400 <name>sizePolicy</name>
401 <sizepolicy>
402 <hsizetype>7</hsizetype>
403 <vsizetype>7</vsizetype>
404 </sizepolicy>
405 </property>
406 <property stdset="1">
407 <name>wordWrap</name>
408 <enum>WidgetWidth</enum>
409 </property>
410 </widget>
411 </vbox>
412</widget>
413<customwidgets>
414 <customwidget>
415 <class>CategorySelect</class>
416 <header location="global">qpe/categoryselect.h</header>
417 <sizehint>
418 <width>-1</width>
419 <height>-1</height>
420 </sizehint>
421 <container>0</container>
422 <sizepolicy>
423 <hordata>7</hordata>
424 <verdata>1</verdata>
425 </sizepolicy>
426 <pixmap>image0</pixmap>
427 </customwidget>
428 <customwidget>
429 <class>OClickableLabel</class>
430 <header location="global">opie/oclickablelabel.h</header>
431 <sizehint>
432 <width>-1</width>
433 <height>-1</height>
434 </sizehint>
435 <container>0</container>
436 <sizepolicy>
437 <hordata>5</hordata>
438 <verdata>5</verdata>
439 </sizepolicy>
440 <pixmap>image0</pixmap>
441 <signal>clicked()</signal>
442 <signal>toggled(bool)</signal>
443 <slot access="public">slotOn(bool)</slot>
444 </customwidget>
445</customwidgets>
446<images>
447 <image>
448 <name>image0</name>
449 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
450 </image>
451</images>
452<connections>
453 <connection>
454 <sender>checkDate</sender>
455 <signal>toggled(bool)</signal>
456 <receiver>buttonDate</receiver>
457 <slot>setEnabled(bool)</slot>
458 </connection>
459 <connection>
460 <sender>lblDown</sender>
461 <signal>clicked()</signal>
462 <receiver>NewTaskDialogBase</receiver>
463 <slot>slotCopy()</slot>
464 </connection>
465 <slot access="protected">dateChanged( const QString &amp; )</slot>
466 <slot access="protected">dateChanged( int, int, int )</slot>
467 <slot access="protected">slotCopy()</slot>
468</connections>
469<tabstops>
470 <tabstop>comboPriority</tabstop>
471 <tabstop>comboCategory</tabstop>
472 <tabstop>selectGroupButton</tabstop>
473 <tabstop>cmbProg</tabstop>
474 <tabstop>checkCompleted</tabstop>
475 <tabstop>checkDate</tabstop>
476 <tabstop>buttonDate</tabstop>
477 <tabstop>lneSum</tabstop>
478 <tabstop>lblDown</tabstop>
479 <tabstop>txtTodo</tabstop>
480</tabstops>
481</UI>
diff --git a/core/pim/todo/todoentryimpl.cpp b/core/pim/todo/todoentryimpl.cpp
new file mode 100644
index 0000000..4211ae2
--- a/dev/null
+++ b/core/pim/todo/todoentryimpl.cpp
@@ -0,0 +1,189 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** Copyright (C) 2002 zecke
4**
5** This file is part of Qtopia Environment.
6**
7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file.
11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16**
17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you.
19**
20**********************************************************************/
21
22#include "todoentryimpl.h"
23
24#include <opie/oclickablelabel.h>
25#include <opie/otodo.h>
26
27#include <qpe/categoryselect.h>
28#include <qpe/datebookmonth.h>
29#include <qpe/global.h>
30#include <qpe/resource.h>
31#include <qpe/imageedit.h>
32#include <qpe/timestring.h>
33#include <qpe/palmtoprecord.h>
34
35#include <qlayout.h>
36#include <qmessagebox.h>
37#include <qpopupmenu.h>
38#include <qtoolbutton.h>
39#include <qcombobox.h>
40#include <qcheckbox.h>
41#include <qlineedit.h>
42#include <qmultilineedit.h>
43#include <qlabel.h>
44#include <qtimer.h>
45#include <qapplication.h>
46#include <qvaluelist.h>
47
48NewTaskDialog::NewTaskDialog( const OTodo& task, QWidget *parent,
49 const char *name, bool modal, WFlags fl )
50 : NewTaskDialogBase( parent, name, modal, fl ),
51 todo( task )
52{
53 todo.setCategories( task.categories() );
54 if ( todo.hasDueDate() )
55 date = todo.dueDate();
56 else
57 date = QDate::currentDate();
58
59 init();
60 comboPriority->setCurrentItem( task.priority() - 1 );
61
62 checkCompleted->setChecked( task.isCompleted() );
63 checkDate->setChecked( task.hasDueDate() );
64 buttonDate->setText( TimeString::longDateString( date ) );
65
66 txtTodo->setText( task.description() );
67 lneSum->setText( task.summary() );
68 cmbProg->setCurrentItem( task.progress()/20 );
69}
70
71/*
72 * Constructs a NewTaskDialog which is a child of 'parent', with the
73 * name 'name' and widget flags set to 'f'
74 *
75 * The dialog will by default be modeless, unless you set 'modal' to
76 * TRUE to construct a modal dialog.
77 */
78NewTaskDialog::NewTaskDialog( int id, QWidget* parent, const char* name, bool modal,
79 WFlags fl )
80 : NewTaskDialogBase( parent, name, modal, fl ),
81 date( QDate::currentDate() )
82{
83 if ( id != -1 )
84 todo.setCategories( id );
85 init();
86}
87
88void NewTaskDialog::init()
89{
90 if( layout() != 0 ){
91 layout()->setMargin( 2 );
92 }
93 QPopupMenu *m1 = new QPopupMenu( this );
94 picker = new DateBookMonth( m1, 0, TRUE );
95 m1->insertItem( picker );
96 buttonDate->setPopup( m1 );
97 comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") );
98
99 connect( picker, SIGNAL( dateClicked( int, int, int ) ),
100 this, SLOT( dateChanged( int, int, int ) ) );
101
102 connect ( selectGroupButton, SIGNAL( clicked() ),
103 this, SLOT( groupButtonClicked () ) );
104
105 buttonDate->setText( TimeString::longDateString( date ) );
106 picker->setDate( date.year(), date.month(), date.day() );
107 lblDown->setPixmap(Resource::loadPixmap("down") );
108}
109
110/*
111 * Destroys the object and frees any allocated resources
112 */
113NewTaskDialog::~NewTaskDialog()
114{
115 // no need to delete child widgets, Qt does it all for us
116}
117void NewTaskDialog::dateChanged( int y, int m, int d )
118{
119 date = QDate( y, m, d );
120 buttonDate->setText( TimeString::longDateString( date ) );
121}
122void NewTaskDialog::groupButtonClicked ()
123{
124 /*OContactSelectorDialog cd( this );
125 QArray<int> todo_relations = todo.relations ( "addressbook" );
126 QValueList<int> selectedContacts;
127
128 for ( uint i=0; i < todo_relations.size(); i++ ){
129 printf ("old: %d\n", todo_relations[i]);
130 selectedContacts.append( todo_relations[i] );
131 }
132 cd.setSelected (selectedContacts);
133 cd.showMaximized();
134 if ( cd.exec() == QDialog::Accepted ){
135 selectedContacts = cd.selected ();
136 QValueListIterator<int> it;
137 todo.clearRelated("addressbook");
138 for( it = selectedContacts.begin(); it != selectedContacts.end(); ++it ){
139 printf ("Adding: %d\n", (*it));
140 todo.addRelated( "addressbook", (*it) );
141 }
142
143 }
144*/
145}
146
147OTodo NewTaskDialog::todoEntry()
148{
149 if( checkDate->isChecked() ){
150 todo.setDueDate( date );
151 todo.setHasDueDate( true );
152 }else{
153 todo.setHasDueDate( false );
154 }
155 if ( comboCategory->currentCategory() != -1 ) {
156 QArray<int> arr = comboCategory->currentCategories();
157 QStringList list;
158 todo.setCategories( arr );
159 }
160 todo.setPriority( comboPriority->currentItem() + 1 );
161 todo.setCompleted( checkCompleted->isChecked() );
162
163 todo.setDescription( txtTodo->text() );
164 todo.setSummary( lneSum->text() );
165 QString text = cmbProg->currentText();
166 todo.setProgress( text.remove( text.length()-1, 1 ).toUShort() );
167 return todo;
168}
169void NewTaskDialog::slotCopy()
170{
171 txtTodo->clear();
172 txtTodo->setText( lneSum->text() );
173}
174
175/*!
176
177*/
178
179void NewTaskDialog::accept()
180{
181 QString strText = txtTodo->text();
182 QString strSumm = lneSum->text();
183 if ( strSumm.isEmpty() && strText.isEmpty() ) {
184 // hmm... just decline it then, the user obviously didn't care about it
185 QDialog::reject();
186 return;
187 }
188 QDialog::accept();
189}
diff --git a/core/pim/todo/todoentryimpl.h b/core/pim/todo/todoentryimpl.h
new file mode 100644
index 0000000..2dfdd22
--- a/dev/null
+++ b/core/pim/todo/todoentryimpl.h
@@ -0,0 +1,65 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef NEWTASKDIALOG_H
22#define NEWTASKDIALOG_H
23
24#include "todoentry.h"
25
26#include <opie/otodo.h>
27//#include <opie/ocontactselector.h>
28
29#include <qdatetime.h>
30#include <qpalette.h>
31
32class QLabel;
33class QTimer;
34class DateBookMonth;
35
36
37
38class NewTaskDialog : public NewTaskDialogBase
39{
40 Q_OBJECT
41
42public:
43 NewTaskDialog( const OTodo& task, QWidget *parent = 0, const char* name = 0,
44 bool modal = FALSE, WFlags fl = 0 );
45 NewTaskDialog( int id, QWidget* parent = 0, const char* name = 0,
46 bool modal = FALSE, WFlags fl = 0 );
47 ~NewTaskDialog();
48
49 OTodo todoEntry();
50
51protected slots:
52 void dateChanged( int y, int m, int d );
53 void groupButtonClicked ();
54 void slotCopy();
55protected:
56 virtual void accept();
57
58private:
59 void init();
60 OTodo todo;
61 QDate date;
62 DateBookMonth *picker;
63};
64
65#endif // NEWTASKDIALOG_H
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
new file mode 100644
index 0000000..8e3fa88
--- a/dev/null
+++ b/core/pim/todo/todomanager.cpp
@@ -0,0 +1,125 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28#include <qdatetime.h>
29#include <qpe/categoryselect.h>
30
31#include "todomanager.h"
32
33using namespace Todo;
34
35TodoManager::TodoManager( QObject *obj )
36 : QObject( obj ) {
37 m_db = 0l;
38 QTime time;
39 time.start();
40 int el = time.elapsed();
41 qWarning("QTimer for loading %d", el/1000 );
42}
43TodoManager::~TodoManager() {
44 delete m_db;
45}
46OTodo TodoManager::event(int uid ) {
47 return m_db->find( uid );
48}
49void TodoManager::updateList() {
50 m_list = m_db->allRecords();
51}
52OTodoAccess::List::Iterator TodoManager::begin() {
53 m_it = m_list.begin();
54 return m_it;
55}
56OTodoAccess::List::Iterator TodoManager::end() {
57 return m_list.end();
58}
59OTodoAccess::List::Iterator TodoManager::overDue() {
60 int filter = 2 & 1;
61 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca );
62 m_it = m_list.begin();
63 return m_it;
64}
65OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start,
66 const QDate& end ) {
67 m_list = m_db->effectiveToDos( start, end );
68 m_it = m_list.begin();
69 return m_it;
70}
71OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) {
72 m_list = m_db->queryByExample( ev, query );
73 m_it = m_list.begin();
74 return m_it;
75}
76OTodoAccess* TodoManager::todoDB() {
77 return m_db;
78}
79void TodoManager::add( const OTodo& ev ) {
80 m_db->add( ev );
81}
82void TodoManager::update( int, const SmallTodo& ) {
83
84}
85void TodoManager::update( int, const OTodo& ev) {
86 m_db->replace( ev );
87}
88void TodoManager::remove( int uid ) {
89 m_db->remove( uid );
90}
91void TodoManager::removeAll() {
92 m_db->clear();
93}
94void TodoManager::save() {
95 m_db->save();
96}
97bool TodoManager::saveAll() {
98 return m_db->save();
99}
100void TodoManager::reload() {
101 m_db->reload();
102}
103QStringList TodoManager::categories() {
104 m_cat.load(categoryFileName() );
105 return m_cat.labels( "Todo List");
106}
107/*
108 * we rely on load beeing called from populateCategories
109 */
110int TodoManager::catId( const QString& cats ) {
111 return m_cat.id( "Todo List", cats );
112}
113void TodoManager::remove( const QArray<int>& ids) {
114 for (uint i=0; i < ids.size(); i++ )
115 remove( ids[i] );
116}
117bool TodoManager::isLoaded()const {
118 return (m_db == 0 );
119}
120void TodoManager::load() {
121 if (!m_db) {
122 m_db = new OTodoAccess();
123 m_db->load();
124 }
125}
diff --git a/core/pim/todo/todomanager.h b/core/pim/todo/todomanager.h
new file mode 100644
index 0000000..1f9e288
--- a/dev/null
+++ b/core/pim/todo/todomanager.h
@@ -0,0 +1,107 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef OPIE_TODO_MANAGER_H
30#define OPIE_TODO_MANAGER_H
31
32#include <qarray.h>
33#include <qobject.h>
34#include <qstring.h>
35
36#include <qpe/categories.h>
37
38#include <opie/otodo.h>
39#include <opie/otodoaccess.h>
40
41#include "smalltodo.h"
42
43
44namespace Todo {
45 class TodoManager : public QObject{
46 Q_OBJECT
47 public:
48 bool isLoaded()const;
49 void load();
50 TodoManager(QObject* obj = 0);
51 ~TodoManager();
52
53 QStringList categories()/*const*/;
54 int catId(const QString&);
55 OTodo event(int uid );
56
57 void updateList();
58 /** returns the iterator sorted if set sorted*/
59 OTodoAccess::List::Iterator begin();
60 OTodoAccess::List::Iterator end();
61 OTodoAccess::List& list();
62
63 OTodoAccess::List::Iterator overDue();
64 OTodoAccess::List::Iterator fromTo( const QDate& start,
65 const QDate& end );
66 OTodoAccess::List::Iterator query( const OTodo& ev, int query );
67
68 void setCategory( bool sort, int category = -1);
69 void setShowOverDue( bool show );
70 void setSortOrder( int sortOrder );
71 void setSortASC( bool );
72 void sort();
73
74 OTodoAccess* todoDB();
75 bool saveAll();
76
77
78 signals:
79 void update();
80 void updateCategories();
81
82 public slots:
83 void add( const OTodo& );
84 void update( int uid, const SmallTodo& );
85 void update( int uid, const OTodo& );
86 void remove( int uid );
87 void remove( const QArray<int>& );
88 void removeAll();
89 void reload();
90 void save();
91
92 private:
93 OTodoAccess* m_db;
94 OTodoAccess::List m_list;
95 OTodoAccess::List::Iterator m_it;
96 OTodoAccess::List m_sorted;
97 Categories m_cat;
98 int m_ca;
99 /* sort cat */
100 bool m_shCat;
101 int m_sortOrder;
102 bool m_asc;
103
104 };
105};
106
107#endif
diff --git a/core/pim/todo/todoshow.cpp b/core/pim/todo/todoshow.cpp
new file mode 100644
index 0000000..c84a08f
--- a/dev/null
+++ b/core/pim/todo/todoshow.cpp
@@ -0,0 +1,9 @@
1#include "todoshow.h"
2
3using namespace Todo;
4
5TodoShow::TodoShow() {
6}
7TodoShow::~TodoShow() {
8}
9
diff --git a/core/pim/todo/todoshow.h b/core/pim/todo/todoshow.h
new file mode 100644
index 0000000..198e9ae
--- a/dev/null
+++ b/core/pim/todo/todoshow.h
@@ -0,0 +1,53 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28#ifndef TODO_TODO_SHOW_H
29#define TODO_TODO_SHOW_H
30
31#include <qstring.h>
32#include <qwidget.h>
33
34#include <opie/otodo.h>
35
36namespace Todo {
37 /**
38 * TodoShow is the baseclass of
39 * of all TodoShows.
40 * The first implementation is a QTextView
41 * implementation showing the Todo as richtext
42 */
43 class TodoShow {
44 public:
45 TodoShow();
46 virtual ~TodoShow();
47 virtual QString type()const = 0;
48 virtual void slotShow( const OTodo& ev ) = 0;
49 virtual QWidget* widget() = 0;
50 };
51};
52
53#endif
diff --git a/core/pim/todo/todotemplatemanager.cpp b/core/pim/todo/todotemplatemanager.cpp
new file mode 100644
index 0000000..02941ac
--- a/dev/null
+++ b/core/pim/todo/todotemplatemanager.cpp
@@ -0,0 +1,75 @@
1#include <qpe/config.h>
2#include <qpe/global.h>
3
4#include <opie/otodoaccess.h>
5#include <opie/otodoaccessxml.h>
6
7#include "todotemplatemanager.h"
8
9
10using namespace Todo;
11
12TemplateManager::TemplateManager() {
13 m_path = Global::applicationFileName("todolist", "templates.xml");
14}
15TemplateManager::~TemplateManager() {
16
17}
18void TemplateManager::load() {
19 Config conf("todolist_templates");
20 OTodoAccessXML *xml = new OTodoAccessXML( QString::fromLatin1("template"),
21 m_path );
22 OTodoAccess todoDB(xml );
23 todoDB.load();
24
25 OTodoAccess::List::Iterator it;
26 OTodoAccess::List list = todoDB.allRecords();
27 for ( it = list.begin(); it != list.end(); ++it ) {
28 OTodo ev = (*it);
29 conf.setGroup( QString::number( ev.uid() ) );
30 QString str = conf.readEntry("Name", QString::null );
31 if (str.isEmpty() )
32 continue;
33
34 m_templates.insert( str,
35 ev );
36 }
37}
38void TemplateManager::save() {
39 Config conf("todolist_templates");
40
41 OTodoAccessXML *res = new OTodoAccessXML( "template",
42 m_path );
43 OTodoAccess db(res);
44
45
46 QMap<QString, OTodo>::Iterator it;
47 for ( it = m_templates.begin(); it != m_templates.end(); ++it ) {
48 OTodo ev = it.data();
49 conf.setGroup( QString::number( ev.uid() ) );
50 qWarning("Name" + it.key() );
51 conf.writeEntry("Name", it.key() );
52 db.add( ev );
53 }
54 db.save();
55}
56void TemplateManager::addEvent( const QString& str,
57 const OTodo& ev) {
58 qWarning("AddEvent"+ str );
59 m_templates.replace( str, ev );
60}
61void TemplateManager::removeEvent( const QString& str ) {
62 m_templates.remove( str );
63}
64QStringList TemplateManager::templates() const {
65 QStringList list;
66 QMap<QString, OTodo>::ConstIterator it;
67 for (it = m_templates.begin(); it != m_templates.end(); ++it ) {
68 list << it.key();
69 }
70
71 return list;
72}
73OTodo TemplateManager::templateEvent( const QString& templateName ) {
74 return m_templates[templateName];
75}
diff --git a/core/pim/todo/todotemplatemanager.h b/core/pim/todo/todotemplatemanager.h
new file mode 100644
index 0000000..387ced1
--- a/dev/null
+++ b/core/pim/todo/todotemplatemanager.h
@@ -0,0 +1,32 @@
1#ifndef OPIE_TODO_TEMPLATE_H
2#define OPIE_TODO_TEMPLATE_H
3
4#include <qstring.h>
5#include <qmap.h>
6
7#include <opie/otodo.h>
8
9
10namespace Todo {
11 class TemplateManager {
12 public:
13 TemplateManager();
14 ~TemplateManager();
15 void load();
16 void save();
17 QStringList templates()const;
18 OTodo templateEvent( const QString& templateName );
19
20 /* also replaces one */
21 void addEvent( const QString&, const OTodo& );
22 void removeEvent( const QString& );
23 private:
24 QString m_path;
25 QMap<QString, OTodo> m_templates;
26
27
28
29 };
30};
31
32#endif
diff --git a/core/pim/todo/todoview.cpp b/core/pim/todo/todoview.cpp
new file mode 100644
index 0000000..5362b23
--- a/dev/null
+++ b/core/pim/todo/todoview.cpp
@@ -0,0 +1,62 @@
1#include "mainwindow.h"
2
3#include "todoview.h"
4
5using namespace Todo;
6
7TodoView::TodoView( MainWindow* win )
8 : m_main( win )
9{
10 hack = new InternQtHack;
11}
12TodoView::~TodoView() {
13 delete hack;
14};
15
16void TodoView::connectShow(QObject* obj,
17 const char* slot ) {
18 QObject::connect( hack, SIGNAL(showTodo(int) ),
19 obj, slot );
20}
21void TodoView::connectEdit( QObject* obj,
22 const char* slot ) {
23 QObject::connect( hack, SIGNAL(edit(int) ),
24 obj, slot );
25}
26void TodoView::connectUpdateSmall( QObject* obj,
27 const char* slot ) {
28 QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ),
29 obj, slot );
30}
31void TodoView::connectUpdateBig( QObject* obj,
32 const char* slot ) {
33 QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ),
34 obj, slot );
35}
36void TodoView::connectUpdateView( QObject* obj,
37 const char* slot ) {
38 QObject::connect( hack, SIGNAL(update(QWidget*) ),
39 obj, slot );
40}
41void TodoView::connectRemove( QObject* obj,
42 const char* slot ) {
43 QObject::connect( hack, SIGNAL(remove(int) ),
44 obj, slot );
45}
46MainWindow* TodoView::todoWindow() {
47 return m_main;
48}
49
50OTodo TodoView::event(int uid ) { return m_main->event( uid ); }
51OTodoAccess::List::Iterator TodoView::begin() {
52 m_main->updateList();
53 return m_main->begin();
54}
55OTodoAccess::List::Iterator TodoView::end() { return m_main->end(); }
56
57void TodoView::update(int uid, const SmallTodo& to ) {
58 //m_main->slotUpate1( uid, to );
59}
60void TodoView::update(int uid, const OTodo& ev ) {
61 m_main->updateTodo( ev );
62}
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h
new file mode 100644
index 0000000..e4985a7
--- a/dev/null
+++ b/core/pim/todo/todoview.h
@@ -0,0 +1,178 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef TODO_VIEW_H
30#define TODO_VIEW_H
31
32#include <qarray.h>
33#include <qstring.h>
34#include <qvaluelist.h>
35#include <qwidget.h>
36
37#include <opie/otodoaccess.h>
38
39#include "smalltodo.h"
40
41
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;
81
82 /**
83 * due to inheretince problems we need this base class
84 */
85 class ViewBase {
86 public:
87 virtual QWidget* widget() = 0;
88 virtual QString type()const = 0;
89 virtual int current() = 0;
90 virtual QString currentRepresentation() = 0;
91 virtual void showOverDue( bool ) = 0;
92 virtual void setTodos( OTodoAccess::List::Iterator it,
93 OTodoAccess::List::Iterator end ) = 0;
94
95 virtual void addEvent( const OTodo& ) = 0;
96 virtual void replaceEvent( const OTodo& ) = 0;
97 virtual void removeEvent( int uid ) = 0;
98 virtual void setShowCompleted( bool ) = 0;
99 virtual void setShowDeadline( bool ) = 0;
100 virtual void setShowCategory( const QString& = QString::null ) = 0;
101 virtual void clear() = 0;
102 virtual QArray<int> completed() = 0;
103 virtual void newDay() = 0;
104
105 virtual void connectShow( QObject*, const char* ) = 0;
106 virtual void connectEdit( QObject*, const char* ) = 0;
107 virtual void connectUpdateSmall( QObject*, const char* ) = 0;
108 virtual void connectUpdateBig( QObject*, const char* ) = 0;
109 virtual void connectUpdateView( QObject*, const char*) = 0;
110 virtual void connectRemove( QObject*, const char* ) = 0;
111
112 };
113
114 /**
115 * A base class for all TodoView which are showing
116 * a list of todos.
117 * Either in a QTable, QListView or any other QWidget
118 * derived class
119 * Through the MainWindow( dispatcher ) one can access
120 * the relevant informations
121 *
122 * It's not possible to have signal and slots from within
123 * templates this way you've to register for a signal
124 */
125 class TodoView : public ViewBase{
126
127 public:
128 /**
129 * c'tor
130 */
131 TodoView( MainWindow* win );
132
133 /**
134 *d'tor
135 */
136 virtual ~TodoView();
137
138 /* connect to the show signal */
139 void connectShow(QObject* obj,
140 const char* slot );
141
142 /* connect to edit */
143 void connectEdit( QObject* obj,
144 const char* slot );
145 void connectUpdateSmall( QObject* obj,
146 const char* slot );
147 void connectUpdateBig( QObject* obj,
148 const char* slot ) ;
149 void connectUpdateView( QObject* obj,
150 const char* slot );
151 void connectRemove( QObject* obj,
152 const char* slot );
153 protected:
154 MainWindow* todoWindow();
155 OTodo event(int uid );
156 OTodoAccess::List::Iterator begin();
157 OTodoAccess::List::Iterator end();
158
159 /*
160 These things needs to be implemented
161 in a implementation
162 signals:
163 */
164 protected:
165 void showTodo( int uid ) { hack->emitShow(uid); }
166 void edit( int uid ) { hack->emitEdit(uid); }
167 void update(int uid, const SmallTodo& to );
168 void update(int uid, const OTodo& ev);
169 void remove( int uid ) {
170 hack->emitRemove( uid );
171 }
172 private:
173 InternQtHack* hack;
174 MainWindow *m_main;
175 };
176};
177
178#endif