-rw-r--r-- | core/pim/todo/TODO | 2 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 2 | ||||
-rw-r--r-- | core/pim/todo/todoentryimpl.cpp | 6 | ||||
-rw-r--r-- | core/pim/todo/todotable.cpp | 48 | ||||
-rw-r--r-- | core/pim/todo/todotable.h | 5 |
5 files changed, 38 insertions, 25 deletions
diff --git a/core/pim/todo/TODO b/core/pim/todo/TODO index 040f163..7601dd2 100644 --- a/core/pim/todo/TODO +++ b/core/pim/todo/TODO | |||
@@ -1,4 +1,4 @@ | |||
1 | -fix the journal | 1 | -fix the journal (wip ) |
2 | -fix day wrapping update all DueDateItems | 2 | -fix day wrapping update all DueDateItems |
3 | -when checking the C. box update the deadline | 3 | -when checking the C. box update the deadline |
4 | -TodoLabel : public TextView | 4 | -TodoLabel : public TextView |
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 883d78c..fc17c5f 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -181,193 +181,193 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
181 | if ( Ir::supported() ) { | 181 | if ( Ir::supported() ) { |
182 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), | 182 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), |
183 | QString::null, 0, this, 0 ); | 183 | QString::null, 0, this, 0 ); |
184 | connect( a, SIGNAL( activated() ), | 184 | connect( a, SIGNAL( activated() ), |
185 | this, SLOT( slotBeam() ) ); | 185 | this, SLOT( slotBeam() ) ); |
186 | a->addTo( edit ); | 186 | a->addTo( edit ); |
187 | a->addTo( bar ); | 187 | a->addTo( bar ); |
188 | } | 188 | } |
189 | 189 | ||
190 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), | 190 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), |
191 | QString::null, 0, this, 0 ); | 191 | QString::null, 0, this, 0 ); |
192 | connect( a, SIGNAL( activated() ), | 192 | connect( a, SIGNAL( activated() ), |
193 | this, SLOT( slotFind() ) ); | 193 | this, SLOT( slotFind() ) ); |
194 | a->addTo( bar ); | 194 | a->addTo( bar ); |
195 | a->addTo( options ); | 195 | a->addTo( options ); |
196 | options->insertSeparator(); | 196 | options->insertSeparator(); |
197 | 197 | ||
198 | if ( table->numRows() ) | 198 | if ( table->numRows() ) |
199 | a->setEnabled( TRUE ); | 199 | a->setEnabled( TRUE ); |
200 | else | 200 | else |
201 | a->setEnabled( FALSE ); | 201 | a->setEnabled( FALSE ); |
202 | 202 | ||
203 | //a->setEnabled( FALSE ); | 203 | //a->setEnabled( FALSE ); |
204 | findAction = a; | 204 | findAction = a; |
205 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); | 205 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); |
206 | 206 | ||
207 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); | 207 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); |
208 | 208 | ||
209 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); | 209 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); |
210 | 210 | ||
211 | catMenu->setCheckable( true ); | 211 | catMenu->setCheckable( true ); |
212 | populateCategories(); | 212 | populateCategories(); |
213 | 213 | ||
214 | 214 | ||
215 | completedAction->addTo( options ); | 215 | completedAction->addTo( options ); |
216 | completedAction->setOn( table->showCompleted() ); | 216 | completedAction->setOn( table->showCompleted() ); |
217 | showdeadlineAction->addTo( options ); | 217 | showdeadlineAction->addTo( options ); |
218 | showdeadlineAction->setOn( table->showDeadline() ); | 218 | showdeadlineAction->setOn( table->showDeadline() ); |
219 | options->insertSeparator( ); | 219 | options->insertSeparator( ); |
220 | QList<QWidget> list; | 220 | QList<QWidget> list; |
221 | list.append(table ); | 221 | list.append(table ); |
222 | OFontMenu *menu = new OFontMenu(this, "menu",list ); | 222 | OFontMenu *menu = new OFontMenu(this, "menu",list ); |
223 | menu->forceSize( table->horizontalHeader(), 10 ); | 223 | menu->forceSize( table->horizontalHeader(), 10 ); |
224 | //catMenu->insertItem(tr("Fonts"), menu ); | 224 | //catMenu->insertItem(tr("Fonts"), menu ); |
225 | list.clear(); | 225 | list.clear(); |
226 | options->insertItem( tr("Fonts"), menu ); | 226 | options->insertItem( tr("Fonts"), menu ); |
227 | 227 | ||
228 | 228 | ||
229 | mb->insertItem( tr( "Data" ), edit ); | 229 | mb->insertItem( tr( "Data" ), edit ); |
230 | mb->insertItem( tr( "Category" ), catMenu ); | 230 | mb->insertItem( tr( "Category" ), catMenu ); |
231 | mb->insertItem( tr( "Options"), options ); | 231 | mb->insertItem( tr( "Options"), options ); |
232 | resize( 200, 300 ); | 232 | resize( 200, 300 ); |
233 | if ( table->numRows() > 0 ) | 233 | if ( table->numRows() > 0 ) |
234 | currentEntryChanged( 0, 0 ); | 234 | currentEntryChanged( 0, 0 ); |
235 | connect( table, SIGNAL( signalEdit() ), | 235 | connect( table, SIGNAL( signalEdit() ), |
236 | this, SLOT( slotEdit() ) ); | 236 | this, SLOT( slotEdit() ) ); |
237 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), | 237 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), |
238 | this, SLOT( slotShowPopup(const QPoint &)) ); | 238 | this, SLOT( slotShowPopup(const QPoint &)) ); |
239 | 239 | ||
240 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); | 240 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); |
241 | table->updateVisible(); | 241 | table->updateVisible(); |
242 | table->setUpdatesEnabled( TRUE ); | 242 | table->setUpdatesEnabled( TRUE ); |
243 | table->setPaintingEnabled( TRUE ); | 243 | table->setPaintingEnabled( TRUE ); |
244 | table->viewport()->setUpdatesEnabled( TRUE ); | 244 | table->viewport()->setUpdatesEnabled( TRUE ); |
245 | 245 | ||
246 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); | 246 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); |
247 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); | 247 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); |
248 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); | 248 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); |
249 | connect( table, SIGNAL( currentChanged( int, int ) ), | 249 | connect( table, SIGNAL( currentChanged( int, int ) ), |
250 | this, SLOT( currentEntryChanged( int, int ) ) ); | 250 | this, SLOT( currentEntryChanged( int, int ) ) ); |
251 | 251 | ||
252 | // qDebug("done: t=%d", t.elapsed() ); | 252 | // qDebug("done: t=%d", t.elapsed() ); |
253 | } | 253 | } |
254 | 254 | ||
255 | void TodoWindow::slotNew() | 255 | void TodoWindow::slotNew() |
256 | { | 256 | { |
257 | if(syncing) { | 257 | if(syncing) { |
258 | QMessageBox::warning(this, tr("Todo"), | 258 | QMessageBox::warning(this, tr("Todo"), |
259 | tr("Can not edit data, currently syncing")); | 259 | tr("Can not edit data, currently syncing")); |
260 | return; | 260 | return; |
261 | } | 261 | } |
262 | 262 | ||
263 | int id; | 263 | int id; |
264 | id = -1; | 264 | id = -1; |
265 | QArray<int> ids; | 265 | QArray<int> ids; |
266 | ids = table->currentEntry().categories(); | 266 | ids = table->currentEntry().categories(); |
267 | if ( ids.count() ) | 267 | if ( ids.count() ) |
268 | id = ids[0]; | 268 | id = ids[0]; |
269 | NewTaskDialog e( id, this, 0, TRUE ); | 269 | NewTaskDialog e( id, this, 0, TRUE ); |
270 | 270 | ||
271 | ToDoEvent todo; | 271 | ToDoEvent todo; |
272 | 272 | ||
273 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 273 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
274 | e.showMaximized(); | 274 | e.showMaximized(); |
275 | #endif | 275 | #endif |
276 | int ret = e.exec(); | 276 | int ret = e.exec(); |
277 | qWarning("finished" ); | 277 | // qWarning("finished" ); |
278 | if ( ret == QDialog::Accepted ) { | 278 | if ( ret == QDialog::Accepted ) { |
279 | table->setPaintingEnabled( false ); | 279 | table->setPaintingEnabled( false ); |
280 | todo = e.todoEntry(); | 280 | todo = e.todoEntry(); |
281 | //todo.assignUid(); | 281 | //todo.assignUid(); |
282 | table->addEntry( todo ); | 282 | table->addEntry( todo ); |
283 | table->setPaintingEnabled( true ); | 283 | table->setPaintingEnabled( true ); |
284 | findAction->setEnabled( TRUE ); | 284 | findAction->setEnabled( TRUE ); |
285 | } | 285 | } |
286 | // I'm afraid we must call this every time now, otherwise | 286 | // I'm afraid we must call this every time now, otherwise |
287 | // spend expensive time comparing all these strings... | 287 | // spend expensive time comparing all these strings... |
288 | populateCategories(); | 288 | populateCategories(); |
289 | } | 289 | } |
290 | 290 | ||
291 | TodoWindow::~TodoWindow() | 291 | TodoWindow::~TodoWindow() |
292 | { | 292 | { |
293 | } | 293 | } |
294 | 294 | ||
295 | void TodoWindow::slotDelete() | 295 | void TodoWindow::slotDelete() |
296 | { | 296 | { |
297 | if(syncing) { | 297 | if(syncing) { |
298 | QMessageBox::warning(this, tr("Todo"), | 298 | QMessageBox::warning(this, tr("Todo"), |
299 | tr("Can not edit data, currently syncing")); | 299 | tr("Can not edit data, currently syncing")); |
300 | return; | 300 | return; |
301 | } | 301 | } |
302 | 302 | ||
303 | if ( table->currentRow() == -1 ) | 303 | if ( table->currentRow() == -1 ) |
304 | return; | 304 | return; |
305 | 305 | ||
306 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 306 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
307 | 307 | ||
308 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) | 308 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) |
309 | return; | 309 | return; |
310 | 310 | ||
311 | 311 | ||
312 | 312 | ||
313 | table->setPaintingEnabled( false ); | 313 | table->setPaintingEnabled( false ); |
314 | table->removeCurrentEntry(); | 314 | table->removeCurrentEntry(); |
315 | table->setPaintingEnabled( true ); | 315 | table->setPaintingEnabled( true ); |
316 | 316 | ||
317 | if ( table->numRows() == 0 ) { | 317 | if ( table->numRows() == 0 ) { |
318 | currentEntryChanged( -1, 0 ); | 318 | currentEntryChanged( -1, 0 ); |
319 | findAction->setEnabled( FALSE ); | 319 | findAction->setEnabled( FALSE ); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | void TodoWindow::slotDeleteAll() | 322 | void TodoWindow::slotDeleteAll() |
323 | { | 323 | { |
324 | if(syncing) { | 324 | if(syncing) { |
325 | QMessageBox::warning(this, tr("Todo"), | 325 | QMessageBox::warning(this, tr("Todo"), |
326 | tr("Can not edit data, currently syncing")); | 326 | tr("Can not edit data, currently syncing")); |
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | 329 | ||
330 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 330 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
331 | 331 | ||
332 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Should I delete all tasks?") ) ) | 332 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Should I delete all tasks?") ) ) |
333 | return; | 333 | return; |
334 | 334 | ||
335 | 335 | ||
336 | 336 | ||
337 | table->setPaintingEnabled( false ); | 337 | table->setPaintingEnabled( false ); |
338 | table->removeAllEntries(); | 338 | table->removeAllEntries(); |
339 | table->setPaintingEnabled( true ); | 339 | table->setPaintingEnabled( true ); |
340 | 340 | ||
341 | if ( table->numRows() == 0 ) { | 341 | if ( table->numRows() == 0 ) { |
342 | currentEntryChanged( -1, 0 ); | 342 | currentEntryChanged( -1, 0 ); |
343 | findAction->setEnabled( FALSE ); | 343 | findAction->setEnabled( FALSE ); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | 346 | ||
347 | void TodoWindow::slotEdit() | 347 | void TodoWindow::slotEdit() |
348 | { | 348 | { |
349 | if(syncing) { | 349 | if(syncing) { |
350 | QMessageBox::warning(this, tr("Todo"), | 350 | QMessageBox::warning(this, tr("Todo"), |
351 | tr("Can not edit data, currently syncing")); | 351 | tr("Can not edit data, currently syncing")); |
352 | return; | 352 | return; |
353 | } | 353 | } |
354 | 354 | ||
355 | ToDoEvent todo = table->currentEntry(); | 355 | ToDoEvent todo = table->currentEntry(); |
356 | 356 | ||
357 | NewTaskDialog e( todo, this, 0, TRUE ); | 357 | NewTaskDialog e( todo, this, 0, TRUE ); |
358 | e.setCaption( tr( "Edit Task" ) ); | 358 | e.setCaption( tr( "Edit Task" ) ); |
359 | 359 | ||
360 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 360 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
361 | e.showMaximized(); | 361 | e.showMaximized(); |
362 | #endif | 362 | #endif |
363 | int ret = e.exec(); | 363 | int ret = e.exec(); |
364 | 364 | ||
365 | if ( ret == QDialog::Accepted ) { | 365 | if ( ret == QDialog::Accepted ) { |
366 | table->setPaintingEnabled( false ); | 366 | table->setPaintingEnabled( false ); |
367 | todo = e.todoEntry(); | 367 | todo = e.todoEntry(); |
368 | table->replaceCurrentEntry( todo ); | 368 | table->replaceCurrentEntry( todo ); |
369 | table->setPaintingEnabled( true ); | 369 | table->setPaintingEnabled( true ); |
370 | } | 370 | } |
371 | populateCategories(); | 371 | populateCategories(); |
372 | 372 | ||
373 | } | 373 | } |
diff --git a/core/pim/todo/todoentryimpl.cpp b/core/pim/todo/todoentryimpl.cpp index f938d61..26a685c 100644 --- a/core/pim/todo/todoentryimpl.cpp +++ b/core/pim/todo/todoentryimpl.cpp | |||
@@ -1,159 +1,153 @@ | |||
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 "todoentryimpl.h" | 21 | #include "todoentryimpl.h" |
22 | 22 | ||
23 | #include <opie/todoevent.h> | 23 | #include <opie/todoevent.h> |
24 | #include <opie/tododb.h> | 24 | #include <opie/tododb.h> |
25 | 25 | ||
26 | #include <qpe/categoryselect.h> | 26 | #include <qpe/categoryselect.h> |
27 | #include <qpe/datebookmonth.h> | 27 | #include <qpe/datebookmonth.h> |
28 | #include <qpe/global.h> | 28 | #include <qpe/global.h> |
29 | #include <qpe/imageedit.h> | 29 | #include <qpe/imageedit.h> |
30 | #include <qpe/timestring.h> | 30 | #include <qpe/timestring.h> |
31 | #include <qpe/palmtoprecord.h> | 31 | #include <qpe/palmtoprecord.h> |
32 | 32 | ||
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtoolbutton.h> | 35 | #include <qtoolbutton.h> |
36 | #include <qcombobox.h> | 36 | #include <qcombobox.h> |
37 | #include <qcheckbox.h> | 37 | #include <qcheckbox.h> |
38 | #include <qlineedit.h> | 38 | #include <qlineedit.h> |
39 | #include <qmultilineedit.h> | 39 | #include <qmultilineedit.h> |
40 | #include <qlabel.h> | 40 | #include <qlabel.h> |
41 | #include <qtimer.h> | 41 | #include <qtimer.h> |
42 | #include <qapplication.h> | 42 | #include <qapplication.h> |
43 | 43 | ||
44 | 44 | ||
45 | NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent, | 45 | NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent, |
46 | const char *name, bool modal, WFlags fl ) | 46 | const char *name, bool modal, WFlags fl ) |
47 | : NewTaskDialogBase( parent, name, modal, fl ), | 47 | : NewTaskDialogBase( parent, name, modal, fl ), |
48 | todo( task ) | 48 | todo( task ) |
49 | { | 49 | { |
50 | qWarning("setting category" ); | ||
51 | todo.setCategories( task.allCategories() ); | 50 | todo.setCategories( task.allCategories() ); |
52 | if ( todo.hasDate() ) | 51 | if ( todo.hasDate() ) |
53 | date = todo.date(); | 52 | date = todo.date(); |
54 | else | 53 | else |
55 | date = QDate::currentDate(); | 54 | date = QDate::currentDate(); |
56 | 55 | ||
57 | init(); | 56 | init(); |
58 | comboPriority->setCurrentItem( task.priority() - 1 ); | 57 | comboPriority->setCurrentItem( task.priority() - 1 ); |
59 | 58 | ||
60 | checkCompleted->setChecked( task.isCompleted() ); | 59 | checkCompleted->setChecked( task.isCompleted() ); |
61 | checkDate->setChecked( task.hasDate() ); | 60 | checkDate->setChecked( task.hasDate() ); |
62 | buttonDate->setText( TimeString::longDateString( date ) ); | 61 | buttonDate->setText( TimeString::longDateString( date ) ); |
63 | 62 | ||
64 | txtTodo->setText( task.description() ); | 63 | txtTodo->setText( task.description() ); |
65 | } | 64 | } |
66 | 65 | ||
67 | /* | 66 | /* |
68 | * Constructs a NewTaskDialog which is a child of 'parent', with the | 67 | * Constructs a NewTaskDialog which is a child of 'parent', with the |
69 | * name 'name' and widget flags set to 'f' | 68 | * name 'name' and widget flags set to 'f' |
70 | * | 69 | * |
71 | * The dialog will by default be modeless, unless you set 'modal' to | 70 | * The dialog will by default be modeless, unless you set 'modal' to |
72 | * TRUE to construct a modal dialog. | 71 | * TRUE to construct a modal dialog. |
73 | */ | 72 | */ |
74 | NewTaskDialog::NewTaskDialog( int id, QWidget* parent, const char* name, bool modal, | 73 | NewTaskDialog::NewTaskDialog( int id, QWidget* parent, const char* name, bool modal, |
75 | WFlags fl ) | 74 | WFlags fl ) |
76 | : NewTaskDialogBase( parent, name, modal, fl ), | 75 | : NewTaskDialogBase( parent, name, modal, fl ), |
77 | date( QDate::currentDate() ) | 76 | date( QDate::currentDate() ) |
78 | { | 77 | { |
79 | if ( id != -1 ) { | 78 | if ( id != -1 ) { |
80 | QArray<int> ids( 1 ); | 79 | QArray<int> ids( 1 ); |
81 | ids[0] = id; | 80 | ids[0] = id; |
82 | todo.setCategory( Qtopia::Record::idsToString( ids ) ); | 81 | todo.setCategory( Qtopia::Record::idsToString( ids ) ); |
83 | } | 82 | } |
84 | init(); | 83 | init(); |
85 | } | 84 | } |
86 | 85 | ||
87 | void NewTaskDialog::init() | 86 | void NewTaskDialog::init() |
88 | { | 87 | { |
89 | QPopupMenu *m1 = new QPopupMenu( this ); | 88 | QPopupMenu *m1 = new QPopupMenu( this ); |
90 | picker = new DateBookMonth( m1, 0, TRUE ); | 89 | picker = new DateBookMonth( m1, 0, TRUE ); |
91 | m1->insertItem( picker ); | 90 | m1->insertItem( picker ); |
92 | buttonDate->setPopup( m1 ); | 91 | buttonDate->setPopup( m1 ); |
93 | comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") ); | 92 | comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") ); |
94 | 93 | ||
95 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), | 94 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), |
96 | this, SLOT( dateChanged( int, int, int ) ) ); | 95 | this, SLOT( dateChanged( int, int, int ) ) ); |
97 | 96 | ||
98 | buttonDate->setText( TimeString::longDateString( date ) ); | 97 | buttonDate->setText( TimeString::longDateString( date ) ); |
99 | picker->setDate( date.year(), date.month(), date.day() ); | 98 | picker->setDate( date.year(), date.month(), date.day() ); |
100 | } | 99 | } |
101 | 100 | ||
102 | /* | 101 | /* |
103 | * Destroys the object and frees any allocated resources | 102 | * Destroys the object and frees any allocated resources |
104 | */ | 103 | */ |
105 | NewTaskDialog::~NewTaskDialog() | 104 | NewTaskDialog::~NewTaskDialog() |
106 | { | 105 | { |
107 | qWarning("d'tor" ); | ||
108 | // no need to delete child widgets, Qt does it all for us | 106 | // no need to delete child widgets, Qt does it all for us |
109 | } | 107 | } |
110 | void NewTaskDialog::dateChanged( int y, int m, int d ) | 108 | void NewTaskDialog::dateChanged( int y, int m, int d ) |
111 | { | 109 | { |
112 | date = QDate( y, m, d ); | 110 | date = QDate( y, m, d ); |
113 | buttonDate->setText( TimeString::longDateString( date ) ); | 111 | buttonDate->setText( TimeString::longDateString( date ) ); |
114 | } | 112 | } |
115 | 113 | ||
116 | /*! | 114 | /*! |
117 | */ | 115 | */ |
118 | 116 | ||
119 | ToDoEvent NewTaskDialog::todoEntry() | 117 | ToDoEvent NewTaskDialog::todoEntry() |
120 | { | 118 | { |
121 | qWarning("todoEntry()" ); | ||
122 | if( checkDate->isChecked() ){ | 119 | if( checkDate->isChecked() ){ |
123 | todo.setDate( date ); | 120 | todo.setDate( date ); |
124 | todo.setHasDate( true ); | 121 | todo.setHasDate( true ); |
125 | }else{ | 122 | }else{ |
126 | todo.setHasDate( false ); | 123 | todo.setHasDate( false ); |
127 | } | 124 | } |
128 | qWarning("todoEntry::category()" ); | ||
129 | if ( comboCategory->currentCategory() != -1 ) { | 125 | if ( comboCategory->currentCategory() != -1 ) { |
130 | QArray<int> arr = comboCategory->currentCategories(); | 126 | QArray<int> arr = comboCategory->currentCategories(); |
131 | QStringList list; | 127 | QStringList list; |
132 | list = QStringList::split(";", Qtopia::Record::idsToString( arr )) ; | 128 | list = QStringList::split(";", Qtopia::Record::idsToString( arr )) ; |
133 | qWarning("saving category"); | ||
134 | todo.setCategories( list ); | 129 | todo.setCategories( list ); |
135 | } | 130 | } |
136 | todo.setPriority( comboPriority->currentItem() + 1 ); | 131 | todo.setPriority( comboPriority->currentItem() + 1 ); |
137 | todo.setCompleted( checkCompleted->isChecked() ); | 132 | todo.setCompleted( checkCompleted->isChecked() ); |
138 | 133 | ||
139 | todo.setDescription( txtTodo->text() ); | 134 | todo.setDescription( txtTodo->text() ); |
140 | 135 | ||
141 | return todo; | 136 | return todo; |
142 | } | 137 | } |
143 | 138 | ||
144 | 139 | ||
145 | /*! | 140 | /*! |
146 | 141 | ||
147 | */ | 142 | */ |
148 | 143 | ||
149 | void NewTaskDialog::accept() | 144 | void NewTaskDialog::accept() |
150 | { | 145 | { |
151 | qWarning("accept" ); | ||
152 | QString strText = txtTodo->text(); | 146 | QString strText = txtTodo->text(); |
153 | if ( strText.isEmpty() ) { | 147 | if ( strText.isEmpty() ) { |
154 | // hmm... just decline it then, the user obviously didn't care about it | 148 | // hmm... just decline it then, the user obviously didn't care about it |
155 | QDialog::reject(); | 149 | QDialog::reject(); |
156 | return; | 150 | return; |
157 | } | 151 | } |
158 | QDialog::accept(); | 152 | QDialog::accept(); |
159 | } | 153 | } |
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index 401d2c8..96cd860 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp | |||
@@ -259,627 +259,647 @@ TodoTable::TodoTable( QWidget *parent, const char *name ) | |||
259 | connect( this, SIGNAL( currentChanged( int, int ) ), | 259 | connect( this, SIGNAL( currentChanged( int, int ) ), |
260 | this, SLOT( slotCurrentChanged( int, int ) ) ); | 260 | this, SLOT( slotCurrentChanged( int, int ) ) ); |
261 | 261 | ||
262 | menuTimer = new QTimer( this ); | 262 | menuTimer = new QTimer( this ); |
263 | connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); | 263 | connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); |
264 | } | 264 | } |
265 | 265 | ||
266 | void TodoTable::addEntry( const ToDoEvent &todo ) | 266 | void TodoTable::addEntry( const ToDoEvent &todo ) |
267 | { | 267 | { |
268 | int row = numRows(); | 268 | int row = numRows(); |
269 | setNumRows( row + 1 ); | 269 | setNumRows( row + 1 ); |
270 | updateJournal( todo, ACTION_ADD ); | 270 | updateJournal( todo, ACTION_ADD ); |
271 | insertIntoTable( new ToDoEvent(todo), row ); | 271 | insertIntoTable( new ToDoEvent(todo), row ); |
272 | setCurrentCell(row, currentColumn()); | 272 | setCurrentCell(row, currentColumn()); |
273 | updateVisible(); | 273 | updateVisible(); |
274 | } | 274 | } |
275 | 275 | ||
276 | void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) | 276 | void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) |
277 | { | 277 | { |
278 | if ( !cellGeometry( row, col ).contains(pos) ) | 278 | if ( !cellGeometry( row, col ).contains(pos) ) |
279 | return; | 279 | return; |
280 | // let's switch on the column number... | 280 | // let's switch on the column number... |
281 | switch ( col ) | 281 | switch ( col ) |
282 | { | 282 | { |
283 | case 0: { | 283 | case 0: { |
284 | CheckItem *i = static_cast<CheckItem*>(item( row, col )); | 284 | CheckItem *i = static_cast<CheckItem*>(item( row, col )); |
285 | if ( i ) { | 285 | if ( i ) { |
286 | int x = pos.x() - columnPos( col ); | 286 | int x = pos.x() - columnPos( col ); |
287 | int y = pos.y() - rowPos( row ); | 287 | int y = pos.y() - rowPos( row ); |
288 | int w = columnWidth( col ); | 288 | int w = columnWidth( col ); |
289 | int h = rowHeight( row ); | 289 | int h = rowHeight( row ); |
290 | if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && | 290 | if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && |
291 | y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { | 291 | y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { |
292 | i->toggle(); | 292 | i->toggle(); |
293 | } | 293 | } |
294 | emit signalDoneChanged( i->isChecked() ); | 294 | emit signalDoneChanged( i->isChecked() ); |
295 | } | 295 | } |
296 | } | 296 | } |
297 | break; | 297 | break; |
298 | case 1: | 298 | case 1: |
299 | break; | 299 | break; |
300 | case 2: | 300 | case 2: |
301 | // may as well edit it... | 301 | // may as well edit it... |
302 | // menuTimer->stop(); | 302 | // menuTimer->stop(); |
303 | // emit signalEdit(); | 303 | // emit signalEdit(); |
304 | // fall through | 304 | // fall through |
305 | case 3: | 305 | case 3: |
306 | // may as well edit it... | 306 | // may as well edit it... |
307 | menuTimer->stop(); | 307 | menuTimer->stop(); |
308 | // emit signalEdit(); | 308 | // emit signalEdit(); |
309 | break; | 309 | break; |
310 | } | 310 | } |
311 | } | 311 | } |
312 | 312 | ||
313 | void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) | 313 | void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) |
314 | { | 314 | { |
315 | if ( col == 2 && cellGeometry( row, col ).contains(pos) ) | 315 | if ( col == 2 && cellGeometry( row, col ).contains(pos) ) |
316 | menuTimer->start( 750, TRUE ); | 316 | menuTimer->start( 750, TRUE ); |
317 | } | 317 | } |
318 | 318 | ||
319 | void TodoTable::slotShowMenu() | 319 | void TodoTable::slotShowMenu() |
320 | { | 320 | { |
321 | emit signalShowMenu( QCursor::pos() ); | 321 | emit signalShowMenu( QCursor::pos() ); |
322 | } | 322 | } |
323 | 323 | ||
324 | void TodoTable::slotCurrentChanged( int, int ) | 324 | void TodoTable::slotCurrentChanged( int, int ) |
325 | { | 325 | { |
326 | menuTimer->stop(); | 326 | menuTimer->stop(); |
327 | } | 327 | } |
328 | 328 | ||
329 | void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) | 329 | void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) |
330 | { | 330 | { |
331 | setNumRows( list.count() ); | 331 | setNumRows( list.count() ); |
332 | int row = 0; | 332 | int row = 0; |
333 | ToDoEvent *it; | 333 | ToDoEvent *it; |
334 | for ( it = list.first(); it; it = list.next() ) | 334 | for ( it = list.first(); it; it = list.next() ) |
335 | insertIntoTable( it, row++ ); | 335 | insertIntoTable( it, row++ ); |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | ToDoEvent TodoTable::currentEntry() const | 339 | ToDoEvent TodoTable::currentEntry() const |
340 | { | 340 | { |
341 | printf ("in currentEntry\n"); | 341 | printf ("in currentEntry\n"); |
342 | 342 | ||
343 | QTableItem *i = item( currentRow(), 0 ); | 343 | QTableItem *i = item( currentRow(), 0 ); |
344 | if ( !i || rowHeight( currentRow() ) <= 0 ) | 344 | if ( !i || rowHeight( currentRow() ) <= 0 ) |
345 | return ToDoEvent(); | 345 | return ToDoEvent(); |
346 | ToDoEvent *todo = todoList[(CheckItem*)i]; | 346 | ToDoEvent *todo = todoList[(CheckItem*)i]; |
347 | todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); | 347 | todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); |
348 | todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); | 348 | todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); |
349 | return *todo; | 349 | return *todo; |
350 | } | 350 | } |
351 | 351 | ||
352 | void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) | 352 | void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) |
353 | { | 353 | { |
354 | int row = currentRow(); | 354 | int row = currentRow(); |
355 | updateJournal( todo, ACTION_REPLACE, row ); | 355 | updateJournal( todo, ACTION_REPLACE); |
356 | 356 | ||
357 | if ( !fromTableItem ) { | 357 | if ( !fromTableItem ) { |
358 | journalFreeReplaceEntry( todo, row ); | 358 | journalFreeReplaceEntry( todo, row ); |
359 | updateVisible(); | 359 | updateVisible(); |
360 | } | 360 | } |
361 | } | 361 | } |
362 | 362 | ||
363 | void TodoTable::removeCurrentEntry() | 363 | void TodoTable::removeCurrentEntry() |
364 | { | 364 | { |
365 | ToDoEvent *oldTodo; | 365 | ToDoEvent *oldTodo; |
366 | int row = currentRow(); | 366 | int row = currentRow(); |
367 | CheckItem *chk; | 367 | CheckItem *chk; |
368 | 368 | ||
369 | chk = static_cast<CheckItem*>(item(row, 0 )); | 369 | chk = static_cast<CheckItem*>(item(row, 0 )); |
370 | if ( !chk ) | 370 | if ( !chk ) |
371 | return; | 371 | return; |
372 | oldTodo = todoList[chk]; | 372 | oldTodo = todoList[chk]; |
373 | todoList.remove( chk ); | 373 | todoList.remove( chk ); |
374 | oldTodo->setCompleted( chk->isChecked() ); | 374 | oldTodo->setCompleted( chk->isChecked() ); |
375 | oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() ); | 375 | oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() ); |
376 | realignTable( row ); | 376 | realignTable( row ); |
377 | updateVisible(); | 377 | updateVisible(); |
378 | updateJournal( *oldTodo, ACTION_REMOVE, row ); | 378 | updateJournal( *oldTodo, ACTION_REMOVE); |
379 | delete oldTodo; | 379 | delete oldTodo; |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | bool TodoTable::save( const QString &fn ) | 383 | bool TodoTable::save( const QString &fn ) |
384 | { | 384 | { |
385 | QString strNewFile = fn + ".new"; | 385 | QString strNewFile = fn + ".new"; |
386 | QFile::remove( strNewFile ); // just to be sure | 386 | QFile::remove( strNewFile ); // just to be sure |
387 | ToDoDB todoDB( strNewFile ); | 387 | ToDoDB todoDB( strNewFile ); |
388 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); | 388 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); |
389 | it != todoList.end(); ++it ) { | 389 | it != todoList.end(); ++it ) { |
390 | if ( !item( it.key()->row(), 0 ) ) | 390 | if ( !item( it.key()->row(), 0 ) ) |
391 | continue; | 391 | continue; |
392 | ToDoEvent *todo = *it; | 392 | ToDoEvent *todo = *it; |
393 | // sync item with table | 393 | // sync item with table |
394 | todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() ); | 394 | todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() ); |
395 | todo->setPriority( ((ComboItem*)item( it.key()->row(), 1))->text().toInt() ); | 395 | todo->setPriority( ((ComboItem*)item( it.key()->row(), 1))->text().toInt() ); |
396 | todoDB.addEvent( *todo ); | 396 | todoDB.addEvent( *todo ); |
397 | } | 397 | } |
398 | if(!todoDB.save() ){ | 398 | if(!todoDB.save() ){ |
399 | QFile::remove( strNewFile ); | 399 | QFile::remove( strNewFile ); |
400 | return false; | 400 | return false; |
401 | }; | 401 | }; |
402 | // now do the rename | 402 | // now do the rename |
403 | if ( ::rename( strNewFile, fn ) < 0 ) | 403 | if ( ::rename( strNewFile, fn ) < 0 ) |
404 | qWarning( "problem renaming file %s to %s errno %d", | 404 | qWarning( "problem renaming file %s to %s errno %d", |
405 | strNewFile.latin1(), fn.latin1(), errno ); | 405 | strNewFile.latin1(), fn.latin1(), errno ); |
406 | 406 | ||
407 | // remove the journal | 407 | // remove the journal |
408 | QFile::remove( journalFileName() ); | 408 | QFile::remove( journalFileName() ); |
409 | return true; | 409 | return true; |
410 | } | 410 | } |
411 | 411 | ||
412 | void TodoTable::load( const QString &fn ) | 412 | void TodoTable::load( const QString &fn ) |
413 | { | 413 | { |
414 | loadFile( fn, false ); | 414 | if ( QFile::exists(journalFileName()) ) { |
415 | if ( QFile::exists(journalFileName()) ) { | 415 | applyJournal(); |
416 | applyJournal( ); | 416 | QFile::remove(journalFileName() ); |
417 | save( fn ); | 417 | } |
418 | } | 418 | loadFile( fn ); |
419 | // QTable::sortColumn(2,TRUE,TRUE); | 419 | // QTable::sortColumn(2,TRUE,TRUE); |
420 | // QTable::sortColumn(1,TRUE,TRUE); | 420 | // QTable::sortColumn(1,TRUE,TRUE); |
421 | QTable::sortColumn(0,TRUE,TRUE); | 421 | QTable::sortColumn(0,TRUE,TRUE); |
422 | setCurrentCell( 0, 2 ); | 422 | setCurrentCell( 0, 2 ); |
423 | setSorting(true ); | 423 | setSorting(true ); |
424 | } | 424 | } |
425 | void TodoTable::updateVisible() | 425 | void TodoTable::updateVisible() |
426 | { | 426 | { |
427 | if ( !isUpdatesEnabled() ) | 427 | if ( !isUpdatesEnabled() ) |
428 | return; | 428 | return; |
429 | 429 | ||
430 | if (showDeadl){ | 430 | if (showDeadl){ |
431 | showColumn (3); | 431 | showColumn (3); |
432 | adjustColumn(3); | 432 | adjustColumn(3); |
433 | }else{ | 433 | }else{ |
434 | hideColumn (3); | 434 | hideColumn (3); |
435 | adjustColumn(2); | 435 | adjustColumn(2); |
436 | } | 436 | } |
437 | 437 | ||
438 | int visible = 0; | 438 | int visible = 0; |
439 | int id = mCat.id( "Todo List", showCat ); | 439 | int id = mCat.id( "Todo List", showCat ); |
440 | for ( int row = 0; row < numRows(); row++ ) { | 440 | for ( int row = 0; row < numRows(); row++ ) { |
441 | CheckItem *ci = (CheckItem *)item( row, 0 ); | 441 | CheckItem *ci = (CheckItem *)item( row, 0 ); |
442 | ToDoEvent *t = todoList[ci]; | 442 | ToDoEvent *t = todoList[ci]; |
443 | QArray<int> vlCats = t->categories(); | 443 | QArray<int> vlCats = t->categories(); |
444 | bool hide = false; | 444 | bool hide = false; |
445 | if ( !showComp && ci->isChecked() ) | 445 | if ( !showComp && ci->isChecked() ) |
446 | hide = true; | 446 | hide = true; |
447 | if ( !showCat.isEmpty() ) { | 447 | if ( !showCat.isEmpty() ) { |
448 | if ( showCat == tr( "Unfiled" ) ) { | 448 | if ( showCat == tr( "Unfiled" ) ) { |
449 | if ( vlCats.count() > 0 ) | 449 | if ( vlCats.count() > 0 ) |
450 | hide = true; | 450 | hide = true; |
451 | } else { | 451 | } else { |
452 | // do some comparing, we have to reverse our idea here... which idea? - zecke | 452 | // do some comparing, we have to reverse our idea here... which idea? - zecke |
453 | if ( !hide ) { | 453 | if ( !hide ) { |
454 | hide = true; | 454 | hide = true; |
455 | for ( uint it = 0; it < vlCats.count(); ++it ) { | 455 | for ( uint it = 0; it < vlCats.count(); ++it ) { |
456 | if ( vlCats[it] == id ) { | 456 | if ( vlCats[it] == id ) { |
457 | hide = false; | 457 | hide = false; |
458 | break; | 458 | break; |
459 | } | 459 | } |
460 | } | 460 | } |
461 | } | 461 | } |
462 | } | 462 | } |
463 | } | 463 | } |
464 | if ( hide ) { | 464 | if ( hide ) { |
465 | if ( currentRow() == row ) | 465 | if ( currentRow() == row ) |
466 | setCurrentCell( -1, 0 ); | 466 | setCurrentCell( -1, 0 ); |
467 | if ( rowHeight( row ) > 0 ) | 467 | if ( rowHeight( row ) > 0 ) |
468 | hideRow( row ); | 468 | hideRow( row ); |
469 | } else { | 469 | } else { |
470 | if ( rowHeight( row ) == 0 ) { | 470 | if ( rowHeight( row ) == 0 ) { |
471 | showRow( row ); | 471 | showRow( row ); |
472 | adjustRow( row ); | 472 | adjustRow( row ); |
473 | } | 473 | } |
474 | visible++; | 474 | visible++; |
475 | } | 475 | } |
476 | } | 476 | } |
477 | if ( !visible ) | 477 | if ( !visible ) |
478 | setCurrentCell( -1, 0 ); | 478 | setCurrentCell( -1, 0 ); |
479 | } | 479 | } |
480 | 480 | ||
481 | void TodoTable::viewportPaintEvent( QPaintEvent *pe ) | 481 | void TodoTable::viewportPaintEvent( QPaintEvent *pe ) |
482 | { | 482 | { |
483 | if ( enablePainting ) | 483 | if ( enablePainting ) |
484 | QTable::viewportPaintEvent( pe ); | 484 | QTable::viewportPaintEvent( pe ); |
485 | } | 485 | } |
486 | 486 | ||
487 | void TodoTable::setPaintingEnabled( bool e ) | 487 | void TodoTable::setPaintingEnabled( bool e ) |
488 | { | 488 | { |
489 | if ( e != enablePainting ) { | 489 | if ( e != enablePainting ) { |
490 | if ( !enablePainting ) { | 490 | if ( !enablePainting ) { |
491 | enablePainting = true; | 491 | enablePainting = true; |
492 | rowHeightChanged( 0 ); | 492 | rowHeightChanged( 0 ); |
493 | viewport()->update(); | 493 | viewport()->update(); |
494 | } else { | 494 | } else { |
495 | enablePainting = false; | 495 | enablePainting = false; |
496 | } | 496 | } |
497 | } | 497 | } |
498 | } | 498 | } |
499 | 499 | ||
500 | void TodoTable::clear() | 500 | void TodoTable::clear() |
501 | { | 501 | { |
502 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); | 502 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); |
503 | it != todoList.end(); ++it ) { | 503 | it != todoList.end(); ++it ) { |
504 | ToDoEvent *todo = *it; | 504 | ToDoEvent *todo = it.data(); |
505 | updateJournal( todo, ACTION_REMOVE, 0 ); | 505 | updateJournal( *todo, ACTION_REMOVE ); |
506 | delete todo; | 506 | delete todo; |
507 | } | 507 | } |
508 | todoList.clear(); | 508 | todoList.clear(); |
509 | for ( int r = 0; r < numRows(); ++r ) { | 509 | for ( int r = 0; r < numRows(); ++r ) { |
510 | for ( int c = 0; c < numCols(); ++c ) { | 510 | for ( int c = 0; c < numCols(); ++c ) { |
511 | if ( cellWidget( r, c ) ) | 511 | if ( cellWidget( r, c ) ) |
512 | clearCellWidget( r, c ); | 512 | clearCellWidget( r, c ); |
513 | clearCell( r, c ); | 513 | clearCell( r, c ); |
514 | } | 514 | } |
515 | } | 515 | } |
516 | setNumRows( 0 ); | 516 | setNumRows( 0 ); |
517 | } | 517 | } |
518 | 518 | ||
519 | void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ ) | 519 | void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ ) |
520 | { | 520 | { |
521 | // The default for wholeRows is false, however | 521 | // The default for wholeRows is false, however |
522 | // for this todo table we want to exchange complete | 522 | // for this todo table we want to exchange complete |
523 | // rows when sorting. Also, we always want ascending, since | 523 | // rows when sorting. Also, we always want ascending, since |
524 | // the values have a logical order. | 524 | // the values have a logical order. |
525 | QTable::sortColumn( col, ascending, TRUE ); | 525 | QTable::sortColumn( col, ascending, TRUE ); |
526 | updateVisible(); | 526 | updateVisible(); |
527 | } | 527 | } |
528 | 528 | ||
529 | void TodoTable::slotCheckPriority(int row, int col ) | 529 | void TodoTable::slotCheckPriority(int row, int col ) |
530 | { | 530 | { |
531 | // kludgey work around to make forward along the updated priority... | 531 | // kludgey work around to make forward along the updated priority... |
532 | if ( col == 1 ) { | 532 | if ( col == 1 ) { |
533 | // let everyone know!! | 533 | // let everyone know!! |
534 | ComboItem* i = static_cast<ComboItem*>( item( row, col ) ); | 534 | ComboItem* i = static_cast<ComboItem*>( item( row, col ) ); |
535 | emit signalPriorityChanged( i->text().toInt() ); | 535 | emit signalPriorityChanged( i->text().toInt() ); |
536 | } | 536 | } |
537 | } | 537 | } |
538 | 538 | ||
539 | 539 | ||
540 | void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action, int row ) | 540 | void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) |
541 | { | 541 | { |
542 | QFile f( journalFileName() ); | 542 | QFile f( journalFileName() ); |
543 | if ( !f.open(IO_WriteOnly|IO_Append) ) | 543 | if ( !f.open(IO_WriteOnly|IO_Append) ) |
544 | return; | 544 | return; |
545 | QString buf; | 545 | QString buf; |
546 | QCString str; | 546 | QCString str; |
547 | buf = "<Task"; | 547 | buf = "<Task"; |
548 | // todo.save( buf ); | 548 | // todo.save( buf ); |
549 | buf += " Action=\"" + QString::number( int(action) ) + "\""; | 549 | buf += " Action=\"" + QString::number( int(action) ) + "\""; |
550 | buf += " Uid=\"" + QString::number( todo.uid() ) + "\""; // better write the id | 550 | buf += " Uid=\"" + QString::number( todo.uid() ) + "\""; // better write the id |
551 | buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; | 551 | buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; |
552 | buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; | 552 | buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; |
553 | buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; | 553 | buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; |
554 | QArray<int> arrat = todo.categories(); | 554 | QArray<int> arrat = todo.categories(); |
555 | QString attr; | 555 | QString attr; |
556 | for(uint i=0; i < arrat.count(); i++ ){ | 556 | for(uint i=0; i < arrat.count(); i++ ){ |
557 | attr.append(QString::number(arrat[i])+";" ); | 557 | attr.append(QString::number(arrat[i])+";" ); |
558 | } | 558 | } |
559 | if(!attr.isEmpty() ) // remove the last ; | 559 | if(!attr.isEmpty() ) // remove the last ; |
560 | attr.remove(attr.length()-1, 1 ); | 560 | attr.remove(attr.length()-1, 1 ); |
561 | buf += " Categories=\"" + attr + "\""; | 561 | buf += " Categories=\"" + attr + "\""; |
562 | buf += " Description=\"" + todo.description() + "\""; | 562 | buf += " Description=\"" + todo.description() + "\""; |
563 | if(todo.hasDate() ) { | 563 | if(todo.hasDate() ) { |
564 | buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; | 564 | buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; |
565 | buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; | 565 | buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; |
566 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; | 566 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; |
567 | } | 567 | } |
568 | buf += "/>\n"; | 568 | buf += "/>\n"; |
569 | str = buf.utf8(); | 569 | str = buf.utf8(); |
570 | f.writeBlock( str.data(), str.length() ); | 570 | f.writeBlock( str.data(), str.length() ); |
571 | f.close(); | 571 | f.close(); |
572 | } | 572 | } |
573 | 573 | ||
574 | void TodoTable::rowHeightChanged( int row ) | 574 | void TodoTable::rowHeightChanged( int row ) |
575 | { | 575 | { |
576 | if ( enablePainting ) | 576 | if ( enablePainting ) |
577 | QTable::rowHeightChanged( row ); | 577 | QTable::rowHeightChanged( row ); |
578 | } | 578 | } |
579 | 579 | ||
580 | void TodoTable::loadFile( const QString &strFile, bool fromJournal ) | 580 | void TodoTable::loadFile( const QString &/*we use the standard*/ ) |
581 | { | 581 | { |
582 | 582 | ||
583 | QList<ToDoEvent> list; | 583 | QList<ToDoEvent> list; |
584 | ToDoDB todoDB; | 584 | ToDoDB todoDB; |
585 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); | 585 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); |
586 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ | 586 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ |
587 | list.append( new ToDoEvent( (*it) ) ); | 587 | list.append( new ToDoEvent( (*it) ) ); |
588 | } | 588 | } |
589 | vaList.clear(); | 589 | vaList.clear(); |
590 | // qDebug("parsing done=%d", t.elapsed() ); | 590 | // qDebug("parsing done=%d", t.elapsed() ); |
591 | if ( list.count() > 0 ) { | 591 | if ( list.count() > 0 ) { |
592 | internalAddEntries( list ); | 592 | internalAddEntries( list ); |
593 | list.clear(); | 593 | list.clear(); |
594 | } | 594 | } |
595 | // qDebug("loading done: t=%d", t.elapsed() ); | 595 | // qDebug("loading done: t=%d", t.elapsed() ); |
596 | } | 596 | } |
597 | 597 | ||
598 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) | 598 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) |
599 | { | 599 | { |
600 | QString strTodo; | 600 | QString strTodo; |
601 | strTodo = todo.description().left(40).simplifyWhiteSpace(); | 601 | strTodo = todo.description().left(40).simplifyWhiteSpace(); |
602 | if ( row == -1 ) { | 602 | if ( row == -1 ) { |
603 | QMapIterator<CheckItem*, ToDoEvent *> it; | 603 | QMapIterator<CheckItem*, ToDoEvent *> it; |
604 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { | 604 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { |
605 | if ( *(*it) == todo ) { | 605 | if ( *(*it) == todo ) { |
606 | row = it.key()->row(); | 606 | row = it.key()->row(); |
607 | it.key()->setChecked( todo.isCompleted() ); | 607 | it.key()->setChecked( todo.isCompleted() ); |
608 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 608 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
609 | item( row, 2 )->setText( strTodo ); | 609 | item( row, 2 )->setText( strTodo ); |
610 | 610 | ||
611 | if (showDeadl){ | 611 | if (showDeadl){ |
612 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 612 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
613 | } | 613 | } |
614 | 614 | ||
615 | *(*it) = todo; | 615 | *(*it) = todo; |
616 | } | 616 | } |
617 | } | 617 | } |
618 | } else { | 618 | } else { |
619 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; | 619 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; |
620 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); | 620 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); |
621 | delete t; | 621 | delete t; |
622 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); | 622 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); |
623 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 623 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
624 | item( row, 2 )->setText( strTodo ); | 624 | item( row, 2 )->setText( strTodo ); |
625 | 625 | ||
626 | if (showDeadl){ | 626 | if (showDeadl){ |
627 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 627 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
628 | } | 628 | } |
629 | 629 | ||
630 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); | 630 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); |
631 | } | 631 | } |
632 | } | 632 | } |
633 | 633 | ||
634 | void TodoTable::journalFreeRemoveEntry( int row ) | 634 | void TodoTable::journalFreeRemoveEntry( int row ) |
635 | { | 635 | { |
636 | CheckItem *chk; | 636 | CheckItem *chk; |
637 | chk = static_cast<CheckItem*>(item(row, 0 )); | 637 | chk = static_cast<CheckItem*>(item(row, 0 )); |
638 | if ( !chk ) | 638 | if ( !chk ) |
639 | return; | 639 | return; |
640 | todoList.remove( chk ); | 640 | todoList.remove( chk ); |
641 | 641 | ||
642 | realignTable( row ); | 642 | realignTable( row ); |
643 | } | 643 | } |
644 | 644 | ||
645 | void TodoTable::keyPressEvent( QKeyEvent *e ) | 645 | void TodoTable::keyPressEvent( QKeyEvent *e ) |
646 | { | 646 | { |
647 | if ( e->key() == Key_Space || e->key() == Key_Return ) { | 647 | if ( e->key() == Key_Space || e->key() == Key_Return ) { |
648 | switch ( currentColumn() ) { | 648 | switch ( currentColumn() ) { |
649 | case 0: { | 649 | case 0: { |
650 | CheckItem *i = static_cast<CheckItem*>(item(currentRow(), | 650 | CheckItem *i = static_cast<CheckItem*>(item(currentRow(), |
651 | currentColumn())); | 651 | currentColumn())); |
652 | if ( i ) | 652 | if ( i ) |
653 | i->toggle(); | 653 | i->toggle(); |
654 | break; | 654 | break; |
655 | } | 655 | } |
656 | case 1: | 656 | case 1: |
657 | break; | 657 | break; |
658 | case 2: | 658 | case 2: |
659 | emit signalEdit(); | 659 | emit signalEdit(); |
660 | default: | 660 | default: |
661 | break; | 661 | break; |
662 | } | 662 | } |
663 | } else { | 663 | } else { |
664 | QTable::keyPressEvent( e ); | 664 | QTable::keyPressEvent( e ); |
665 | } | 665 | } |
666 | } | 666 | } |
667 | 667 | ||
668 | QStringList TodoTable::categories() | 668 | QStringList TodoTable::categories() |
669 | { | 669 | { |
670 | // This is called seldom, so calling a load in here | 670 | // This is called seldom, so calling a load in here |
671 | // should be fine. | 671 | // should be fine. |
672 | mCat.load( categoryFileName() ); | 672 | mCat.load( categoryFileName() ); |
673 | QStringList categoryList = mCat.labels( "Todo List" ); | 673 | QStringList categoryList = mCat.labels( "Todo List" ); |
674 | return categoryList; | 674 | return categoryList; |
675 | } | 675 | } |
676 | 676 | ||
677 | void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, | 677 | void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, |
678 | bool backwards, int category ) | 678 | bool backwards, int category ) |
679 | { | 679 | { |
680 | // we have to iterate through the table, this gives the illusion that | 680 | // we have to iterate through the table, this gives the illusion that |
681 | // sorting is actually being used. | 681 | // sorting is actually being used. |
682 | if ( currFindRow < -1 ) | 682 | if ( currFindRow < -1 ) |
683 | currFindRow = currentRow() - 1; | 683 | currFindRow = currentRow() - 1; |
684 | clearSelection( TRUE ); | 684 | clearSelection( TRUE ); |
685 | int rows, | 685 | int rows, |
686 | row; | 686 | row; |
687 | CheckItem *chk; | 687 | CheckItem *chk; |
688 | QRegExp r( findString ); | 688 | QRegExp r( findString ); |
689 | 689 | ||
690 | r.setCaseSensitive( caseSensitive ); | 690 | r.setCaseSensitive( caseSensitive ); |
691 | rows = numRows(); | 691 | rows = numRows(); |
692 | static bool wrapAround = true; | 692 | static bool wrapAround = true; |
693 | 693 | ||
694 | if ( !backwards ) { | 694 | if ( !backwards ) { |
695 | for ( row = currFindRow + 1; row < rows; row++ ) { | 695 | for ( row = currFindRow + 1; row < rows; row++ ) { |
696 | chk = static_cast<CheckItem*>( item(row, 0) ); | 696 | chk = static_cast<CheckItem*>( item(row, 0) ); |
697 | if ( taskCompare(*(todoList[chk]), r, category) ) | 697 | if ( taskCompare(*(todoList[chk]), r, category) ) |
698 | break; | 698 | break; |
699 | } | 699 | } |
700 | } else { | 700 | } else { |
701 | for ( row = currFindRow - 1; row > -1; row-- ) { | 701 | for ( row = currFindRow - 1; row > -1; row-- ) { |
702 | chk = static_cast<CheckItem*>( item(row, 0) ); | 702 | chk = static_cast<CheckItem*>( item(row, 0) ); |
703 | if ( taskCompare(*(todoList[chk]), r, category) ) | 703 | if ( taskCompare(*(todoList[chk]), r, category) ) |
704 | break; | 704 | break; |
705 | } | 705 | } |
706 | } | 706 | } |
707 | if ( row >= rows || row < 0 ) { | 707 | if ( row >= rows || row < 0 ) { |
708 | if ( row < 0 ) | 708 | if ( row < 0 ) |
709 | currFindRow = rows; | 709 | currFindRow = rows; |
710 | else | 710 | else |
711 | currFindRow = -1; | 711 | currFindRow = -1; |
712 | if ( wrapAround ) | 712 | if ( wrapAround ) |
713 | emit signalWrapAround(); | 713 | emit signalWrapAround(); |
714 | else | 714 | else |
715 | emit signalNotFound(); | 715 | emit signalNotFound(); |
716 | wrapAround = !wrapAround; | 716 | wrapAround = !wrapAround; |
717 | } else { | 717 | } else { |
718 | currFindRow = row; | 718 | currFindRow = row; |
719 | QTableSelection foundSelection; | 719 | QTableSelection foundSelection; |
720 | foundSelection.init( currFindRow, 0 ); | 720 | foundSelection.init( currFindRow, 0 ); |
721 | foundSelection.expandTo( currFindRow, numCols() - 1 ); | 721 | foundSelection.expandTo( currFindRow, numCols() - 1 ); |
722 | addSelection( foundSelection ); | 722 | addSelection( foundSelection ); |
723 | setCurrentCell( currFindRow, numCols() - 1 ); | 723 | setCurrentCell( currFindRow, numCols() - 1 ); |
724 | // we should always be able to wrap around and find this again, | 724 | // we should always be able to wrap around and find this again, |
725 | // so don't give confusing not found message... | 725 | // so don't give confusing not found message... |
726 | wrapAround = true; | 726 | wrapAround = true; |
727 | } | 727 | } |
728 | } | 728 | } |
729 | 729 | ||
730 | int TodoTable::showCategoryId() const | 730 | int TodoTable::showCategoryId() const |
731 | { | 731 | { |
732 | int id; | 732 | int id; |
733 | id = -1; | 733 | id = -1; |
734 | // if allcategories are selected, you get unfiled... | 734 | // if allcategories are selected, you get unfiled... |
735 | if ( showCat != tr( "Unfiled" ) && showCat != tr( "All" ) ) | 735 | if ( showCat != tr( "Unfiled" ) && showCat != tr( "All" ) ) |
736 | id = mCat.id( "Todo List", showCat ); | 736 | id = mCat.id( "Todo List", showCat ); |
737 | return id; | 737 | return id; |
738 | } | 738 | } |
739 | void TodoTable::applyJournal() | 739 | void TodoTable::applyJournal() |
740 | { | 740 | { |
741 | // we need to hack | 741 | // we need to hack |
742 | QFile file( journalFileName() ); | 742 | QFile file( journalFileName() ); |
743 | if( file.open(IO_ReadOnly ) ) { | 743 | if( file.open(IO_ReadOnly ) ) { |
744 | QByteArray ar = file.readAll(); | 744 | QByteArray ar = file.readAll(); |
745 | file.close(); | 745 | file.close(); |
746 | QFile file2( journalFileName() + "_new" ); | 746 | QFile file2( journalFileName() + "_new" ); |
747 | if( file2.open(IO_WriteOnly ) ){ | 747 | if( file2.open(IO_WriteOnly ) ){ |
748 | QTextStream str(&file2 ); | 748 | QTextStream str(&file2 ); |
749 | str << QString::fromLatin1("<Tasks>") << endl; | 749 | str << QString::fromLatin1("<Tasks>") << endl; |
750 | str << ar.data(); | 750 | str << ar.data(); |
751 | str << QString::fromLatin1("</Tasks>") << endl; | 751 | str << QString::fromLatin1("</Tasks>") << endl; |
752 | file2.close(); | 752 | file2.close(); |
753 | } | 753 | } |
754 | XMLElement *root = XMLElement::load(journalFileName()+ "_new"); | 754 | XMLElement *root = XMLElement::load(journalFileName()+ "_new"); |
755 | XMLElement *el = root->firstChild(); | 755 | XMLElement *el = root->firstChild(); |
756 | el = el->firstChild(); | 756 | el = el->firstChild(); |
757 | ToDoDB tododb; // allready loaded ;) | ||
758 | bool ok; | ||
759 | int action; | ||
760 | QString dummy; | ||
757 | while( el ){ | 761 | while( el ){ |
758 | qWarning("journal: %s %s", el->attribute("Uid" ).latin1(), el->tagName().latin1() ); | 762 | dummy = el->attribute("Action" ); |
759 | doApply( el ); | 763 | action = dummy.toInt(&ok ); |
764 | ToDoEvent ev = xmlToEvent( el ); | ||
765 | if(ok ){ | ||
766 | switch( action){ | ||
767 | case ACTION_ADD: | ||
768 | tododb.addEvent(ev ); | ||
769 | break; | ||
770 | case ACTION_REMOVE: | ||
771 | tododb.removeEvent( ev ); | ||
772 | break; | ||
773 | case ACTION_REPLACE: | ||
774 | tododb.replaceEvent( ev ); | ||
775 | break; | ||
776 | } | ||
777 | } | ||
760 | el = el->nextChild(); | 778 | el = el->nextChild(); |
761 | } | 779 | } |
762 | QFile::remove(journalFileName()+ "_new" ); | 780 | QFile::remove(journalFileName()+ "_new" ); |
781 | tododb.save(); | ||
763 | } | 782 | } |
764 | } | 783 | } |
765 | // check Action and decide | 784 | // check Action and decide |
785 | /* | ||
766 | void TodoTable::doApply(XMLElement *el ) | 786 | void TodoTable::doApply(XMLElement *el ) |
767 | { | 787 | { |
768 | QString dummy; | 788 | QString dummy; |
769 | bool ok; | 789 | bool ok; |
770 | int action; | 790 | int action; |
771 | dummy = el->attribute("Action" ); | 791 | dummy = el->attribute("Action" ); |
772 | action = dummy.toInt(&ok ); | 792 | action = dummy.toInt(&ok ); |
773 | ToDoEvent ev = xmlToEvent( el ); | 793 | ToDoEvent ev = xmlToEvent( el ); |
774 | if( ok ){ | 794 | if( ok ){ |
775 | switch( action ){ | 795 | switch( action ){ |
776 | case ACTION_ADD: | 796 | case ACTION_ADD: |
777 | addEntry( ev ); | 797 | addEntry( ev ); |
778 | break; | 798 | break; |
779 | case ACTION_REMOVE:{ // find an entry with the same uid and remove it then | 799 | case ACTION_REMOVE:{ // find an entry with the same uid and remove it then |
780 | break; | 800 | break; |
781 | } | 801 | } |
782 | case ACTION_REPLACE: | 802 | case ACTION_REPLACE: |
783 | break; | 803 | break; |
784 | } | 804 | } |
785 | } | 805 | } |
786 | } | 806 | } |
807 | */ | ||
787 | namespace { | 808 | namespace { |
788 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ) | 809 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ) |
789 | { | 810 | { |
790 | bool returnMe; | 811 | bool returnMe; |
791 | QArray<int> cats; | 812 | QArray<int> cats; |
792 | cats = task.categories(); | 813 | cats = task.categories(); |
793 | 814 | ||
794 | returnMe = false; | 815 | returnMe = false; |
795 | if ( (category == -1 && cats.count() == 0) || category == -2 ) | 816 | if ( (category == -1 && cats.count() == 0) || category == -2 ) |
796 | returnMe = task.match( r ); | 817 | returnMe = task.match( r ); |
797 | else { | 818 | else { |
798 | int i; | 819 | int i; |
799 | for ( i = 0; i < int(cats.count()); i++ ) { | 820 | for ( i = 0; i < int(cats.count()); i++ ) { |
800 | if ( cats[i] == category ) { | 821 | if ( cats[i] == category ) { |
801 | returnMe = task.match( r ); | 822 | returnMe = task.match( r ); |
802 | break; | 823 | break; |
803 | } | 824 | } |
804 | } | 825 | } |
805 | } | 826 | } |
806 | return returnMe; | 827 | return returnMe; |
807 | } | 828 | } |
808 | 829 | ||
809 | static QString journalFileName() | 830 | static QString journalFileName() |
810 | { | 831 | { |
811 | QString str; | 832 | QString str; |
812 | str = getenv( "HOME" ); | 833 | str = getenv( "HOME" ); |
813 | str += "/.opie_todojournal"; | 834 | str += "/.opie_todojournal"; |
814 | return str; | 835 | return str; |
815 | } | 836 | } |
816 | static ToDoEvent xmlToEvent( XMLElement *element ) | 837 | static ToDoEvent xmlToEvent( XMLElement *element ) |
817 | { | 838 | { |
818 | QString dummy; | 839 | QString dummy; |
819 | ToDoEvent event; | 840 | ToDoEvent event; |
820 | bool ok; | 841 | bool ok; |
821 | int dumInt; | 842 | int dumInt; |
822 | // completed | 843 | // completed |
823 | dummy = element->attribute("Completed" ); | 844 | dummy = element->attribute("Completed" ); |
824 | dumInt = dummy.toInt(&ok ); | 845 | dumInt = dummy.toInt(&ok ); |
825 | if(ok ) event.setCompleted( dumInt == 0 ? false : true ); | 846 | if(ok ) event.setCompleted( dumInt == 0 ? false : true ); |
826 | // hasDate | 847 | // hasDate |
827 | dummy = element->attribute("HasDate" ); | 848 | dummy = element->attribute("HasDate" ); |
828 | dumInt = dummy.toInt(&ok ); | 849 | dumInt = dummy.toInt(&ok ); |
829 | if(ok ) event.setHasDate( dumInt == 0 ? false: true ); | 850 | if(ok ) event.setHasDate( dumInt == 0 ? false: true ); |
830 | // set the date | 851 | // set the date |
831 | bool hasDa = dumInt; | 852 | bool hasDa = dumInt; |
832 | if ( hasDa ) { //parse the date | 853 | if ( hasDa ) { //parse the date |
833 | int year, day, month = 0; | 854 | int year, day, month = 0; |
834 | year = day = month; | 855 | year = day = month; |
835 | // year | 856 | // year |
836 | dummy = element->attribute("DateYear" ); | 857 | dummy = element->attribute("DateYear" ); |
837 | dumInt = dummy.toInt(&ok ); | 858 | dumInt = dummy.toInt(&ok ); |
838 | if( ok ) year = dumInt; | 859 | if( ok ) year = dumInt; |
839 | // month | 860 | // month |
840 | dummy = element->attribute("DateMonth" ); | 861 | dummy = element->attribute("DateMonth" ); |
841 | dumInt = dummy.toInt(&ok ); | 862 | dumInt = dummy.toInt(&ok ); |
842 | if(ok ) month = dumInt; | 863 | if(ok ) month = dumInt; |
843 | dummy = element->attribute("DateDay" ); | 864 | dummy = element->attribute("DateDay" ); |
844 | dumInt = dummy.toInt(&ok ); | 865 | dumInt = dummy.toInt(&ok ); |
845 | if(ok ) day = dumInt; | 866 | if(ok ) day = dumInt; |
846 | // set the date | 867 | // set the date |
847 | QDate date( year, month, day ); | 868 | QDate date( year, month, day ); |
848 | event.setDate( date); | 869 | event.setDate( date); |
849 | } | 870 | } |
850 | dummy = element->attribute("Priority" ); | 871 | dummy = element->attribute("Priority" ); |
851 | dumInt = dummy.toInt(&ok ); | 872 | dumInt = dummy.toInt(&ok ); |
852 | if(!ok ) dumInt = ToDoEvent::NORMAL; | 873 | if(!ok ) dumInt = ToDoEvent::NORMAL; |
853 | event.setPriority( dumInt ); | 874 | event.setPriority( dumInt ); |
854 | //description | 875 | //description |
855 | dummy = element->attribute("Description" ); | 876 | dummy = element->attribute("Description" ); |
856 | event.setDescription( dummy ); | 877 | event.setDescription( dummy ); |
857 | // category | 878 | // category |
858 | dummy = element->attribute("Categories" ); | 879 | dummy = element->attribute("Categories" ); |
859 | QStringList ids = QStringList::split(";", dummy ); | 880 | QStringList ids = QStringList::split(";", dummy ); |
860 | event.setCategories( ids ); | 881 | event.setCategories( ids ); |
861 | 882 | ||
862 | //uid | 883 | //uid |
863 | dummy = element->attribute("Uid" ); | 884 | dummy = element->attribute("Uid" ); |
864 | dumInt = dummy.toInt(&ok ); | 885 | dumInt = dummy.toInt(&ok ); |
865 | if(ok ) event.setUid( dumInt ); | 886 | if(ok ) event.setUid( dumInt ); |
866 | |||
867 | return event; | 887 | return event; |
868 | } | 888 | } |
869 | 889 | ||
870 | } | 890 | } |
871 | // int TodoTable::rowHeight( int ) const | 891 | // int TodoTable::rowHeight( int ) const |
872 | // { | 892 | // { |
873 | // return 18; | 893 | // return 18; |
874 | // } | 894 | // } |
875 | 895 | ||
876 | // int TodoTable::rowPos( int row ) const | 896 | // int TodoTable::rowPos( int row ) const |
877 | // { | 897 | // { |
878 | // return 18*row; | 898 | // return 18*row; |
879 | // } | 899 | // } |
880 | 900 | ||
881 | // int TodoTable::rowAt( int pos ) const | 901 | // int TodoTable::rowAt( int pos ) const |
882 | // { | 902 | // { |
883 | // return QMIN( pos/18, numRows()-1 ); | 903 | // return QMIN( pos/18, numRows()-1 ); |
884 | // } | 904 | // } |
885 | 905 | ||
diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h index 6917e04..6e371e8 100644 --- a/core/pim/todo/todotable.h +++ b/core/pim/todo/todotable.h | |||
@@ -58,181 +58,180 @@ public: | |||
58 | ComboItem( QTable *t, EditType et ); | 58 | ComboItem( QTable *t, EditType et ); |
59 | QWidget *createEditor() const; | 59 | QWidget *createEditor() const; |
60 | void setContentFromEditor( QWidget *w ); | 60 | void setContentFromEditor( QWidget *w ); |
61 | void setText( const QString &s ); | 61 | void setText( const QString &s ); |
62 | int alignment() const { return Qt::AlignCenter; } | 62 | int alignment() const { return Qt::AlignCenter; } |
63 | 63 | ||
64 | QString text() const; | 64 | QString text() const; |
65 | 65 | ||
66 | private: | 66 | private: |
67 | QGuardedPtr<QComboBox> cb; | 67 | QGuardedPtr<QComboBox> cb; |
68 | 68 | ||
69 | }; | 69 | }; |
70 | 70 | ||
71 | class TodoTextItem : public QTableItem | 71 | class TodoTextItem : public QTableItem |
72 | { | 72 | { |
73 | public: | 73 | public: |
74 | TodoTextItem( QTable *t, const QString & str ) | 74 | TodoTextItem( QTable *t, const QString & str ) |
75 | :QTableItem( t, QTableItem::Never, str ) {} | 75 | :QTableItem( t, QTableItem::Never, str ) {} |
76 | 76 | ||
77 | QString key () const { return Qtopia::buildSortKey( text() ); } | 77 | QString key () const { return Qtopia::buildSortKey( text() ); } |
78 | }; | 78 | }; |
79 | 79 | ||
80 | class DueTextItem : public QTableItem | 80 | class DueTextItem : public QTableItem |
81 | { | 81 | { |
82 | public: | 82 | public: |
83 | DueTextItem( QTable *t, ToDoEvent *ev ); | 83 | DueTextItem( QTable *t, ToDoEvent *ev ); |
84 | QString key() const; | 84 | QString key() const; |
85 | void setToDoEvent( const ToDoEvent *ev ); | 85 | void setToDoEvent( const ToDoEvent *ev ); |
86 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); | 86 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); |
87 | private: | 87 | private: |
88 | int m_off; | 88 | int m_off; |
89 | bool m_hasDate:1; | 89 | bool m_hasDate:1; |
90 | bool m_completed:1; | 90 | bool m_completed:1; |
91 | 91 | ||
92 | }; | 92 | }; |
93 | 93 | ||
94 | 94 | ||
95 | enum journal_action { ACTION_ADD=0, ACTION_REMOVE, ACTION_REPLACE }; | 95 | enum journal_action { ACTION_ADD=0, ACTION_REMOVE, ACTION_REPLACE }; |
96 | 96 | ||
97 | class XMLElement; | 97 | class XMLElement; |
98 | class TodoTable : public QTable | 98 | class TodoTable : public QTable |
99 | { | 99 | { |
100 | Q_OBJECT | 100 | Q_OBJECT |
101 | 101 | ||
102 | public: | 102 | public: |
103 | TodoTable( QWidget *parent = 0, const char * name = 0 ); | 103 | TodoTable( QWidget *parent = 0, const char * name = 0 ); |
104 | void addEntry( const ToDoEvent &todo ); | 104 | void addEntry( const ToDoEvent &todo ); |
105 | void clearFindRow() { currFindRow = -2; } | 105 | void clearFindRow() { currFindRow = -2; } |
106 | 106 | ||
107 | ToDoEvent currentEntry() const; | 107 | ToDoEvent currentEntry() const; |
108 | void replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem = false ); | 108 | void replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem = false ); |
109 | 109 | ||
110 | QStringList categories(); | 110 | QStringList categories(); |
111 | 111 | ||
112 | void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); } | 112 | void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); } |
113 | bool showCompleted() const { return showComp; } | 113 | bool showCompleted() const { return showComp; } |
114 | 114 | ||
115 | void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();} | 115 | void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();} |
116 | bool showDeadline() const { return showDeadl;} | 116 | bool showDeadline() const { return showDeadl;} |
117 | 117 | ||
118 | void setShowCategory( const QString &c ) { showCat = c; updateVisible(); } | 118 | void setShowCategory( const QString &c ) { showCat = c; updateVisible(); } |
119 | const QString &showCategory() const { return showCat; } | 119 | const QString &showCategory() const { return showCat; } |
120 | int showCategoryId() const; | 120 | int showCategoryId() const; |
121 | 121 | ||
122 | bool save( const QString &fn ); | 122 | bool save( const QString &fn ); |
123 | void load( const QString &fn ); | 123 | void load( const QString &fn ); |
124 | void applyJournal( ); | 124 | void applyJournal( ); |
125 | void clear(); | 125 | void clear(); |
126 | void removeCurrentEntry(); | 126 | void removeCurrentEntry(); |
127 | void removeAllEntries() { clear(); }; | 127 | void removeAllEntries() { clear(); }; |
128 | //void removeAllEntriesInCategory(const QString &category ); | 128 | //void removeAllEntriesInCategory(const QString &category ); |
129 | 129 | ||
130 | void setPaintingEnabled( bool e ); | 130 | void setPaintingEnabled( bool e ); |
131 | 131 | ||
132 | virtual void sortColumn( int col, bool ascending, bool /*wholeRows*/ ); | 132 | virtual void sortColumn( int col, bool ascending, bool /*wholeRows*/ ); |
133 | 133 | ||
134 | // int rowHeight( int ) const; | 134 | // int rowHeight( int ) const; |
135 | // int rowPos( int row ) const; | 135 | // int rowPos( int row ) const; |
136 | // virtual int rowAt( int pos ) const; | 136 | // virtual int rowAt( int pos ) const; |
137 | 137 | ||
138 | signals: | 138 | signals: |
139 | void signalEdit(); | 139 | void signalEdit(); |
140 | void signalDoneChanged( bool b ); | 140 | void signalDoneChanged( bool b ); |
141 | void signalPriorityChanged( int i ); | 141 | void signalPriorityChanged( int i ); |
142 | void signalShowMenu( const QPoint & ); | 142 | void signalShowMenu( const QPoint & ); |
143 | void signalNotFound(); | 143 | void signalNotFound(); |
144 | void signalWrapAround(); | 144 | void signalWrapAround(); |
145 | 145 | ||
146 | protected: | 146 | protected: |
147 | void keyPressEvent( QKeyEvent *e ); | 147 | void keyPressEvent( QKeyEvent *e ); |
148 | 148 | ||
149 | private: | 149 | private: |
150 | void updateVisible(); | 150 | void updateVisible(); |
151 | void viewportPaintEvent( QPaintEvent * ); | 151 | void viewportPaintEvent( QPaintEvent * ); |
152 | void internalAddEntries( QList<ToDoEvent> &list); | 152 | void internalAddEntries( QList<ToDoEvent> &list); |
153 | inline void insertIntoTable( ToDoEvent *todo, int row ); | 153 | inline void insertIntoTable( ToDoEvent *todo, int row ); |
154 | void updateJournal( const ToDoEvent &todo, journal_action action, int row = -1); | 154 | void updateJournal( const ToDoEvent &todo, journal_action action); |
155 | void mergeJournal(); | 155 | void mergeJournal(); |
156 | void journalFreeReplaceEntry( const ToDoEvent &todo, int row ); | 156 | void journalFreeReplaceEntry( const ToDoEvent &todo, int row ); |
157 | void journalFreeRemoveEntry( int row ); | 157 | void journalFreeRemoveEntry( int row ); |
158 | inline void realignTable( int row ); | 158 | inline void realignTable( int row ); |
159 | void loadFile( const QString &strFile, bool fromJournal = false ); | 159 | void loadFile( const QString &strFile); |
160 | void doApply(XMLElement *el ); | ||
161 | 160 | ||
162 | private slots: | 161 | private slots: |
163 | void slotClicked( int row, int col, int button, const QPoint &pos ); | 162 | void slotClicked( int row, int col, int button, const QPoint &pos ); |
164 | void slotPressed( int row, int col, int button, const QPoint &pos ); | 163 | void slotPressed( int row, int col, int button, const QPoint &pos ); |
165 | void slotCheckPriority(int row, int col ); | 164 | void slotCheckPriority(int row, int col ); |
166 | void slotCurrentChanged(int row, int col ); | 165 | void slotCurrentChanged(int row, int col ); |
167 | void slotDoFind( const QString &findString, bool caseSensetive, | 166 | void slotDoFind( const QString &findString, bool caseSensetive, |
168 | bool backwards, int category ); | 167 | bool backwards, int category ); |
169 | void slotShowMenu(); | 168 | void slotShowMenu(); |
170 | void rowHeightChanged( int row ); | 169 | void rowHeightChanged( int row ); |
171 | 170 | ||
172 | private: | 171 | private: |
173 | friend class TodoWindow; | 172 | friend class TodoWindow; |
174 | 173 | ||
175 | QMap<CheckItem*, ToDoEvent *> todoList; | 174 | QMap<CheckItem*, ToDoEvent *> todoList; |
176 | QStringList categoryList; | 175 | QStringList categoryList; |
177 | bool showComp; | 176 | bool showComp; |
178 | QString showCat; | 177 | QString showCat; |
179 | QTimer *menuTimer; | 178 | QTimer *menuTimer; |
180 | bool enablePainting; | 179 | bool enablePainting; |
181 | Categories mCat; | 180 | Categories mCat; |
182 | int currFindRow; | 181 | int currFindRow; |
183 | bool showDeadl:1; | 182 | bool showDeadl:1; |
184 | }; | 183 | }; |
185 | 184 | ||
186 | 185 | ||
187 | inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) | 186 | inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) |
188 | { | 187 | { |
189 | QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') | 188 | QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') |
190 | + todo->priority() ) | 189 | + todo->priority() ) |
191 | + Qtopia::buildSortKey( todo->description() ); | 190 | + Qtopia::buildSortKey( todo->description() ); |
192 | CheckItem *chk = new CheckItem( this, sortKey ); | 191 | CheckItem *chk = new CheckItem( this, sortKey ); |
193 | chk->setChecked( todo->isCompleted() ); | 192 | chk->setChecked( todo->isCompleted() ); |
194 | ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent ); | 193 | ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent ); |
195 | cmb->setText( QString::number( todo->priority() ) ); | 194 | cmb->setText( QString::number( todo->priority() ) ); |
196 | QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() ); | 195 | QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() ); |
197 | ti->setReplaceable( false ); | 196 | ti->setReplaceable( false ); |
198 | 197 | ||
199 | DueTextItem *due = new DueTextItem(this, todo ); | 198 | DueTextItem *due = new DueTextItem(this, todo ); |
200 | setItem( row, 3, due); | 199 | setItem( row, 3, due); |
201 | 200 | ||
202 | setItem( row, 0, chk ); | 201 | setItem( row, 0, chk ); |
203 | setItem( row, 1, cmb ); | 202 | setItem( row, 1, cmb ); |
204 | setItem( row, 2, ti ); | 203 | setItem( row, 2, ti ); |
205 | 204 | ||
206 | 205 | ||
207 | todoList.insert( chk, todo ); | 206 | todoList.insert( chk, todo ); |
208 | } | 207 | } |
209 | 208 | ||
210 | inline void TodoTable::realignTable( int row ) | 209 | inline void TodoTable::realignTable( int row ) |
211 | { | 210 | { |
212 | QTableItem *ti1, | 211 | QTableItem *ti1, |
213 | *ti2, | 212 | *ti2, |
214 | *ti3, | 213 | *ti3, |
215 | *ti4; | 214 | *ti4; |
216 | int totalRows = numRows(); | 215 | int totalRows = numRows(); |
217 | for ( int curr = row; curr < totalRows - 1; curr++ ) { | 216 | for ( int curr = row; curr < totalRows - 1; curr++ ) { |
218 | // this is bad, we must take the item out and then | 217 | // this is bad, we must take the item out and then |
219 | // set it. In the end, it behaves no worse (time wise) | 218 | // set it. In the end, it behaves no worse (time wise) |
220 | // then the old way of saving the entries to file, clearing | 219 | // then the old way of saving the entries to file, clearing |
221 | // the table re-reading in the file and resetting the table | 220 | // the table re-reading in the file and resetting the table |
222 | ti1 = item( curr + 1, 0 ); | 221 | ti1 = item( curr + 1, 0 ); |
223 | ti2 = item( curr + 1, 1 ); | 222 | ti2 = item( curr + 1, 1 ); |
224 | ti3 = item( curr + 1, 2 ); | 223 | ti3 = item( curr + 1, 2 ); |
225 | ti4 = item( curr + 1, 3 ); | 224 | ti4 = item( curr + 1, 3 ); |
226 | takeItem( ti1 ); | 225 | takeItem( ti1 ); |
227 | takeItem( ti2 ); | 226 | takeItem( ti2 ); |
228 | takeItem( ti3 ); | 227 | takeItem( ti3 ); |
229 | takeItem( ti4 ); | 228 | takeItem( ti4 ); |
230 | setItem( curr, 0, ti1 ); | 229 | setItem( curr, 0, ti1 ); |
231 | setItem( curr, 1, ti2 ); | 230 | setItem( curr, 1, ti2 ); |
232 | setItem( curr, 2, ti3 ); | 231 | setItem( curr, 2, ti3 ); |
233 | setItem( curr, 3, ti4 ); | 232 | setItem( curr, 3, ti4 ); |
234 | } | 233 | } |
235 | setNumRows( totalRows - 1 ); | 234 | setNumRows( totalRows - 1 ); |
236 | } | 235 | } |
237 | 236 | ||
238 | #endif | 237 | #endif |