author | zecke <zecke> | 2002-05-09 15:51:20 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-05-09 15:51:20 (UTC) |
commit | 168d7dcdaee8555365af4c918dc941d8cc0dcb68 (patch) (unidiff) | |
tree | ce5b6b357c4247345797ae7c8c059532b3aa142d | |
parent | 7999411de407eaaf57cae9e2d0cb3767c714d161 (diff) | |
download | opie-168d7dcdaee8555365af4c918dc941d8cc0dcb68.zip opie-168d7dcdaee8555365af4c918dc941d8cc0dcb68.tar.gz opie-168d7dcdaee8555365af4c918dc941d8cc0dcb68.tar.bz2 |
Patch from Stefan Eilers to make the Table align better and the viewing of events more easy
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 3 | ||||
-rw-r--r-- | core/pim/todo/todotable.cpp | 49 |
2 files changed, 29 insertions, 23 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 5609211..b7b1da0 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -212,96 +212,99 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f ) : | |||
212 | if ( table->numRows() ) | 212 | if ( table->numRows() ) |
213 | a->setEnabled( TRUE ); | 213 | a->setEnabled( TRUE ); |
214 | else | 214 | else |
215 | a->setEnabled( FALSE ); | 215 | a->setEnabled( FALSE ); |
216 | 216 | ||
217 | //a->setEnabled( FALSE ); | 217 | //a->setEnabled( FALSE ); |
218 | findAction = a; | 218 | findAction = a; |
219 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); | 219 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); |
220 | 220 | ||
221 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); | 221 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); |
222 | 222 | ||
223 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); | 223 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); |
224 | 224 | ||
225 | catMenu->setCheckable( true ); | 225 | catMenu->setCheckable( true ); |
226 | populateCategories(); | 226 | populateCategories(); |
227 | 227 | ||
228 | 228 | ||
229 | completedAction->addTo( options ); | 229 | completedAction->addTo( options ); |
230 | completedAction->setOn( table->showCompleted() ); | 230 | completedAction->setOn( table->showCompleted() ); |
231 | showdeadlineAction->addTo( options ); | 231 | showdeadlineAction->addTo( options ); |
232 | showdeadlineAction->setOn( table->showDeadline() ); | 232 | showdeadlineAction->setOn( table->showDeadline() ); |
233 | options->insertSeparator( ); | 233 | options->insertSeparator( ); |
234 | QList<QWidget> list; | 234 | QList<QWidget> list; |
235 | list.append(table ); | 235 | list.append(table ); |
236 | OFontMenu *menu = new OFontMenu(this, "menu",list ); | 236 | OFontMenu *menu = new OFontMenu(this, "menu",list ); |
237 | menu->forceSize( table->horizontalHeader(), 10 ); | 237 | menu->forceSize( table->horizontalHeader(), 10 ); |
238 | //catMenu->insertItem(tr("Fonts"), menu ); | 238 | //catMenu->insertItem(tr("Fonts"), menu ); |
239 | list.clear(); | 239 | list.clear(); |
240 | options->insertItem( tr("Fonts"), menu ); | 240 | options->insertItem( tr("Fonts"), menu ); |
241 | 241 | ||
242 | 242 | ||
243 | mb->insertItem( tr( "Data" ), edit ); | 243 | mb->insertItem( tr( "Data" ), edit ); |
244 | mb->insertItem( tr( "Category" ), catMenu ); | 244 | mb->insertItem( tr( "Category" ), catMenu ); |
245 | mb->insertItem( tr( "Options"), options ); | 245 | mb->insertItem( tr( "Options"), options ); |
246 | resize( 200, 300 ); | 246 | resize( 200, 300 ); |
247 | if ( table->numRows() > 0 ) | 247 | if ( table->numRows() > 0 ) |
248 | currentEntryChanged( 0, 0 ); | 248 | currentEntryChanged( 0, 0 ); |
249 | connect( table, SIGNAL( signalEdit() ), | 249 | connect( table, SIGNAL( signalEdit() ), |
250 | this, SLOT( slotEdit() ) ); | 250 | this, SLOT( slotEdit() ) ); |
251 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), | 251 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), |
252 | this, SLOT( slotShowPopup(const QPoint &)) ); | 252 | this, SLOT( slotShowPopup(const QPoint &)) ); |
253 | 253 | ||
254 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); | 254 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); |
255 | table->updateVisible(); | 255 | table->updateVisible(); |
256 | table->setUpdatesEnabled( TRUE ); | 256 | table->setUpdatesEnabled( TRUE ); |
257 | table->setPaintingEnabled( TRUE ); | 257 | table->setPaintingEnabled( TRUE ); |
258 | table->viewport()->setUpdatesEnabled( TRUE ); | 258 | table->viewport()->setUpdatesEnabled( TRUE ); |
259 | 259 | ||
260 | // Initialize the table | ||
261 | table->updateVisible(); | ||
262 | |||
260 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); | 263 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); |
261 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); | 264 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); |
262 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); | 265 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); |
263 | connect( table, SIGNAL( currentChanged( int, int ) ), | 266 | connect( table, SIGNAL( currentChanged( int, int ) ), |
264 | this, SLOT( currentEntryChanged( int, int ) ) ); | 267 | this, SLOT( currentEntryChanged( int, int ) ) ); |
265 | 268 | ||
266 | connect( table, SIGNAL(showDetails(const ToDoEvent &) ), | 269 | connect( table, SIGNAL(showDetails(const ToDoEvent &) ), |
267 | this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); | 270 | this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); |
268 | // qDebug("done: t=%d", t.elapsed() ); | 271 | // qDebug("done: t=%d", t.elapsed() ); |
269 | } | 272 | } |
270 | 273 | ||
271 | void TodoWindow::slotNew() | 274 | void TodoWindow::slotNew() |
272 | { | 275 | { |
273 | if(syncing) { | 276 | if(syncing) { |
274 | QMessageBox::warning(this, tr("Todo"), | 277 | QMessageBox::warning(this, tr("Todo"), |
275 | tr("Can not edit data, currently syncing")); | 278 | tr("Can not edit data, currently syncing")); |
276 | return; | 279 | return; |
277 | } | 280 | } |
278 | 281 | ||
279 | int id; | 282 | int id; |
280 | id = -1; | 283 | id = -1; |
281 | QArray<int> ids; | 284 | QArray<int> ids; |
282 | ids = table->currentEntry().categories(); | 285 | ids = table->currentEntry().categories(); |
283 | if ( ids.count() ) | 286 | if ( ids.count() ) |
284 | id = ids[0]; | 287 | id = ids[0]; |
285 | NewTaskDialog e( id, this, 0, TRUE ); | 288 | NewTaskDialog e( id, this, 0, TRUE ); |
286 | 289 | ||
287 | ToDoEvent todo; | 290 | ToDoEvent todo; |
288 | 291 | ||
289 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 292 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
290 | e.showMaximized(); | 293 | e.showMaximized(); |
291 | #endif | 294 | #endif |
292 | int ret = e.exec(); | 295 | int ret = e.exec(); |
293 | // qWarning("finished" ); | 296 | // qWarning("finished" ); |
294 | if ( ret == QDialog::Accepted ) { | 297 | if ( ret == QDialog::Accepted ) { |
295 | table->setPaintingEnabled( false ); | 298 | table->setPaintingEnabled( false ); |
296 | todo = e.todoEntry(); | 299 | todo = e.todoEntry(); |
297 | //todo.assignUid(); | 300 | //todo.assignUid(); |
298 | table->addEntry( todo ); | 301 | table->addEntry( todo ); |
299 | table->setPaintingEnabled( true ); | 302 | table->setPaintingEnabled( true ); |
300 | findAction->setEnabled( TRUE ); | 303 | findAction->setEnabled( TRUE ); |
301 | } | 304 | } |
302 | // I'm afraid we must call this every time now, otherwise | 305 | // I'm afraid we must call this every time now, otherwise |
303 | // spend expensive time comparing all these strings... | 306 | // spend expensive time comparing all these strings... |
304 | populateCategories(); | 307 | populateCategories(); |
305 | mStack->raiseWidget(1 ); | 308 | mStack->raiseWidget(1 ); |
306 | } | 309 | } |
307 | 310 | ||
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index 877308a..52a3087 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp | |||
@@ -261,110 +261,107 @@ TodoTable::TodoTable( QWidget *parent, const char *name ) | |||
261 | connect( this, SIGNAL( valueChanged( int, int ) ), | 261 | connect( this, SIGNAL( valueChanged( int, int ) ), |
262 | this, SLOT( slotCheckPriority( int, int ) ) ); | 262 | this, SLOT( slotCheckPriority( int, int ) ) ); |
263 | connect( this, SIGNAL( currentChanged( int, int ) ), | 263 | connect( this, SIGNAL( currentChanged( int, int ) ), |
264 | this, SLOT( slotCurrentChanged( int, int ) ) ); | 264 | this, SLOT( slotCurrentChanged( int, int ) ) ); |
265 | 265 | ||
266 | menuTimer = new QTimer( this ); | 266 | menuTimer = new QTimer( this ); |
267 | connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); | 267 | connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); |
268 | 268 | ||
269 | mDayTimer = new QTimer( this ); | 269 | mDayTimer = new QTimer( this ); |
270 | connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) ); | 270 | connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) ); |
271 | mDay = QDate::currentDate(); | 271 | mDay = QDate::currentDate(); |
272 | } | 272 | } |
273 | 273 | ||
274 | void TodoTable::addEntry( const ToDoEvent &todo ) | 274 | void TodoTable::addEntry( const ToDoEvent &todo ) |
275 | { | 275 | { |
276 | int row = numRows(); | 276 | int row = numRows(); |
277 | setNumRows( row + 1 ); | 277 | setNumRows( row + 1 ); |
278 | updateJournal( todo, ACTION_ADD ); | 278 | updateJournal( todo, ACTION_ADD ); |
279 | insertIntoTable( new ToDoEvent(todo), row ); | 279 | insertIntoTable( new ToDoEvent(todo), row ); |
280 | setCurrentCell(row, currentColumn()); | 280 | setCurrentCell(row, currentColumn()); |
281 | updateVisible(); | 281 | updateVisible(); |
282 | } | 282 | } |
283 | 283 | ||
284 | void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) | 284 | void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) |
285 | { | 285 | { |
286 | if ( !cellGeometry( row, col ).contains(pos) ) | 286 | if ( !cellGeometry( row, col ).contains(pos) ) |
287 | return; | 287 | return; |
288 | // let's switch on the column number... | 288 | // let's switch on the column number... |
289 | switch ( col ) | 289 | switch ( col ) |
290 | { | 290 | { |
291 | case 0: { | 291 | case 0: { |
292 | CheckItem *i = static_cast<CheckItem*>(item( row, col )); | 292 | CheckItem *i = static_cast<CheckItem*>(item( row, col )); |
293 | if ( i ) { | 293 | if ( i ) { |
294 | int x = pos.x() - columnPos( col ); | 294 | int x = pos.x() - columnPos( col ); |
295 | int y = pos.y() - rowPos( row ); | 295 | int y = pos.y() - rowPos( row ); |
296 | int w = columnWidth( col ); | 296 | int w = columnWidth( col ); |
297 | int h = rowHeight( row ); | 297 | int h = rowHeight( row ); |
298 | if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && | 298 | if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && |
299 | y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { | 299 | y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { |
300 | i->toggle(); | 300 | i->toggle(); |
301 | } | 301 | } |
302 | emit signalDoneChanged( i->isChecked() ); | 302 | emit signalDoneChanged( i->isChecked() ); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | break; | 305 | break; |
306 | case 1: | 306 | case 1: |
307 | break; | 307 | break; |
308 | case 2: | 308 | case 2: |
309 | // may as well edit it... | ||
310 | // menuTimer->stop(); | ||
311 | // emit signalEdit(); | ||
312 | // Show detailed view of the selected entry | 309 | // Show detailed view of the selected entry |
313 | { | 310 | { |
314 | menuTimer->stop(); | 311 | menuTimer->stop(); |
315 | ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))]; | 312 | ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))]; |
316 | emit showDetails( *todo ); | 313 | emit showDetails( *todo ); |
317 | } | 314 | } |
318 | break; | 315 | break; |
319 | case 3: | 316 | case 3: |
320 | // may as well edit it... | 317 | // may as well edit it... |
321 | menuTimer->stop(); | 318 | menuTimer->stop(); |
322 | // emit signalEdit(); | 319 | emit signalEdit(); |
323 | break; | 320 | break; |
324 | } | 321 | } |
325 | } | 322 | } |
326 | 323 | ||
327 | void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) | 324 | void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) |
328 | { | 325 | { |
329 | if ( col == 2 && cellGeometry( row, col ).contains(pos) ) | 326 | if ( col == 2 && cellGeometry( row, col ).contains(pos) ) |
330 | menuTimer->start( 750, TRUE ); | 327 | menuTimer->start( 750, TRUE ); |
331 | } | 328 | } |
332 | 329 | ||
333 | void TodoTable::slotShowMenu() | 330 | void TodoTable::slotShowMenu() |
334 | { | 331 | { |
335 | emit signalShowMenu( QCursor::pos() ); | 332 | emit signalShowMenu( QCursor::pos() ); |
336 | } | 333 | } |
337 | 334 | ||
338 | void TodoTable::slotCurrentChanged( int, int ) | 335 | void TodoTable::slotCurrentChanged( int, int ) |
339 | { | 336 | { |
340 | menuTimer->stop(); | 337 | menuTimer->stop(); |
341 | } | 338 | } |
342 | 339 | ||
343 | void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) | 340 | void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) |
344 | { | 341 | { |
345 | setNumRows( list.count() ); | 342 | setNumRows( list.count() ); |
346 | int row = 0; | 343 | int row = 0; |
347 | ToDoEvent *it; | 344 | ToDoEvent *it; |
348 | for ( it = list.first(); it; it = list.next() ) | 345 | for ( it = list.first(); it; it = list.next() ) |
349 | insertIntoTable( it, row++ ); | 346 | insertIntoTable( it, row++ ); |
350 | } | 347 | } |
351 | 348 | ||
352 | 349 | ||
353 | ToDoEvent TodoTable::currentEntry() const | 350 | ToDoEvent TodoTable::currentEntry() const |
354 | { | 351 | { |
355 | //qWarning ("in currentEntry\n"); | 352 | //qWarning ("in currentEntry\n"); |
356 | 353 | ||
357 | QTableItem *i = item( currentRow(), 0 ); | 354 | QTableItem *i = item( currentRow(), 0 ); |
358 | if ( !i || rowHeight( currentRow() ) <= 0 ) | 355 | if ( !i || rowHeight( currentRow() ) <= 0 ) |
359 | return ToDoEvent(); | 356 | return ToDoEvent(); |
360 | ToDoEvent *todo = todoList[(CheckItem*)i]; | 357 | ToDoEvent *todo = todoList[(CheckItem*)i]; |
361 | todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); | 358 | todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); |
362 | todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); | 359 | todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); |
363 | return *todo; | 360 | return *todo; |
364 | } | 361 | } |
365 | 362 | ||
366 | void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) | 363 | void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) |
367 | { | 364 | { |
368 | int row = currentRow(); | 365 | int row = currentRow(); |
369 | updateJournal( todo, ACTION_REPLACE); | 366 | updateJournal( todo, ACTION_REPLACE); |
370 | 367 | ||
@@ -614,117 +611,123 @@ void TodoTable::loadFile( const QString &/*we use the standard*/ ) | |||
614 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) | 611 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) |
615 | { | 612 | { |
616 | QString strTodo; | 613 | QString strTodo; |
617 | strTodo = todo.description().left(40).simplifyWhiteSpace(); | 614 | strTodo = todo.description().left(40).simplifyWhiteSpace(); |
618 | if ( row == -1 ) { | 615 | if ( row == -1 ) { |
619 | QMapIterator<CheckItem*, ToDoEvent *> it; | 616 | QMapIterator<CheckItem*, ToDoEvent *> it; |
620 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { | 617 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { |
621 | if ( *(*it) == todo ) { | 618 | if ( *(*it) == todo ) { |
622 | row = it.key()->row(); | 619 | row = it.key()->row(); |
623 | it.key()->setChecked( todo.isCompleted() ); | 620 | it.key()->setChecked( todo.isCompleted() ); |
624 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 621 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
625 | item( row, 2 )->setText( strTodo ); | 622 | item( row, 2 )->setText( strTodo ); |
626 | 623 | ||
627 | if (showDeadl){ | 624 | if (showDeadl){ |
628 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 625 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
629 | } | 626 | } |
630 | 627 | ||
631 | *(*it) = todo; | 628 | *(*it) = todo; |
632 | } | 629 | } |
633 | } | 630 | } |
634 | } else { | 631 | } else { |
635 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; | 632 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; |
636 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); | 633 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); |
637 | delete t; | 634 | delete t; |
638 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); | 635 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); |
639 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 636 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
640 | item( row, 2 )->setText( strTodo ); | 637 | item( row, 2 )->setText( strTodo ); |
641 | 638 | ||
642 | if (showDeadl){ | 639 | if (showDeadl){ |
643 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 640 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
644 | } | 641 | } |
645 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); | 642 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); |
646 | } | 643 | } |
647 | } | 644 | } |
648 | 645 | ||
649 | void TodoTable::journalFreeRemoveEntry( int row ) | 646 | void TodoTable::journalFreeRemoveEntry( int row ) |
650 | { | 647 | { |
651 | CheckItem *chk; | 648 | CheckItem *chk; |
652 | chk = static_cast<CheckItem*>(item(row, 0 )); | 649 | chk = static_cast<CheckItem*>(item(row, 0 )); |
653 | if ( !chk ) | 650 | if ( !chk ) |
654 | return; | 651 | return; |
655 | todoList.remove( chk ); | 652 | todoList.remove( chk ); |
656 | 653 | ||
657 | realignTable( row ); | 654 | realignTable( row ); |
658 | } | 655 | } |
659 | 656 | ||
660 | void TodoTable::keyPressEvent( QKeyEvent *e ) | 657 | void TodoTable::keyPressEvent( QKeyEvent *e ) |
661 | { | 658 | { |
662 | if ( e->key() == Key_Space || e->key() == Key_Return ) { | 659 | if ( e->key() == Key_Space || e->key() == Key_Return ) { |
663 | switch ( currentColumn() ) { | 660 | switch ( currentColumn() ) { |
664 | case 0: { | 661 | case 0: { |
665 | CheckItem *i = static_cast<CheckItem*>(item(currentRow(), | 662 | CheckItem *i = static_cast<CheckItem*>(item(currentRow(), |
666 | currentColumn())); | 663 | currentColumn())); |
667 | if ( i ) | 664 | if ( i ) |
668 | i->toggle(); | 665 | i->toggle(); |
669 | break; | 666 | break; |
670 | } | 667 | } |
671 | case 1: | 668 | case 1: |
672 | break; | 669 | break; |
673 | case 2: | 670 | case 2:{ |
674 | emit signalEdit(); | 671 | ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(currentRow(), 0))]; |
675 | default: | 672 | emit showDetails(*todo); |
676 | break; | 673 | break; |
677 | } | 674 | } |
678 | } else { | 675 | case 3: |
679 | QTable::keyPressEvent( e ); | 676 | // Future: Let us change the dueDate directly... |
680 | } | 677 | emit signalEdit(); |
678 | default: | ||
679 | break; | ||
680 | } | ||
681 | } else | ||
682 | QTable::keyPressEvent( e ); | ||
681 | } | 683 | } |
682 | 684 | ||
685 | |||
683 | QStringList TodoTable::categories() | 686 | QStringList TodoTable::categories() |
684 | { | 687 | { |
685 | // This is called seldom, so calling a load in here | 688 | // This is called seldom, so calling a load in here |
686 | // should be fine. | 689 | // should be fine. |
687 | mCat.load( categoryFileName() ); | 690 | mCat.load( categoryFileName() ); |
688 | QStringList categoryList = mCat.labels( "Todo List" ); | 691 | QStringList categoryList = mCat.labels( "Todo List" ); |
689 | return categoryList; | 692 | return categoryList; |
690 | } | 693 | } |
691 | 694 | ||
692 | void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, | 695 | void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, |
693 | bool backwards, int category ) | 696 | bool backwards, int category ) |
694 | { | 697 | { |
695 | // we have to iterate through the table, this gives the illusion that | 698 | // we have to iterate through the table, this gives the illusion that |
696 | // sorting is actually being used. | 699 | // sorting is actually being used. |
697 | if ( currFindRow < -1 ) | 700 | if ( currFindRow < -1 ) |
698 | currFindRow = currentRow() - 1; | 701 | currFindRow = currentRow() - 1; |
699 | clearSelection( TRUE ); | 702 | clearSelection( TRUE ); |
700 | int rows, | 703 | int rows, |
701 | row; | 704 | row; |
702 | CheckItem *chk; | 705 | CheckItem *chk; |
703 | QRegExp r( findString ); | 706 | QRegExp r( findString ); |
704 | 707 | ||
705 | r.setCaseSensitive( caseSensitive ); | 708 | r.setCaseSensitive( caseSensitive ); |
706 | rows = numRows(); | 709 | rows = numRows(); |
707 | static bool wrapAround = true; | 710 | static bool wrapAround = true; |
708 | 711 | ||
709 | if ( !backwards ) { | 712 | if ( !backwards ) { |
710 | for ( row = currFindRow + 1; row < rows; row++ ) { | 713 | for ( row = currFindRow + 1; row < rows; row++ ) { |
711 | chk = static_cast<CheckItem*>( item(row, 0) ); | 714 | chk = static_cast<CheckItem*>( item(row, 0) ); |
712 | if ( taskCompare(*(todoList[chk]), r, category) ) | 715 | if ( taskCompare(*(todoList[chk]), r, category) ) |
713 | break; | 716 | break; |
714 | } | 717 | } |
715 | } else { | 718 | } else { |
716 | for ( row = currFindRow - 1; row > -1; row-- ) { | 719 | for ( row = currFindRow - 1; row > -1; row-- ) { |
717 | chk = static_cast<CheckItem*>( item(row, 0) ); | 720 | chk = static_cast<CheckItem*>( item(row, 0) ); |
718 | if ( taskCompare(*(todoList[chk]), r, category) ) | 721 | if ( taskCompare(*(todoList[chk]), r, category) ) |
719 | break; | 722 | break; |
720 | } | 723 | } |
721 | } | 724 | } |
722 | if ( row >= rows || row < 0 ) { | 725 | if ( row >= rows || row < 0 ) { |
723 | if ( row < 0 ) | 726 | if ( row < 0 ) |
724 | currFindRow = rows; | 727 | currFindRow = rows; |
725 | else | 728 | else |
726 | currFindRow = -1; | 729 | currFindRow = -1; |
727 | if ( wrapAround ) | 730 | if ( wrapAround ) |
728 | emit signalWrapAround(); | 731 | emit signalWrapAround(); |
729 | else | 732 | else |
730 | emit signalNotFound(); | 733 | emit signalNotFound(); |