-rw-r--r-- | core/pim/todo/mainwindow.cpp | 3 | ||||
-rw-r--r-- | core/pim/todo/todotable.cpp | 3 |
2 files changed, 3 insertions, 3 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index a28fc3e..294f37c 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -119,505 +119,506 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
119 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); | 119 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); |
120 | table->setShowDeadline (showdeadline); | 120 | table->setShowDeadline (showdeadline); |
121 | 121 | ||
122 | QString category = config.readEntry( "Category", QString::null ); | 122 | QString category = config.readEntry( "Category", QString::null ); |
123 | table->setShowCategory( category ); | 123 | table->setShowCategory( category ); |
124 | 124 | ||
125 | QPEToolBar *bar = new QPEToolBar( this ); | 125 | QPEToolBar *bar = new QPEToolBar( this ); |
126 | bar->setHorizontalStretchable( TRUE ); | 126 | bar->setHorizontalStretchable( TRUE ); |
127 | 127 | ||
128 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 128 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
129 | 129 | ||
130 | catMenu = new QPopupMenu( this ); | 130 | catMenu = new QPopupMenu( this ); |
131 | QPopupMenu *edit = new QPopupMenu( this ); | 131 | QPopupMenu *edit = new QPopupMenu( this ); |
132 | QPopupMenu *options = new QPopupMenu(this ); | 132 | QPopupMenu *options = new QPopupMenu(this ); |
133 | 133 | ||
134 | contextMenu = new QPopupMenu( this ); | 134 | contextMenu = new QPopupMenu( this ); |
135 | 135 | ||
136 | bar = new QPEToolBar( this ); | 136 | bar = new QPEToolBar( this ); |
137 | 137 | ||
138 | QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), | 138 | QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), |
139 | QString::null, 0, this, 0 ); | 139 | QString::null, 0, this, 0 ); |
140 | connect( a, SIGNAL( activated() ), | 140 | connect( a, SIGNAL( activated() ), |
141 | this, SLOT( slotNew() ) ); | 141 | this, SLOT( slotNew() ) ); |
142 | a->addTo( bar ); | 142 | a->addTo( bar ); |
143 | a->addTo( edit ); | 143 | a->addTo( edit ); |
144 | 144 | ||
145 | a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ), | 145 | a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ), |
146 | QString::null, 0, this, 0 ); | 146 | QString::null, 0, this, 0 ); |
147 | connect( a, SIGNAL( activated() ), | 147 | connect( a, SIGNAL( activated() ), |
148 | this, SLOT( slotEdit() ) ); | 148 | this, SLOT( slotEdit() ) ); |
149 | a->addTo( bar ); | 149 | a->addTo( bar ); |
150 | a->addTo( edit ); | 150 | a->addTo( edit ); |
151 | a->addTo( contextMenu ); | 151 | a->addTo( contextMenu ); |
152 | a->setEnabled( FALSE ); | 152 | a->setEnabled( FALSE ); |
153 | editAction = a; | 153 | editAction = a; |
154 | 154 | ||
155 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); | 155 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); |
156 | a->addTo( edit ); | 156 | a->addTo( edit ); |
157 | a->addTo( contextMenu ); | 157 | a->addTo( contextMenu ); |
158 | connect( a, SIGNAL( activated() ), | 158 | connect( a, SIGNAL( activated() ), |
159 | this, SLOT(slotShowDetails() ) ); | 159 | this, SLOT(slotShowDetails() ) ); |
160 | 160 | ||
161 | edit->insertSeparator(); | 161 | edit->insertSeparator(); |
162 | 162 | ||
163 | a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), | 163 | a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), |
164 | QString::null, 0, this, 0 ); | 164 | QString::null, 0, this, 0 ); |
165 | connect( a, SIGNAL( activated() ), | 165 | connect( a, SIGNAL( activated() ), |
166 | this, SLOT( slotDelete() ) ); | 166 | this, SLOT( slotDelete() ) ); |
167 | a->addTo( bar ); | 167 | a->addTo( bar ); |
168 | a->addTo( edit ); | 168 | a->addTo( edit ); |
169 | a->addTo( contextMenu ); | 169 | a->addTo( contextMenu ); |
170 | a->setEnabled( FALSE ); | 170 | a->setEnabled( FALSE ); |
171 | deleteAction = a; | 171 | deleteAction = a; |
172 | 172 | ||
173 | // delete All in category is missing.... | 173 | // delete All in category is missing.... |
174 | // set All Done | 174 | // set All Done |
175 | // set All Done in category | 175 | // set All Done in category |
176 | 176 | ||
177 | a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 ); | 177 | a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 ); |
178 | connect(a, SIGNAL( activated() ), | 178 | connect(a, SIGNAL( activated() ), |
179 | this, SLOT( slotDeleteAll() ) ); | 179 | this, SLOT( slotDeleteAll() ) ); |
180 | a->addTo(edit ); | 180 | a->addTo(edit ); |
181 | a->setEnabled( FALSE ); | 181 | a->setEnabled( FALSE ); |
182 | deleteAllAction = a; | 182 | deleteAllAction = a; |
183 | 183 | ||
184 | edit->insertSeparator(); | 184 | edit->insertSeparator(); |
185 | a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); | 185 | a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); |
186 | connect(a, SIGNAL( activated() ), | 186 | connect(a, SIGNAL( activated() ), |
187 | this, SLOT( slotDuplicate() ) ); | 187 | this, SLOT( slotDuplicate() ) ); |
188 | a->addTo(edit ); | 188 | a->addTo(edit ); |
189 | a->setEnabled( FALSE ); | 189 | a->setEnabled( FALSE ); |
190 | duplicateAction = a; | 190 | duplicateAction = a; |
191 | edit->insertSeparator(); | 191 | edit->insertSeparator(); |
192 | 192 | ||
193 | 193 | ||
194 | 194 | ||
195 | if ( Ir::supported() ) { | 195 | if ( Ir::supported() ) { |
196 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), | 196 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), |
197 | QString::null, 0, this, 0 ); | 197 | QString::null, 0, this, 0 ); |
198 | connect( a, SIGNAL( activated() ), | 198 | connect( a, SIGNAL( activated() ), |
199 | this, SLOT( slotBeam() ) ); | 199 | this, SLOT( slotBeam() ) ); |
200 | a->addTo( edit ); | 200 | a->addTo( edit ); |
201 | a->addTo( bar ); | 201 | a->addTo( bar ); |
202 | } | 202 | } |
203 | 203 | ||
204 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), | 204 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), |
205 | QString::null, 0, this, 0 ); | 205 | QString::null, 0, this, 0 ); |
206 | connect( a, SIGNAL( activated() ), | 206 | connect( a, SIGNAL( activated() ), |
207 | this, SLOT( slotFind() ) ); | 207 | this, SLOT( slotFind() ) ); |
208 | a->addTo( bar ); | 208 | a->addTo( bar ); |
209 | a->addTo( options ); | 209 | a->addTo( options ); |
210 | options->insertSeparator(); | 210 | options->insertSeparator(); |
211 | 211 | ||
212 | if ( table->numRows() ) | 212 | if ( table->numRows() ) |
213 | a->setEnabled( TRUE ); | 213 | a->setEnabled( TRUE ); |
214 | else | 214 | else |
215 | a->setEnabled( FALSE ); | 215 | a->setEnabled( FALSE ); |
216 | 216 | ||
217 | //a->setEnabled( FALSE ); | 217 | //a->setEnabled( FALSE ); |
218 | findAction = a; | 218 | findAction = a; |
219 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); | 219 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); |
220 | 220 | ||
221 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); | 221 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); |
222 | 222 | ||
223 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); | 223 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); |
224 | 224 | ||
225 | catMenu->setCheckable( true ); | 225 | catMenu->setCheckable( true ); |
226 | populateCategories(); | 226 | populateCategories(); |
227 | 227 | ||
228 | 228 | ||
229 | completedAction->addTo( options ); | 229 | completedAction->addTo( options ); |
230 | completedAction->setOn( table->showCompleted() ); | 230 | completedAction->setOn( table->showCompleted() ); |
231 | showdeadlineAction->addTo( options ); | 231 | showdeadlineAction->addTo( options ); |
232 | showdeadlineAction->setOn( table->showDeadline() ); | 232 | showdeadlineAction->setOn( table->showDeadline() ); |
233 | options->insertSeparator( ); | 233 | options->insertSeparator( ); |
234 | QList<QWidget> list; | 234 | QList<QWidget> list; |
235 | list.append(table ); | 235 | list.append(table ); |
236 | OFontMenu *menu = new OFontMenu(this, "menu",list ); | 236 | OFontMenu *menu = new OFontMenu(this, "menu",list ); |
237 | menu->forceSize( table->horizontalHeader(), 10 ); | 237 | menu->forceSize( table->horizontalHeader(), 10 ); |
238 | //catMenu->insertItem(tr("Fonts"), menu ); | 238 | //catMenu->insertItem(tr("Fonts"), menu ); |
239 | list.clear(); | 239 | list.clear(); |
240 | options->insertItem( tr("Fonts"), menu ); | 240 | options->insertItem( tr("Fonts"), menu ); |
241 | 241 | ||
242 | 242 | ||
243 | mb->insertItem( tr( "Data" ), edit ); | 243 | mb->insertItem( tr( "Data" ), edit ); |
244 | mb->insertItem( tr( "Category" ), catMenu ); | 244 | mb->insertItem( tr( "Category" ), catMenu ); |
245 | mb->insertItem( tr( "Options"), options ); | 245 | mb->insertItem( tr( "Options"), options ); |
246 | resize( 200, 300 ); | 246 | resize( 200, 300 ); |
247 | if ( table->numRows() > 0 ) | 247 | if ( table->numRows() > 0 ) |
248 | currentEntryChanged( 0, 0 ); | 248 | currentEntryChanged( 0, 0 ); |
249 | connect( table, SIGNAL( signalEdit() ), | 249 | connect( table, SIGNAL( signalEdit() ), |
250 | this, SLOT( slotEdit() ) ); | 250 | this, SLOT( slotEdit() ) ); |
251 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), | 251 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), |
252 | this, SLOT( slotShowPopup(const QPoint &)) ); | 252 | this, SLOT( slotShowPopup(const QPoint &)) ); |
253 | 253 | ||
254 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); | 254 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); |
255 | table->updateVisible(); | 255 | table->updateVisible(); |
256 | table->setUpdatesEnabled( TRUE ); | 256 | table->setUpdatesEnabled( TRUE ); |
257 | table->setPaintingEnabled( TRUE ); | 257 | table->setPaintingEnabled( TRUE ); |
258 | table->viewport()->setUpdatesEnabled( TRUE ); | 258 | table->viewport()->setUpdatesEnabled( TRUE ); |
259 | 259 | ||
260 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); | 260 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); |
261 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); | 261 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); |
262 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); | 262 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); |
263 | connect( table, SIGNAL( currentChanged( int, int ) ), | 263 | connect( table, SIGNAL( currentChanged( int, int ) ), |
264 | this, SLOT( currentEntryChanged( int, int ) ) ); | 264 | this, SLOT( currentEntryChanged( int, int ) ) ); |
265 | 265 | ||
266 | connect( table, SIGNAL(showDetails(const ToDoEvent &) ), | 266 | connect( table, SIGNAL(showDetails(const ToDoEvent &) ), |
267 | this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); | 267 | this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); |
268 | // qDebug("done: t=%d", t.elapsed() ); | 268 | // qDebug("done: t=%d", t.elapsed() ); |
269 | } | 269 | } |
270 | 270 | ||
271 | void TodoWindow::slotNew() | 271 | void TodoWindow::slotNew() |
272 | { | 272 | { |
273 | if(syncing) { | 273 | if(syncing) { |
274 | QMessageBox::warning(this, tr("Todo"), | 274 | QMessageBox::warning(this, tr("Todo"), |
275 | tr("Can not edit data, currently syncing")); | 275 | tr("Can not edit data, currently syncing")); |
276 | return; | 276 | return; |
277 | } | 277 | } |
278 | 278 | ||
279 | int id; | 279 | int id; |
280 | id = -1; | 280 | id = -1; |
281 | QArray<int> ids; | 281 | QArray<int> ids; |
282 | ids = table->currentEntry().categories(); | 282 | ids = table->currentEntry().categories(); |
283 | if ( ids.count() ) | 283 | if ( ids.count() ) |
284 | id = ids[0]; | 284 | id = ids[0]; |
285 | NewTaskDialog e( id, this, 0, TRUE ); | 285 | NewTaskDialog e( id, this, 0, TRUE ); |
286 | 286 | ||
287 | ToDoEvent todo; | 287 | ToDoEvent todo; |
288 | 288 | ||
289 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 289 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
290 | e.showMaximized(); | 290 | e.showMaximized(); |
291 | #endif | 291 | #endif |
292 | int ret = e.exec(); | 292 | int ret = e.exec(); |
293 | // qWarning("finished" ); | 293 | // qWarning("finished" ); |
294 | if ( ret == QDialog::Accepted ) { | 294 | if ( ret == QDialog::Accepted ) { |
295 | table->setPaintingEnabled( false ); | 295 | table->setPaintingEnabled( false ); |
296 | todo = e.todoEntry(); | 296 | todo = e.todoEntry(); |
297 | //todo.assignUid(); | 297 | //todo.assignUid(); |
298 | table->addEntry( todo ); | 298 | table->addEntry( todo ); |
299 | table->setPaintingEnabled( true ); | 299 | table->setPaintingEnabled( true ); |
300 | findAction->setEnabled( TRUE ); | 300 | findAction->setEnabled( TRUE ); |
301 | } | 301 | } |
302 | // I'm afraid we must call this every time now, otherwise | 302 | // I'm afraid we must call this every time now, otherwise |
303 | // spend expensive time comparing all these strings... | 303 | // spend expensive time comparing all these strings... |
304 | populateCategories(); | 304 | populateCategories(); |
305 | mStack->raiseWidget(1 ); | 305 | mStack->raiseWidget(1 ); |
306 | } | 306 | } |
307 | 307 | ||
308 | TodoWindow::~TodoWindow() | 308 | TodoWindow::~TodoWindow() |
309 | { | 309 | { |
310 | } | 310 | } |
311 | 311 | ||
312 | void TodoWindow::slotDelete() | 312 | void TodoWindow::slotDelete() |
313 | { | 313 | { |
314 | if(syncing) { | 314 | if(syncing) { |
315 | QMessageBox::warning(this, tr("Todo"), | 315 | QMessageBox::warning(this, tr("Todo"), |
316 | tr("Can not edit data, currently syncing")); | 316 | tr("Can not edit data, currently syncing")); |
317 | return; | 317 | return; |
318 | } | 318 | } |
319 | 319 | ||
320 | if ( table->currentRow() == -1 ) | 320 | if ( table->currentRow() == -1 ) |
321 | return; | 321 | return; |
322 | 322 | ||
323 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 323 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
324 | 324 | ||
325 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) | 325 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) |
326 | return; | 326 | return; |
327 | 327 | ||
328 | 328 | ||
329 | 329 | ||
330 | table->setPaintingEnabled( false ); | 330 | table->setPaintingEnabled( false ); |
331 | table->removeCurrentEntry(); | 331 | table->removeCurrentEntry(); |
332 | table->setPaintingEnabled( true ); | 332 | table->setPaintingEnabled( true ); |
333 | 333 | ||
334 | if ( table->numRows() == 0 ) { | 334 | if ( table->numRows() == 0 ) { |
335 | currentEntryChanged( -1, 0 ); | 335 | currentEntryChanged( -1, 0 ); |
336 | findAction->setEnabled( FALSE ); | 336 | findAction->setEnabled( FALSE ); |
337 | } | 337 | } |
338 | mStack->raiseWidget(1); | 338 | mStack->raiseWidget(1); |
339 | } | 339 | } |
340 | void TodoWindow::slotDeleteAll() | 340 | void TodoWindow::slotDeleteAll() |
341 | { | 341 | { |
342 | if(syncing) { | 342 | if(syncing) { |
343 | QMessageBox::warning(this, tr("Todo"), | 343 | QMessageBox::warning(this, tr("Todo"), |
344 | tr("Can not edit data, currently syncing")); | 344 | tr("Can not edit data, currently syncing")); |
345 | return; | 345 | return; |
346 | } | 346 | } |
347 | 347 | ||
348 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 348 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
349 | 349 | ||
350 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) | 350 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) |
351 | return; | 351 | return; |
352 | 352 | ||
353 | 353 | ||
354 | 354 | ||
355 | table->setPaintingEnabled( false ); | 355 | table->setPaintingEnabled( false ); |
356 | table->removeAllEntries(); | 356 | table->removeAllEntries(); |
357 | table->setPaintingEnabled( true ); | 357 | table->setPaintingEnabled( true ); |
358 | 358 | ||
359 | if ( table->numRows() == 0 ) { | 359 | if ( table->numRows() == 0 ) { |
360 | currentEntryChanged( -1, 0 ); | 360 | currentEntryChanged( -1, 0 ); |
361 | findAction->setEnabled( FALSE ); | 361 | findAction->setEnabled( FALSE ); |
362 | } | 362 | } |
363 | mStack->raiseWidget(1 ); | 363 | mStack->raiseWidget(1 ); |
364 | } | 364 | } |
365 | 365 | ||
366 | void TodoWindow::slotEdit() | 366 | void TodoWindow::slotEdit() |
367 | { | 367 | { |
368 | if(syncing) { | 368 | if(syncing) { |
369 | QMessageBox::warning(this, tr("Todo"), | 369 | QMessageBox::warning(this, tr("Todo"), |
370 | tr("Can not edit data, currently syncing")); | 370 | tr("Can not edit data, currently syncing")); |
371 | return; | 371 | return; |
372 | } | 372 | } |
373 | 373 | ||
374 | ToDoEvent todo = table->currentEntry(); | 374 | ToDoEvent todo = table->currentEntry(); |
375 | 375 | qWarning("slotEdit" ); | |
376 | NewTaskDialog e( todo, this, 0, TRUE ); | 376 | NewTaskDialog e( todo, this, 0, TRUE ); |
377 | e.setCaption( tr( "Edit Task" ) ); | 377 | e.setCaption( tr( "Edit Task" ) ); |
378 | 378 | ||
379 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 379 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
380 | e.showMaximized(); | 380 | e.showMaximized(); |
381 | #endif | 381 | #endif |
382 | int ret = e.exec(); | 382 | int ret = e.exec(); |
383 | 383 | ||
384 | if ( ret == QDialog::Accepted ) { | 384 | if ( ret == QDialog::Accepted ) { |
385 | qWarning("Replacing now" ); | ||
385 | table->setPaintingEnabled( false ); | 386 | table->setPaintingEnabled( false ); |
386 | todo = e.todoEntry(); | 387 | todo = e.todoEntry(); |
387 | table->replaceCurrentEntry( todo ); | 388 | table->replaceCurrentEntry( todo ); |
388 | table->setPaintingEnabled( true ); | 389 | table->setPaintingEnabled( true ); |
389 | } | 390 | } |
390 | populateCategories(); | 391 | populateCategories(); |
391 | mStack->raiseWidget( 1 ); | 392 | mStack->raiseWidget( 1 ); |
392 | } | 393 | } |
393 | void TodoWindow::slotDuplicate() | 394 | void TodoWindow::slotDuplicate() |
394 | { | 395 | { |
395 | if(syncing) { | 396 | if(syncing) { |
396 | QMessageBox::warning(this, tr("Todo"), | 397 | QMessageBox::warning(this, tr("Todo"), |
397 | tr("Can not edit data, currently syncing")); | 398 | tr("Can not edit data, currently syncing")); |
398 | return; | 399 | return; |
399 | } | 400 | } |
400 | ToDoEvent ev = table->currentEntry(); | 401 | ToDoEvent ev = table->currentEntry(); |
401 | ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid | 402 | ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid |
402 | int uid; | 403 | int uid; |
403 | { // uid | 404 | { // uid |
404 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); | 405 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); |
405 | uid = uidgen->generate(); | 406 | uid = uidgen->generate(); |
406 | delete uidgen; | 407 | delete uidgen; |
407 | } | 408 | } |
408 | ev2.setUid( uid ); | 409 | ev2.setUid( uid ); |
409 | table->setPaintingEnabled( false ); | 410 | table->setPaintingEnabled( false ); |
410 | table->addEntry( ev2 ); | 411 | table->addEntry( ev2 ); |
411 | table->setPaintingEnabled( true ); | 412 | table->setPaintingEnabled( true ); |
412 | 413 | ||
413 | mStack->raiseWidget( 1 ); | 414 | mStack->raiseWidget( 1 ); |
414 | } | 415 | } |
415 | void TodoWindow::slotShowPopup( const QPoint &p ) | 416 | void TodoWindow::slotShowPopup( const QPoint &p ) |
416 | { | 417 | { |
417 | contextMenu->popup( p ); | 418 | contextMenu->popup( p ); |
418 | } | 419 | } |
419 | 420 | ||
420 | void TodoWindow::showCompleted( bool s ) | 421 | void TodoWindow::showCompleted( bool s ) |
421 | { | 422 | { |
422 | if ( !table->isUpdatesEnabled() ) | 423 | if ( !table->isUpdatesEnabled() ) |
423 | return; | 424 | return; |
424 | table->setPaintingEnabled( false ); | 425 | table->setPaintingEnabled( false ); |
425 | table->setShowCompleted( s ); | 426 | table->setShowCompleted( s ); |
426 | table->setPaintingEnabled( true ); | 427 | table->setPaintingEnabled( true ); |
427 | mStack->raiseWidget( 1 ); | 428 | mStack->raiseWidget( 1 ); |
428 | } | 429 | } |
429 | 430 | ||
430 | void TodoWindow::currentEntryChanged( int r, int ) | 431 | void TodoWindow::currentEntryChanged( int r, int ) |
431 | { | 432 | { |
432 | if ( r != -1 && table->rowHeight( r ) > 0 ) { | 433 | if ( r != -1 && table->rowHeight( r ) > 0 ) { |
433 | editAction->setEnabled( TRUE ); | 434 | editAction->setEnabled( TRUE ); |
434 | deleteAction->setEnabled( TRUE ); | 435 | deleteAction->setEnabled( TRUE ); |
435 | duplicateAction->setEnabled( TRUE ); | 436 | duplicateAction->setEnabled( TRUE ); |
436 | deleteAllAction->setEnabled( TRUE ); | 437 | deleteAllAction->setEnabled( TRUE ); |
437 | } else { | 438 | } else { |
438 | editAction->setEnabled( FALSE ); | 439 | editAction->setEnabled( FALSE ); |
439 | deleteAction->setEnabled( FALSE ); | 440 | deleteAction->setEnabled( FALSE ); |
440 | duplicateAction->setEnabled( FALSE ); | 441 | duplicateAction->setEnabled( FALSE ); |
441 | deleteAllAction->setEnabled( FALSE ); | 442 | deleteAllAction->setEnabled( FALSE ); |
442 | } | 443 | } |
443 | } | 444 | } |
444 | 445 | ||
445 | void TodoWindow::setCategory( int c ) | 446 | void TodoWindow::setCategory( int c ) |
446 | { | 447 | { |
447 | if ( c <= 0 ) return; | 448 | if ( c <= 0 ) return; |
448 | if ( !table->isUpdatesEnabled() ) | 449 | if ( !table->isUpdatesEnabled() ) |
449 | return; | 450 | return; |
450 | table->setPaintingEnabled( false ); | 451 | table->setPaintingEnabled( false ); |
451 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) | 452 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) |
452 | catMenu->setItemChecked( i, c == (int)i ); | 453 | catMenu->setItemChecked( i, c == (int)i ); |
453 | if ( c == 1 ) { | 454 | if ( c == 1 ) { |
454 | table->setShowCategory( QString::null ); | 455 | table->setShowCategory( QString::null ); |
455 | setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); | 456 | setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); |
456 | } else if ( c == (int)catMenu->count() - 1 ) { | 457 | } else if ( c == (int)catMenu->count() - 1 ) { |
457 | table->setShowCategory( tr( "Unfiled" ) ); | 458 | table->setShowCategory( tr( "Unfiled" ) ); |
458 | setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); | 459 | setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); |
459 | } else { | 460 | } else { |
460 | QString cat = table->categories()[c - 2]; | 461 | QString cat = table->categories()[c - 2]; |
461 | table->setShowCategory( cat ); | 462 | table->setShowCategory( cat ); |
462 | setCaption( tr("Todo") + " - " + cat ); | 463 | setCaption( tr("Todo") + " - " + cat ); |
463 | } | 464 | } |
464 | table->setPaintingEnabled( true ); | 465 | table->setPaintingEnabled( true ); |
465 | 466 | ||
466 | mStack->raiseWidget( 1 ); | 467 | mStack->raiseWidget( 1 ); |
467 | } | 468 | } |
468 | 469 | ||
469 | void TodoWindow::populateCategories() | 470 | void TodoWindow::populateCategories() |
470 | { | 471 | { |
471 | catMenu->clear(); | 472 | catMenu->clear(); |
472 | int id, rememberId; | 473 | int id, rememberId; |
473 | id = 1; | 474 | id = 1; |
474 | rememberId = 0; | 475 | rememberId = 0; |
475 | catMenu->insertItem( tr( "All Categories" ), id++ ); | 476 | catMenu->insertItem( tr( "All Categories" ), id++ ); |
476 | catMenu->insertSeparator(); | 477 | catMenu->insertSeparator(); |
477 | QStringList categories = table->categories(); | 478 | QStringList categories = table->categories(); |
478 | categories.append( tr( "Unfiled" ) ); | 479 | categories.append( tr( "Unfiled" ) ); |
479 | for ( QStringList::Iterator it = categories.begin(); | 480 | for ( QStringList::Iterator it = categories.begin(); |
480 | it != categories.end(); ++it ) { | 481 | it != categories.end(); ++it ) { |
481 | catMenu->insertItem( *it, id ); | 482 | catMenu->insertItem( *it, id ); |
482 | if ( *it == table->showCategory() ) | 483 | if ( *it == table->showCategory() ) |
483 | rememberId = id; | 484 | rememberId = id; |
484 | ++id; | 485 | ++id; |
485 | } | 486 | } |
486 | if ( table->showCategory().isEmpty() ) | 487 | if ( table->showCategory().isEmpty() ) |
487 | setCategory( 1 ); | 488 | setCategory( 1 ); |
488 | else | 489 | else |
489 | setCategory( rememberId ); | 490 | setCategory( rememberId ); |
490 | } | 491 | } |
491 | 492 | ||
492 | void TodoWindow::reload() | 493 | void TodoWindow::reload() |
493 | { | 494 | { |
494 | table->clear(); | 495 | table->clear(); |
495 | table->load( todolistXMLFilename() ); | 496 | table->load( todolistXMLFilename() ); |
496 | syncing = FALSE; | 497 | syncing = FALSE; |
497 | } | 498 | } |
498 | 499 | ||
499 | void TodoWindow::flush() | 500 | void TodoWindow::flush() |
500 | { | 501 | { |
501 | syncing = TRUE; | 502 | syncing = TRUE; |
502 | table->save( todolistXMLFilename() ); | 503 | table->save( todolistXMLFilename() ); |
503 | } | 504 | } |
504 | 505 | ||
505 | void TodoWindow::closeEvent( QCloseEvent *e ) | 506 | void TodoWindow::closeEvent( QCloseEvent *e ) |
506 | { | 507 | { |
507 | if( mStack->visibleWidget() != table ){ | 508 | if( mStack->visibleWidget() != table ){ |
508 | mStack->raiseWidget( 1 ); | 509 | mStack->raiseWidget( 1 ); |
509 | e->ignore(); | 510 | e->ignore(); |
510 | return; | 511 | return; |
511 | } | 512 | } |
512 | if(syncing) { | 513 | if(syncing) { |
513 | /* no need to save if in the middle of syncing */ | 514 | /* no need to save if in the middle of syncing */ |
514 | e->accept(); | 515 | e->accept(); |
515 | return; | 516 | return; |
516 | } | 517 | } |
517 | 518 | ||
518 | if ( table->save( todolistXMLFilename() ) ) { | 519 | if ( table->save( todolistXMLFilename() ) ) { |
519 | e->accept(); | 520 | e->accept(); |
520 | // repeat for categories... | 521 | // repeat for categories... |
521 | // if writing configs fail, it will emit an | 522 | // if writing configs fail, it will emit an |
522 | // error, but I feel that it is "ok" for us to exit | 523 | // error, but I feel that it is "ok" for us to exit |
523 | // espically since we aren't told if the write succeeded... | 524 | // espically since we aren't told if the write succeeded... |
524 | Config config( "todo" ); | 525 | Config config( "todo" ); |
525 | config.setGroup( "View" ); | 526 | config.setGroup( "View" ); |
526 | config.writeEntry( "ShowComplete", table->showCompleted() ); | 527 | config.writeEntry( "ShowComplete", table->showCompleted() ); |
527 | config.writeEntry( "Category", table->showCategory() ); | 528 | config.writeEntry( "Category", table->showCategory() ); |
528 | /* added 20.01.2k2 by se */ | 529 | /* added 20.01.2k2 by se */ |
529 | config.writeEntry( "ShowDeadLine", table->showDeadline()); | 530 | config.writeEntry( "ShowDeadLine", table->showDeadline()); |
530 | } else { | 531 | } else { |
531 | if ( QMessageBox::critical( this, tr("Out of space"), | 532 | if ( QMessageBox::critical( this, tr("Out of space"), |
532 | tr("Todo was unable\n" | 533 | tr("Todo was unable\n" |
533 | "to save your changes.\n" | 534 | "to save your changes.\n" |
534 | "Free up some space\n" | 535 | "Free up some space\n" |
535 | "and try again.\n" | 536 | "and try again.\n" |
536 | "\nQuit Anyway?"), | 537 | "\nQuit Anyway?"), |
537 | QMessageBox::Yes|QMessageBox::Escape, | 538 | QMessageBox::Yes|QMessageBox::Escape, |
538 | QMessageBox::No|QMessageBox::Default) | 539 | QMessageBox::No|QMessageBox::Default) |
539 | != QMessageBox::No ) | 540 | != QMessageBox::No ) |
540 | e->accept(); | 541 | e->accept(); |
541 | else | 542 | else |
542 | e->ignore(); | 543 | e->ignore(); |
543 | } | 544 | } |
544 | } | 545 | } |
545 | 546 | ||
546 | void TodoWindow::slotFind() | 547 | void TodoWindow::slotFind() |
547 | { | 548 | { |
548 | // put everything back to view all for searching... | 549 | // put everything back to view all for searching... |
549 | mStack->raiseWidget( 1 ); | 550 | mStack->raiseWidget( 1 ); |
550 | if ( !catMenu->isItemChecked( 0 ) ) | 551 | if ( !catMenu->isItemChecked( 0 ) ) |
551 | setCategory( 0 ); | 552 | setCategory( 0 ); |
552 | 553 | ||
553 | FindDialog dlg( "Todo List", this ); | 554 | FindDialog dlg( "Todo List", this ); |
554 | QObject::connect( &dlg, | 555 | QObject::connect( &dlg, |
555 | SIGNAL(signalFindClicked(const QString &, | 556 | SIGNAL(signalFindClicked(const QString &, |
556 | bool, bool, int)), | 557 | bool, bool, int)), |
557 | table, | 558 | table, |
558 | SLOT(slotDoFind(const QString&, bool, bool, int)) ); | 559 | SLOT(slotDoFind(const QString&, bool, bool, int)) ); |
559 | QObject::connect( table, SIGNAL(signalNotFound()), &dlg, | 560 | QObject::connect( table, SIGNAL(signalNotFound()), &dlg, |
560 | SLOT(slotNotFound()) ); | 561 | SLOT(slotNotFound()) ); |
561 | QObject::connect( table, SIGNAL(signalWrapAround()), &dlg, | 562 | QObject::connect( table, SIGNAL(signalWrapAround()), &dlg, |
562 | SLOT(slotWrapAround()) ); | 563 | SLOT(slotWrapAround()) ); |
563 | dlg.exec(); | 564 | dlg.exec(); |
564 | if ( table->numSelections() ) | 565 | if ( table->numSelections() ) |
565 | table->clearSelection(); | 566 | table->clearSelection(); |
566 | table->clearFindRow(); | 567 | table->clearFindRow(); |
567 | } | 568 | } |
568 | 569 | ||
569 | 570 | ||
570 | void TodoWindow::setDocument( const QString &filename ) | 571 | void TodoWindow::setDocument( const QString &filename ) |
571 | { | 572 | { |
572 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; | 573 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; |
573 | 574 | ||
574 | ToDoDB todoDB(filename, new ToDoVCalResource() ); | 575 | ToDoDB todoDB(filename, new ToDoVCalResource() ); |
575 | QValueList<ToDoEvent> tl = todoDB.rawToDos(); | 576 | QValueList<ToDoEvent> tl = todoDB.rawToDos(); |
576 | for( QValueList<ToDoEvent>::Iterator it = tl.begin(); it != tl.end(); ++it ) { | 577 | for( QValueList<ToDoEvent>::Iterator it = tl.begin(); it != tl.end(); ++it ) { |
577 | table->addEntry( *it ); | 578 | table->addEntry( *it ); |
578 | } | 579 | } |
579 | } | 580 | } |
580 | 581 | ||
581 | static const char * beamfile = "/tmp/obex/todo.vcs"; | 582 | static const char * beamfile = "/tmp/obex/todo.vcs"; |
582 | 583 | ||
583 | void TodoWindow::slotBeam() | 584 | void TodoWindow::slotBeam() |
584 | { | 585 | { |
585 | unlink( beamfile ); // delete if exists | 586 | unlink( beamfile ); // delete if exists |
586 | ToDoEvent c = table->currentEntry(); | 587 | ToDoEvent c = table->currentEntry(); |
587 | mkdir("/tmp/obex/", 0755); | 588 | mkdir("/tmp/obex/", 0755); |
588 | ToDoDB todoDB( beamfile, new ToDoVCalResource() ); | 589 | ToDoDB todoDB( beamfile, new ToDoVCalResource() ); |
589 | todoDB.addEvent( c ); | 590 | todoDB.addEvent( c ); |
590 | todoDB.save(); | 591 | todoDB.save(); |
591 | Ir *ir = new Ir( this ); | 592 | Ir *ir = new Ir( this ); |
592 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 593 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
593 | QString description = c.description(); | 594 | QString description = c.description(); |
594 | ir->send( beamfile, description, "text/x-vCalendar" ); | 595 | ir->send( beamfile, description, "text/x-vCalendar" ); |
595 | } | 596 | } |
596 | 597 | ||
597 | void TodoWindow::beamDone( Ir *ir ) | 598 | void TodoWindow::beamDone( Ir *ir ) |
598 | { | 599 | { |
599 | delete ir; | 600 | delete ir; |
600 | unlink( beamfile ); | 601 | unlink( beamfile ); |
601 | } | 602 | } |
602 | 603 | ||
603 | void TodoWindow::showDeadline( bool s ) | 604 | void TodoWindow::showDeadline( bool s ) |
604 | { | 605 | { |
605 | table->setPaintingEnabled( false ); | 606 | table->setPaintingEnabled( false ); |
606 | table->setShowDeadline( s ); | 607 | table->setShowDeadline( s ); |
607 | table->setPaintingEnabled( true ); | 608 | table->setPaintingEnabled( true ); |
608 | } | 609 | } |
609 | void TodoWindow::slotShowDetails() | 610 | void TodoWindow::slotShowDetails() |
610 | { | 611 | { |
611 | ToDoEvent event = table->currentEntry(); | 612 | ToDoEvent event = table->currentEntry(); |
612 | slotShowDetails( event ); | 613 | slotShowDetails( event ); |
613 | } | 614 | } |
614 | void TodoWindow::slotShowDetails( const ToDoEvent &event ) | 615 | void TodoWindow::slotShowDetails( const ToDoEvent &event ) |
615 | { | 616 | { |
616 | if( mView == 0l ){ | 617 | if( mView == 0l ){ |
617 | mView = new TodoLabel(mStack); | 618 | mView = new TodoLabel(mStack); |
618 | mStack->addWidget( mView, 2 ); | 619 | mStack->addWidget( mView, 2 ); |
619 | } | 620 | } |
620 | mView->init( event ); | 621 | mView->init( event ); |
621 | mView->sync(); | 622 | mView->sync(); |
622 | mStack->raiseWidget( 2); | 623 | mStack->raiseWidget( 2); |
623 | } | 624 | } |
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index dc60cc4..208a084 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp | |||
@@ -388,514 +388,513 @@ void TodoTable::removeCurrentEntry() | |||
388 | oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() ); | 388 | oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() ); |
389 | realignTable( row ); | 389 | realignTable( row ); |
390 | updateVisible(); | 390 | updateVisible(); |
391 | updateJournal( *oldTodo, ACTION_REMOVE); | 391 | updateJournal( *oldTodo, ACTION_REMOVE); |
392 | delete oldTodo; | 392 | delete oldTodo; |
393 | } | 393 | } |
394 | 394 | ||
395 | 395 | ||
396 | bool TodoTable::save( const QString &fn ) | 396 | bool TodoTable::save( const QString &fn ) |
397 | { | 397 | { |
398 | QString strNewFile = fn + ".new"; | 398 | QString strNewFile = fn + ".new"; |
399 | QFile::remove( strNewFile ); // just to be sure | 399 | QFile::remove( strNewFile ); // just to be sure |
400 | ToDoDB todoDB( strNewFile ); | 400 | ToDoDB todoDB( strNewFile ); |
401 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); | 401 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); |
402 | it != todoList.end(); ++it ) { | 402 | it != todoList.end(); ++it ) { |
403 | if ( !item( it.key()->row(), 0 ) ) | 403 | if ( !item( it.key()->row(), 0 ) ) |
404 | continue; | 404 | continue; |
405 | ToDoEvent *todo = *it; | 405 | ToDoEvent *todo = *it; |
406 | // sync item with table | 406 | // sync item with table |
407 | todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() ); | 407 | todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() ); |
408 | todo->setPriority( ((ComboItem*)item( it.key()->row(), 1))->text().toInt() ); | 408 | todo->setPriority( ((ComboItem*)item( it.key()->row(), 1))->text().toInt() ); |
409 | todoDB.addEvent( *todo ); | 409 | todoDB.addEvent( *todo ); |
410 | } | 410 | } |
411 | if(!todoDB.save() ){ | 411 | if(!todoDB.save() ){ |
412 | QFile::remove( strNewFile ); | 412 | QFile::remove( strNewFile ); |
413 | return false; | 413 | return false; |
414 | }; | 414 | }; |
415 | // now do the rename | 415 | // now do the rename |
416 | if ( ::rename( strNewFile, fn ) < 0 ) | 416 | if ( ::rename( strNewFile, fn ) < 0 ) |
417 | qWarning( "problem renaming file %s to %s errno %d", | 417 | qWarning( "problem renaming file %s to %s errno %d", |
418 | strNewFile.latin1(), fn.latin1(), errno ); | 418 | strNewFile.latin1(), fn.latin1(), errno ); |
419 | 419 | ||
420 | // remove the journal | 420 | // remove the journal |
421 | QFile::remove( journalFileName() ); | 421 | QFile::remove( journalFileName() ); |
422 | return true; | 422 | return true; |
423 | } | 423 | } |
424 | 424 | ||
425 | void TodoTable::load( const QString &fn ) | 425 | void TodoTable::load( const QString &fn ) |
426 | { | 426 | { |
427 | if ( QFile::exists(journalFileName()) ) { | 427 | if ( QFile::exists(journalFileName()) ) { |
428 | applyJournal(); | 428 | applyJournal(); |
429 | QFile::remove(journalFileName() ); | 429 | QFile::remove(journalFileName() ); |
430 | } | 430 | } |
431 | loadFile( fn ); | 431 | loadFile( fn ); |
432 | // QTable::sortColumn(2,TRUE,TRUE); | 432 | // QTable::sortColumn(2,TRUE,TRUE); |
433 | // QTable::sortColumn(1,TRUE,TRUE); | 433 | // QTable::sortColumn(1,TRUE,TRUE); |
434 | QTable::sortColumn(0,TRUE,TRUE); | 434 | QTable::sortColumn(0,TRUE,TRUE); |
435 | setCurrentCell( 0, 2 ); | 435 | setCurrentCell( 0, 2 ); |
436 | setSorting(true ); | 436 | setSorting(true ); |
437 | mDayTimer->start( 60 * 1000 ); // gone in 60 seconds? | 437 | mDayTimer->start( 60 * 1000 ); // gone in 60 seconds? |
438 | } | 438 | } |
439 | void TodoTable::updateVisible() | 439 | void TodoTable::updateVisible() |
440 | { | 440 | { |
441 | if ( !isUpdatesEnabled() ) | 441 | if ( !isUpdatesEnabled() ) |
442 | return; | 442 | return; |
443 | 443 | ||
444 | if (showDeadl){ | 444 | if (showDeadl){ |
445 | showColumn (3); | 445 | showColumn (3); |
446 | adjustColumn(3); | 446 | adjustColumn(3); |
447 | }else{ | 447 | }else{ |
448 | hideColumn (3); | 448 | hideColumn (3); |
449 | adjustColumn(2); | 449 | adjustColumn(2); |
450 | } | 450 | } |
451 | 451 | ||
452 | int visible = 0; | 452 | int visible = 0; |
453 | int id = mCat.id( "Todo List", showCat ); | 453 | int id = mCat.id( "Todo List", showCat ); |
454 | for ( int row = 0; row < numRows(); row++ ) { | 454 | for ( int row = 0; row < numRows(); row++ ) { |
455 | CheckItem *ci = (CheckItem *)item( row, 0 ); | 455 | CheckItem *ci = (CheckItem *)item( row, 0 ); |
456 | ToDoEvent *t = todoList[ci]; | 456 | ToDoEvent *t = todoList[ci]; |
457 | QArray<int> vlCats = t->categories(); | 457 | QArray<int> vlCats = t->categories(); |
458 | bool hide = false; | 458 | bool hide = false; |
459 | if ( !showComp && ci->isChecked() ) | 459 | if ( !showComp && ci->isChecked() ) |
460 | hide = true; | 460 | hide = true; |
461 | if ( !showCat.isEmpty() ) { | 461 | if ( !showCat.isEmpty() ) { |
462 | if ( showCat == tr( "Unfiled" ) ) { | 462 | if ( showCat == tr( "Unfiled" ) ) { |
463 | if ( vlCats.count() > 0 ) | 463 | if ( vlCats.count() > 0 ) |
464 | hide = true; | 464 | hide = true; |
465 | } else { | 465 | } else { |
466 | // do some comparing, we have to reverse our idea here... which idea? - zecke | 466 | // do some comparing, we have to reverse our idea here... which idea? - zecke |
467 | if ( !hide ) { | 467 | if ( !hide ) { |
468 | hide = true; | 468 | hide = true; |
469 | for ( uint it = 0; it < vlCats.count(); ++it ) { | 469 | for ( uint it = 0; it < vlCats.count(); ++it ) { |
470 | if ( vlCats[it] == id ) { | 470 | if ( vlCats[it] == id ) { |
471 | hide = false; | 471 | hide = false; |
472 | break; | 472 | break; |
473 | } | 473 | } |
474 | } | 474 | } |
475 | } | 475 | } |
476 | } | 476 | } |
477 | } | 477 | } |
478 | if ( hide ) { | 478 | if ( hide ) { |
479 | if ( currentRow() == row ) | 479 | if ( currentRow() == row ) |
480 | setCurrentCell( -1, 0 ); | 480 | setCurrentCell( -1, 0 ); |
481 | if ( rowHeight( row ) > 0 ) | 481 | if ( rowHeight( row ) > 0 ) |
482 | hideRow( row ); | 482 | hideRow( row ); |
483 | } else { | 483 | } else { |
484 | if ( rowHeight( row ) == 0 ) { | 484 | if ( rowHeight( row ) == 0 ) { |
485 | showRow( row ); | 485 | showRow( row ); |
486 | adjustRow( row ); | 486 | adjustRow( row ); |
487 | } | 487 | } |
488 | visible++; | 488 | visible++; |
489 | } | 489 | } |
490 | } | 490 | } |
491 | if ( !visible ) | 491 | if ( !visible ) |
492 | setCurrentCell( -1, 0 ); | 492 | setCurrentCell( -1, 0 ); |
493 | } | 493 | } |
494 | 494 | ||
495 | void TodoTable::viewportPaintEvent( QPaintEvent *pe ) | 495 | void TodoTable::viewportPaintEvent( QPaintEvent *pe ) |
496 | { | 496 | { |
497 | if ( enablePainting ) | 497 | if ( enablePainting ) |
498 | QTable::viewportPaintEvent( pe ); | 498 | QTable::viewportPaintEvent( pe ); |
499 | } | 499 | } |
500 | 500 | ||
501 | void TodoTable::setPaintingEnabled( bool e ) | 501 | void TodoTable::setPaintingEnabled( bool e ) |
502 | { | 502 | { |
503 | if ( e != enablePainting ) { | 503 | if ( e != enablePainting ) { |
504 | if ( !enablePainting ) { | 504 | if ( !enablePainting ) { |
505 | enablePainting = true; | 505 | enablePainting = true; |
506 | rowHeightChanged( 0 ); | 506 | rowHeightChanged( 0 ); |
507 | viewport()->update(); | 507 | viewport()->update(); |
508 | } else { | 508 | } else { |
509 | enablePainting = false; | 509 | enablePainting = false; |
510 | } | 510 | } |
511 | } | 511 | } |
512 | } | 512 | } |
513 | 513 | ||
514 | void TodoTable::clear() | 514 | void TodoTable::clear() |
515 | { | 515 | { |
516 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); | 516 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); |
517 | it != todoList.end(); ++it ) { | 517 | it != todoList.end(); ++it ) { |
518 | ToDoEvent *todo = it.data(); | 518 | ToDoEvent *todo = it.data(); |
519 | updateJournal( *todo, ACTION_REMOVE ); | 519 | updateJournal( *todo, ACTION_REMOVE ); |
520 | delete todo; | 520 | delete todo; |
521 | } | 521 | } |
522 | todoList.clear(); | 522 | todoList.clear(); |
523 | for ( int r = 0; r < numRows(); ++r ) { | 523 | for ( int r = 0; r < numRows(); ++r ) { |
524 | for ( int c = 0; c < numCols(); ++c ) { | 524 | for ( int c = 0; c < numCols(); ++c ) { |
525 | if ( cellWidget( r, c ) ) | 525 | if ( cellWidget( r, c ) ) |
526 | clearCellWidget( r, c ); | 526 | clearCellWidget( r, c ); |
527 | clearCell( r, c ); | 527 | clearCell( r, c ); |
528 | } | 528 | } |
529 | } | 529 | } |
530 | setNumRows( 0 ); | 530 | setNumRows( 0 ); |
531 | } | 531 | } |
532 | 532 | ||
533 | void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ ) | 533 | void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ ) |
534 | { | 534 | { |
535 | // The default for wholeRows is false, however | 535 | // The default for wholeRows is false, however |
536 | // for this todo table we want to exchange complete | 536 | // for this todo table we want to exchange complete |
537 | // rows when sorting. Also, we always want ascending, since | 537 | // rows when sorting. Also, we always want ascending, since |
538 | // the values have a logical order. | 538 | // the values have a logical order. |
539 | QTable::sortColumn( col, ascending, TRUE ); | 539 | QTable::sortColumn( col, ascending, TRUE ); |
540 | updateVisible(); | 540 | updateVisible(); |
541 | } | 541 | } |
542 | 542 | ||
543 | void TodoTable::slotCheckPriority(int row, int col ) | 543 | void TodoTable::slotCheckPriority(int row, int col ) |
544 | { | 544 | { |
545 | // kludgey work around to make forward along the updated priority... | 545 | // kludgey work around to make forward along the updated priority... |
546 | if ( col == 1 ) { | 546 | if ( col == 1 ) { |
547 | // let everyone know!! | 547 | // let everyone know!! |
548 | ComboItem* i = static_cast<ComboItem*>( item( row, col ) ); | 548 | ComboItem* i = static_cast<ComboItem*>( item( row, col ) ); |
549 | emit signalPriorityChanged( i->text().toInt() ); | 549 | emit signalPriorityChanged( i->text().toInt() ); |
550 | } | 550 | } |
551 | } | 551 | } |
552 | 552 | ||
553 | 553 | ||
554 | void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) | 554 | void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) |
555 | { | 555 | { |
556 | QFile f( journalFileName() ); | 556 | QFile f( journalFileName() ); |
557 | if ( !f.open(IO_WriteOnly|IO_Append) ) | 557 | if ( !f.open(IO_WriteOnly|IO_Append) ) |
558 | return; | 558 | return; |
559 | QString buf; | 559 | QString buf; |
560 | QCString str; | 560 | QCString str; |
561 | buf = "<Task"; | 561 | buf = "<Task"; |
562 | // todo.save( buf ); | 562 | // todo.save( buf ); |
563 | buf += " Action=\"" + QString::number( int(action) ) + "\""; | 563 | buf += " Action=\"" + QString::number( int(action) ) + "\""; |
564 | buf += " Uid=\"" + QString::number( todo.uid() ) + "\""; // better write the id | 564 | buf += " Uid=\"" + QString::number( todo.uid() ) + "\""; // better write the id |
565 | buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; | 565 | buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; |
566 | buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; | 566 | buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; |
567 | buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; | 567 | buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; |
568 | QArray<int> arrat = todo.categories(); | 568 | QArray<int> arrat = todo.categories(); |
569 | QString attr; | 569 | QString attr; |
570 | for(uint i=0; i < arrat.count(); i++ ){ | 570 | for(uint i=0; i < arrat.count(); i++ ){ |
571 | attr.append(QString::number(arrat[i])+";" ); | 571 | attr.append(QString::number(arrat[i])+";" ); |
572 | } | 572 | } |
573 | if(!attr.isEmpty() ) // remove the last ; | 573 | if(!attr.isEmpty() ) // remove the last ; |
574 | attr.remove(attr.length()-1, 1 ); | 574 | attr.remove(attr.length()-1, 1 ); |
575 | buf += " Categories=\"" + attr + "\""; | 575 | buf += " Categories=\"" + attr + "\""; |
576 | buf += " Description=\"" + todo.description() + "\""; | 576 | buf += " Description=\"" + todo.description() + "\""; |
577 | if(todo.hasDate() ) { | 577 | if(todo.hasDate() ) { |
578 | buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; | 578 | buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; |
579 | buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; | 579 | buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; |
580 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; | 580 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; |
581 | } | 581 | } |
582 | buf += "/>\n"; | 582 | buf += "/>\n"; |
583 | str = buf.utf8(); | 583 | str = buf.utf8(); |
584 | f.writeBlock( str.data(), str.length() ); | 584 | f.writeBlock( str.data(), str.length() ); |
585 | f.close(); | 585 | f.close(); |
586 | } | 586 | } |
587 | 587 | ||
588 | void TodoTable::rowHeightChanged( int row ) | 588 | void TodoTable::rowHeightChanged( int row ) |
589 | { | 589 | { |
590 | if ( enablePainting ) | 590 | if ( enablePainting ) |
591 | QTable::rowHeightChanged( row ); | 591 | QTable::rowHeightChanged( row ); |
592 | } | 592 | } |
593 | 593 | ||
594 | void TodoTable::loadFile( const QString &/*we use the standard*/ ) | 594 | void TodoTable::loadFile( const QString &/*we use the standard*/ ) |
595 | { | 595 | { |
596 | 596 | ||
597 | QList<ToDoEvent> list; | 597 | QList<ToDoEvent> list; |
598 | ToDoDB todoDB; | 598 | ToDoDB todoDB; |
599 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); | 599 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); |
600 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ | 600 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ |
601 | ToDoEvent *event = new ToDoEvent( (*it) ); | 601 | ToDoEvent *event = new ToDoEvent( (*it) ); |
602 | list.append( event ); | 602 | list.append( event ); |
603 | } | 603 | } |
604 | vaList.clear(); | 604 | vaList.clear(); |
605 | // qDebug("parsing done=%d", t.elapsed() ); | 605 | // qDebug("parsing done=%d", t.elapsed() ); |
606 | if ( list.count() > 0 ) { | 606 | if ( list.count() > 0 ) { |
607 | internalAddEntries( list ); | 607 | internalAddEntries( list ); |
608 | list.clear(); | 608 | list.clear(); |
609 | } | 609 | } |
610 | // qDebug("loading done: t=%d", t.elapsed() ); | 610 | // qDebug("loading done: t=%d", t.elapsed() ); |
611 | } | 611 | } |
612 | 612 | ||
613 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) | 613 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) |
614 | { | 614 | { |
615 | QString strTodo; | 615 | QString strTodo; |
616 | strTodo = todo.description().left(40).simplifyWhiteSpace(); | 616 | strTodo = todo.description().left(40).simplifyWhiteSpace(); |
617 | if ( row == -1 ) { | 617 | if ( row == -1 ) { |
618 | QMapIterator<CheckItem*, ToDoEvent *> it; | 618 | QMapIterator<CheckItem*, ToDoEvent *> it; |
619 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { | 619 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { |
620 | if ( *(*it) == todo ) { | 620 | if ( *(*it) == todo ) { |
621 | row = it.key()->row(); | 621 | row = it.key()->row(); |
622 | it.key()->setChecked( todo.isCompleted() ); | 622 | it.key()->setChecked( todo.isCompleted() ); |
623 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 623 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
624 | item( row, 2 )->setText( strTodo ); | 624 | item( row, 2 )->setText( strTodo ); |
625 | 625 | ||
626 | if (showDeadl){ | 626 | if (showDeadl){ |
627 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 627 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
628 | } | 628 | } |
629 | 629 | ||
630 | *(*it) = todo; | 630 | *(*it) = todo; |
631 | } | 631 | } |
632 | } | 632 | } |
633 | } else { | 633 | } else { |
634 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; | 634 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; |
635 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); | 635 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); |
636 | delete t; | 636 | delete t; |
637 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); | 637 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); |
638 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 638 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
639 | item( row, 2 )->setText( strTodo ); | 639 | item( row, 2 )->setText( strTodo ); |
640 | 640 | ||
641 | if (showDeadl){ | 641 | if (showDeadl){ |
642 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 642 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
643 | } | 643 | } |
644 | ToDoEvent *ev = new ToDoEvent( todo ); | 644 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); |
645 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(ev) ); | ||
646 | } | 645 | } |
647 | } | 646 | } |
648 | 647 | ||
649 | void TodoTable::journalFreeRemoveEntry( int row ) | 648 | void TodoTable::journalFreeRemoveEntry( int row ) |
650 | { | 649 | { |
651 | CheckItem *chk; | 650 | CheckItem *chk; |
652 | chk = static_cast<CheckItem*>(item(row, 0 )); | 651 | chk = static_cast<CheckItem*>(item(row, 0 )); |
653 | if ( !chk ) | 652 | if ( !chk ) |
654 | return; | 653 | return; |
655 | todoList.remove( chk ); | 654 | todoList.remove( chk ); |
656 | 655 | ||
657 | realignTable( row ); | 656 | realignTable( row ); |
658 | } | 657 | } |
659 | 658 | ||
660 | void TodoTable::keyPressEvent( QKeyEvent *e ) | 659 | void TodoTable::keyPressEvent( QKeyEvent *e ) |
661 | { | 660 | { |
662 | if ( e->key() == Key_Space || e->key() == Key_Return ) { | 661 | if ( e->key() == Key_Space || e->key() == Key_Return ) { |
663 | switch ( currentColumn() ) { | 662 | switch ( currentColumn() ) { |
664 | case 0: { | 663 | case 0: { |
665 | CheckItem *i = static_cast<CheckItem*>(item(currentRow(), | 664 | CheckItem *i = static_cast<CheckItem*>(item(currentRow(), |
666 | currentColumn())); | 665 | currentColumn())); |
667 | if ( i ) | 666 | if ( i ) |
668 | i->toggle(); | 667 | i->toggle(); |
669 | break; | 668 | break; |
670 | } | 669 | } |
671 | case 1: | 670 | case 1: |
672 | break; | 671 | break; |
673 | case 2: | 672 | case 2: |
674 | emit signalEdit(); | 673 | emit signalEdit(); |
675 | default: | 674 | default: |
676 | break; | 675 | break; |
677 | } | 676 | } |
678 | } else { | 677 | } else { |
679 | QTable::keyPressEvent( e ); | 678 | QTable::keyPressEvent( e ); |
680 | } | 679 | } |
681 | } | 680 | } |
682 | 681 | ||
683 | QStringList TodoTable::categories() | 682 | QStringList TodoTable::categories() |
684 | { | 683 | { |
685 | // This is called seldom, so calling a load in here | 684 | // This is called seldom, so calling a load in here |
686 | // should be fine. | 685 | // should be fine. |
687 | mCat.load( categoryFileName() ); | 686 | mCat.load( categoryFileName() ); |
688 | QStringList categoryList = mCat.labels( "Todo List" ); | 687 | QStringList categoryList = mCat.labels( "Todo List" ); |
689 | return categoryList; | 688 | return categoryList; |
690 | } | 689 | } |
691 | 690 | ||
692 | void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, | 691 | void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, |
693 | bool backwards, int category ) | 692 | bool backwards, int category ) |
694 | { | 693 | { |
695 | // we have to iterate through the table, this gives the illusion that | 694 | // we have to iterate through the table, this gives the illusion that |
696 | // sorting is actually being used. | 695 | // sorting is actually being used. |
697 | if ( currFindRow < -1 ) | 696 | if ( currFindRow < -1 ) |
698 | currFindRow = currentRow() - 1; | 697 | currFindRow = currentRow() - 1; |
699 | clearSelection( TRUE ); | 698 | clearSelection( TRUE ); |
700 | int rows, | 699 | int rows, |
701 | row; | 700 | row; |
702 | CheckItem *chk; | 701 | CheckItem *chk; |
703 | QRegExp r( findString ); | 702 | QRegExp r( findString ); |
704 | 703 | ||
705 | r.setCaseSensitive( caseSensitive ); | 704 | r.setCaseSensitive( caseSensitive ); |
706 | rows = numRows(); | 705 | rows = numRows(); |
707 | static bool wrapAround = true; | 706 | static bool wrapAround = true; |
708 | 707 | ||
709 | if ( !backwards ) { | 708 | if ( !backwards ) { |
710 | for ( row = currFindRow + 1; row < rows; row++ ) { | 709 | for ( row = currFindRow + 1; row < rows; row++ ) { |
711 | chk = static_cast<CheckItem*>( item(row, 0) ); | 710 | chk = static_cast<CheckItem*>( item(row, 0) ); |
712 | if ( taskCompare(*(todoList[chk]), r, category) ) | 711 | if ( taskCompare(*(todoList[chk]), r, category) ) |
713 | break; | 712 | break; |
714 | } | 713 | } |
715 | } else { | 714 | } else { |
716 | for ( row = currFindRow - 1; row > -1; row-- ) { | 715 | for ( row = currFindRow - 1; row > -1; row-- ) { |
717 | chk = static_cast<CheckItem*>( item(row, 0) ); | 716 | chk = static_cast<CheckItem*>( item(row, 0) ); |
718 | if ( taskCompare(*(todoList[chk]), r, category) ) | 717 | if ( taskCompare(*(todoList[chk]), r, category) ) |
719 | break; | 718 | break; |
720 | } | 719 | } |
721 | } | 720 | } |
722 | if ( row >= rows || row < 0 ) { | 721 | if ( row >= rows || row < 0 ) { |
723 | if ( row < 0 ) | 722 | if ( row < 0 ) |
724 | currFindRow = rows; | 723 | currFindRow = rows; |
725 | else | 724 | else |
726 | currFindRow = -1; | 725 | currFindRow = -1; |
727 | if ( wrapAround ) | 726 | if ( wrapAround ) |
728 | emit signalWrapAround(); | 727 | emit signalWrapAround(); |
729 | else | 728 | else |
730 | emit signalNotFound(); | 729 | emit signalNotFound(); |
731 | wrapAround = !wrapAround; | 730 | wrapAround = !wrapAround; |
732 | } else { | 731 | } else { |
733 | currFindRow = row; | 732 | currFindRow = row; |
734 | QTableSelection foundSelection; | 733 | QTableSelection foundSelection; |
735 | foundSelection.init( currFindRow, 0 ); | 734 | foundSelection.init( currFindRow, 0 ); |
736 | foundSelection.expandTo( currFindRow, numCols() - 1 ); | 735 | foundSelection.expandTo( currFindRow, numCols() - 1 ); |
737 | addSelection( foundSelection ); | 736 | addSelection( foundSelection ); |
738 | setCurrentCell( currFindRow, numCols() - 1 ); | 737 | setCurrentCell( currFindRow, numCols() - 1 ); |
739 | // we should always be able to wrap around and find this again, | 738 | // we should always be able to wrap around and find this again, |
740 | // so don't give confusing not found message... | 739 | // so don't give confusing not found message... |
741 | wrapAround = true; | 740 | wrapAround = true; |
742 | } | 741 | } |
743 | } | 742 | } |
744 | 743 | ||
745 | int TodoTable::showCategoryId() const | 744 | int TodoTable::showCategoryId() const |
746 | { | 745 | { |
747 | int id; | 746 | int id; |
748 | id = -1; | 747 | id = -1; |
749 | // if allcategories are selected, you get unfiled... | 748 | // if allcategories are selected, you get unfiled... |
750 | if ( showCat != tr( "Unfiled" ) && showCat != tr( "All" ) ) | 749 | if ( showCat != tr( "Unfiled" ) && showCat != tr( "All" ) ) |
751 | id = mCat.id( "Todo List", showCat ); | 750 | id = mCat.id( "Todo List", showCat ); |
752 | return id; | 751 | return id; |
753 | } | 752 | } |
754 | void TodoTable::applyJournal() | 753 | void TodoTable::applyJournal() |
755 | { | 754 | { |
756 | // we need to hack | 755 | // we need to hack |
757 | QFile file( journalFileName() ); | 756 | QFile file( journalFileName() ); |
758 | if( file.open(IO_ReadOnly ) ) { | 757 | if( file.open(IO_ReadOnly ) ) { |
759 | QByteArray ar = file.readAll(); | 758 | QByteArray ar = file.readAll(); |
760 | file.close(); | 759 | file.close(); |
761 | QFile file2( journalFileName() + "_new" ); | 760 | QFile file2( journalFileName() + "_new" ); |
762 | if( file2.open(IO_WriteOnly ) ){ | 761 | if( file2.open(IO_WriteOnly ) ){ |
763 | QTextStream str(&file2 ); | 762 | QTextStream str(&file2 ); |
764 | str << QString::fromLatin1("<Tasks>") << endl; | 763 | str << QString::fromLatin1("<Tasks>") << endl; |
765 | str << ar.data(); | 764 | str << ar.data(); |
766 | str << QString::fromLatin1("</Tasks>") << endl; | 765 | str << QString::fromLatin1("</Tasks>") << endl; |
767 | file2.close(); | 766 | file2.close(); |
768 | } | 767 | } |
769 | XMLElement *root = XMLElement::load(journalFileName()+ "_new"); | 768 | XMLElement *root = XMLElement::load(journalFileName()+ "_new"); |
770 | XMLElement *el = root->firstChild(); | 769 | XMLElement *el = root->firstChild(); |
771 | el = el->firstChild(); | 770 | el = el->firstChild(); |
772 | ToDoDB tododb; // allready loaded ;) | 771 | ToDoDB tododb; // allready loaded ;) |
773 | bool ok; | 772 | bool ok; |
774 | int action; | 773 | int action; |
775 | QString dummy; | 774 | QString dummy; |
776 | while( el ){ | 775 | while( el ){ |
777 | dummy = el->attribute("Action" ); | 776 | dummy = el->attribute("Action" ); |
778 | action = dummy.toInt(&ok ); | 777 | action = dummy.toInt(&ok ); |
779 | ToDoEvent ev = xmlToEvent( el ); | 778 | ToDoEvent ev = xmlToEvent( el ); |
780 | if(ok ){ | 779 | if(ok ){ |
781 | switch( action){ | 780 | switch( action){ |
782 | case ACTION_ADD: | 781 | case ACTION_ADD: |
783 | tododb.addEvent(ev ); | 782 | tododb.addEvent(ev ); |
784 | break; | 783 | break; |
785 | case ACTION_REMOVE: | 784 | case ACTION_REMOVE: |
786 | tododb.removeEvent( ev ); | 785 | tododb.removeEvent( ev ); |
787 | break; | 786 | break; |
788 | case ACTION_REPLACE: | 787 | case ACTION_REPLACE: |
789 | tododb.replaceEvent( ev ); | 788 | tododb.replaceEvent( ev ); |
790 | break; | 789 | break; |
791 | } | 790 | } |
792 | } | 791 | } |
793 | el = el->nextChild(); | 792 | el = el->nextChild(); |
794 | } | 793 | } |
795 | QFile::remove(journalFileName()+ "_new" ); | 794 | QFile::remove(journalFileName()+ "_new" ); |
796 | tododb.save(); | 795 | tododb.save(); |
797 | } | 796 | } |
798 | } | 797 | } |
799 | void TodoTable::slotCheckDay() | 798 | void TodoTable::slotCheckDay() |
800 | { | 799 | { |
801 | QDate date = QDate::currentDate(); | 800 | QDate date = QDate::currentDate(); |
802 | if( mDay.daysTo(date )!= 0 ){ | 801 | if( mDay.daysTo(date )!= 0 ){ |
803 | setPaintingEnabled( FALSE ); | 802 | setPaintingEnabled( FALSE ); |
804 | for(int i=0; i < numRows(); i++ ){ | 803 | for(int i=0; i < numRows(); i++ ){ |
805 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(i, 0))]; | 804 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(i, 0))]; |
806 | static_cast<DueTextItem*>(item(i, 3) )->setToDoEvent( t ); | 805 | static_cast<DueTextItem*>(item(i, 3) )->setToDoEvent( t ); |
807 | 806 | ||
808 | } | 807 | } |
809 | setPaintingEnabled( TRUE ); | 808 | setPaintingEnabled( TRUE ); |
810 | mDay = date; | 809 | mDay = date; |
811 | } | 810 | } |
812 | mDayTimer->start( 60 * 1000 ); // 60 seconds | 811 | mDayTimer->start( 60 * 1000 ); // 60 seconds |
813 | } | 812 | } |
814 | // check Action and decide | 813 | // check Action and decide |
815 | /* | 814 | /* |
816 | void TodoTable::doApply(XMLElement *el ) | 815 | void TodoTable::doApply(XMLElement *el ) |
817 | { | 816 | { |
818 | QString dummy; | 817 | QString dummy; |
819 | bool ok; | 818 | bool ok; |
820 | int action; | 819 | int action; |
821 | dummy = el->attribute("Action" ); | 820 | dummy = el->attribute("Action" ); |
822 | action = dummy.toInt(&ok ); | 821 | action = dummy.toInt(&ok ); |
823 | ToDoEvent ev = xmlToEvent( el ); | 822 | ToDoEvent ev = xmlToEvent( el ); |
824 | if( ok ){ | 823 | if( ok ){ |
825 | switch( action ){ | 824 | switch( action ){ |
826 | case ACTION_ADD: | 825 | case ACTION_ADD: |
827 | addEntry( ev ); | 826 | addEntry( ev ); |
828 | break; | 827 | break; |
829 | case ACTION_REMOVE:{ // find an entry with the same uid and remove it then | 828 | case ACTION_REMOVE:{ // find an entry with the same uid and remove it then |
830 | break; | 829 | break; |
831 | } | 830 | } |
832 | case ACTION_REPLACE: | 831 | case ACTION_REPLACE: |
833 | break; | 832 | break; |
834 | } | 833 | } |
835 | } | 834 | } |
836 | } | 835 | } |
837 | */ | 836 | */ |
838 | namespace { | 837 | namespace { |
839 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ) | 838 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ) |
840 | { | 839 | { |
841 | bool returnMe; | 840 | bool returnMe; |
842 | QArray<int> cats; | 841 | QArray<int> cats; |
843 | cats = task.categories(); | 842 | cats = task.categories(); |
844 | 843 | ||
845 | returnMe = false; | 844 | returnMe = false; |
846 | if ( (category == -1 && cats.count() == 0) || category == -2 ) | 845 | if ( (category == -1 && cats.count() == 0) || category == -2 ) |
847 | returnMe = task.match( r ); | 846 | returnMe = task.match( r ); |
848 | else { | 847 | else { |
849 | int i; | 848 | int i; |
850 | for ( i = 0; i < int(cats.count()); i++ ) { | 849 | for ( i = 0; i < int(cats.count()); i++ ) { |
851 | if ( cats[i] == category ) { | 850 | if ( cats[i] == category ) { |
852 | returnMe = task.match( r ); | 851 | returnMe = task.match( r ); |
853 | break; | 852 | break; |
854 | } | 853 | } |
855 | } | 854 | } |
856 | } | 855 | } |
857 | return returnMe; | 856 | return returnMe; |
858 | } | 857 | } |
859 | 858 | ||
860 | static QString journalFileName() | 859 | static QString journalFileName() |
861 | { | 860 | { |
862 | QString str; | 861 | QString str; |
863 | str = getenv( "HOME" ); | 862 | str = getenv( "HOME" ); |
864 | str += "/.opie_todojournal"; | 863 | str += "/.opie_todojournal"; |
865 | return str; | 864 | return str; |
866 | } | 865 | } |
867 | static ToDoEvent xmlToEvent( XMLElement *element ) | 866 | static ToDoEvent xmlToEvent( XMLElement *element ) |
868 | { | 867 | { |
869 | QString dummy; | 868 | QString dummy; |
870 | ToDoEvent event; | 869 | ToDoEvent event; |
871 | bool ok; | 870 | bool ok; |
872 | int dumInt; | 871 | int dumInt; |
873 | // completed | 872 | // completed |
874 | dummy = element->attribute("Completed" ); | 873 | dummy = element->attribute("Completed" ); |
875 | dumInt = dummy.toInt(&ok ); | 874 | dumInt = dummy.toInt(&ok ); |
876 | if(ok ) event.setCompleted( dumInt == 0 ? false : true ); | 875 | if(ok ) event.setCompleted( dumInt == 0 ? false : true ); |
877 | // hasDate | 876 | // hasDate |
878 | dummy = element->attribute("HasDate" ); | 877 | dummy = element->attribute("HasDate" ); |
879 | dumInt = dummy.toInt(&ok ); | 878 | dumInt = dummy.toInt(&ok ); |
880 | if(ok ) event.setHasDate( dumInt == 0 ? false: true ); | 879 | if(ok ) event.setHasDate( dumInt == 0 ? false: true ); |
881 | // set the date | 880 | // set the date |
882 | bool hasDa = dumInt; | 881 | bool hasDa = dumInt; |
883 | if ( hasDa ) { //parse the date | 882 | if ( hasDa ) { //parse the date |
884 | int year, day, month = 0; | 883 | int year, day, month = 0; |
885 | year = day = month; | 884 | year = day = month; |
886 | // year | 885 | // year |
887 | dummy = element->attribute("DateYear" ); | 886 | dummy = element->attribute("DateYear" ); |
888 | dumInt = dummy.toInt(&ok ); | 887 | dumInt = dummy.toInt(&ok ); |
889 | if( ok ) year = dumInt; | 888 | if( ok ) year = dumInt; |
890 | // month | 889 | // month |
891 | dummy = element->attribute("DateMonth" ); | 890 | dummy = element->attribute("DateMonth" ); |
892 | dumInt = dummy.toInt(&ok ); | 891 | dumInt = dummy.toInt(&ok ); |
893 | if(ok ) month = dumInt; | 892 | if(ok ) month = dumInt; |
894 | dummy = element->attribute("DateDay" ); | 893 | dummy = element->attribute("DateDay" ); |
895 | dumInt = dummy.toInt(&ok ); | 894 | dumInt = dummy.toInt(&ok ); |
896 | if(ok ) day = dumInt; | 895 | if(ok ) day = dumInt; |
897 | // set the date | 896 | // set the date |
898 | QDate date( year, month, day ); | 897 | QDate date( year, month, day ); |
899 | event.setDate( date); | 898 | event.setDate( date); |
900 | } | 899 | } |
901 | dummy = element->attribute("Priority" ); | 900 | dummy = element->attribute("Priority" ); |