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,86 +1,89 @@ | |||
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 | ** |
8 | ** This file may be distributed and/or modified under the terms of the | 8 | ** This file may be distributed and/or modified under the terms of the |
9 | ** GNU General Public License version 2 as published by the Free Software | 9 | ** GNU General Public License version 2 as published by the Free Software |
10 | ** Foundation and appearing in the file LICENSE.GPL included in the | 10 | ** Foundation and appearing in the file LICENSE.GPL included in the |
11 | ** packaging of this file. | 11 | ** packaging of this file. |
12 | ** | 12 | ** |
13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
15 | ** | 15 | ** |
16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
17 | ** | 17 | ** |
18 | ** Contact info@trolltech.com if any conditions of this licensing are | 18 | ** Contact info@trolltech.com if any conditions of this licensing are |
19 | ** not clear to you. | 19 | ** not clear to you. |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | 22 | ||
23 | #define QTOPIA_INTERNAL_FD | 23 | #define QTOPIA_INTERNAL_FD |
24 | 24 | ||
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> |
31 | #include <opie/ofontmenu.h> | 32 | #include <opie/ofontmenu.h> |
32 | 33 | ||
33 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
34 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
35 | #include <qpe/finddialog.h> | 36 | #include <qpe/finddialog.h> |
36 | #include <qpe/global.h> | 37 | #include <qpe/global.h> |
37 | #include <qpe/ir.h> | 38 | #include <qpe/ir.h> |
38 | #include <qpe/qpemenubar.h> | 39 | #include <qpe/qpemenubar.h> |
39 | #include <qpe/qpemessagebox.h> | 40 | #include <qpe/qpemessagebox.h> |
40 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
41 | //#include <qpe/task.h> | 42 | //#include <qpe/task.h> |
42 | #include <qpe/qpetoolbar.h> | 43 | #include <qpe/qpetoolbar.h> |
43 | 44 | ||
44 | #include <qaction.h> | 45 | #include <qaction.h> |
45 | #include <qarray.h> | 46 | #include <qarray.h> |
46 | #include <qdatastream.h> | 47 | #include <qdatastream.h> |
47 | #include <qdatetime.h> | 48 | #include <qdatetime.h> |
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> |
54 | #include <fcntl.h> | 56 | #include <fcntl.h> |
55 | #include <unistd.h> | 57 | #include <unistd.h> |
56 | 58 | ||
57 | #include <stdlib.h> | 59 | #include <stdlib.h> |
58 | 60 | ||
59 | static QString todolistXMLFilename() | 61 | static QString todolistXMLFilename() |
60 | { | 62 | { |
61 | return Global::applicationFileName("todolist","todolist.xml"); | 63 | return Global::applicationFileName("todolist","todolist.xml"); |
62 | } | 64 | } |
63 | 65 | ||
64 | static QString categoriesXMLFilename() | 66 | static QString categoriesXMLFilename() |
65 | { | 67 | { |
66 | return Global::applicationFileName("todolist","categories.xml"); | 68 | return Global::applicationFileName("todolist","categories.xml"); |
67 | } | 69 | } |
68 | 70 | ||
69 | TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | 71 | TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : |
70 | QMainWindow( parent, name, f ), syncing(FALSE) | 72 | QMainWindow( parent, name, f ), syncing(FALSE) |
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 ); |
78 | table->setColumnWidth( 2, 10 ); | 81 | table->setColumnWidth( 2, 10 ); |
79 | table->setPaintingEnabled( FALSE ); | 82 | table->setPaintingEnabled( FALSE ); |
80 | table->setUpdatesEnabled( FALSE ); | 83 | table->setUpdatesEnabled( FALSE ); |
81 | table->viewport()->setUpdatesEnabled( FALSE ); | 84 | table->viewport()->setUpdatesEnabled( FALSE ); |
82 | 85 | ||
83 | { | 86 | { |
84 | str = todolistXMLFilename(); | 87 | str = todolistXMLFilename(); |
85 | if ( str.isNull() ) | 88 | if ( str.isNull() ) |
86 | QMessageBox::critical( this, | 89 | QMessageBox::critical( this, |
@@ -92,25 +95,27 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
92 | table->load( str ); | 95 | table->load( str ); |
93 | } | 96 | } |
94 | 97 | ||
95 | // repeat for categories... | 98 | // repeat for categories... |
96 | str = categoriesXMLFilename(); | 99 | str = categoriesXMLFilename(); |
97 | if ( str.isNull() ) | 100 | if ( str.isNull() ) |
98 | QMessageBox::critical( this, | 101 | QMessageBox::critical( this, |
99 | tr( "Out of Space" ), | 102 | tr( "Out of Space" ), |
100 | tr( "Unable to create startup files\n" | 103 | tr( "Unable to create startup files\n" |
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() ); |
108 | 113 | ||
109 | Config config( "todo" ); | 114 | Config config( "todo" ); |
110 | config.setGroup( "View" ); | 115 | config.setGroup( "View" ); |
111 | bool complete = config.readBoolEntry( "ShowComplete", true ); | 116 | bool complete = config.readBoolEntry( "ShowComplete", true ); |
112 | table->setShowCompleted( complete ); | 117 | table->setShowCompleted( complete ); |
113 | 118 | ||
114 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); | 119 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); |
115 | table->setShowDeadline (showdeadline); | 120 | table->setShowDeadline (showdeadline); |
116 | 121 | ||
@@ -137,24 +142,31 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
137 | a->addTo( bar ); | 142 | a->addTo( bar ); |
138 | a->addTo( edit ); | 143 | a->addTo( edit ); |
139 | 144 | ||
140 | a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ), | 145 | a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ), |
141 | QString::null, 0, this, 0 ); | 146 | QString::null, 0, this, 0 ); |
142 | connect( a, SIGNAL( activated() ), | 147 | connect( a, SIGNAL( activated() ), |
143 | this, SLOT( slotEdit() ) ); | 148 | this, SLOT( slotEdit() ) ); |
144 | a->addTo( bar ); | 149 | a->addTo( bar ); |
145 | a->addTo( edit ); | 150 | a->addTo( edit ); |
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" ), |
152 | QString::null, 0, this, 0 ); | 164 | QString::null, 0, this, 0 ); |
153 | connect( a, SIGNAL( activated() ), | 165 | connect( a, SIGNAL( activated() ), |
154 | this, SLOT( slotDelete() ) ); | 166 | this, SLOT( slotDelete() ) ); |
155 | a->addTo( bar ); | 167 | a->addTo( bar ); |
156 | a->addTo( edit ); | 168 | a->addTo( edit ); |
157 | a->addTo( contextMenu ); | 169 | a->addTo( contextMenu ); |
158 | a->setEnabled( FALSE ); | 170 | a->setEnabled( FALSE ); |
159 | deleteAction = a; | 171 | deleteAction = a; |
160 | 172 | ||
@@ -167,26 +179,28 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
167 | this, SLOT( slotDeleteAll() ) ); | 179 | this, SLOT( slotDeleteAll() ) ); |
168 | a->addTo(edit ); | 180 | a->addTo(edit ); |
169 | a->setEnabled( FALSE ); | 181 | a->setEnabled( FALSE ); |
170 | deleteAllAction = a; | 182 | deleteAllAction = a; |
171 | 183 | ||
172 | edit->insertSeparator(); | 184 | edit->insertSeparator(); |
173 | a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); | 185 | a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); |
174 | connect(a, SIGNAL( activated() ), | 186 | connect(a, SIGNAL( activated() ), |
175 | this, SLOT( slotDuplicate() ) ); | 187 | this, SLOT( slotDuplicate() ) ); |
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 ); |
184 | connect( a, SIGNAL( activated() ), | 198 | connect( a, SIGNAL( activated() ), |
185 | this, SLOT( slotBeam() ) ); | 199 | this, SLOT( slotBeam() ) ); |
186 | a->addTo( edit ); | 200 | a->addTo( edit ); |
187 | a->addTo( bar ); | 201 | a->addTo( bar ); |
188 | } | 202 | } |
189 | 203 | ||
190 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), | 204 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), |
191 | QString::null, 0, this, 0 ); | 205 | QString::null, 0, this, 0 ); |
192 | connect( a, SIGNAL( activated() ), | 206 | connect( a, SIGNAL( activated() ), |
@@ -240,24 +254,26 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
240 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); | 254 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); |
241 | table->updateVisible(); | 255 | table->updateVisible(); |
242 | table->setUpdatesEnabled( TRUE ); | 256 | table->setUpdatesEnabled( TRUE ); |
243 | table->setPaintingEnabled( TRUE ); | 257 | table->setPaintingEnabled( TRUE ); |
244 | table->viewport()->setUpdatesEnabled( TRUE ); | 258 | table->viewport()->setUpdatesEnabled( TRUE ); |
245 | 259 | ||
246 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); | 260 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); |
247 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); | 261 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); |
248 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); | 262 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); |
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 | ||
255 | void TodoWindow::slotNew() | 271 | void TodoWindow::slotNew() |
256 | { | 272 | { |
257 | if(syncing) { | 273 | if(syncing) { |
258 | QMessageBox::warning(this, tr("Todo"), | 274 | QMessageBox::warning(this, tr("Todo"), |
259 | tr("Can not edit data, currently syncing")); | 275 | tr("Can not edit data, currently syncing")); |
260 | return; | 276 | return; |
261 | } | 277 | } |
262 | 278 | ||
263 | int id; | 279 | int id; |
@@ -277,24 +293,25 @@ void TodoWindow::slotNew() | |||
277 | // qWarning("finished" ); | 293 | // qWarning("finished" ); |
278 | if ( ret == QDialog::Accepted ) { | 294 | if ( ret == QDialog::Accepted ) { |
279 | table->setPaintingEnabled( false ); | 295 | table->setPaintingEnabled( false ); |
280 | todo = e.todoEntry(); | 296 | todo = e.todoEntry(); |
281 | //todo.assignUid(); | 297 | //todo.assignUid(); |
282 | table->addEntry( todo ); | 298 | table->addEntry( todo ); |
283 | table->setPaintingEnabled( true ); | 299 | table->setPaintingEnabled( true ); |
284 | findAction->setEnabled( TRUE ); | 300 | findAction->setEnabled( TRUE ); |
285 | } | 301 | } |
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() |
292 | { | 309 | { |
293 | } | 310 | } |
294 | 311 | ||
295 | void TodoWindow::slotDelete() | 312 | void TodoWindow::slotDelete() |
296 | { | 313 | { |
297 | if(syncing) { | 314 | if(syncing) { |
298 | QMessageBox::warning(this, tr("Todo"), | 315 | QMessageBox::warning(this, tr("Todo"), |
299 | tr("Can not edit data, currently syncing")); | 316 | tr("Can not edit data, currently syncing")); |
300 | return; | 317 | return; |
@@ -309,48 +326,50 @@ void TodoWindow::slotDelete() | |||
309 | return; | 326 | return; |
310 | 327 | ||
311 | 328 | ||
312 | 329 | ||
313 | table->setPaintingEnabled( false ); | 330 | table->setPaintingEnabled( false ); |
314 | table->removeCurrentEntry(); | 331 | table->removeCurrentEntry(); |
315 | table->setPaintingEnabled( true ); | 332 | table->setPaintingEnabled( true ); |
316 | 333 | ||
317 | if ( table->numRows() == 0 ) { | 334 | if ( table->numRows() == 0 ) { |
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 | { |
324 | if(syncing) { | 342 | if(syncing) { |
325 | QMessageBox::warning(this, tr("Todo"), | 343 | QMessageBox::warning(this, tr("Todo"), |
326 | tr("Can not edit data, currently syncing")); | 344 | tr("Can not edit data, currently syncing")); |
327 | return; | 345 | return; |
328 | } | 346 | } |
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 | ||
336 | 354 | ||
337 | table->setPaintingEnabled( false ); | 355 | table->setPaintingEnabled( false ); |
338 | table->removeAllEntries(); | 356 | table->removeAllEntries(); |
339 | table->setPaintingEnabled( true ); | 357 | table->setPaintingEnabled( true ); |
340 | 358 | ||
341 | if ( table->numRows() == 0 ) { | 359 | if ( table->numRows() == 0 ) { |
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() |
348 | { | 367 | { |
349 | if(syncing) { | 368 | if(syncing) { |
350 | QMessageBox::warning(this, tr("Todo"), | 369 | QMessageBox::warning(this, tr("Todo"), |
351 | tr("Can not edit data, currently syncing")); | 370 | tr("Can not edit data, currently syncing")); |
352 | return; | 371 | return; |
353 | } | 372 | } |
354 | 373 | ||
355 | ToDoEvent todo = table->currentEntry(); | 374 | ToDoEvent todo = table->currentEntry(); |
356 | 375 | ||
@@ -360,38 +379,47 @@ void TodoWindow::slotEdit() | |||
360 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 379 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
361 | e.showMaximized(); | 380 | e.showMaximized(); |
362 | #endif | 381 | #endif |
363 | int ret = e.exec(); | 382 | int ret = e.exec(); |
364 | 383 | ||
365 | if ( ret == QDialog::Accepted ) { | 384 | if ( ret == QDialog::Accepted ) { |
366 | table->setPaintingEnabled( false ); | 385 | table->setPaintingEnabled( false ); |
367 | todo = e.todoEntry(); | 386 | todo = e.todoEntry(); |
368 | table->replaceCurrentEntry( todo ); | 387 | table->replaceCurrentEntry( todo ); |
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 | { |
376 | if(syncing) { | 395 | if(syncing) { |
377 | QMessageBox::warning(this, tr("Todo"), | 396 | QMessageBox::warning(this, tr("Todo"), |
378 | tr("Can not edit data, currently syncing")); | 397 | tr("Can not edit data, currently syncing")); |
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 | { |
389 | contextMenu->popup( p ); | 417 | contextMenu->popup( p ); |
390 | } | 418 | } |
391 | 419 | ||
392 | void TodoWindow::showCompleted( bool s ) | 420 | void TodoWindow::showCompleted( bool s ) |
393 | { | 421 | { |
394 | if ( !table->isUpdatesEnabled() ) | 422 | if ( !table->isUpdatesEnabled() ) |
395 | return; | 423 | return; |
396 | table->setPaintingEnabled( false ); | 424 | table->setPaintingEnabled( false ); |
397 | table->setShowCompleted( s ); | 425 | table->setShowCompleted( s ); |
@@ -424,31 +452,34 @@ void TodoWindow::setCategory( int c ) | |||
424 | if ( c == 1 ) { | 452 | if ( c == 1 ) { |
425 | table->setShowCategory( QString::null ); | 453 | table->setShowCategory( QString::null ); |
426 | setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); | 454 | setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); |
427 | } else if ( c == (int)catMenu->count() - 1 ) { | 455 | } else if ( c == (int)catMenu->count() - 1 ) { |
428 | table->setShowCategory( tr( "Unfiled" ) ); | 456 | table->setShowCategory( tr( "Unfiled" ) ); |
429 | setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); | 457 | setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); |
430 | } else { | 458 | } else { |
431 | QString cat = table->categories()[c - 2]; | 459 | QString cat = table->categories()[c - 2]; |
432 | table->setShowCategory( cat ); | 460 | table->setShowCategory( cat ); |
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() |
439 | { | 469 | { |
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(); |
446 | categories.append( tr( "Unfiled" ) ); | 477 | categories.append( tr( "Unfiled" ) ); |
447 | for ( QStringList::Iterator it = categories.begin(); | 478 | for ( QStringList::Iterator it = categories.begin(); |
448 | it != categories.end(); ++it ) { | 479 | it != categories.end(); ++it ) { |
449 | catMenu->insertItem( *it, id ); | 480 | catMenu->insertItem( *it, id ); |
450 | if ( *it == table->showCategory() ) | 481 | if ( *it == table->showCategory() ) |
451 | rememberId = id; | 482 | rememberId = id; |
452 | ++id; | 483 | ++id; |
453 | } | 484 | } |
454 | if ( table->showCategory().isEmpty() ) | 485 | if ( table->showCategory().isEmpty() ) |
@@ -463,24 +494,29 @@ void TodoWindow::reload() | |||
463 | table->load( todolistXMLFilename() ); | 494 | table->load( todolistXMLFilename() ); |
464 | syncing = FALSE; | 495 | syncing = FALSE; |
465 | } | 496 | } |
466 | 497 | ||
467 | void TodoWindow::flush() | 498 | void TodoWindow::flush() |
468 | { | 499 | { |
469 | syncing = TRUE; | 500 | syncing = TRUE; |
470 | table->save( todolistXMLFilename() ); | 501 | table->save( todolistXMLFilename() ); |
471 | } | 502 | } |
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(); |
478 | return; | 514 | return; |
479 | } | 515 | } |
480 | 516 | ||
481 | if ( table->save( todolistXMLFilename() ) ) { | 517 | if ( table->save( todolistXMLFilename() ) ) { |
482 | e->accept(); | 518 | e->accept(); |
483 | // repeat for categories... | 519 | // repeat for categories... |
484 | // if writing configs fail, it will emit an | 520 | // if writing configs fail, it will emit an |
485 | // error, but I feel that it is "ok" for us to exit | 521 | // error, but I feel that it is "ok" for us to exit |
486 | // espically since we aren't told if the write succeeded... | 522 | // espically since we aren't told if the write succeeded... |
@@ -553,19 +589,33 @@ void TodoWindow::slotBeam() | |||
553 | Ir *ir = new Ir( this ); | 589 | Ir *ir = new Ir( this ); |
554 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 590 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
555 | QString description = c.description(); | 591 | QString description = c.description(); |
556 | ir->send( beamfile, description, "text/x-vCalendar" ); | 592 | ir->send( beamfile, description, "text/x-vCalendar" ); |
557 | } | 593 | } |
558 | 594 | ||
559 | void TodoWindow::beamDone( Ir *ir ) | 595 | void TodoWindow::beamDone( Ir *ir ) |
560 | { | 596 | { |
561 | delete ir; | 597 | delete 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 | } | ||