Diffstat (limited to 'core/pim/todo/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-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,8 +1,8 @@ /********************************************************************** ** 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. ** ** This file may be distributed and/or modified under the terms of the @@ -24,8 +24,9 @@ #include "mainwindow.h" #include "todoentryimpl.h" #include "todotable.h" +#include "todolabel.h" #include <opie/tododb.h> #include <opie/todovcalresource.h> #include <opie/ofontmenu.h> @@ -47,8 +48,9 @@ #include <qdatetime.h> #include <qfile.h> #include <qmessagebox.h> #include <qpopupmenu.h> +#include <qwidgetstack.h> #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> @@ -70,9 +72,10 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : QMainWindow( parent, name, f ), syncing(FALSE) { // QTime t; // t.start(); - + mView = 0l; + mStack = new QWidgetStack(this, "main stack"); setCaption( tr("Todo") ); QString str; table = new TodoTable( this ); table->setColumnWidth( 2, 10 ); @@ -100,9 +103,11 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : tr( "Unable to create startup files\n" "Free up some space\n" "before you enter any data") ); - setCentralWidget( table ); + mStack->addWidget(table, 1 ); + mStack->raiseWidget( 1 ); + setCentralWidget( mStack ); setToolBarsMovable( FALSE ); // qDebug("after load: t=%d", t.elapsed() ); @@ -145,8 +150,15 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : a->addTo( edit ); a->addTo( contextMenu ); 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(); a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), QString::null, 0, this, 0 ); @@ -175,10 +187,12 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : 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() ), @@ -248,8 +262,10 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : 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() @@ -285,8 +301,9 @@ void TodoWindow::slotNew() } // I'm afraid we must call this every time now, otherwise // spend expensive time comparing all these strings... populateCategories(); + mStack->raiseWidget(1 ); } TodoWindow::~TodoWindow() { @@ -317,8 +334,9 @@ void TodoWindow::slotDelete() if ( table->numRows() == 0 ) { currentEntryChanged( -1, 0 ); findAction->setEnabled( FALSE ); } + mStack->raiseWidget(1); } void TodoWindow::slotDeleteAll() { if(syncing) { @@ -328,9 +346,9 @@ 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; @@ -341,8 +359,9 @@ void TodoWindow::slotDeleteAll() if ( table->numRows() == 0 ) { currentEntryChanged( -1, 0 ); findAction->setEnabled( FALSE ); } + mStack->raiseWidget(1 ); } void TodoWindow::slotEdit() { @@ -368,9 +387,9 @@ void TodoWindow::slotEdit() table->replaceCurrentEntry( todo ); table->setPaintingEnabled( true ); } populateCategories(); - + mStack->raiseWidget( 1 ); } void TodoWindow::slotDuplicate() { if(syncing) { @@ -378,12 +397,21 @@ void TodoWindow::slotDuplicate() tr("Can not edit data, currently syncing")); return; } 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 ) { contextMenu->popup( p ); @@ -432,15 +460,18 @@ void TodoWindow::setCategory( int c ) table->setShowCategory( cat ); setCaption( tr("Todo") + " - " + cat ); } table->setPaintingEnabled( true ); + + mStack->raiseWidget( 1 ); } void TodoWindow::populateCategories() { catMenu->clear(); int id, rememberId; id = 1; + rememberId = 0; catMenu->insertItem( tr( "All Categories" ), id++ ); catMenu->insertSeparator(); QStringList categories = table->categories(); categories.append( tr( "Unfiled" ) ); @@ -471,8 +502,13 @@ 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 */ e->accept(); return; @@ -561,11 +597,25 @@ void TodoWindow::beamDone( Ir *ir ) delete ir; unlink( beamfile ); } -/* added 20.01.2k2 by se */ void TodoWindow::showDeadline( bool s ) { table->setPaintingEnabled( false ); table->setShowDeadline( 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); +} |