summaryrefslogtreecommitdiff
path: root/core/pim/todo
Unidiff
Diffstat (limited to 'core/pim/todo') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp3
-rw-r--r--core/pim/todo/todotable.cpp49
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
@@ -236,48 +236,51 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f ) :
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
271void TodoWindow::slotNew() 274void 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() )
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
@@ -285,62 +285,59 @@ 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
327void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) 324void 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
333void TodoTable::slotShowMenu() 330void TodoTable::slotShowMenu()
334{ 331{
335 emit signalShowMenu( QCursor::pos() ); 332 emit signalShowMenu( QCursor::pos() );
336} 333}
337 334
338void TodoTable::slotCurrentChanged( int, int ) 335void TodoTable::slotCurrentChanged( int, int )
339{ 336{
340 menuTimer->stop(); 337 menuTimer->stop();
341} 338}
342 339
343void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) 340void TodoTable::internalAddEntries( QList<ToDoEvent> &list )
344{ 341{
345 setNumRows( list.count() ); 342 setNumRows( list.count() );
346 int row = 0; 343 int row = 0;
@@ -638,69 +635,75 @@ void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row )
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
649void TodoTable::journalFreeRemoveEntry( int row ) 646void 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
660void TodoTable::keyPressEvent( QKeyEvent *e ) 657void 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
683QStringList TodoTable::categories() 686QStringList 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
692void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, 695void 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();