summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/main.cpp2
-rw-r--r--core/pim/todo/mainwindow.cpp7
-rw-r--r--core/pim/todo/tableview.cpp97
-rw-r--r--core/pim/todo/tableview.h7
-rw-r--r--core/pim/todo/todomanager.cpp2
-rw-r--r--core/pim/todo/todoview.cpp3
-rw-r--r--core/pim/todo/todoview.h2
7 files changed, 86 insertions, 34 deletions
diff --git a/core/pim/todo/main.cpp b/core/pim/todo/main.cpp
index 58ed45c..aeae794 100644
--- a/core/pim/todo/main.cpp
+++ b/core/pim/todo/main.cpp
@@ -1,49 +1,49 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "mainwindow.h" 21#include "mainwindow.h"
22 22
23 23
24#include <qdatetime.h> 24#include <qdatetime.h>
25 25
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27 27
28void myMessages( QtMsgType, const char* ) { 28void myMessages( QtMsgType, const char* ) {
29 29
30} 30}
31 31
32int main( int argc, char **argv ) 32int main( int argc, char **argv )
33{ 33{
34 qInstallMsgHandler( myMessages ); 34// qInstallMsgHandler( myMessages );
35 QPEApplication a( argc, argv ); 35 QPEApplication a( argc, argv );
36 36
37 QTime time; 37 QTime time;
38 time.start(); 38 time.start();
39 Todo::MainWindow mw; 39 Todo::MainWindow mw;
40 int t = time.elapsed(); 40 int t = time.elapsed();
41 qWarning("QTime %d", t/1000 ); 41 qWarning("QTime %d", t/1000 );
42 mw.setCaption("Opie Todolist"); 42 mw.setCaption("Opie Todolist");
43 QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) ); 43 QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) );
44 QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) ); 44 QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) );
45 45
46 a.showMainWidget(&mw); 46 a.showMainWidget(&mw);
47 47
48 return a.exec(); 48 return a.exec();
49} 49}
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 48954ce..c9c43d4 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,638 +1,639 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = General Public License along with 21  -_. . .   )=.  = General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include <qmenubar.h> 29#include <qmenubar.h>
30#include <qmessagebox.h> 30#include <qmessagebox.h>
31#include <qtoolbar.h> 31#include <qtoolbar.h>
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qwidgetstack.h> 33#include <qwidgetstack.h>
34#include <qaction.h> 34#include <qaction.h>
35#include <qtimer.h> 35#include <qtimer.h>
36 36
37#include <qpe/config.h> 37#include <qpe/config.h>
38#include <qpe/ir.h> 38#include <qpe/ir.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40#include <qpe/qpemessagebox.h> 40#include <qpe/qpemessagebox.h>
41 41
42 42
43#include "todotemplatemanager.h" 43#include "todotemplatemanager.h"
44#include "templateeditor.h" 44#include "templateeditor.h"
45#include "todoentryimpl.h" 45#include "todoentryimpl.h"
46#include "tableview.h" 46#include "tableview.h"
47 47
48#include "textviewshow.h" 48#include "textviewshow.h"
49#include "todoeditor.h" 49#include "todoeditor.h"
50#include "mainwindow.h" 50#include "mainwindow.h"
51 51
52 52
53using namespace Todo; 53using namespace Todo;
54 54
55MainWindow::MainWindow( QWidget* parent, 55MainWindow::MainWindow( QWidget* parent,
56 const char* name ) { 56 const char* name ) {
57 57
58 m_syncing = false; 58 m_syncing = false;
59 m_counter = 0; 59 m_counter = 0;
60 m_tempManager = new TemplateManager(); 60 m_tempManager = new TemplateManager();
61 m_tempManager->load(); 61 m_tempManager->load();
62 62
63 initUI(); 63 initUI();
64 initConfig(); 64 initConfig();
65 initViews(); 65 initViews();
66 initActions(); 66 initActions();
67 initEditor(); 67 initEditor();
68 initShow(); 68 initShow();
69 initTemplate(); 69 initTemplate();
70 70
71 populateTemplates(); 71 populateTemplates();
72 raiseCurrentView(); 72 raiseCurrentView();
73 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 73 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
74} 74}
75void MainWindow::initTemplate() { 75void MainWindow::initTemplate() {
76 m_curTempEd = new TemplateEditor( this, templateManager() ); 76 m_curTempEd = new TemplateEditor( this, templateManager() );
77} 77}
78void MainWindow::initActions() { 78void MainWindow::initActions() {
79 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), 79 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ),
80 QString::null, 0, this, 0 ); 80 QString::null, 0, this, 0 );
81 connect(a, SIGNAL( activated() ), 81 connect(a, SIGNAL( activated() ),
82 this, SLOT( slotNew() ) ); 82 this, SLOT( slotNew() ) );
83 a->addTo(m_tool ); 83 a->addTo(m_tool );
84 a->addTo(m_edit ); 84 a->addTo(m_edit );
85 85
86 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), 86 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ),
87 QString::null, 0, this, 0 ); 87 QString::null, 0, this, 0 );
88 connect(a, SIGNAL(activated() ), 88 connect(a, SIGNAL(activated() ),
89 this, SLOT( slotEdit() ) ); 89 this, SLOT( slotEdit() ) );
90 a->addTo( m_tool ); 90 a->addTo( m_tool );
91 a->addTo( m_edit ); 91 a->addTo( m_edit );
92 m_editAction = a; 92 m_editAction = a;
93 93
94 a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); 94 a = new QAction( QString::null, tr("View Task"), 0, this, 0 );
95 connect(a, SIGNAL( activated() ), 95 connect(a, SIGNAL( activated() ),
96 this, SLOT( slotShowDetails() ) ); 96 this, SLOT( slotShowDetails() ) );
97 a->addTo( m_edit ); 97 a->addTo( m_edit );
98 98
99 m_edit->insertSeparator(); 99 m_edit->insertSeparator();
100 100
101 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), 101 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ),
102 QString::null, 0, this, 0 ); 102 QString::null, 0, this, 0 );
103 connect(a, SIGNAL(activated() ), 103 connect(a, SIGNAL(activated() ),
104 this, SLOT(slotDelete() ) ); 104 this, SLOT(slotDelete() ) );
105 a->addTo( m_tool ); 105 a->addTo( m_tool );
106 a->addTo( m_edit ); 106 a->addTo( m_edit );
107 m_deleteAction = a; 107 m_deleteAction = a;
108 108
109 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); 109 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 );
110 connect(a, SIGNAL( activated() ), 110 connect(a, SIGNAL( activated() ),
111 this, SLOT( slotDeleteAll() ) ); 111 this, SLOT( slotDeleteAll() ) );
112 a->addTo(m_edit ); 112 a->addTo(m_edit );
113 m_deleteAllAction = a; 113 m_deleteAllAction = a;
114 114
115 a = new QAction( QString::null, tr("Delete completed"), 115 a = new QAction( QString::null, tr("Delete completed"),
116 0, this, 0 ); 116 0, this, 0 );
117 connect(a, SIGNAL( activated() ), 117 connect(a, SIGNAL( activated() ),
118 this, SLOT( slotDeleteCompleted() ) ); 118 this, SLOT( slotDeleteCompleted() ) );
119 a->addTo(m_edit ); 119 a->addTo(m_edit );
120 a->setEnabled( TRUE ); 120 a->setEnabled( TRUE );
121 m_deleteCompleteAction = a; 121 m_deleteCompleteAction = a;
122 122
123 m_edit->insertSeparator(); 123 m_edit->insertSeparator();
124 124
125 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); 125 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 );
126 connect(a, SIGNAL( activated() ), 126 connect(a, SIGNAL( activated() ),
127 this, SLOT( slotDuplicate() ) ); 127 this, SLOT( slotDuplicate() ) );
128 a->addTo(m_edit ); 128 a->addTo(m_edit );
129 m_duplicateAction = a; 129 m_duplicateAction = a;
130 130
131 m_edit->insertSeparator(); 131 m_edit->insertSeparator();
132 132
133 if ( Ir::supported() ) { 133 if ( Ir::supported() ) {
134 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), 134 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
135 QString::null, 0, this, 0 ); 135 QString::null, 0, this, 0 );
136 connect( a, SIGNAL( activated() ), 136 connect( a, SIGNAL( activated() ),
137 this, SLOT( slotBeam() ) ); 137 this, SLOT( slotBeam() ) );
138 a->addTo( m_edit ); 138 a->addTo( m_edit );
139 a->addTo( m_tool ); 139 a->addTo( m_tool );
140 } 140 }
141 141
142 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), 142 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ),
143 QString::null, 0, this, 0 ); 143 QString::null, 0, this, 0 );
144 connect(a, SIGNAL( activated() ), 144 connect(a, SIGNAL( activated() ),
145 this, SLOT( slotFind() ) ); 145 this, SLOT( slotFind() ) );
146 a->addTo( m_options ); 146 a->addTo( m_options );
147 m_findAction = a; 147 m_findAction = a;
148 148
149 m_options->insertSeparator(); 149 m_options->insertSeparator();
150 150
151 m_completedAction = new QAction( QString::null, tr("Completed tasks"), 151 m_completedAction = new QAction( QString::null, tr("Completed tasks"),
152 0, this, 0, TRUE ); 152 0, this, 0, TRUE );
153 m_completedAction->addTo( m_options ); 153 m_completedAction->addTo( m_options );
154 m_completedAction->setOn( showCompleted() ); 154 m_completedAction->setOn( showCompleted() );
155 connect(m_completedAction, SIGNAL( toggled(bool) ), 155 connect(m_completedAction, SIGNAL( toggled(bool) ),
156 this, SLOT(slotShowCompleted(bool) ) ); 156 this, SLOT(slotShowCompleted(bool) ) );
157 157
158 m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), 158 m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"),
159 0, this, 0, TRUE ); 159 0, this, 0, TRUE );
160 m_showDeadLineAction->addTo( m_options ); 160 m_showDeadLineAction->addTo( m_options );
161 m_showDeadLineAction->setOn( showDeadline() ); 161 m_showDeadLineAction->setOn( showDeadline() );
162 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), 162 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ),
163 this, SLOT( slotShowDeadLine( bool ) ) ); 163 this, SLOT( slotShowDeadLine( bool ) ) );
164 164
165 m_options->insertSeparator(); 165 m_options->insertSeparator();
166 166
167 m_bar->insertItem( tr("Data") ,m_edit ); 167 m_bar->insertItem( tr("Data") ,m_edit );
168 m_bar->insertItem( tr("Category"), m_catMenu ); 168 m_bar->insertItem( tr("Category"), m_catMenu );
169 m_bar->insertItem( tr("Options"), m_options ); 169 m_bar->insertItem( tr("Options"), m_options );
170 170
171 /* initialize the view menu */ 171 /* initialize the view menu */
172 a = new QAction( QString::null, tr("Show over due"), 172 a = new QAction( QString::null, tr("Show over due"),
173 0, this, 0, TRUE ); 173 0, this, 0, TRUE );
174 a->addTo( m_view ); 174 a->addTo( m_view );
175 a->setOn( showOverDue() ); 175 a->setOn( showOverDue() );
176 connect(a, SIGNAL(toggled(bool)), 176 connect(a, SIGNAL(toggled(bool)),
177 this, SLOT(slotShowDue(bool) ) ); 177 this, SLOT(slotShowDue(bool) ) );
178 m_view->insertSeparator(); 178 m_view->insertSeparator();
179 179
180 m_bar->insertItem( tr("View"), m_view ); 180 m_bar->insertItem( tr("View"), m_view );
181 181
182 /* templates */ 182 /* templates */
183 m_edit->insertItem(tr("New from template"), m_template, 183 m_edit->insertItem(tr("New from template"), m_template,
184 -1, 0 ); 184 -1, 0 );
185 185
186} 186}
187/* m_curCat from Config */ 187/* m_curCat from Config */
188void MainWindow::initConfig() { 188void MainWindow::initConfig() {
189 Config config( "todo" ); 189 Config config( "todo" );
190 config.setGroup( "View" ); 190 config.setGroup( "View" );
191 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 191 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
192 m_curCat = config.readEntry( "Category", QString::null ); 192 m_curCat = config.readEntry( "Category", QString::null );
193 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 193 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
194 m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); 194 m_overdue = config.readBoolEntry("ShowOverDue", TRUE );
195} 195}
196void MainWindow::initUI() { 196void MainWindow::initUI() {
197 m_stack = new QWidgetStack(this, "main stack"); 197 m_stack = new QWidgetStack(this, "main stack");
198 setCentralWidget( m_stack ); 198 setCentralWidget( m_stack );
199 199
200 setToolBarsMovable( FALSE ); 200 setToolBarsMovable( FALSE );
201 201
202 m_tool = new QToolBar( this ); 202 m_tool = new QToolBar( this );
203 m_tool->setHorizontalStretchable( TRUE ); 203 m_tool->setHorizontalStretchable( TRUE );
204 204
205 m_bar = new QMenuBar( m_tool ); 205 m_bar = new QMenuBar( m_tool );
206 206
207 /** QPopupMenu */ 207 /** QPopupMenu */
208 m_edit = new QPopupMenu( this ); 208 m_edit = new QPopupMenu( this );
209 m_options = new QPopupMenu( this ); 209 m_options = new QPopupMenu( this );
210 m_view = new QPopupMenu( this ); 210 m_view = new QPopupMenu( this );
211 m_catMenu = new QPopupMenu( this ); 211 m_catMenu = new QPopupMenu( this );
212 m_template = new QPopupMenu( this ); 212 m_template = new QPopupMenu( this );
213 213
214 m_catMenu->setCheckable( TRUE ); 214 m_catMenu->setCheckable( TRUE );
215 m_template->setCheckable( TRUE ); 215 m_template->setCheckable( TRUE );
216 216
217 connect(m_catMenu, SIGNAL(activated(int) ), 217 connect(m_catMenu, SIGNAL(activated(int) ),
218 this, SLOT(setCategory(int) ) ); 218 this, SLOT(setCategory(int) ) );
219 connect(m_template, SIGNAL(activated(int) ), 219 connect(m_template, SIGNAL(activated(int) ),
220 this, SLOT(slotNewFromTemplate(int) ) ); 220 this, SLOT(slotNewFromTemplate(int) ) );
221} 221}
222void MainWindow::initViews() { 222void MainWindow::initViews() {
223 TableView* tableView = new TableView( this, this ); 223 TableView* tableView = new TableView( this, this );
224 m_stack->addWidget( tableView, m_counter++ ); 224 m_stack->addWidget( tableView, m_counter++ );
225 m_views.append( tableView ); 225 m_views.append( tableView );
226 m_curView = tableView; 226 m_curView = tableView;
227 connectBase( tableView ); 227 connectBase( tableView );
228 /* add QString type + QString configname to 228 /* add QString type + QString configname to
229 * the View menu 229 * the View menu
230 * and subdirs for multiple views 230 * and subdirs for multiple views
231 */ 231 */
232} 232}
233void MainWindow::initEditor() { 233void MainWindow::initEditor() {
234 m_curEdit = new Editor(); 234 m_curEdit = new Editor();
235} 235}
236void MainWindow::initShow() { 236void MainWindow::initShow() {
237 m_curShow = new TextViewShow(this); 237 m_curShow = new TextViewShow(this);
238 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 238 m_stack->addWidget( m_curShow->widget() , m_counter++ );
239} 239}
240MainWindow::~MainWindow() { 240MainWindow::~MainWindow() {
241 delete templateManager(); 241 delete templateManager();
242} 242}
243void MainWindow::connectBase( ViewBase* base) { 243void MainWindow::connectBase( ViewBase* base) {
244 base->connectShow( this, SLOT(slotShow(int) ) ); 244 base->connectShow( this, SLOT(slotShow(int) ) );
245 base->connectEdit( this, SLOT(slotEdit(int) ) ); 245 base->connectEdit( this, SLOT(slotEdit(int) ) );
246 base->connectUpdateSmall( this, 246 base->connectUpdateSmall( this,
247 SLOT(slotUpate1(int, const Todo::SmallTodo&) )); 247 SLOT(slotUpate1(int, const Todo::SmallTodo&) ));
248 base->connectUpdateBig( this, 248 base->connectUpdateBig( this,
249 SLOT(slotUpate2(int, const OTodo& ) ) ); 249 SLOT(slotUpate2(int, const OTodo& ) ) );
250 base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; 250 base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ;
251 base->connectRemove(&m_todoMgr, 251 base->connectRemove(&m_todoMgr,
252 SLOT(remove(int)) ); 252 SLOT(remove(int)) );
253} 253}
254QPopupMenu* MainWindow::contextMenu( int uid ) { 254QPopupMenu* MainWindow::contextMenu( int uid ) {
255 QPopupMenu* menu = new QPopupMenu(); 255 QPopupMenu* menu = new QPopupMenu();
256 256
257 m_editAction->addTo( menu ); 257 m_editAction->addTo( menu );
258 m_deleteAction->addTo( menu ); 258 m_deleteAction->addTo( menu );
259 m_duplicateAction->addTo( menu ); 259 m_duplicateAction->addTo( menu );
260 menu->insertSeparator(); 260 menu->insertSeparator();
261 261
262 return menu; 262 return menu;
263} 263}
264QPopupMenu* MainWindow::options() { 264QPopupMenu* MainWindow::options() {
265 qWarning("Options"); 265 qWarning("Options");
266 return m_options; 266 return m_options;
267} 267}
268QPopupMenu* MainWindow::edit() { 268QPopupMenu* MainWindow::edit() {
269 return m_edit; 269 return m_edit;
270} 270}
271QPopupMenu* MainWindow::view() { 271QPopupMenu* MainWindow::view() {
272 return m_view; 272 return m_view;
273} 273}
274QToolBar* MainWindow::toolbar() { 274QToolBar* MainWindow::toolbar() {
275 return m_tool; 275 return m_tool;
276} 276}
277OTodoAccess::List MainWindow::list()const { 277OTodoAccess::List MainWindow::list()const {
278 return m_todoMgr.list(); 278 return m_todoMgr.list();
279} 279}
280OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 280OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
281 int cat = 0; 281 int cat = 0;
282 if ( m_curCat != tr("All Categories") ) 282 if ( m_curCat != tr("All Categories") )
283 cat = currentCatId(); 283 cat = currentCatId();
284 284
285 int filter = 1; 285 int filter = 1;
286 286
287 if (!m_completed ) 287 if (!m_completed )
288 filter |= 4; 288 filter |= 4;
289 if (m_overdue) 289 if (m_overdue)
290 filter |= 2; 290 filter |= 2;
291 291
292 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 292 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
293} 293}
294OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 294OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
295 int cat = 0; 295 int cat = 0;
296 if ( m_curCat != tr("All Categories") ) 296 if ( m_curCat != tr("All Categories") )
297 cat = currentCatId(); 297 cat = currentCatId();
298 298
299 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 299 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
300} 300}
301OTodo MainWindow::event( int uid ) { 301OTodo MainWindow::event( int uid ) {
302 return m_todoMgr.event( uid ); 302 return m_todoMgr.event( uid );
303} 303}
304bool MainWindow::isSyncing()const { 304bool MainWindow::isSyncing()const {
305 return m_syncing; 305 return m_syncing;
306} 306}
307TemplateManager* MainWindow::templateManager() { 307TemplateManager* MainWindow::templateManager() {
308 return m_tempManager; 308 return m_tempManager;
309} 309}
310Editor* MainWindow::currentEditor() { 310Editor* MainWindow::currentEditor() {
311 return m_curEdit; 311 return m_curEdit;
312} 312}
313TodoShow* MainWindow::currentShow() { 313TodoShow* MainWindow::currentShow() {
314 return m_curShow; 314 return m_curShow;
315} 315}
316void MainWindow::slotReload() { 316void MainWindow::slotReload() {
317 m_todoMgr.reload(); 317 m_todoMgr.reload();
318 currentView()->updateView( ); 318 currentView()->updateView( );
319 raiseCurrentView(); 319 raiseCurrentView();
320} 320}
321void MainWindow::closeEvent( QCloseEvent* e ) { 321void MainWindow::closeEvent( QCloseEvent* e ) {
322 if (m_stack->visibleWidget() == currentShow()->widget() ) { 322 if (m_stack->visibleWidget() == currentShow()->widget() ) {
323 raiseCurrentView(); 323 raiseCurrentView();
324 e->ignore(); 324 e->ignore();
325 return; 325 return;
326 } 326 }
327 /* 327 /*
328 * we should have flushed and now we're still saving 328 * we should have flushed and now we're still saving
329 * so there is no need to flush 329 * so there is no need to flush
330 */ 330 */
331 if (m_syncing ) { 331 if (m_syncing ) {
332 e->accept(); 332 e->accept();
333 return; 333 return;
334 } 334 }
335 bool quit = false; 335 bool quit = false;
336 if ( m_todoMgr.saveAll() ){ 336 if ( m_todoMgr.saveAll() ){
337 qWarning("saved"); 337 qWarning("saved");
338 quit = true; 338 quit = true;
339 }else { 339 }else {
340 if ( QMessageBox::critical( this, tr("Out of space"), 340 if ( QMessageBox::critical( this, tr("Out of space"),
341 tr("Todo was unable\n" 341 tr("Todo was unable\n"
342 "to save your changes.\n" 342 "to save your changes.\n"
343 "Free up some space\n" 343 "Free up some space\n"
344 "and try again.\n" 344 "and try again.\n"
345 "\nQuit Anyway?"), 345 "\nQuit Anyway?"),
346 QMessageBox::Yes|QMessageBox::Escape, 346 QMessageBox::Yes|QMessageBox::Escape,
347 QMessageBox::No|QMessageBox::Default) 347 QMessageBox::No|QMessageBox::Default)
348 != QMessageBox::No ) { 348 != QMessageBox::No ) {
349 e->accept(); 349 e->accept();
350 quit = true; 350 quit = true;
351 }else 351 }else
352 e->ignore(); 352 e->ignore();
353 353
354 } 354 }
355 355
356 if (quit ) { 356 if (quit ) {
357 Config config( "todo" ); 357 Config config( "todo" );
358 config.setGroup( "View" ); 358 config.setGroup( "View" );
359 config.writeEntry( "ShowComplete", showCompleted() ); 359 config.writeEntry( "ShowComplete", showCompleted() );
360 config.writeEntry( "Category", currentCategory() ); 360 config.writeEntry( "Category", currentCategory() );
361 config.writeEntry( "ShowDeadLine", showDeadline()); 361 config.writeEntry( "ShowDeadLine", showDeadline());
362 config.writeEntry( "ShowOverDue", showOverDue() ); 362 config.writeEntry( "ShowOverDue", showOverDue() );
363 /* svae templates */ 363 /* svae templates */
364 templateManager()->save(); 364 templateManager()->save();
365 e->accept(); 365 e->accept();
366 } 366 }
367} 367}
368void MainWindow::populateTemplates() { 368void MainWindow::populateTemplates() {
369 m_template->clear(); 369 m_template->clear();
370 QStringList list = templateManager()->templates(); 370 QStringList list = templateManager()->templates();
371 QStringList::Iterator it; 371 QStringList::Iterator it;
372 for ( it = list.begin(); it != list.end(); ++it ) { 372 for ( it = list.begin(); it != list.end(); ++it ) {
373 m_template->insertItem( (*it) ); 373 m_template->insertItem( (*it) );
374 } 374 }
375} 375}
376/* 376/*
377 * slotNewFromTemplate 377 * slotNewFromTemplate
378 * We use the edit widget to do 378 * We use the edit widget to do
379 * the config but we setUid(-1) 379 * the config but we setUid(-1)
380 * to get a new uid 380 * to get a new uid
381 */ 381 */
382/* 382/*
383 * first we get the name of the template 383 * first we get the name of the template
384 * then we will use the TemplateManager 384 * then we will use the TemplateManager
385 */ 385 */
386void MainWindow::slotNewFromTemplate( int id ) { 386void MainWindow::slotNewFromTemplate( int id ) {
387 QString name = m_template->text( id ); 387 QString name = m_template->text( id );
388 388
389 OTodo event = templateManager()->templateEvent( name ); 389 OTodo event = templateManager()->templateEvent( name );
390 event = currentEditor()->edit(this, 390 event = currentEditor()->edit(this,
391 event ); 391 event );
392 392
393 if ( currentEditor()->accepted() ) { 393 if ( currentEditor()->accepted() ) {
394 /* assign new todo */ 394 /* assign new todo */
395 event.setUid( -1 ); 395 event.setUid( -1 );
396 currentView()->addEvent( event ); 396 currentView()->addEvent( event );
397 m_todoMgr.add( event ); 397 m_todoMgr.add( event );
398 398
399 populateCategories(); 399 populateCategories();
400 } 400 }
401} 401}
402void MainWindow::slotNew() { 402void MainWindow::slotNew() {
403 if(m_syncing) { 403 if(m_syncing) {
404 QMessageBox::warning(this, tr("Todo"), 404 QMessageBox::warning(this, tr("Todo"),
405 tr("Can not edit data, currently syncing")); 405 tr("Can not edit data, currently syncing"));
406 return; 406 return;
407 } 407 }
408 408
409 409
410 OTodo todo = currentEditor()->newTodo( currentCatId(), 410 OTodo todo = currentEditor()->newTodo( currentCatId(),
411 this ); 411 this );
412 412
413 if ( currentEditor()->accepted() ) { 413 if ( currentEditor()->accepted() ) {
414 //todo.assignUid(); 414 //todo.assignUid();
415 currentView()->addEvent( todo ); 415 currentView()->addEvent( todo );
416 m_todoMgr.add( todo ); 416 m_todoMgr.add( todo );
417 417
418 // I'm afraid we must call this every time now, otherwise 418 // I'm afraid we must call this every time now, otherwise
419 // spend expensive time comparing all these strings... 419 // spend expensive time comparing all these strings...
420 // but only call if we changed something -zecke 420 // but only call if we changed something -zecke
421 populateCategories(); 421 populateCategories();
422 } 422 }
423
424 raiseCurrentView( ); 423 raiseCurrentView( );
425} 424}
426void MainWindow::slotDuplicate() { 425void MainWindow::slotDuplicate() {
427 if(m_syncing) { 426 if(m_syncing) {
428 QMessageBox::warning(this, tr("Todo"), 427 QMessageBox::warning(this, tr("Todo"),
429 tr("Can not edit data, currently syncing")); 428 tr("Can not edit data, currently syncing"));
430 return; 429 return;
431 } 430 }
432 OTodo ev = m_todoMgr.event( currentView()->current() ); 431 OTodo ev = m_todoMgr.event( currentView()->current() );
433 /* let's generate a new uid */ 432 /* let's generate a new uid */
434 ev.setUid(-1); 433 ev.setUid(-1);
435 m_todoMgr.add( ev ); 434 m_todoMgr.add( ev );
436 435
437 currentView()->addEvent( ev ); 436 currentView()->addEvent( ev );
438 raiseCurrentView(); 437 raiseCurrentView();
439} 438}
440void MainWindow::slotDelete() { 439void MainWindow::slotDelete() {
441 if (!currentView()->current() ) 440 if (!currentView()->current() )
442 return; 441 return;
443 442
444 if(m_syncing) { 443 if(m_syncing) {
445 QMessageBox::warning(this, tr("Todo"), 444 QMessageBox::warning(this, tr("Todo"),
446 tr("Can not edit data, currently syncing")); 445 tr("Can not edit data, currently syncing"));
447 return; 446 return;
448 } 447 }
449 QString strName = currentView()->currentRepresentation(); 448 QString strName = currentView()->currentRepresentation();
450 if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) 449 if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) )
451 return; 450 return;
452 451
453 m_todoMgr.remove( currentView()->current() ); 452 m_todoMgr.remove( currentView()->current() );
454 currentView()->removeEvent( currentView()->current() ); 453 currentView()->removeEvent( currentView()->current() );
455 raiseCurrentView(); 454 raiseCurrentView();
456} 455}
457void MainWindow::slotDeleteAll() { 456void MainWindow::slotDeleteAll() {
458 if(m_syncing) { 457 if(m_syncing) {
459 QMessageBox::warning(this, tr("Todo"), 458 QMessageBox::warning(this, tr("Todo"),
460 tr("Can not edit data, currently syncing")); 459 tr("Can not edit data, currently syncing"));
461 return; 460 return;
462 } 461 }
463 462
464 //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); 463 //QString strName = table->text( table->currentRow(), 2 ).left( 30 );
465 464
466 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) 465 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) )
467 return; 466 return;
468 467
469 m_todoMgr.removeAll(); 468 m_todoMgr.removeAll();
470 currentView()->clear(); 469 currentView()->clear();
471 470
472 raiseCurrentView(); 471 raiseCurrentView();
473} 472}
474void MainWindow::slotDeleteCompleted() { 473void MainWindow::slotDeleteCompleted() {
475 if(m_syncing) { 474 if(m_syncing) {
476 QMessageBox::warning(this, tr("Todo"), 475 QMessageBox::warning(this, tr("Todo"),
477 tr("Can not edit data, currently syncing")); 476 tr("Can not edit data, currently syncing"));
478 return; 477 return;
479 } 478 }
480 479
481 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) 480 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) )
482 return; 481 return;
483 482
484 // FIXME 483 // FIXME
485 //m_todoMgr.remove( currentView()->completed() ); 484 //m_todoMgr.remove( currentView()->completed() );
486 currentView()->updateView( ); 485 currentView()->updateView( );
487} 486}
488void MainWindow::slotFind() { 487void MainWindow::slotFind() {
489 488
490} 489}
491void MainWindow::slotEdit() { 490void MainWindow::slotEdit() {
492 slotEdit( currentView()->current() ); 491 slotEdit( currentView()->current() );
493} 492}
494/* 493/*
495 * set the category 494 * set the category
496 */ 495 */
497void MainWindow::setCategory( int c) { 496void MainWindow::setCategory( int c) {
498 if ( c <= 0 ) return; 497 if ( c <= 0 ) return;
499 498
499
500 qWarning("Iterating over cats %d", c ); 500 qWarning("Iterating over cats %d", c );
501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
502 m_catMenu->setItemChecked(i, c == (int)i ); 502 m_catMenu->setItemChecked(i, c == (int)i );
503 503
504 if (c == 1 ) { 504 if (c == 1 ) {
505 m_curCat = QString::null; 505 m_curCat = QString::null;
506 setCaption( tr("Todo") + " - " + tr("All Categories" ) ); 506 setCaption( tr("Todo") + " - " + tr("All Categories" ) );
507 507
508 }else if ( c == (int)m_catMenu->count() - 1 ) { 508 }else if ( c == (int)m_catMenu->count() - 1 ) {
509 m_curCat = tr("Unfiled"); 509 m_curCat = tr("Unfiled");
510 setCaption( tr("Todo") + " - " + tr("Unfiled") ); 510 setCaption( tr("Todo") + " - " + tr("Unfiled") );
511 }else { 511 }else {
512 m_curCat = m_todoMgr.categories()[c-2]; 512 m_curCat = m_todoMgr.categories()[c-2];
513 setCaption( tr("Todo") + " - " + m_curCat ); 513 setCaption( tr("Todo") + " - " + m_curCat );
514 } 514 }
515 m_catMenu->setItemChecked( c, true ); 515 m_catMenu->setItemChecked( c, true );
516
516 currentView()->setShowCategory( m_curCat ); 517 currentView()->setShowCategory( m_curCat );
517 raiseCurrentView(); 518 raiseCurrentView();
518} 519}
519void MainWindow::slotShowDeadLine( bool dead) { 520void MainWindow::slotShowDeadLine( bool dead) {
520 m_deadline = dead; 521 m_deadline = dead;
521 currentView()->setShowDeadline( dead ); 522 currentView()->setShowDeadline( dead );
522} 523}
523void MainWindow::slotShowCompleted( bool show) { 524void MainWindow::slotShowCompleted( bool show) {
524 m_completed = show; 525 m_completed = show;
525 currentView()->setShowCompleted( m_completed ); 526 currentView()->setShowCompleted( m_completed );
526} 527}
527bool MainWindow::showOverDue()const { 528bool MainWindow::showOverDue()const {
528 return m_overdue; 529 return m_overdue;
529} 530}
530void MainWindow::setDocument( const QString& ) { 531void MainWindow::setDocument( const QString& ) {
531 532
532} 533}
533void MainWindow::slotBeam() { 534void MainWindow::slotBeam() {
534 535
535} 536}
536void MainWindow::beamDone( Ir* ) { 537void MainWindow::beamDone( Ir* ) {
537 538
538} 539}
539 540
540void MainWindow::slotFlush() { 541void MainWindow::slotFlush() {
541 m_syncing = FALSE; 542 m_syncing = FALSE;
542 m_todoMgr.save(); 543 m_todoMgr.save();
543} 544}
544void MainWindow::slotShowDetails() { 545void MainWindow::slotShowDetails() {
545 slotShow( currentView()->current() ); 546 slotShow( currentView()->current() );
546} 547}
547/* 548/*
548 * populate the Categories 549 * populate the Categories
549 * Menu 550 * Menu
550 */ 551 */
551void MainWindow::populateCategories() { 552void MainWindow::populateCategories() {
552 if (m_todoMgr.isLoaded() ) 553 m_todoMgr.load();
553 m_todoMgr.load();
554 554
555 m_catMenu->clear(); 555 m_catMenu->clear();
556 int id, rememberId; 556 int id, rememberId;
557 id = 1; 557 id = 1;
558 rememberId = 1; 558 rememberId = 1;
559 559
560 m_catMenu->insertItem( tr( "All Categories" ), id++ ); 560 m_catMenu->insertItem( tr( "All Categories" ), id++ );
561 m_catMenu->insertSeparator(); 561 m_catMenu->insertSeparator();
562 QStringList categories = m_todoMgr.categories(); 562 QStringList categories = m_todoMgr.categories();
563 categories.append( tr( "Unfiled" ) ); 563 categories.append( tr( "Unfiled" ) );
564 for ( QStringList::Iterator it = categories.begin(); 564 for ( QStringList::Iterator it = categories.begin();
565 it != categories.end(); ++it ) { 565 it != categories.end(); ++it ) {
566 m_catMenu->insertItem( *it, id ); 566 m_catMenu->insertItem( *it, id );
567 if ( *it == currentCategory() ) 567 if ( *it == currentCategory() )
568 rememberId = id; 568 rememberId = id;
569 ++id; 569 ++id;
570 } 570 }
571 setCategory( rememberId ); 571 setCategory( rememberId );
572} 572}
573bool MainWindow::showCompleted()const { 573bool MainWindow::showCompleted()const {
574 return m_completed; 574 return m_completed;
575} 575}
576bool MainWindow::showDeadline()const { 576bool MainWindow::showDeadline()const {
577 return m_deadline; 577 return m_deadline;
578} 578}
579QString MainWindow::currentCategory()const { 579QString MainWindow::currentCategory()const {
580 return m_curCat; 580 return m_curCat;
581} 581}
582int MainWindow::currentCatId() { 582int MainWindow::currentCatId() {
583 return m_todoMgr.catId( m_curCat ); 583 return m_todoMgr.catId( m_curCat );
584} 584}
585ViewBase* MainWindow::currentView() { 585ViewBase* MainWindow::currentView() {
586 return m_curView; 586 return m_curView;
587} 587}
588void MainWindow::raiseCurrentView() { 588void MainWindow::raiseCurrentView() {
589 m_stack->raiseWidget( m_curView->widget() ); 589 m_stack->raiseWidget( m_curView->widget() );
590} 590}
591void MainWindow::slotShowDue(bool ov) { 591void MainWindow::slotShowDue(bool ov) {
592 m_overdue = ov; 592 m_overdue = ov;
593 currentView()->showOverDue( ov ); 593 currentView()->showOverDue( ov );
594 raiseCurrentView(); 594 raiseCurrentView();
595} 595}
596void MainWindow::slotShow( int uid ) { 596void MainWindow::slotShow( int uid ) {
597 qWarning("slotShow"); 597 qWarning("slotShow");
598 currentShow()->slotShow( event( uid ) ); 598 currentShow()->slotShow( event( uid ) );
599 m_stack->raiseWidget( currentShow()->widget() ); 599 m_stack->raiseWidget( currentShow()->widget() );
600} 600}
601void MainWindow::slotEdit( int uid ) { 601void MainWindow::slotEdit( int uid ) {
602 if(m_syncing) { 602 if(m_syncing) {
603 QMessageBox::warning(this, tr("Todo"), 603 QMessageBox::warning(this, tr("Todo"),
604 tr("Can not edit data, currently syncing")); 604 tr("Can not edit data, currently syncing"));
605 return; 605 return;
606 } 606 }
607 607
608 OTodo todo = m_todoMgr.event( uid ); 608 OTodo todo = m_todoMgr.event( uid );
609 609
610 todo = currentEditor()->edit(this, todo ); 610 todo = currentEditor()->edit(this, todo );
611 611
612 /* if completed */ 612 /* if completed */
613 if ( currentEditor()->accepted() ) { 613 if ( currentEditor()->accepted() ) {
614 qWarning("Replacing now" ); 614 qWarning("Replacing now" );
615 m_todoMgr.update( todo.uid(), todo ); 615 m_todoMgr.update( todo.uid(), todo );
616 currentView()->replaceEvent( todo ); 616 currentView()->replaceEvent( todo );
617 /* a Category might have changed */
617 populateCategories(); 618 populateCategories();
618 } 619 }
619 620
620 raiseCurrentView(); 621 raiseCurrentView();
621} 622}
622/* 623/*
623void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 624void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
624 m_todoMgr.update( uid, ev ); 625 m_todoMgr.update( uid, ev );
625} 626}
626*/ 627*/
627void MainWindow::updateTodo( const OTodo& ev) { 628void MainWindow::updateTodo( const OTodo& ev) {
628 m_todoMgr.update( ev.uid() , ev ); 629 m_todoMgr.update( ev.uid() , ev );
629} 630}
630/* The view changed it's configuration 631/* The view changed it's configuration
631 * update the view menu 632 * update the view menu
632 */ 633 */
633void MainWindow::slotUpdate3( QWidget* ) { 634void MainWindow::slotUpdate3( QWidget* ) {
634 635
635} 636}
636void MainWindow::updateList() { 637void MainWindow::updateList() {
637 m_todoMgr.updateList(); 638 m_todoMgr.updateList();
638} 639}
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index 5594b13..5d82eb2 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -1,359 +1,400 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include <qtimer.h> 29#include <qtimer.h>
30#include <qpoint.h> 30#include <qpoint.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32 32
33#include "mainwindow.h" 33#include "mainwindow.h"
34//#include "tableitems.h" 34//#include "tableitems.h"
35#include "tableview.h" 35#include "tableview.h"
36 36
37using namespace Todo; 37using namespace Todo;
38 38
39namespace { 39namespace {
40 static const int BoxSize = 14; 40 static const int BoxSize = 14;
41 static const int RowHeight = 20; 41 static const int RowHeight = 20;
42} 42}
43 43
44 44
45TableView::TableView( MainWindow* window, QWidget* wid ) 45TableView::TableView( MainWindow* window, QWidget* wid )
46 : QTable( wid ), TodoView( window ) { 46 : QTable( wid ), TodoView( window ) {
47 setUpdatesEnabled( false ); 47 setUpdatesEnabled( false );
48 viewport()->setUpdatesEnabled( false ); 48 viewport()->setUpdatesEnabled( false );
49 m_enablePaint = false; 49 m_enablePaint = false;
50 setNumRows(0); 50 setNumRows(0);
51 setNumCols(4); 51 setNumCols(4);
52 52
53 setSorting( TRUE ); 53 setSorting( TRUE );
54 setSelectionMode( NoSelection ); 54 setSelectionMode( NoSelection );
55 setColumnStretchable( 2, TRUE ); 55 setColumnStretchable( 2, TRUE );
56 setColumnWidth(0, 20 ); 56 setColumnWidth(0, 20 );
57 setColumnWidth(1, 35 ); 57 setColumnWidth(1, 35 );
58 58
59 setLeftMargin( 0 ); 59 setLeftMargin( 0 );
60 verticalHeader()->hide(); 60 verticalHeader()->hide();
61 61
62 horizontalHeader()->setLabel(0, tr("C.") ); 62 horizontalHeader()->setLabel(0, tr("C.") );
63 horizontalHeader()->setLabel(1, tr("Prior.") ); 63 horizontalHeader()->setLabel(1, tr("Prior.") );
64 horizontalHeader()->setLabel(2, tr("Description" ) ); 64 horizontalHeader()->setLabel(2, tr("Description" ) );
65 65
66 setColumnStretchable(3, FALSE ); 66 setColumnStretchable(3, FALSE );
67 setColumnWidth(3, 20 ); 67 setColumnWidth(3, 20 );
68 horizontalHeader()->setLabel(3, tr("Deadline") ); 68 horizontalHeader()->setLabel(3, tr("Deadline") );
69 69
70 if ( todoWindow()->showDeadline() ) 70 if ( todoWindow()->showDeadline() )
71 showColumn( 3); 71 showColumn( 3);
72 else 72 else
73 hideColumn(3 ); 73 hideColumn(3 );
74 74
75 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), 75 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ),
76 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); 76 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) );
77 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), 77 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ),
78 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); 78 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) );
79 connect((QTable*)this, SIGNAL(valueChanged(int, int) ), 79 connect((QTable*)this, SIGNAL(valueChanged(int, int) ),
80 this, SLOT( slotValueChanged(int, int) ) ); 80 this, SLOT( slotValueChanged(int, int) ) );
81 connect((QTable*)this, SIGNAL(currentChanged(int, int) ), 81 connect((QTable*)this, SIGNAL(currentChanged(int, int) ),
82 this, SLOT( slotCurrentChanged(int, int) ) ); 82 this, SLOT( slotCurrentChanged(int, int) ) );
83 83
84 m_menuTimer = new QTimer( this ); 84 m_menuTimer = new QTimer( this );
85 connect( m_menuTimer, SIGNAL(timeout()), 85 connect( m_menuTimer, SIGNAL(timeout()),
86 this, SLOT(slotShowMenu()) ); 86 this, SLOT(slotShowMenu()) );
87 87
88 m_enablePaint = true; 88 m_enablePaint = true;
89 setUpdatesEnabled( true ); 89 setUpdatesEnabled( true );
90 viewport()->setUpdatesEnabled( true ); 90 viewport()->setUpdatesEnabled( true );
91 viewport()->update(); 91 viewport()->update();
92 setSortOrder( 0 );
93 setAscending( TRUE );
94 m_first = true;
92} 95}
93/* a new day has started 96/* a new day has started
94 * update the day 97 * update the day
95 */ 98 */
96void TableView::newDay() { 99void TableView::newDay() {
97 clear(); 100 clear();
98 updateView(); 101 updateView();
99} 102}
100TableView::~TableView() { 103TableView::~TableView() {
101 104
102} 105}
103void TableView::slotShowMenu() { 106void TableView::slotShowMenu() {
104 QPopupMenu *menu = todoWindow()->contextMenu( current() ); 107 QPopupMenu *menu = todoWindow()->contextMenu( current() );
105 menu->exec(QCursor::pos() ); 108 menu->exec(QCursor::pos() );
106 delete menu; 109 delete menu;
107} 110}
108QString TableView::type() const { 111QString TableView::type() const {
109 return QString::fromLatin1( tr("Table View") ); 112 return QString::fromLatin1( tr("Table View") );
110} 113}
111int TableView::current() { 114int TableView::current() {
112 int cur = 0; 115 int uid = sorted().uidAt(currentRow() );
113 // FIXME 116 qWarning("uid %d", uid );
114 return cur; 117 return uid;
115} 118}
116QString TableView::currentRepresentation() { 119QString TableView::currentRepresentation() {
117 return text( currentRow(), 2); 120 return text( currentRow(), 2);
118} 121}
119/* show overdue */ 122/* show overdue */
120void TableView::showOverDue( bool ) { 123void TableView::showOverDue( bool ) {
121 clear(); 124 clear();
122 updateView(); 125 updateView();
123} 126}
124 127
125void TableView::updateView( ) { 128void TableView::updateView( ) {
126 setSortOrder( 0 );
127 setAscending( true );
128 sort(); 129 sort();
129 OTodoAccess::List::Iterator it, end; 130 OTodoAccess::List::Iterator it, end;
130 it = sorted().begin(); 131 it = sorted().begin();
131 end = sorted().end(); 132 end = sorted().end();
132 133
133 qWarning("setTodos"); 134 qWarning("setTodos");
134 QTime time; 135 QTime time;
135 time.start(); 136 time.start();
136 m_enablePaint = false; 137 m_enablePaint = false;
137 setUpdatesEnabled( false ); 138 setUpdatesEnabled( false );
138 viewport()->setUpdatesEnabled( false ); 139 viewport()->setUpdatesEnabled( false );
139 140
140 QTime t; 141 QTime t;
141 t.start(); 142 t.start();
142 setNumRows( it.count() ); 143 setNumRows( it.count() );
143 int elc = time.elapsed(); 144 int elc = time.elapsed();
144 qWarning("Adding took %d", elc/1000 ); 145 qWarning("Adding took %d", elc/1000 );
145 setUpdatesEnabled( true ); 146 setUpdatesEnabled( true );
146 viewport()->setUpdatesEnabled( true ); 147 viewport()->setUpdatesEnabled( true );
147 viewport()->update(); 148 viewport()->update();
148 149
149 m_enablePaint = true; 150 m_enablePaint = true;
150 int el = time.elapsed(); 151 int el = time.elapsed();
151 qWarning("adding took %d", el/1000 ); 152 qWarning("adding took %d", el/1000 );
152} 153}
153void TableView::setTodo( int, const OTodo&) { 154void TableView::setTodo( int, const OTodo&) {
154 sort(); 155 sort();
155 156
156 /* repaint */ 157 /* repaint */
157 QTable::update(); 158 QTable::update();
158} 159}
159void TableView::addEvent( const OTodo&) { 160void TableView::addEvent( const OTodo&) {
160 sort(); 161 sort();
161 162
162 QTable::update(); 163 QTable::update();
163} 164}
164/* 165/*
165 * find the event 166 * find the event
166 * and then replace the complete row 167 * and then replace the complete row
167 */ 168 */
168void TableView::replaceEvent( const OTodo& ev) { 169void TableView::replaceEvent( const OTodo& ev) {
169 addEvent( ev ); 170 addEvent( ev );
170} 171}
171/* 172/*
172 * re aligning table can be slow too 173 * re aligning table can be slow too
173 * FIXME: look what performs better 174 * FIXME: look what performs better
174 * either this or the old align table 175 * either this or the old align table
175 */ 176 */
176void TableView::removeEvent( int ) { 177void TableView::removeEvent( int ) {
177 updateView(); 178 updateView();
178} 179}
179void TableView::setShowCompleted( bool b) { 180void TableView::setShowCompleted( bool b) {
180 qWarning("Show Completed %d" + b ); 181 qWarning("Show Completed %d" + b );
181 updateView(); 182 updateView();
182} 183}
183void TableView::setShowDeadline( bool b) { 184void TableView::setShowDeadline( bool b) {
184 qWarning("Show DeadLine %d" + b ); 185 qWarning("Show DeadLine %d" + b );
185 if (b) 186 if (b)
186 showColumn(3 ); 187 showColumn(3 );
187 else 188 else
188 hideColumn(3 ); 189 hideColumn(3 );
189} 190}
190void TableView::setShowCategory( const QString& ) { 191void TableView::setShowCategory( const QString& str) {
191 qWarning("setShowCategory"); 192 qWarning("setShowCategory");
192 updateView(); 193 if ( str != m_oleCat || m_first )
194 updateView();
195
196 m_oleCat = str;
197 m_first = false;
198
193} 199}
194void TableView::clear() { 200void TableView::clear() {
195 setNumRows(0); 201 setNumRows(0);
196} 202}
197void TableView::slotClicked(int row, int col, int, 203void TableView::slotClicked(int row, int col, int,
198 const QPoint& point) { 204 const QPoint& point) {
199 if ( !cellGeometry(row, col ).contains(point ) ) 205 if ( !cellGeometry(row, col ).contains(point ) )
200 return; 206 return;
201 int ui=0; // FIXME = uid(row); 207
208 int ui= sorted().uidAt( row );
202 209
203 210
204 switch( col ) { 211 switch( col ) {
205 case 0: { 212 case 0:{
206 // FIXME 213 int x = point.x() -columnPos( col );
207 CheckItem* item = 0l; 214 int y = point.y() -rowPos( row );
208 /* 215 int w = columnWidth( col );
209 * let's see if we centered clicked 216 int h = rowHeight( row );
210 */ 217 if ( x >= ( w - BoxSize ) / 2 &&
211 if ( item ) { 218 x <= ( w - BoxSize ) / 2 + BoxSize &&
212 int x = point.x() -columnPos( col ); 219 y >= ( h - BoxSize ) / 2 &&
213 int y = point.y() -rowPos( row ); 220 y <= ( h - BoxSize ) / 2 + BoxSize ) {
214 int w = columnWidth( col ); 221 OTodo todo = sorted()[row];
215 int h = rowHeight( row ); 222 todo.setCompleted( !todo.isCompleted() );
216 if ( x >= ( w - OCheckItem::BoxSize ) / 2 && 223 TodoView::update( todo.uid(), todo );
217 x <= ( w - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize && 224 updateView();
218 y >= ( h - OCheckItem::BoxSize ) / 2 && 225 }
219 y <= ( h - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize )
220 item->toggle();
221 }
222 } 226 }
223 break; 227 break;
224 228
225 case 1: 229 case 1:
226 break; 230 break;
227 231
228 case 2: { 232 case 2: {
229 m_menuTimer->stop(); 233 m_menuTimer->stop();
230 showTodo( ui ); 234 showTodo( ui );
231 break; 235 break;
232 } 236 }
233 case 3: { 237 case 3: {
234 m_menuTimer->stop(); 238 m_menuTimer->stop();
235 TodoView::edit( ui ); 239 TodoView::edit( ui );
236 break; 240 break;
237 } 241 }
238 } 242 }
239 243
240 244
241} 245}
242void TableView::slotPressed(int row, int col, int, 246void TableView::slotPressed(int row, int col, int,
243 const QPoint& point) { 247 const QPoint& point) {
244 248
245 /* TextColumn column */ 249 /* TextColumn column */
246 if ( col == 2 && cellGeometry( row, col ).contains( point ) ) 250 if ( col == 2 && cellGeometry( row, col ).contains( point ) )
247 m_menuTimer->start( 750, TRUE ); 251 m_menuTimer->start( 750, TRUE );
248} 252}
249void TableView::slotValueChanged( int, int ) { 253void TableView::slotValueChanged( int, int ) {
250 qWarning("Value Changed"); 254 qWarning("Value Changed");
251} 255}
252void TableView::slotCurrentChanged(int, int ) { 256void TableView::slotCurrentChanged(int, int ) {
253 m_menuTimer->stop(); 257 m_menuTimer->stop();
254} 258}
255QWidget* TableView::widget() { 259QWidget* TableView::widget() {
256 return this; 260 return this;
257} 261}
258/* 262/*
259 * We need to overwrite sortColumn 263 * We need to overwrite sortColumn
260 * because we want to sort whole row 264 * because we want to sort whole row
261 * based 265 * based
262 * We event want to set the setOrder 266 * We event want to set the setOrder
263 * to a sort() and update() 267 * to a sort() and update()
264 */ 268 */
265void TableView::sortColumn( int row, bool asc, bool ) { 269void TableView::sortColumn( int col, bool asc, bool ) {
266 QTable::sortColumn( row, asc, TRUE ); 270 qWarning("bool %d", asc );
267 271 setSortOrder( col );
272 setAscending( asc );
273 updateView();
268} 274}
269void TableView::viewportPaintEvent( QPaintEvent* e) { 275void TableView::viewportPaintEvent( QPaintEvent* e) {
270 qWarning("Paint event" ); 276 qWarning("Paint event" );
271 if (m_enablePaint ) 277 if (m_enablePaint )
272 QTable::viewportPaintEvent( e ); 278 QTable::viewportPaintEvent( e );
273} 279}
274/* 280/*
275 * This segment is copyrighted by TT 281 * This segment is copyrighted by TT
276 * it was taken from their todolist 282 * it was taken from their todolist
277 * application this code is GPL 283 * application this code is GPL
278 */ 284 */
279void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { 285void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
280 const QColorGroup &cg = colorGroup(); 286 const QColorGroup &cg = colorGroup();
281 287
282 p->save(); 288 p->save();
283 289
284 OTodo task = sorted()[row]; 290 OTodo task = sorted()[row];
285 291
286 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 292 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
287 293
288 QPen op = p->pen(); 294 QPen op = p->pen();
289 p->setPen(cg.mid()); 295 p->setPen(cg.mid());
290 p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); 296 p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 );
291 p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); 297 p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 );
292 p->setPen(op); 298 p->setPen(op);
293 299
294 QFont f = p->font(); 300 QFont f = p->font();
295 QFontMetrics fm(f); 301 QFontMetrics fm(f);
296 302
297 switch(col) { 303 switch(col) {
298 case 0: 304 case 0:
299 { 305 {
300 // completed field 306 // completed field
301 int marg = ( cr.width() - BoxSize ) / 2; 307 int marg = ( cr.width() - BoxSize ) / 2;
302 int x = 0; 308 int x = 0;
303 int y = ( cr.height() - BoxSize ) / 2; 309 int y = ( cr.height() - BoxSize ) / 2;
304 p->setPen( QPen( cg.text() ) ); 310 p->setPen( QPen( cg.text() ) );
305 p->drawRect( x + marg, y, BoxSize, BoxSize ); 311 p->drawRect( x + marg, y, BoxSize, BoxSize );
306 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); 312 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
307 p->setPen( darkGreen ); 313 p->setPen( darkGreen );
308 x += 1; 314 x += 1;
309 y += 1; 315 y += 1;
310 if ( task.isCompleted() ) { 316 if ( task.isCompleted() ) {
311 QPointArray a( 9*2 ); 317 QPointArray a( 9*2 );
312 int i, xx, yy; 318 int i, xx, yy;
313 xx = x+2+marg; 319 xx = x+2+marg;
314 yy = y+4; 320 yy = y+4;
315 for ( i=0; i<4; i++ ) { 321 for ( i=0; i<4; i++ ) {
316 a.setPoint( 2*i, xx, yy ); 322 a.setPoint( 2*i, xx, yy );
317 a.setPoint( 2*i+1, xx, yy+2 ); 323 a.setPoint( 2*i+1, xx, yy+2 );
318 xx++; yy++; 324 xx++; yy++;
319 } 325 }
320 yy -= 2; 326 yy -= 2;
321 for ( i=4; i<9; i++ ) { 327 for ( i=4; i<9; i++ ) {
322 a.setPoint( 2*i, xx, yy ); 328 a.setPoint( 2*i, xx, yy );
323 a.setPoint( 2*i+1, xx, yy+2 ); 329 a.setPoint( 2*i+1, xx, yy+2 );
324 xx++; yy--; 330 xx++; yy--;
325 } 331 }
326 p->drawLineSegments( a ); 332 p->drawLineSegments( a );
327 } 333 }
328 } 334 }
329 break; 335 break;
330 case 1: 336 case 1:
331 // priority field 337 // priority field
332 { 338 {
333 QString text = QString::number(task.priority()); 339 QString text = QString::number(task.priority());
334 p->drawText(2,2 + fm.ascent(), text); 340 p->drawText(2,2 + fm.ascent(), text);
335 } 341 }
336 break; 342 break;
337 case 2: 343 case 2:
338 // description field 344 // description field
339 { 345 {
340 QString text = task.summary().isEmpty() ? 346 QString text = task.summary().isEmpty() ?
341 task.description() : 347 task.description() :
342 task.summary(); 348 task.summary();
343 p->drawText(2,2 + fm.ascent(), text); 349 p->drawText(2,2 + fm.ascent(), text);
344 } 350 }
345 break; 351 break;
346 case 3: 352 case 3:
347 { 353 {
348 QString text; 354 QString text;
349 if (task.hasDueDate()) { 355 if (task.hasDueDate()) {
350 text = "HAS"; 356 text = "HAS";
351 } else { 357 } else {
352 text = tr("None"); 358 text = tr("None");
353 } 359 }
354 p->drawText(2,2 + fm.ascent(), text); 360 p->drawText(2,2 + fm.ascent(), text);
355 } 361 }
356 break; 362 break;
357 } 363 }
358 p->restore(); 364 p->restore();
359} 365}
366QWidget* TableView::createEditor(int row, int col, bool )const {
367 switch( col ) {
368 case 1: {
369 /* the priority stuff */
370 QComboBox* combo = new QComboBox( viewport() );
371 combo->insertItem( "1" );
372 combo->insertItem( "2" );
373 combo->insertItem( "3" );
374 combo->insertItem( "4" );
375 combo->insertItem( "5" );
376 combo->setCurrentItem( sorted()[row].priority()-1 );
377 return combo;
378 }
379 case 0:
380 default:
381 return 0l;
382 }
383}
384void TableView::setCellContentFromEditor(int row, int col ) {
385 if ( col == 1 ) {
386 QWidget* wid = cellWidget(row, 1 );
387 if ( wid->inherits("QComboBox") ) {
388 int pri = ((QComboBox*)wid)->currentItem() + 1;
389 OTodo todo = sorted()[row];
390 if ( todo.priority() != pri ) {
391 todo.setPriority( pri );
392 TodoView::update( todo.uid(), todo );
393 updateView();
394 }
395 }
396 }
397}
398void TableView::slotPriority() {
399 setCellContentFromEditor( currentRow(), currentColumn() );
400}
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h
index b608204..bf41aea 100644
--- a/core/pim/todo/tableview.h
+++ b/core/pim/todo/tableview.h
@@ -1,93 +1,100 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef OPIE_TABLE_VIEW_H 29#ifndef OPIE_TABLE_VIEW_H
30#define OPIE_TABLE_VIEW_H 30#define OPIE_TABLE_VIEW_H
31 31
32#include <qtable.h> 32#include <qtable.h>
33#include <qmap.h> 33#include <qmap.h>
34 34
35#include "tableitems.h" 35#include "tableitems.h"
36#include "todoview.h" 36#include "todoview.h"
37 37
38class QTimer; 38class QTimer;
39 39
40namespace Todo { 40namespace Todo {
41 class CheckItem; 41 class CheckItem;
42 class DueTextItem; 42 class DueTextItem;
43 class TableView : public QTable, public TodoView { 43 class TableView : public QTable, public TodoView {
44 Q_OBJECT 44 Q_OBJECT
45 public: 45 public:
46 TableView( MainWindow*, QWidget* parent ); 46 TableView( MainWindow*, QWidget* parent );
47 ~TableView(); 47 ~TableView();
48 48
49 49
50 QString type()const; 50 QString type()const;
51 int current(); 51 int current();
52 QString currentRepresentation(); 52 QString currentRepresentation();
53 53
54 void clear(); 54 void clear();
55 void showOverDue( bool ); 55 void showOverDue( bool );
56 void updateView(); 56 void updateView();
57 void setTodo( int uid, const OTodo& ); 57 void setTodo( int uid, const OTodo& );
58 void addEvent( const OTodo& event ); 58 void addEvent( const OTodo& event );
59 void replaceEvent( const OTodo& ); 59 void replaceEvent( const OTodo& );
60 void removeEvent( int uid ); 60 void removeEvent( int uid );
61 void setShowCompleted( bool ); 61 void setShowCompleted( bool );
62 void setShowDeadline( bool ); 62 void setShowDeadline( bool );
63 63
64 void setShowCategory(const QString& =QString::null ); 64 void setShowCategory(const QString& =QString::null );
65 void newDay(); 65 void newDay();
66 QWidget* widget(); 66 QWidget* widget();
67 void sortColumn(int, bool, bool ); 67 void sortColumn(int, bool, bool );
68 68
69 /* 69 /*
70 * we do our drawing ourselves 70 * we do our drawing ourselves
71 * because we don't want to have 71 * because we don't want to have
72 * 40.000 QTableItems for 10.000 72 * 40.000 QTableItems for 10.000
73 * OTodos where we only show 10 at a time! 73 * OTodos where we only show 10 at a time!
74 */ 74 */
75 void paintCell(QPainter* p, int row, int col, const QRect&, bool ); 75 void paintCell(QPainter* p, int row, int col, const QRect&, bool );
76 private: 76 private:
77 /* reimplented for internal reasons */ 77 /* reimplented for internal reasons */
78 void viewportPaintEvent( QPaintEvent* ); 78 void viewportPaintEvent( QPaintEvent* );
79 QTimer *m_menuTimer; 79 QTimer *m_menuTimer;
80 bool m_enablePaint:1; 80 bool m_enablePaint:1;
81 QString m_oleCat;
82 bool m_first : 1;
83
84 protected:
85 QWidget* createEditor(int row, int col, bool initFromCell )const;
86 void setCellContentFromEditor( int row, int col );
81 87
82private slots: 88private slots:
83 void slotShowMenu(); 89 void slotShowMenu();
84 void slotClicked(int, int, int, 90 void slotClicked(int, int, int,
85 const QPoint& ); 91 const QPoint& );
86 void slotPressed(int, int, int, 92 void slotPressed(int, int, int,
87 const QPoint& ); 93 const QPoint& );
88 void slotValueChanged(int, int); 94 void slotValueChanged(int, int);
89 void slotCurrentChanged(int, int ); 95 void slotCurrentChanged(int, int );
96 void slotPriority();
90 }; 97 };
91}; 98};
92 99
93#endif 100#endif
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
index ebf9e8a..1f81539 100644
--- a/core/pim/todo/todomanager.cpp
+++ b/core/pim/todo/todomanager.cpp
@@ -1,124 +1,126 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qpe/categoryselect.h> 29#include <qpe/categoryselect.h>
30 30
31#include "todomanager.h" 31#include "todomanager.h"
32 32
33using namespace Todo; 33using namespace Todo;
34 34
35TodoManager::TodoManager( QObject *obj ) 35TodoManager::TodoManager( QObject *obj )
36 : QObject( obj ) { 36 : QObject( obj ) {
37 m_db = 0l; 37 m_db = 0l;
38 QTime time; 38 QTime time;
39 time.start(); 39 time.start();
40 int el = time.elapsed(); 40 int el = time.elapsed();
41 qWarning("QTimer for loading %d", el/1000 ); 41 qWarning("QTimer for loading %d", el/1000 );
42} 42}
43TodoManager::~TodoManager() { 43TodoManager::~TodoManager() {
44 delete m_db; 44 delete m_db;
45} 45}
46OTodo TodoManager::event(int uid ) { 46OTodo TodoManager::event(int uid ) {
47 return m_db->find( uid ); 47 return m_db->find( uid );
48} 48}
49void TodoManager::updateList() { 49void TodoManager::updateList() {
50 qWarning("update list");
50 m_list = m_db->allRecords(); 51 m_list = m_db->allRecords();
51} 52}
52OTodoAccess::List TodoManager::list() const{ 53OTodoAccess::List TodoManager::list() const{
53 return m_list; 54 return m_list;
54} 55}
55OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { 56OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) {
56 return m_db->sorted( asc, so, f, cat ); 57 return m_db->sorted( asc, so, f, cat );
57} 58}
58OTodoAccess::List::Iterator TodoManager::overDue() { 59OTodoAccess::List::Iterator TodoManager::overDue() {
59 int filter = 2 | 1; 60 int filter = 2 | 1;
60 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); 61 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca );
61 m_it = m_list.begin(); 62 m_it = m_list.begin();
62 return m_it; 63 return m_it;
63} 64}
64OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, 65OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start,
65 const QDate& end ) { 66 const QDate& end ) {
66 m_list = m_db->effectiveToDos( start, end ); 67 m_list = m_db->effectiveToDos( start, end );
67 m_it = m_list.begin(); 68 m_it = m_list.begin();
68 return m_it; 69 return m_it;
69} 70}
70OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) { 71OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) {
71 m_list = m_db->queryByExample( ev, query ); 72 m_list = m_db->queryByExample( ev, query );
72 m_it = m_list.begin(); 73 m_it = m_list.begin();
73 return m_it; 74 return m_it;
74} 75}
75OTodoAccess* TodoManager::todoDB() { 76OTodoAccess* TodoManager::todoDB() {
76 return m_db; 77 return m_db;
77} 78}
78void TodoManager::add( const OTodo& ev ) { 79void TodoManager::add( const OTodo& ev ) {
79 m_db->add( ev ); 80 m_db->add( ev );
80} 81}
81void TodoManager::update( int, const SmallTodo& ) { 82void TodoManager::update( int, const SmallTodo& ) {
82 83
83} 84}
84void TodoManager::update( int, const OTodo& ev) { 85void TodoManager::update( int, const OTodo& ev) {
85 m_db->replace( ev ); 86 m_db->replace( ev );
86} 87}
87void TodoManager::remove( int uid ) { 88void TodoManager::remove( int uid ) {
88 m_db->remove( uid ); 89 m_db->remove( uid );
89} 90}
90void TodoManager::removeAll() { 91void TodoManager::removeAll() {
91 m_db->clear(); 92 m_db->clear();
92} 93}
93void TodoManager::save() { 94void TodoManager::save() {
94 m_db->save(); 95 m_db->save();
95} 96}
96bool TodoManager::saveAll() { 97bool TodoManager::saveAll() {
97 return m_db->save(); 98 return m_db->save();
98} 99}
99void TodoManager::reload() { 100void TodoManager::reload() {
100 m_db->reload(); 101 m_db->reload();
101} 102}
102QStringList TodoManager::categories() { 103QStringList TodoManager::categories() {
103 m_cat.load(categoryFileName() ); 104 m_cat.load(categoryFileName() );
104 return m_cat.labels( "Todo List"); 105 return m_cat.labels( "Todo List");
105} 106}
106/* 107/*
107 * we rely on load beeing called from populateCategories 108 * we rely on load beeing called from populateCategories
108 */ 109 */
109int TodoManager::catId( const QString& cats ) { 110int TodoManager::catId( const QString& cats ) {
110 return m_cat.id( "Todo List", cats ); 111 return m_cat.id( "Todo List", cats );
111} 112}
112void TodoManager::remove( const QArray<int>& ids) { 113void TodoManager::remove( const QArray<int>& ids) {
113 for (uint i=0; i < ids.size(); i++ ) 114 for (uint i=0; i < ids.size(); i++ )
114 remove( ids[i] ); 115 remove( ids[i] );
115} 116}
116bool TodoManager::isLoaded()const { 117bool TodoManager::isLoaded()const {
117 return (m_db == 0 ); 118 return (m_db == 0 );
118} 119}
119void TodoManager::load() { 120void TodoManager::load() {
120 if (!m_db) { 121 if (!m_db) {
122 qWarning("loading!");
121 m_db = new OTodoAccess(); 123 m_db = new OTodoAccess();
122 m_db->load(); 124 m_db->load();
123 } 125 }
124} 126}
diff --git a/core/pim/todo/todoview.cpp b/core/pim/todo/todoview.cpp
index 06eaaa9..639fa66 100644
--- a/core/pim/todo/todoview.cpp
+++ b/core/pim/todo/todoview.cpp
@@ -1,78 +1,79 @@
1#include "mainwindow.h" 1#include "mainwindow.h"
2 2
3#include "todoview.h" 3#include "todoview.h"
4 4
5using namespace Todo; 5using namespace Todo;
6 6
7TodoView::TodoView( MainWindow* win ) 7TodoView::TodoView( MainWindow* win )
8 : m_main( win ) 8 : m_main( win )
9{ 9{
10 hack = new InternQtHack; 10 hack = new InternQtHack;
11 m_asc = false; 11 m_asc = false;
12 m_sortOrder = -1; 12 m_sortOrder = -1;
13} 13}
14TodoView::~TodoView() { 14TodoView::~TodoView() {
15 delete hack; 15 delete hack;
16}; 16};
17 17
18void TodoView::connectShow(QObject* obj, 18void TodoView::connectShow(QObject* obj,
19 const char* slot ) { 19 const char* slot ) {
20 QObject::connect( hack, SIGNAL(showTodo(int) ), 20 QObject::connect( hack, SIGNAL(showTodo(int) ),
21 obj, slot ); 21 obj, slot );
22} 22}
23void TodoView::connectEdit( QObject* obj, 23void TodoView::connectEdit( QObject* obj,
24 const char* slot ) { 24 const char* slot ) {
25 QObject::connect( hack, SIGNAL(edit(int) ), 25 QObject::connect( hack, SIGNAL(edit(int) ),
26 obj, slot ); 26 obj, slot );
27} 27}
28void TodoView::connectUpdateSmall( QObject* obj, 28void TodoView::connectUpdateSmall( QObject* obj,
29 const char* slot ) { 29 const char* slot ) {
30 QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ), 30 QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ),
31 obj, slot ); 31 obj, slot );
32} 32}
33void TodoView::connectUpdateBig( QObject* obj, 33void TodoView::connectUpdateBig( QObject* obj,
34 const char* slot ) { 34 const char* slot ) {
35 QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ), 35 QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ),
36 obj, slot ); 36 obj, slot );
37} 37}
38void TodoView::connectUpdateView( QObject* obj, 38void TodoView::connectUpdateView( QObject* obj,
39 const char* slot ) { 39 const char* slot ) {
40 QObject::connect( hack, SIGNAL(update(QWidget*) ), 40 QObject::connect( hack, SIGNAL(update(QWidget*) ),
41 obj, slot ); 41 obj, slot );
42} 42}
43void TodoView::connectRemove( QObject* obj, 43void TodoView::connectRemove( QObject* obj,
44 const char* slot ) { 44 const char* slot ) {
45 QObject::connect( hack, SIGNAL(remove(int) ), 45 QObject::connect( hack, SIGNAL(remove(int) ),
46 obj, slot ); 46 obj, slot );
47} 47}
48MainWindow* TodoView::todoWindow() { 48MainWindow* TodoView::todoWindow() {
49 return m_main; 49 return m_main;
50} 50}
51 51
52OTodo TodoView::event(int uid ) { return m_main->event( uid ); } 52OTodo TodoView::event(int uid ) { return m_main->event( uid ); }
53OTodoAccess::List TodoView::list(){ 53OTodoAccess::List TodoView::list(){
54 todoWindow()->updateList(); 54 todoWindow()->updateList();
55 return todoWindow()->list(); 55 return todoWindow()->list();
56} 56}
57OTodoAccess::List TodoView::sorted(){ 57OTodoAccess::List TodoView::sorted()const{
58 return m_sort; 58 return m_sort;
59} 59}
60void TodoView::sort() { 60void TodoView::sort() {
61 m_sort = todoWindow()->sorted(m_asc,m_sortOrder ); 61 m_sort = todoWindow()->sorted(m_asc,m_sortOrder );
62 qWarning("m_sort.count() = %d", m_sort.count() ); 62 qWarning("m_sort.count() = %d", m_sort.count() );
63} 63}
64void TodoView::sort(int sort) { 64void TodoView::sort(int sort) {
65 m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort ); 65 m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort );
66} 66}
67void TodoView::setSortOrder( int order ) { 67void TodoView::setSortOrder( int order ) {
68 m_sortOrder = order; 68 m_sortOrder = order;
69} 69}
70void TodoView::setAscending( bool b ) { 70void TodoView::setAscending( bool b ) {
71 qWarning("setAscending %d", b );
71 m_asc = b; 72 m_asc = b;
72} 73}
73void TodoView::update(int uid, const SmallTodo& to ) { 74void TodoView::update(int uid, const SmallTodo& to ) {
74 //m_main->slotUpate1( uid, to ); 75 //m_main->slotUpate1( uid, to );
75} 76}
76void TodoView::update(int uid, const OTodo& ev ) { 77void TodoView::update(int uid, const OTodo& ev ) {
77 m_main->updateTodo( ev ); 78 m_main->updateTodo( ev );
78} 79}
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h
index 9408ef1..e5c77f9 100644
--- a/core/pim/todo/todoview.h
+++ b/core/pim/todo/todoview.h
@@ -1,188 +1,188 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef TODO_VIEW_H 29#ifndef TODO_VIEW_H
30#define TODO_VIEW_H 30#define TODO_VIEW_H
31 31
32#include <qarray.h> 32#include <qarray.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qvaluelist.h> 34#include <qvaluelist.h>
35#include <qwidget.h> 35#include <qwidget.h>
36 36
37#include <opie/otodoaccess.h> 37#include <opie/otodoaccess.h>
38 38
39#include "smalltodo.h" 39#include "smalltodo.h"
40 40
41 41
42namespace Todo { 42namespace Todo {
43 43
44 /** 44 /**
45 * According to tronical it's not possible 45 * According to tronical it's not possible
46 * to have Q_OBJECT in a template at all 46 * to have Q_OBJECT in a template at all
47 * so this is a hack widget not meant 47 * so this is a hack widget not meant
48 * to be public 48 * to be public
49 */ 49 */
50 class InternQtHack : public QObject { 50 class InternQtHack : public QObject {
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 InternQtHack() : QObject() {}; 53 InternQtHack() : QObject() {};
54 void emitShow(int uid) { emit showTodo(uid); } 54 void emitShow(int uid) { emit showTodo(uid); }
55 void emitEdit(int uid) { emit edit(uid ); } 55 void emitEdit(int uid) { emit edit(uid ); }
56 void emitUpdate( int uid, 56 void emitUpdate( int uid,
57 const SmallTodo& to) { 57 const SmallTodo& to) {
58 emit update(uid, to ); 58 emit update(uid, to );
59 } 59 }
60 void emitUpdate( int uid, 60 void emitUpdate( int uid,
61 const OTodo& ev ){ 61 const OTodo& ev ){
62 emit update(uid, ev ); 62 emit update(uid, ev );
63 } 63 }
64 void emitRemove( int uid ) { 64 void emitRemove( int uid ) {
65 emit remove( uid ); 65 emit remove( uid );
66 } 66 }
67 void emitUpdate( QWidget* wid ) { 67 void emitUpdate( QWidget* wid ) {
68 emit update( wid ); 68 emit update( wid );
69 } 69 }
70 signals: 70 signals:
71 void showTodo(int uid ); 71 void showTodo(int uid );
72 void edit(int uid ); 72 void edit(int uid );
73 void update( int uid, const Todo::SmallTodo& ); 73 void update( int uid, const Todo::SmallTodo& );
74 void update( int uid, const OTodo& ); 74 void update( int uid, const OTodo& );
75 /* sorry you need to cast */; 75 /* sorry you need to cast */;
76 void update( QWidget* wid ); 76 void update( QWidget* wid );
77 void remove( int uid ); 77 void remove( int uid );
78 78
79 }; 79 };
80 class MainWindow; 80 class MainWindow;
81 81
82 /** 82 /**
83 * due to inheretince problems we need this base class 83 * due to inheretince problems we need this base class
84 */ 84 */
85 class ViewBase { 85 class ViewBase {
86 public: 86 public:
87 virtual QWidget* widget() = 0; 87 virtual QWidget* widget() = 0;
88 virtual QString type()const = 0; 88 virtual QString type()const = 0;
89 virtual int current() = 0; 89 virtual int current() = 0;
90 virtual QString currentRepresentation() = 0; 90 virtual QString currentRepresentation() = 0;
91 virtual void showOverDue( bool ) = 0; 91 virtual void showOverDue( bool ) = 0;
92 92
93 /* 93 /*
94 * update the view 94 * update the view
95 */ 95 */
96 virtual void updateView() = 0; 96 virtual void updateView() = 0;
97 97
98 virtual void addEvent( const OTodo& ) = 0; 98 virtual void addEvent( const OTodo& ) = 0;
99 virtual void replaceEvent( const OTodo& ) = 0; 99 virtual void replaceEvent( const OTodo& ) = 0;
100 virtual void removeEvent( int uid ) = 0; 100 virtual void removeEvent( int uid ) = 0;
101 virtual void setShowCompleted( bool ) = 0; 101 virtual void setShowCompleted( bool ) = 0;
102 virtual void setShowDeadline( bool ) = 0; 102 virtual void setShowDeadline( bool ) = 0;
103 virtual void setShowCategory( const QString& = QString::null ) = 0; 103 virtual void setShowCategory( const QString& = QString::null ) = 0;
104 virtual void clear() = 0; 104 virtual void clear() = 0;
105/* virtual QArray<int> completed() = 0; */ 105/* virtual QArray<int> completed() = 0; */
106 virtual void newDay() = 0; 106 virtual void newDay() = 0;
107 107
108 virtual void connectShow( QObject*, const char* ) = 0; 108 virtual void connectShow( QObject*, const char* ) = 0;
109 virtual void connectEdit( QObject*, const char* ) = 0; 109 virtual void connectEdit( QObject*, const char* ) = 0;
110 virtual void connectUpdateSmall( QObject*, const char* ) = 0; 110 virtual void connectUpdateSmall( QObject*, const char* ) = 0;
111 virtual void connectUpdateBig( QObject*, const char* ) = 0; 111 virtual void connectUpdateBig( QObject*, const char* ) = 0;
112 virtual void connectUpdateView( QObject*, const char*) = 0; 112 virtual void connectUpdateView( QObject*, const char*) = 0;
113 virtual void connectRemove( QObject*, const char* ) = 0; 113 virtual void connectRemove( QObject*, const char* ) = 0;
114 114
115 }; 115 };
116 116
117 /** 117 /**
118 * A base class for all TodoView which are showing 118 * A base class for all TodoView which are showing
119 * a list of todos. 119 * a list of todos.
120 * Either in a QTable, QListView or any other QWidget 120 * Either in a QTable, QListView or any other QWidget
121 * derived class 121 * derived class
122 * Through the MainWindow( dispatcher ) one can access 122 * Through the MainWindow( dispatcher ) one can access
123 * the relevant informations 123 * the relevant informations
124 * 124 *
125 * It's not possible to have signal and slots from within 125 * It's not possible to have signal and slots from within
126 * templates this way you've to register for a signal 126 * templates this way you've to register for a signal
127 */ 127 */
128 class TodoView : public ViewBase{ 128 class TodoView : public ViewBase{
129 129
130 public: 130 public:
131 /** 131 /**
132 * c'tor 132 * c'tor
133 */ 133 */
134 TodoView( MainWindow* win ); 134 TodoView( MainWindow* win );
135 135
136 /** 136 /**
137 *d'tor 137 *d'tor
138 */ 138 */
139 virtual ~TodoView(); 139 virtual ~TodoView();
140 140
141 /* connect to the show signal */ 141 /* connect to the show signal */
142 void connectShow(QObject* obj, 142 void connectShow(QObject* obj,
143 const char* slot ); 143 const char* slot );
144 144
145 /* connect to edit */ 145 /* connect to edit */
146 void connectEdit( QObject* obj, 146 void connectEdit( QObject* obj,
147 const char* slot ); 147 const char* slot );
148 void connectUpdateSmall( QObject* obj, 148 void connectUpdateSmall( QObject* obj,
149 const char* slot ); 149 const char* slot );
150 void connectUpdateBig( QObject* obj, 150 void connectUpdateBig( QObject* obj,
151 const char* slot ) ; 151 const char* slot ) ;
152 void connectUpdateView( QObject* obj, 152 void connectUpdateView( QObject* obj,
153 const char* slot ); 153 const char* slot );
154 void connectRemove( QObject* obj, 154 void connectRemove( QObject* obj,
155 const char* slot ); 155 const char* slot );
156 protected: 156 protected:
157 MainWindow* todoWindow(); 157 MainWindow* todoWindow();
158 OTodo event(int uid ); 158 OTodo event(int uid );
159 OTodoAccess::List list(); 159 OTodoAccess::List list();
160 OTodoAccess::List sorted(); 160 OTodoAccess::List sorted()const;
161 void sort(); 161 void sort();
162 void sort(int sort ); 162 void sort(int sort );
163 void setSortOrder( int order ); 163 void setSortOrder( int order );
164 void setAscending( bool ); 164 void setAscending( bool );
165 165
166 /* 166 /*
167 These things needs to be implemented 167 These things needs to be implemented
168 in a implementation 168 in a implementation
169 signals: 169 signals:
170 */ 170 */
171 protected: 171 protected:
172 void showTodo( int uid ) { hack->emitShow(uid); } 172 void showTodo( int uid ) { hack->emitShow(uid); }
173 void edit( int uid ) { hack->emitEdit(uid); } 173 void edit( int uid ) { hack->emitEdit(uid); }
174 void update(int uid, const SmallTodo& to ); 174 void update(int uid, const SmallTodo& to );
175 void update(int uid, const OTodo& ev); 175 void update(int uid, const OTodo& ev);
176 void remove( int uid ) { 176 void remove( int uid ) {
177 hack->emitRemove( uid ); 177 hack->emitRemove( uid );
178 } 178 }
179 private: 179 private:
180 InternQtHack* hack; 180 InternQtHack* hack;
181 MainWindow *m_main; 181 MainWindow *m_main;
182 OTodoAccess::List m_sort; 182 OTodoAccess::List m_sort;
183 bool m_asc : 1; 183 bool m_asc : 1;
184 int m_sortOrder; 184 int m_sortOrder;
185 }; 185 };
186}; 186};
187 187
188#endif 188#endif