-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 @@ -228,64 +228,67 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f ) : completedAction->addTo( options ); completedAction->setOn( table->showCompleted() ); showdeadlineAction->addTo( options ); showdeadlineAction->setOn( table->showDeadline() ); options->insertSeparator( ); QList<QWidget> list; list.append(table ); OFontMenu *menu = new OFontMenu(this, "menu",list ); menu->forceSize( table->horizontalHeader(), 10 ); //catMenu->insertItem(tr("Fonts"), menu ); list.clear(); options->insertItem( tr("Fonts"), menu ); mb->insertItem( tr( "Data" ), edit ); mb->insertItem( tr( "Category" ), catMenu ); mb->insertItem( tr( "Options"), options ); resize( 200, 300 ); if ( table->numRows() > 0 ) currentEntryChanged( 0, 0 ); connect( table, SIGNAL( signalEdit() ), this, SLOT( slotEdit() ) ); connect( table, SIGNAL(signalShowMenu(const QPoint &)), this, SLOT( slotShowPopup(const QPoint &)) ); // qDebug("mainwindow #3: t=%d", t.elapsed() ); table->updateVisible(); table->setUpdatesEnabled( TRUE ); table->setPaintingEnabled( TRUE ); table->viewport()->setUpdatesEnabled( TRUE ); + // Initialize the table + table->updateVisible(); + connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); connect( table, SIGNAL( currentChanged( int, int ) ), this, SLOT( currentEntryChanged( int, int ) ) ); connect( table, SIGNAL(showDetails(const ToDoEvent &) ), this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); // qDebug("done: t=%d", t.elapsed() ); } void TodoWindow::slotNew() { if(syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } int id; id = -1; QArray<int> ids; ids = table->currentEntry().categories(); if ( ids.count() ) id = ids[0]; NewTaskDialog e( id, this, 0, TRUE ); ToDoEvent todo; #if defined(Q_WS_QWS) || defined(_WS_QWS_) e.showMaximized(); #endif 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 @@ -277,78 +277,75 @@ void TodoTable::addEntry( const ToDoEvent &todo ) setNumRows( row + 1 ); updateJournal( todo, ACTION_ADD ); insertIntoTable( new ToDoEvent(todo), row ); setCurrentCell(row, currentColumn()); updateVisible(); } void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) { if ( !cellGeometry( row, col ).contains(pos) ) return; // let's switch on the column number... switch ( col ) { case 0: { CheckItem *i = static_cast<CheckItem*>(item( row, col )); if ( i ) { int x = pos.x() - columnPos( col ); int y = pos.y() - rowPos( row ); int w = columnWidth( col ); int h = rowHeight( row ); if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { i->toggle(); } emit signalDoneChanged( i->isChecked() ); } } break; case 1: break; case 2: - // may as well edit it... - // menuTimer->stop(); - // emit signalEdit(); // Show detailed view of the selected entry { menuTimer->stop(); ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))]; emit showDetails( *todo ); } break; case 3: // may as well edit it... menuTimer->stop(); - // emit signalEdit(); + emit signalEdit(); break; } } void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) { if ( col == 2 && cellGeometry( row, col ).contains(pos) ) menuTimer->start( 750, TRUE ); } void TodoTable::slotShowMenu() { emit signalShowMenu( QCursor::pos() ); } void TodoTable::slotCurrentChanged( int, int ) { menuTimer->stop(); } void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) { setNumRows( list.count() ); int row = 0; ToDoEvent *it; for ( it = list.first(); it; it = list.next() ) insertIntoTable( it, row++ ); } ToDoEvent TodoTable::currentEntry() const { @@ -630,85 +627,91 @@ void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) *(*it) = todo; } } } else { ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); delete t; static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); item( row, 2 )->setText( strTodo ); if (showDeadl){ static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); } todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); } } void TodoTable::journalFreeRemoveEntry( int row ) { CheckItem *chk; chk = static_cast<CheckItem*>(item(row, 0 )); if ( !chk ) return; todoList.remove( chk ); realignTable( row ); } void TodoTable::keyPressEvent( QKeyEvent *e ) { - if ( e->key() == Key_Space || e->key() == Key_Return ) { - switch ( currentColumn() ) { - case 0: { - CheckItem *i = static_cast<CheckItem*>(item(currentRow(), - currentColumn())); - if ( i ) - i->toggle(); - break; - } - case 1: - break; - case 2: - emit signalEdit(); - default: - break; - } - } else { - QTable::keyPressEvent( e ); - } + if ( e->key() == Key_Space || e->key() == Key_Return ) { + switch ( currentColumn() ) { + case 0: { + CheckItem *i = static_cast<CheckItem*>(item(currentRow(), + currentColumn())); + if ( i ) + i->toggle(); + break; + } + case 1: + break; + case 2:{ + ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(currentRow(), 0))]; + emit showDetails(*todo); + break; + } + case 3: + // Future: Let us change the dueDate directly... + emit signalEdit(); + default: + break; + } + } else + QTable::keyPressEvent( e ); } + QStringList TodoTable::categories() { // This is called seldom, so calling a load in here // should be fine. mCat.load( categoryFileName() ); QStringList categoryList = mCat.labels( "Todo List" ); return categoryList; } void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, bool backwards, int category ) { // we have to iterate through the table, this gives the illusion that // sorting is actually being used. if ( currFindRow < -1 ) currFindRow = currentRow() - 1; clearSelection( TRUE ); int rows, row; CheckItem *chk; QRegExp r( findString ); r.setCaseSensitive( caseSensitive ); rows = numRows(); static bool wrapAround = true; if ( !backwards ) { for ( row = currFindRow + 1; row < rows; row++ ) { chk = static_cast<CheckItem*>( item(row, 0) ); if ( taskCompare(*(todoList[chk]), r, category) ) break; } |