summaryrefslogtreecommitdiff
path: root/core/pim/todo/mainwindow.cpp
authorzecke <zecke>2002-04-23 12:45:20 (UTC)
committer zecke <zecke>2002-04-23 12:45:20 (UTC)
commite25c5384f3f3025be64ed26d244c59afc5862711 (patch) (side-by-side diff)
tree603f32b0550ecda9cbe95a93807a2a89b32cabcd /core/pim/todo/mainwindow.cpp
parent367304a610dd618ad45ddce8256ba4d7d8ded442 (diff)
downloadopie-e25c5384f3f3025be64ed26d244c59afc5862711.zip
opie-e25c5384f3f3025be64ed26d244c59afc5862711.tar.gz
opie-e25c5384f3f3025be64ed26d244c59afc5862711.tar.bz2
Patch from Stefan Eilers for overview
merged by hand
Diffstat (limited to 'core/pim/todo/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp68
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,10 +1,10 @@
/**********************************************************************
** 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
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
@@ -22,12 +22,13 @@
#define QTOPIA_INTERNAL_FD
#include "mainwindow.h"
#include "todoentryimpl.h"
#include "todotable.h"
+#include "todolabel.h"
#include <opie/tododb.h>
#include <opie/todovcalresource.h>
#include <opie/ofontmenu.h>
#include <qpe/qpeapplication.h>
@@ -45,12 +46,13 @@
#include <qarray.h>
#include <qdatastream.h>
#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>
#include <unistd.h>
@@ -68,13 +70,14 @@ static QString categoriesXMLFilename()
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 );
table->setPaintingEnabled( FALSE );
table->setUpdatesEnabled( FALSE );
@@ -98,13 +101,15 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
QMessageBox::critical( this,
tr( "Out of Space" ),
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() );
Config config( "todo" );
config.setGroup( "View" );
@@ -143,12 +148,19 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
this, SLOT( slotEdit() ) );
a->addTo( bar );
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 );
connect( a, SIGNAL( activated() ),
this, SLOT( slotDelete() ) );
@@ -173,14 +185,16 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
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 );
@@ -246,12 +260,14 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
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) {
@@ -283,12 +299,13 @@ void TodoWindow::slotNew()
table->setPaintingEnabled( true );
findAction->setEnabled( TRUE );
}
// I'm afraid we must call this every time now, otherwise
// spend expensive time comparing all these strings...
populateCategories();
+ mStack->raiseWidget(1 );
}
TodoWindow::~TodoWindow()
{
}
@@ -315,36 +332,38 @@ void TodoWindow::slotDelete()
table->setPaintingEnabled( true );
if ( table->numRows() == 0 ) {
currentEntryChanged( -1, 0 );
findAction->setEnabled( FALSE );
}
+ mStack->raiseWidget(1);
}
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?") ) )
+ if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) )
return;
table->setPaintingEnabled( false );
table->removeAllEntries();
table->setPaintingEnabled( true );
if ( table->numRows() == 0 ) {
currentEntryChanged( -1, 0 );
findAction->setEnabled( FALSE );
}
+ mStack->raiseWidget(1 );
}
void TodoWindow::slotEdit()
{
if(syncing) {
QMessageBox::warning(this, tr("Todo"),
@@ -366,26 +385,35 @@ void TodoWindow::slotEdit()
table->setPaintingEnabled( false );
todo = e.todoEntry();
table->replaceCurrentEntry( todo );
table->setPaintingEnabled( true );
}
populateCategories();
-
+ mStack->raiseWidget( 1 );
}
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 );
+ 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 );
}
@@ -430,19 +458,22 @@ void TodoWindow::setCategory( int c )
} else {
QString cat = table->categories()[c - 2];
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" ) );
for ( QStringList::Iterator it = categories.begin();
it != categories.end(); ++it ) {
@@ -469,12 +500,17 @@ void TodoWindow::flush()
syncing = TRUE;
table->save( todolistXMLFilename() );
}
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;
}
@@ -559,13 +595,27 @@ void TodoWindow::slotBeam()
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);
+}