-rw-r--r-- | core/pim/todo/mainwindow.cpp | 68 |
1 files changed, 59 insertions, 9 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index fc17c5f..d3f4cb4 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp @@ -1,6 +1,6 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. - Copyright (C) 2002 zecke - Copyright (C) 2002 Stefan Eilers +** Copyright (C) 2002 zecke +** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de) ** ** This file is part of Qtopia Environment. @@ -26,4 +26,5 @@ #include "todoentryimpl.h" #include "todotable.h" +#include "todolabel.h" #include <opie/tododb.h> @@ -49,4 +50,5 @@ #include <qmessagebox.h> #include <qpopupmenu.h> +#include <qwidgetstack.h> #include <sys/stat.h> @@ -72,5 +74,6 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : // QTime t; // t.start(); - + mView = 0l; + mStack = new QWidgetStack(this, "main stack"); setCaption( tr("Todo") ); QString str; @@ -102,5 +105,7 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : "before you enter any data") ); - setCentralWidget( table ); + mStack->addWidget(table, 1 ); + mStack->raiseWidget( 1 ); + setCentralWidget( mStack ); setToolBarsMovable( FALSE ); @@ -147,4 +152,11 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : a->setEnabled( FALSE ); editAction = a; + + a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); + a->addTo( edit ); + a->addTo( contextMenu ); + connect( a, SIGNAL( activated() ), + this, SLOT(slotShowDetails() ) ); + edit->insertSeparator(); @@ -177,6 +189,8 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : a->setEnabled( FALSE ); duplicateAction = a; - edit->insertSeparator(); + + + if ( Ir::supported() ) { a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), @@ -250,4 +264,6 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : this, SLOT( currentEntryChanged( int, int ) ) ); + connect( table, SIGNAL(showDetails(const ToDoEvent &) ), + this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); // qDebug("done: t=%d", t.elapsed() ); } @@ -287,4 +303,5 @@ void TodoWindow::slotNew() // spend expensive time comparing all these strings... populateCategories(); + mStack->raiseWidget(1 ); } @@ -319,4 +336,5 @@ void TodoWindow::slotDelete() findAction->setEnabled( FALSE ); } + mStack->raiseWidget(1); } void TodoWindow::slotDeleteAll() @@ -330,5 +348,5 @@ void TodoWindow::slotDeleteAll() //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); - if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Should I delete all tasks?") ) ) + if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) return; @@ -343,4 +361,5 @@ void TodoWindow::slotDeleteAll() findAction->setEnabled( FALSE ); } + mStack->raiseWidget(1 ); } @@ -370,5 +389,5 @@ void TodoWindow::slotEdit() } populateCategories(); - + mStack->raiseWidget( 1 ); } void TodoWindow::slotDuplicate() @@ -380,8 +399,17 @@ void TodoWindow::slotDuplicate() } ToDoEvent ev = table->currentEntry(); - ToDoEvent ev2 = ToDoEvent( ev ); + ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid + int uid; + { // uid + Qtopia::UidGen *uidgen = new Qtopia::UidGen(); + uid = uidgen->generate(); + delete uidgen; + } + ev2.setUid( uid ); table->setPaintingEnabled( false ); table->addEntry( ev2 ); table->setPaintingEnabled( true ); + + mStack->raiseWidget( 1 ); } void TodoWindow::slotShowPopup( const QPoint &p ) @@ -434,4 +462,6 @@ void TodoWindow::setCategory( int c ) } table->setPaintingEnabled( true ); + + mStack->raiseWidget( 1 ); } @@ -441,4 +471,5 @@ void TodoWindow::populateCategories() int id, rememberId; id = 1; + rememberId = 0; catMenu->insertItem( tr( "All Categories" ), id++ ); catMenu->insertSeparator(); @@ -473,4 +504,9 @@ void TodoWindow::flush() void TodoWindow::closeEvent( QCloseEvent *e ) { + if( mStack->visibleWidget() != table ){ + mStack->raiseWidget( 1 ); + e->ignore(); + return; + } if(syncing) { /* no need to save if in the middle of syncing */ @@ -563,5 +599,4 @@ void TodoWindow::beamDone( Ir *ir ) } -/* added 20.01.2k2 by se */ void TodoWindow::showDeadline( bool s ) { @@ -570,2 +605,17 @@ void TodoWindow::showDeadline( bool s ) table->setPaintingEnabled( true ); } +void TodoWindow::slotShowDetails() +{ + ToDoEvent event = table->currentEntry(); + slotShowDetails( event ); +} +void TodoWindow::slotShowDetails( const ToDoEvent &event ) +{ + if( mView == 0l ){ + mView = new TodoLabel(mStack); + mStack->addWidget( mView, 2 ); + } + mView->init( event ); + mView->sync(); + mStack->raiseWidget( 2); +} |