Diffstat (limited to 'core/pim/todo/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 106 |
1 files changed, 87 insertions, 19 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index b5cace9..883d78c 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp @@ -115,89 +115,129 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : table->setShowDeadline (showdeadline); QString category = config.readEntry( "Category", QString::null ); table->setShowCategory( category ); QPEToolBar *bar = new QPEToolBar( this ); bar->setHorizontalStretchable( TRUE ); QPEMenuBar *mb = new QPEMenuBar( bar ); catMenu = new QPopupMenu( this ); QPopupMenu *edit = new QPopupMenu( this ); + QPopupMenu *options = new QPopupMenu(this ); + contextMenu = new QPopupMenu( this ); bar = new QPEToolBar( this ); QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); a->addTo( bar ); a->addTo( edit ); - a = new QAction( tr( "Edit" ), Resource::loadIconSet( "edit" ), + a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); a->addTo( bar ); a->addTo( edit ); a->addTo( contextMenu ); a->setEnabled( FALSE ); editAction = a; + edit->insertSeparator(); - a = new QAction( tr( "Delete" ), Resource::loadIconSet( "trash" ), + a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); a->addTo( bar ); a->addTo( edit ); a->addTo( contextMenu ); a->setEnabled( FALSE ); deleteAction = a; + // delete All in category is missing.... + // set All Done + // set All Done in category + + a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 ); + connect(a, SIGNAL( activated() ), + this, SLOT( slotDeleteAll() ) ); + a->addTo(edit ); + a->setEnabled( FALSE ); + deleteAllAction = a; + + edit->insertSeparator(); + a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); + connect(a, SIGNAL( activated() ), + this, SLOT( slotDuplicate() ) ); + a->addTo(edit ); + a->setEnabled( FALSE ); + duplicateAction = a; + + edit->insertSeparator(); if ( Ir::supported() ) { a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); a->addTo( edit ); a->addTo( bar ); } a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); a->addTo( bar ); - a->addTo( edit ); + a->addTo( options ); + options->insertSeparator(); + if ( table->numRows() ) a->setEnabled( TRUE ); else a->setEnabled( FALSE ); //a->setEnabled( FALSE ); findAction = a; // qDebug("mainwindow #2: t=%d", t.elapsed() ); completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); catMenu->setCheckable( true ); populateCategories(); - mb->insertItem( tr( "Data" ), edit ); - mb->insertItem( tr( "View" ), catMenu ); + + 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 ); @@ -270,24 +310,48 @@ void TodoWindow::slotDelete() table->setPaintingEnabled( false ); table->removeCurrentEntry(); table->setPaintingEnabled( true ); if ( table->numRows() == 0 ) { currentEntryChanged( -1, 0 ); findAction->setEnabled( FALSE ); } } +void TodoWindow::slotDeleteAll() +{ + if(syncing) { + QMessageBox::warning(this, tr("Todo"), + tr("Can not edit data, currently syncing")); + return; + } + + //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); + + if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Should I delete all tasks?") ) ) + return; + + + + table->setPaintingEnabled( false ); + table->removeAllEntries(); + table->setPaintingEnabled( true ); + + if ( table->numRows() == 0 ) { + currentEntryChanged( -1, 0 ); + findAction->setEnabled( FALSE ); + } +} void TodoWindow::slotEdit() { if(syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } ToDoEvent todo = table->currentEntry(); NewTaskDialog e( todo, this, 0, TRUE ); @@ -298,47 +362,63 @@ void TodoWindow::slotEdit() #endif int ret = e.exec(); if ( ret == QDialog::Accepted ) { table->setPaintingEnabled( false ); todo = e.todoEntry(); table->replaceCurrentEntry( todo ); table->setPaintingEnabled( true ); } populateCategories(); } - +void TodoWindow::slotDuplicate() +{ + if(syncing) { + QMessageBox::warning(this, tr("Todo"), + tr("Can not edit data, currently syncing")); + return; + } + ToDoEvent ev = table->currentEntry(); + ToDoEvent ev2 = ToDoEvent( ev ); + table->setPaintingEnabled( false ); + table->addEntry( ev2 ); + table->setPaintingEnabled( true ); +} void TodoWindow::slotShowPopup( const QPoint &p ) { contextMenu->popup( p ); } void TodoWindow::showCompleted( bool s ) { if ( !table->isUpdatesEnabled() ) return; table->setPaintingEnabled( false ); table->setShowCompleted( s ); table->setPaintingEnabled( true ); } void TodoWindow::currentEntryChanged( int r, int ) { if ( r != -1 && table->rowHeight( r ) > 0 ) { editAction->setEnabled( TRUE ); deleteAction->setEnabled( TRUE ); + duplicateAction->setEnabled( TRUE ); + deleteAllAction->setEnabled( TRUE ); } else { editAction->setEnabled( FALSE ); deleteAction->setEnabled( FALSE ); + duplicateAction->setEnabled( FALSE ); + deleteAllAction->setEnabled( FALSE ); } } void TodoWindow::setCategory( int c ) { if ( c <= 0 ) return; if ( !table->isUpdatesEnabled() ) return; table->setPaintingEnabled( false ); for ( unsigned int i = 1; i < catMenu->count(); i++ ) catMenu->setItemChecked( i, c == (int)i ); if ( c == 1 ) { @@ -349,40 +429,28 @@ void TodoWindow::setCategory( int c ) setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); } else { QString cat = table->categories()[c - 2]; table->setShowCategory( cat ); setCaption( tr("Todo") + " - " + cat ); } table->setPaintingEnabled( true ); } void TodoWindow::populateCategories() { catMenu->clear(); - - QList<QWidget> list; - list.append(table ); - OFontMenu *menu = new OFontMenu(this, "menu",list ); - menu->forceSize( table->horizontalHeader(), 10 ); - catMenu->insertItem(tr("Fonts"), menu ); - - completedAction->addTo( catMenu ); - completedAction->setOn( table->showCompleted() ); - showdeadlineAction->addTo( catMenu ); - showdeadlineAction->setOn( table->showDeadline() ); - catMenu->insertSeparator(); int id, rememberId; id = 1; catMenu->insertItem( tr( "All Categories" ), id++ ); -// catMenu->insertSeparator(); + catMenu->insertSeparator(); QStringList categories = table->categories(); categories.append( tr( "Unfiled" ) ); for ( QStringList::Iterator it = categories.begin(); it != categories.end(); ++it ) { catMenu->insertItem( *it, id ); if ( *it == table->showCategory() ) rememberId = id; ++id; } if ( table->showCategory().isEmpty() ) setCategory( 1 ); else |