author | zecke <zecke> | 2002-04-23 12:45:20 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-23 12:45:20 (UTC) |
commit | e25c5384f3f3025be64ed26d244c59afc5862711 (patch) (unidiff) | |
tree | 603f32b0550ecda9cbe95a93807a2a89b32cabcd /core/pim/todo/mainwindow.cpp | |
parent | 367304a610dd618ad45ddce8256ba4d7d8ded442 (diff) | |
download | opie-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.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,7 +1,7 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | Copyright (C) 2002 zecke | 3 | ** Copyright (C) 2002 zecke |
4 | Copyright (C) 2002 Stefan Eilers | 4 | ** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de) |
5 | ** | 5 | ** |
6 | ** This file is part of Qtopia Environment. | 6 | ** This file is part of Qtopia Environment. |
7 | ** | 7 | ** |
@@ -25,6 +25,7 @@ | |||
25 | #include "mainwindow.h" | 25 | #include "mainwindow.h" |
26 | #include "todoentryimpl.h" | 26 | #include "todoentryimpl.h" |
27 | #include "todotable.h" | 27 | #include "todotable.h" |
28 | #include "todolabel.h" | ||
28 | 29 | ||
29 | #include <opie/tododb.h> | 30 | #include <opie/tododb.h> |
30 | #include <opie/todovcalresource.h> | 31 | #include <opie/todovcalresource.h> |
@@ -48,6 +49,7 @@ | |||
48 | #include <qfile.h> | 49 | #include <qfile.h> |
49 | #include <qmessagebox.h> | 50 | #include <qmessagebox.h> |
50 | #include <qpopupmenu.h> | 51 | #include <qpopupmenu.h> |
52 | #include <qwidgetstack.h> | ||
51 | 53 | ||
52 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
53 | #include <sys/types.h> | 55 | #include <sys/types.h> |
@@ -71,7 +73,8 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
71 | { | 73 | { |
72 | // QTime t; | 74 | // QTime t; |
73 | // t.start(); | 75 | // t.start(); |
74 | 76 | mView = 0l; | |
77 | mStack = new QWidgetStack(this, "main stack"); | ||
75 | setCaption( tr("Todo") ); | 78 | setCaption( tr("Todo") ); |
76 | QString str; | 79 | QString str; |
77 | table = new TodoTable( this ); | 80 | table = new TodoTable( this ); |
@@ -101,7 +104,9 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
101 | "Free up some space\n" | 104 | "Free up some space\n" |
102 | "before you enter any data") ); | 105 | "before you enter any data") ); |
103 | 106 | ||
104 | setCentralWidget( table ); | 107 | mStack->addWidget(table, 1 ); |
108 | mStack->raiseWidget( 1 ); | ||
109 | setCentralWidget( mStack ); | ||
105 | setToolBarsMovable( FALSE ); | 110 | setToolBarsMovable( FALSE ); |
106 | 111 | ||
107 | // qDebug("after load: t=%d", t.elapsed() ); | 112 | // qDebug("after load: t=%d", t.elapsed() ); |
@@ -146,6 +151,13 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
146 | a->addTo( contextMenu ); | 151 | a->addTo( contextMenu ); |
147 | a->setEnabled( FALSE ); | 152 | a->setEnabled( FALSE ); |
148 | editAction = a; | 153 | editAction = a; |
154 | |||
155 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); | ||
156 | a->addTo( edit ); | ||
157 | a->addTo( contextMenu ); | ||
158 | connect( a, SIGNAL( activated() ), | ||
159 | this, SLOT(slotShowDetails() ) ); | ||
160 | |||
149 | edit->insertSeparator(); | 161 | edit->insertSeparator(); |
150 | 162 | ||
151 | a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), | 163 | a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), |
@@ -176,8 +188,10 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
176 | a->addTo(edit ); | 188 | a->addTo(edit ); |
177 | a->setEnabled( FALSE ); | 189 | a->setEnabled( FALSE ); |
178 | duplicateAction = a; | 190 | duplicateAction = a; |
179 | |||
180 | edit->insertSeparator(); | 191 | edit->insertSeparator(); |
192 | |||
193 | |||
194 | |||
181 | if ( Ir::supported() ) { | 195 | if ( Ir::supported() ) { |
182 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), | 196 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), |
183 | QString::null, 0, this, 0 ); | 197 | QString::null, 0, this, 0 ); |
@@ -249,6 +263,8 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
249 | connect( table, SIGNAL( currentChanged( int, int ) ), | 263 | connect( table, SIGNAL( currentChanged( int, int ) ), |
250 | this, SLOT( currentEntryChanged( int, int ) ) ); | 264 | this, SLOT( currentEntryChanged( int, int ) ) ); |
251 | 265 | ||
266 | connect( table, SIGNAL(showDetails(const ToDoEvent &) ), | ||
267 | this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); | ||
252 | // qDebug("done: t=%d", t.elapsed() ); | 268 | // qDebug("done: t=%d", t.elapsed() ); |
253 | } | 269 | } |
254 | 270 | ||
@@ -286,6 +302,7 @@ void TodoWindow::slotNew() | |||
286 | // I'm afraid we must call this every time now, otherwise | 302 | // I'm afraid we must call this every time now, otherwise |
287 | // spend expensive time comparing all these strings... | 303 | // spend expensive time comparing all these strings... |
288 | populateCategories(); | 304 | populateCategories(); |
305 | mStack->raiseWidget(1 ); | ||
289 | } | 306 | } |
290 | 307 | ||
291 | TodoWindow::~TodoWindow() | 308 | TodoWindow::~TodoWindow() |
@@ -318,6 +335,7 @@ void TodoWindow::slotDelete() | |||
318 | currentEntryChanged( -1, 0 ); | 335 | currentEntryChanged( -1, 0 ); |
319 | findAction->setEnabled( FALSE ); | 336 | findAction->setEnabled( FALSE ); |
320 | } | 337 | } |
338 | mStack->raiseWidget(1); | ||
321 | } | 339 | } |
322 | void TodoWindow::slotDeleteAll() | 340 | void TodoWindow::slotDeleteAll() |
323 | { | 341 | { |
@@ -329,7 +347,7 @@ void TodoWindow::slotDeleteAll() | |||
329 | 347 | ||
330 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 348 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
331 | 349 | ||
332 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Should I delete all tasks?") ) ) | 350 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) |
333 | return; | 351 | return; |
334 | 352 | ||
335 | 353 | ||
@@ -342,6 +360,7 @@ void TodoWindow::slotDeleteAll() | |||
342 | currentEntryChanged( -1, 0 ); | 360 | currentEntryChanged( -1, 0 ); |
343 | findAction->setEnabled( FALSE ); | 361 | findAction->setEnabled( FALSE ); |
344 | } | 362 | } |
363 | mStack->raiseWidget(1 ); | ||
345 | } | 364 | } |
346 | 365 | ||
347 | void TodoWindow::slotEdit() | 366 | void TodoWindow::slotEdit() |
@@ -369,7 +388,7 @@ void TodoWindow::slotEdit() | |||
369 | table->setPaintingEnabled( true ); | 388 | table->setPaintingEnabled( true ); |
370 | } | 389 | } |
371 | populateCategories(); | 390 | populateCategories(); |
372 | 391 | mStack->raiseWidget( 1 ); | |
373 | } | 392 | } |
374 | void TodoWindow::slotDuplicate() | 393 | void TodoWindow::slotDuplicate() |
375 | { | 394 | { |
@@ -379,10 +398,19 @@ void TodoWindow::slotDuplicate() | |||
379 | return; | 398 | return; |
380 | } | 399 | } |
381 | ToDoEvent ev = table->currentEntry(); | 400 | ToDoEvent ev = table->currentEntry(); |
382 | ToDoEvent ev2 = ToDoEvent( ev ); | 401 | ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid |
402 | int uid; | ||
403 | { // uid | ||
404 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); | ||
405 | uid = uidgen->generate(); | ||
406 | delete uidgen; | ||
407 | } | ||
408 | ev2.setUid( uid ); | ||
383 | table->setPaintingEnabled( false ); | 409 | table->setPaintingEnabled( false ); |
384 | table->addEntry( ev2 ); | 410 | table->addEntry( ev2 ); |
385 | table->setPaintingEnabled( true ); | 411 | table->setPaintingEnabled( true ); |
412 | |||
413 | mStack->raiseWidget( 1 ); | ||
386 | } | 414 | } |
387 | void TodoWindow::slotShowPopup( const QPoint &p ) | 415 | void TodoWindow::slotShowPopup( const QPoint &p ) |
388 | { | 416 | { |
@@ -433,6 +461,8 @@ void TodoWindow::setCategory( int c ) | |||
433 | setCaption( tr("Todo") + " - " + cat ); | 461 | setCaption( tr("Todo") + " - " + cat ); |
434 | } | 462 | } |
435 | table->setPaintingEnabled( true ); | 463 | table->setPaintingEnabled( true ); |
464 | |||
465 | mStack->raiseWidget( 1 ); | ||
436 | } | 466 | } |
437 | 467 | ||
438 | void TodoWindow::populateCategories() | 468 | void TodoWindow::populateCategories() |
@@ -440,6 +470,7 @@ void TodoWindow::populateCategories() | |||
440 | catMenu->clear(); | 470 | catMenu->clear(); |
441 | int id, rememberId; | 471 | int id, rememberId; |
442 | id = 1; | 472 | id = 1; |
473 | rememberId = 0; | ||
443 | catMenu->insertItem( tr( "All Categories" ), id++ ); | 474 | catMenu->insertItem( tr( "All Categories" ), id++ ); |
444 | catMenu->insertSeparator(); | 475 | catMenu->insertSeparator(); |
445 | QStringList categories = table->categories(); | 476 | QStringList categories = table->categories(); |
@@ -472,6 +503,11 @@ void TodoWindow::flush() | |||
472 | 503 | ||
473 | void TodoWindow::closeEvent( QCloseEvent *e ) | 504 | void TodoWindow::closeEvent( QCloseEvent *e ) |
474 | { | 505 | { |
506 | if( mStack->visibleWidget() != table ){ | ||
507 | mStack->raiseWidget( 1 ); | ||
508 | e->ignore(); | ||
509 | return; | ||
510 | } | ||
475 | if(syncing) { | 511 | if(syncing) { |
476 | /* no need to save if in the middle of syncing */ | 512 | /* no need to save if in the middle of syncing */ |
477 | e->accept(); | 513 | e->accept(); |
@@ -562,10 +598,24 @@ void TodoWindow::beamDone( Ir *ir ) | |||
562 | unlink( beamfile ); | 598 | unlink( beamfile ); |
563 | } | 599 | } |
564 | 600 | ||
565 | /* added 20.01.2k2 by se */ | ||
566 | void TodoWindow::showDeadline( bool s ) | 601 | void TodoWindow::showDeadline( bool s ) |
567 | { | 602 | { |
568 | table->setPaintingEnabled( false ); | 603 | table->setPaintingEnabled( false ); |
569 | table->setShowDeadline( s ); | 604 | table->setShowDeadline( s ); |
570 | table->setPaintingEnabled( true ); | 605 | table->setPaintingEnabled( true ); |
571 | } | 606 | } |
607 | void TodoWindow::slotShowDetails() | ||
608 | { | ||
609 | ToDoEvent event = table->currentEntry(); | ||
610 | slotShowDetails( event ); | ||
611 | } | ||
612 | void TodoWindow::slotShowDetails( const ToDoEvent &event ) | ||
613 | { | ||
614 | if( mView == 0l ){ | ||
615 | mView = new TodoLabel(mStack); | ||
616 | mStack->addWidget( mView, 2 ); | ||
617 | } | ||
618 | mView->init( event ); | ||
619 | mView->sync(); | ||
620 | mStack->raiseWidget( 2); | ||
621 | } | ||