author | zecke <zecke> | 2002-10-19 00:10:15 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-19 00:10:15 (UTC) |
commit | e869be9990c0db11288bd196778cadd0ad6976a9 (patch) (unidiff) | |
tree | ee3474f8e5498466896e830bbeee68d618f7aff2 | |
parent | 549472ef07703ef27dc5f58a37e8f16c714fb2a1 (diff) | |
download | opie-e869be9990c0db11288bd196778cadd0ad6976a9.zip opie-e869be9990c0db11288bd196778cadd0ad6976a9.tar.gz opie-e869be9990c0db11288bd196778cadd0ad6976a9.tar.bz2 |
MainWindow setReadAhead added
Tableview we now try to read ahead in timerEvent..
the TodoView interface needs an update on this matter too...
besides that I'm quite happy with the speed and go on to implement new
features
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 4 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 1 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 54 | ||||
-rw-r--r-- | core/pim/todo/tableview.h | 3 |
4 files changed, 60 insertions, 2 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 2994915..a6d657c 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -168,512 +168,516 @@ void MainWindow::initActions() { | |||
168 | 168 | ||
169 | m_options->insertSeparator(); | 169 | m_options->insertSeparator(); |
170 | 170 | ||
171 | m_bar->insertItem( tr("Data") ,m_edit ); | 171 | m_bar->insertItem( tr("Data") ,m_edit ); |
172 | m_bar->insertItem( tr("Category"), m_catMenu ); | 172 | m_bar->insertItem( tr("Category"), m_catMenu ); |
173 | m_bar->insertItem( tr("Options"), m_options ); | 173 | m_bar->insertItem( tr("Options"), m_options ); |
174 | 174 | ||
175 | /* initialize the view menu */ | 175 | /* initialize the view menu */ |
176 | a = new QAction( QString::null, tr("Show over due"), | 176 | a = new QAction( QString::null, tr("Show over due"), |
177 | 0, this, 0, TRUE ); | 177 | 0, this, 0, TRUE ); |
178 | a->addTo( m_view ); | 178 | a->addTo( m_view ); |
179 | a->setOn( showOverDue() ); | 179 | a->setOn( showOverDue() ); |
180 | connect(a, SIGNAL(toggled(bool)), | 180 | connect(a, SIGNAL(toggled(bool)), |
181 | this, SLOT(slotShowDue(bool) ) ); | 181 | this, SLOT(slotShowDue(bool) ) ); |
182 | m_view->insertSeparator(); | 182 | m_view->insertSeparator(); |
183 | 183 | ||
184 | m_bar->insertItem( tr("View"), m_view ); | 184 | m_bar->insertItem( tr("View"), m_view ); |
185 | 185 | ||
186 | /* templates */ | 186 | /* templates */ |
187 | m_edit->insertItem(tr("New from template"), m_template, | 187 | m_edit->insertItem(tr("New from template"), m_template, |
188 | -1, 0 ); | 188 | -1, 0 ); |
189 | 189 | ||
190 | } | 190 | } |
191 | /* m_curCat from Config */ | 191 | /* m_curCat from Config */ |
192 | void MainWindow::initConfig() { | 192 | void MainWindow::initConfig() { |
193 | Config config( "todo" ); | 193 | Config config( "todo" ); |
194 | config.setGroup( "View" ); | 194 | config.setGroup( "View" ); |
195 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); | 195 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); |
196 | m_curCat = config.readEntry( "Category", QString::null ); | 196 | m_curCat = config.readEntry( "Category", QString::null ); |
197 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); | 197 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); |
198 | m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); | 198 | m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); |
199 | } | 199 | } |
200 | void MainWindow::initUI() { | 200 | void MainWindow::initUI() { |
201 | m_stack = new QWidgetStack(this, "main stack"); | 201 | m_stack = new QWidgetStack(this, "main stack"); |
202 | setCentralWidget( m_stack ); | 202 | setCentralWidget( m_stack ); |
203 | 203 | ||
204 | setToolBarsMovable( FALSE ); | 204 | setToolBarsMovable( FALSE ); |
205 | 205 | ||
206 | m_tool = new QToolBar( this ); | 206 | m_tool = new QToolBar( this ); |
207 | m_tool->setHorizontalStretchable( TRUE ); | 207 | m_tool->setHorizontalStretchable( TRUE ); |
208 | 208 | ||
209 | m_bar = new QMenuBar( m_tool ); | 209 | m_bar = new QMenuBar( m_tool ); |
210 | 210 | ||
211 | /** QPopupMenu */ | 211 | /** QPopupMenu */ |
212 | m_edit = new QPopupMenu( this ); | 212 | m_edit = new QPopupMenu( this ); |
213 | m_options = new QPopupMenu( this ); | 213 | m_options = new QPopupMenu( this ); |
214 | m_view = new QPopupMenu( this ); | 214 | m_view = new QPopupMenu( this ); |
215 | m_catMenu = new QPopupMenu( this ); | 215 | m_catMenu = new QPopupMenu( this ); |
216 | m_template = new QPopupMenu( this ); | 216 | m_template = new QPopupMenu( this ); |
217 | 217 | ||
218 | m_catMenu->setCheckable( TRUE ); | 218 | m_catMenu->setCheckable( TRUE ); |
219 | m_template->setCheckable( TRUE ); | 219 | m_template->setCheckable( TRUE ); |
220 | 220 | ||
221 | connect(m_catMenu, SIGNAL(activated(int) ), | 221 | connect(m_catMenu, SIGNAL(activated(int) ), |
222 | this, SLOT(setCategory(int) ) ); | 222 | this, SLOT(setCategory(int) ) ); |
223 | connect(m_template, SIGNAL(activated(int) ), | 223 | connect(m_template, SIGNAL(activated(int) ), |
224 | this, SLOT(slotNewFromTemplate(int) ) ); | 224 | this, SLOT(slotNewFromTemplate(int) ) ); |
225 | } | 225 | } |
226 | void MainWindow::initViews() { | 226 | void MainWindow::initViews() { |
227 | TableView* tableView = new TableView( this, this ); | 227 | TableView* tableView = new TableView( this, this ); |
228 | m_stack->addWidget( tableView, m_counter++ ); | 228 | m_stack->addWidget( tableView, m_counter++ ); |
229 | m_views.append( tableView ); | 229 | m_views.append( tableView ); |
230 | m_curView = tableView; | 230 | m_curView = tableView; |
231 | connectBase( tableView ); | 231 | connectBase( tableView ); |
232 | /* add QString type + QString configname to | 232 | /* add QString type + QString configname to |
233 | * the View menu | 233 | * the View menu |
234 | * and subdirs for multiple views | 234 | * and subdirs for multiple views |
235 | */ | 235 | */ |
236 | } | 236 | } |
237 | void MainWindow::initEditor() { | 237 | void MainWindow::initEditor() { |
238 | m_curEdit = new Editor(); | 238 | m_curEdit = new Editor(); |
239 | } | 239 | } |
240 | void MainWindow::initShow() { | 240 | void MainWindow::initShow() { |
241 | m_curShow = new TextViewShow(this); | 241 | m_curShow = new TextViewShow(this); |
242 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); | 242 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); |
243 | } | 243 | } |
244 | MainWindow::~MainWindow() { | 244 | MainWindow::~MainWindow() { |
245 | delete templateManager(); | 245 | delete templateManager(); |
246 | } | 246 | } |
247 | void MainWindow::connectBase( ViewBase* base) { | 247 | void MainWindow::connectBase( ViewBase* base) { |
248 | base->connectShow( this, SLOT(slotShow(int) ) ); | 248 | base->connectShow( this, SLOT(slotShow(int) ) ); |
249 | base->connectEdit( this, SLOT(slotEdit(int) ) ); | 249 | base->connectEdit( this, SLOT(slotEdit(int) ) ); |
250 | base->connectUpdateSmall( this, | 250 | base->connectUpdateSmall( this, |
251 | SLOT(slotUpate1(int, const Todo::SmallTodo&) )); | 251 | SLOT(slotUpate1(int, const Todo::SmallTodo&) )); |
252 | base->connectUpdateBig( this, | 252 | base->connectUpdateBig( this, |
253 | SLOT(slotUpate2(int, const OTodo& ) ) ); | 253 | SLOT(slotUpate2(int, const OTodo& ) ) ); |
254 | base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; | 254 | base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; |
255 | base->connectRemove(&m_todoMgr, | 255 | base->connectRemove(&m_todoMgr, |
256 | SLOT(remove(int)) ); | 256 | SLOT(remove(int)) ); |
257 | } | 257 | } |
258 | QPopupMenu* MainWindow::contextMenu( int uid ) { | 258 | QPopupMenu* MainWindow::contextMenu( int uid ) { |
259 | QPopupMenu* menu = new QPopupMenu(); | 259 | QPopupMenu* menu = new QPopupMenu(); |
260 | 260 | ||
261 | m_editAction->addTo( menu ); | 261 | m_editAction->addTo( menu ); |
262 | m_deleteAction->addTo( menu ); | 262 | m_deleteAction->addTo( menu ); |
263 | m_duplicateAction->addTo( menu ); | 263 | m_duplicateAction->addTo( menu ); |
264 | menu->insertSeparator(); | 264 | menu->insertSeparator(); |
265 | 265 | ||
266 | return menu; | 266 | return menu; |
267 | } | 267 | } |
268 | QPopupMenu* MainWindow::options() { | 268 | QPopupMenu* MainWindow::options() { |
269 | qWarning("Options"); | 269 | qWarning("Options"); |
270 | return m_options; | 270 | return m_options; |
271 | } | 271 | } |
272 | QPopupMenu* MainWindow::edit() { | 272 | QPopupMenu* MainWindow::edit() { |
273 | return m_edit; | 273 | return m_edit; |
274 | } | 274 | } |
275 | QPopupMenu* MainWindow::view() { | 275 | QPopupMenu* MainWindow::view() { |
276 | return m_view; | 276 | return m_view; |
277 | } | 277 | } |
278 | QToolBar* MainWindow::toolbar() { | 278 | QToolBar* MainWindow::toolbar() { |
279 | return m_tool; | 279 | return m_tool; |
280 | } | 280 | } |
281 | OTodoAccess::List MainWindow::list()const { | 281 | OTodoAccess::List MainWindow::list()const { |
282 | return m_todoMgr.list(); | 282 | return m_todoMgr.list(); |
283 | } | 283 | } |
284 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 284 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
285 | int cat = 0; | 285 | int cat = 0; |
286 | if ( m_curCat != tr("All Categories") ) | 286 | if ( m_curCat != tr("All Categories") ) |
287 | cat = currentCatId(); | 287 | cat = currentCatId(); |
288 | 288 | ||
289 | int filter = 1; | 289 | int filter = 1; |
290 | 290 | ||
291 | if (!m_completed ) | 291 | if (!m_completed ) |
292 | filter |= 4; | 292 | filter |= 4; |
293 | if (m_overdue) | 293 | if (m_overdue) |
294 | filter |= 2; | 294 | filter |= 2; |
295 | 295 | ||
296 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | 296 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); |
297 | } | 297 | } |
298 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 298 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
299 | int cat = 0; | 299 | int cat = 0; |
300 | if ( m_curCat != tr("All Categories") ) | 300 | if ( m_curCat != tr("All Categories") ) |
301 | cat = currentCatId(); | 301 | cat = currentCatId(); |
302 | 302 | ||
303 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | 303 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); |
304 | } | 304 | } |
305 | OTodo MainWindow::event( int uid ) { | 305 | OTodo MainWindow::event( int uid ) { |
306 | return m_todoMgr.event( uid ); | 306 | return m_todoMgr.event( uid ); |
307 | } | 307 | } |
308 | bool MainWindow::isSyncing()const { | 308 | bool MainWindow::isSyncing()const { |
309 | return m_syncing; | 309 | return m_syncing; |
310 | } | 310 | } |
311 | TemplateManager* MainWindow::templateManager() { | 311 | TemplateManager* MainWindow::templateManager() { |
312 | return m_tempManager; | 312 | return m_tempManager; |
313 | } | 313 | } |
314 | Editor* MainWindow::currentEditor() { | 314 | Editor* MainWindow::currentEditor() { |
315 | return m_curEdit; | 315 | return m_curEdit; |
316 | } | 316 | } |
317 | TodoShow* MainWindow::currentShow() { | 317 | TodoShow* MainWindow::currentShow() { |
318 | return m_curShow; | 318 | return m_curShow; |
319 | } | 319 | } |
320 | void MainWindow::slotReload() { | 320 | void MainWindow::slotReload() { |
321 | m_todoMgr.reload(); | 321 | m_todoMgr.reload(); |
322 | currentView()->updateView( ); | 322 | currentView()->updateView( ); |
323 | raiseCurrentView(); | 323 | raiseCurrentView(); |
324 | } | 324 | } |
325 | void MainWindow::closeEvent( QCloseEvent* e ) { | 325 | void MainWindow::closeEvent( QCloseEvent* e ) { |
326 | if (m_stack->visibleWidget() == currentShow()->widget() ) { | 326 | if (m_stack->visibleWidget() == currentShow()->widget() ) { |
327 | raiseCurrentView(); | 327 | raiseCurrentView(); |
328 | e->ignore(); | 328 | e->ignore(); |
329 | return; | 329 | return; |
330 | } | 330 | } |
331 | /* | 331 | /* |
332 | * we should have flushed and now we're still saving | 332 | * we should have flushed and now we're still saving |
333 | * so there is no need to flush | 333 | * so there is no need to flush |
334 | */ | 334 | */ |
335 | if (m_syncing ) { | 335 | if (m_syncing ) { |
336 | e->accept(); | 336 | e->accept(); |
337 | return; | 337 | return; |
338 | } | 338 | } |
339 | bool quit = false; | 339 | bool quit = false; |
340 | if ( m_todoMgr.saveAll() ){ | 340 | if ( m_todoMgr.saveAll() ){ |
341 | qWarning("saved"); | 341 | qWarning("saved"); |
342 | quit = true; | 342 | quit = true; |
343 | }else { | 343 | }else { |
344 | if ( QMessageBox::critical( this, tr("Out of space"), | 344 | if ( QMessageBox::critical( this, tr("Out of space"), |
345 | tr("Todo was unable\n" | 345 | tr("Todo was unable\n" |
346 | "to save your changes.\n" | 346 | "to save your changes.\n" |
347 | "Free up some space\n" | 347 | "Free up some space\n" |
348 | "and try again.\n" | 348 | "and try again.\n" |
349 | "\nQuit Anyway?"), | 349 | "\nQuit Anyway?"), |
350 | QMessageBox::Yes|QMessageBox::Escape, | 350 | QMessageBox::Yes|QMessageBox::Escape, |
351 | QMessageBox::No|QMessageBox::Default) | 351 | QMessageBox::No|QMessageBox::Default) |
352 | != QMessageBox::No ) { | 352 | != QMessageBox::No ) { |
353 | e->accept(); | 353 | e->accept(); |
354 | quit = true; | 354 | quit = true; |
355 | }else | 355 | }else |
356 | e->ignore(); | 356 | e->ignore(); |
357 | 357 | ||
358 | } | 358 | } |
359 | 359 | ||
360 | if (quit ) { | 360 | if (quit ) { |
361 | Config config( "todo" ); | 361 | Config config( "todo" ); |
362 | config.setGroup( "View" ); | 362 | config.setGroup( "View" ); |
363 | config.writeEntry( "ShowComplete", showCompleted() ); | 363 | config.writeEntry( "ShowComplete", showCompleted() ); |
364 | config.writeEntry( "Category", currentCategory() ); | 364 | config.writeEntry( "Category", currentCategory() ); |
365 | config.writeEntry( "ShowDeadLine", showDeadline()); | 365 | config.writeEntry( "ShowDeadLine", showDeadline()); |
366 | config.writeEntry( "ShowOverDue", showOverDue() ); | 366 | config.writeEntry( "ShowOverDue", showOverDue() ); |
367 | /* svae templates */ | 367 | /* svae templates */ |
368 | templateManager()->save(); | 368 | templateManager()->save(); |
369 | e->accept(); | 369 | e->accept(); |
370 | } | 370 | } |
371 | } | 371 | } |
372 | void MainWindow::populateTemplates() { | 372 | void MainWindow::populateTemplates() { |
373 | m_template->clear(); | 373 | m_template->clear(); |
374 | QStringList list = templateManager()->templates(); | 374 | QStringList list = templateManager()->templates(); |
375 | QStringList::Iterator it; | 375 | QStringList::Iterator it; |
376 | for ( it = list.begin(); it != list.end(); ++it ) { | 376 | for ( it = list.begin(); it != list.end(); ++it ) { |
377 | m_template->insertItem( (*it) ); | 377 | m_template->insertItem( (*it) ); |
378 | } | 378 | } |
379 | } | 379 | } |
380 | /* | 380 | /* |
381 | * slotNewFromTemplate | 381 | * slotNewFromTemplate |
382 | * We use the edit widget to do | 382 | * We use the edit widget to do |
383 | * the config but we setUid(-1) | 383 | * the config but we setUid(-1) |
384 | * to get a new uid | 384 | * to get a new uid |
385 | */ | 385 | */ |
386 | /* | 386 | /* |
387 | * first we get the name of the template | 387 | * first we get the name of the template |
388 | * then we will use the TemplateManager | 388 | * then we will use the TemplateManager |
389 | */ | 389 | */ |
390 | void MainWindow::slotNewFromTemplate( int id ) { | 390 | void MainWindow::slotNewFromTemplate( int id ) { |
391 | QString name = m_template->text( id ); | 391 | QString name = m_template->text( id ); |
392 | 392 | ||
393 | OTodo event = templateManager()->templateEvent( name ); | 393 | OTodo event = templateManager()->templateEvent( name ); |
394 | event = currentEditor()->edit(this, | 394 | event = currentEditor()->edit(this, |
395 | event ); | 395 | event ); |
396 | 396 | ||
397 | if ( currentEditor()->accepted() ) { | 397 | if ( currentEditor()->accepted() ) { |
398 | /* assign new todo */ | 398 | /* assign new todo */ |
399 | event.setUid( -1 ); | 399 | event.setUid( -1 ); |
400 | currentView()->addEvent( event ); | 400 | currentView()->addEvent( event ); |
401 | m_todoMgr.add( event ); | 401 | m_todoMgr.add( event ); |
402 | 402 | ||
403 | populateCategories(); | 403 | populateCategories(); |
404 | } | 404 | } |
405 | } | 405 | } |
406 | void MainWindow::slotNew() { | 406 | void MainWindow::slotNew() { |
407 | if(m_syncing) { | 407 | if(m_syncing) { |
408 | QMessageBox::warning(this, tr("Todo"), | 408 | QMessageBox::warning(this, tr("Todo"), |
409 | tr("Can not edit data, currently syncing")); | 409 | tr("Can not edit data, currently syncing")); |
410 | return; | 410 | return; |
411 | } | 411 | } |
412 | 412 | ||
413 | 413 | ||
414 | OTodo todo = currentEditor()->newTodo( currentCatId(), | 414 | OTodo todo = currentEditor()->newTodo( currentCatId(), |
415 | this ); | 415 | this ); |
416 | 416 | ||
417 | if ( currentEditor()->accepted() ) { | 417 | if ( currentEditor()->accepted() ) { |
418 | //todo.assignUid(); | 418 | //todo.assignUid(); |
419 | currentView()->addEvent( todo ); | 419 | currentView()->addEvent( todo ); |
420 | m_todoMgr.add( todo ); | 420 | m_todoMgr.add( todo ); |
421 | 421 | ||
422 | // I'm afraid we must call this every time now, otherwise | 422 | // I'm afraid we must call this every time now, otherwise |
423 | // spend expensive time comparing all these strings... | 423 | // spend expensive time comparing all these strings... |
424 | // but only call if we changed something -zecke | 424 | // but only call if we changed something -zecke |
425 | populateCategories(); | 425 | populateCategories(); |
426 | } | 426 | } |
427 | raiseCurrentView( ); | 427 | raiseCurrentView( ); |
428 | } | 428 | } |
429 | void MainWindow::slotDuplicate() { | 429 | void MainWindow::slotDuplicate() { |
430 | if(m_syncing) { | 430 | if(m_syncing) { |
431 | QMessageBox::warning(this, tr("Todo"), | 431 | QMessageBox::warning(this, tr("Todo"), |
432 | tr("Can not edit data, currently syncing")); | 432 | tr("Can not edit data, currently syncing")); |
433 | return; | 433 | return; |
434 | } | 434 | } |
435 | OTodo ev = m_todoMgr.event( currentView()->current() ); | 435 | OTodo ev = m_todoMgr.event( currentView()->current() ); |
436 | /* let's generate a new uid */ | 436 | /* let's generate a new uid */ |
437 | ev.setUid(-1); | 437 | ev.setUid(-1); |
438 | m_todoMgr.add( ev ); | 438 | m_todoMgr.add( ev ); |
439 | 439 | ||
440 | currentView()->addEvent( ev ); | 440 | currentView()->addEvent( ev ); |
441 | raiseCurrentView(); | 441 | raiseCurrentView(); |
442 | } | 442 | } |
443 | void MainWindow::slotDelete() { | 443 | void MainWindow::slotDelete() { |
444 | if (!currentView()->current() ) | 444 | if (!currentView()->current() ) |
445 | return; | 445 | return; |
446 | 446 | ||
447 | if(m_syncing) { | 447 | if(m_syncing) { |
448 | QMessageBox::warning(this, tr("Todo"), | 448 | QMessageBox::warning(this, tr("Todo"), |
449 | tr("Can not edit data, currently syncing")); | 449 | tr("Can not edit data, currently syncing")); |
450 | return; | 450 | return; |
451 | } | 451 | } |
452 | QString strName = currentView()->currentRepresentation(); | 452 | QString strName = currentView()->currentRepresentation(); |
453 | if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) | 453 | if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) |
454 | return; | 454 | return; |
455 | 455 | ||
456 | m_todoMgr.remove( currentView()->current() ); | 456 | m_todoMgr.remove( currentView()->current() ); |
457 | currentView()->removeEvent( currentView()->current() ); | 457 | currentView()->removeEvent( currentView()->current() ); |
458 | raiseCurrentView(); | 458 | raiseCurrentView(); |
459 | } | 459 | } |
460 | void MainWindow::slotDeleteAll() { | 460 | void MainWindow::slotDeleteAll() { |
461 | if(m_syncing) { | 461 | if(m_syncing) { |
462 | QMessageBox::warning(this, tr("Todo"), | 462 | QMessageBox::warning(this, tr("Todo"), |
463 | tr("Can not edit data, currently syncing")); | 463 | tr("Can not edit data, currently syncing")); |
464 | return; | 464 | return; |
465 | } | 465 | } |
466 | 466 | ||
467 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 467 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
468 | 468 | ||
469 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) | 469 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) |
470 | return; | 470 | return; |
471 | 471 | ||
472 | m_todoMgr.removeAll(); | 472 | m_todoMgr.removeAll(); |
473 | currentView()->clear(); | 473 | currentView()->clear(); |
474 | 474 | ||
475 | raiseCurrentView(); | 475 | raiseCurrentView(); |
476 | } | 476 | } |
477 | void MainWindow::slotDeleteCompleted() { | 477 | void MainWindow::slotDeleteCompleted() { |
478 | if(m_syncing) { | 478 | if(m_syncing) { |
479 | QMessageBox::warning(this, tr("Todo"), | 479 | QMessageBox::warning(this, tr("Todo"), |
480 | tr("Can not edit data, currently syncing")); | 480 | tr("Can not edit data, currently syncing")); |
481 | return; | 481 | return; |
482 | } | 482 | } |
483 | 483 | ||
484 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) | 484 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) |
485 | return; | 485 | return; |
486 | 486 | ||
487 | // FIXME | 487 | // FIXME |
488 | //m_todoMgr.remove( currentView()->completed() ); | 488 | //m_todoMgr.remove( currentView()->completed() ); |
489 | currentView()->updateView( ); | 489 | currentView()->updateView( ); |
490 | } | 490 | } |
491 | void MainWindow::slotFind() { | 491 | void MainWindow::slotFind() { |
492 | 492 | ||
493 | } | 493 | } |
494 | void MainWindow::slotEdit() { | 494 | void MainWindow::slotEdit() { |
495 | slotEdit( currentView()->current() ); | 495 | slotEdit( currentView()->current() ); |
496 | } | 496 | } |
497 | /* | 497 | /* |
498 | * set the category | 498 | * set the category |
499 | */ | 499 | */ |
500 | void MainWindow::setCategory( int c) { | 500 | void MainWindow::setCategory( int c) { |
501 | if ( c <= 0 ) return; | 501 | if ( c <= 0 ) return; |
502 | 502 | ||
503 | 503 | ||
504 | qWarning("Iterating over cats %d", c ); | 504 | qWarning("Iterating over cats %d", c ); |
505 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) | 505 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) |
506 | m_catMenu->setItemChecked(i, c == (int)i ); | 506 | m_catMenu->setItemChecked(i, c == (int)i ); |
507 | 507 | ||
508 | if (c == 1 ) { | 508 | if (c == 1 ) { |
509 | m_curCat = QString::null; | 509 | m_curCat = QString::null; |
510 | setCaption( tr("Todo") + " - " + tr("All Categories" ) ); | 510 | setCaption( tr("Todo") + " - " + tr("All Categories" ) ); |
511 | 511 | ||
512 | }else if ( c == (int)m_catMenu->count() - 1 ) { | 512 | }else if ( c == (int)m_catMenu->count() - 1 ) { |
513 | m_curCat = tr("Unfiled"); | 513 | m_curCat = tr("Unfiled"); |
514 | setCaption( tr("Todo") + " - " + tr("Unfiled") ); | 514 | setCaption( tr("Todo") + " - " + tr("Unfiled") ); |
515 | }else { | 515 | }else { |
516 | m_curCat = m_todoMgr.categories()[c-2]; | 516 | m_curCat = m_todoMgr.categories()[c-2]; |
517 | setCaption( tr("Todo") + " - " + m_curCat ); | 517 | setCaption( tr("Todo") + " - " + m_curCat ); |
518 | } | 518 | } |
519 | m_catMenu->setItemChecked( c, true ); | 519 | m_catMenu->setItemChecked( c, true ); |
520 | 520 | ||
521 | currentView()->setShowCategory( m_curCat ); | 521 | currentView()->setShowCategory( m_curCat ); |
522 | raiseCurrentView(); | 522 | raiseCurrentView(); |
523 | } | 523 | } |
524 | void MainWindow::slotShowDeadLine( bool dead) { | 524 | void MainWindow::slotShowDeadLine( bool dead) { |
525 | m_deadline = dead; | 525 | m_deadline = dead; |
526 | currentView()->setShowDeadline( dead ); | 526 | currentView()->setShowDeadline( dead ); |
527 | } | 527 | } |
528 | void MainWindow::slotShowCompleted( bool show) { | 528 | void MainWindow::slotShowCompleted( bool show) { |
529 | m_completed = show; | 529 | m_completed = show; |
530 | currentView()->setShowCompleted( m_completed ); | 530 | currentView()->setShowCompleted( m_completed ); |
531 | } | 531 | } |
532 | bool MainWindow::showOverDue()const { | 532 | bool MainWindow::showOverDue()const { |
533 | return m_overdue; | 533 | return m_overdue; |
534 | } | 534 | } |
535 | void MainWindow::setDocument( const QString& fi) { | 535 | void MainWindow::setDocument( const QString& fi) { |
536 | DocLnk doc(fi); | 536 | DocLnk doc(fi); |
537 | if (doc.isValid() ) | 537 | if (doc.isValid() ) |
538 | receiveFile(doc.file() ); | 538 | receiveFile(doc.file() ); |
539 | else | 539 | else |
540 | receiveFile(fi ); | 540 | receiveFile(fi ); |
541 | } | 541 | } |
542 | 542 | ||
543 | static const char *beamfile = "/tmp/opie-todo.vcs"; | 543 | static const char *beamfile = "/tmp/opie-todo.vcs"; |
544 | void MainWindow::slotBeam() { | 544 | void MainWindow::slotBeam() { |
545 | ::unlink( beamfile ); | 545 | ::unlink( beamfile ); |
546 | OTodo todo = event( currentView()->current() ); | 546 | OTodo todo = event( currentView()->current() ); |
547 | OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); | 547 | OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); |
548 | OTodoAccess acc( cal ); | 548 | OTodoAccess acc( cal ); |
549 | acc.load(); | 549 | acc.load(); |
550 | acc.add( todo ); | 550 | acc.add( todo ); |
551 | acc.save(); | 551 | acc.save(); |
552 | Ir* ir = new Ir(this ); | 552 | Ir* ir = new Ir(this ); |
553 | connect(ir, SIGNAL(done(Ir*) ), | 553 | connect(ir, SIGNAL(done(Ir*) ), |
554 | this, SLOT(beamDone(Ir*) ) ); | 554 | this, SLOT(beamDone(Ir*) ) ); |
555 | ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); | 555 | ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); |
556 | 556 | ||
557 | } | 557 | } |
558 | void MainWindow::beamDone( Ir* ir) { | 558 | void MainWindow::beamDone( Ir* ir) { |
559 | delete ir; | 559 | delete ir; |
560 | ::unlink( beamfile ); | 560 | ::unlink( beamfile ); |
561 | } | 561 | } |
562 | void MainWindow::receiveFile( const QString& filename ) { | 562 | void MainWindow::receiveFile( const QString& filename ) { |
563 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); | 563 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); |
564 | OTodoAccess acc( cal ); | 564 | OTodoAccess acc( cal ); |
565 | acc.load(); | 565 | acc.load(); |
566 | OTodoAccess::List list = acc.allRecords(); | 566 | OTodoAccess::List list = acc.allRecords(); |
567 | 567 | ||
568 | QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); | 568 | QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); |
569 | 569 | ||
570 | if ( QMessageBox::information(this, tr("New Tasks"), | 570 | if ( QMessageBox::information(this, tr("New Tasks"), |
571 | message, QMessageBox::Ok, | 571 | message, QMessageBox::Ok, |
572 | QMessageBox::Cancel ) == QMessageBox::Ok ) { | 572 | QMessageBox::Cancel ) == QMessageBox::Ok ) { |
573 | OTodoAccess::List::Iterator it; | 573 | OTodoAccess::List::Iterator it; |
574 | for ( it = list.begin(); it != list.end(); ++it ) | 574 | for ( it = list.begin(); it != list.end(); ++it ) |
575 | m_todoMgr.add( (*it) ); | 575 | m_todoMgr.add( (*it) ); |
576 | 576 | ||
577 | currentView()->updateView(); | 577 | currentView()->updateView(); |
578 | } | 578 | } |
579 | } | 579 | } |
580 | 580 | ||
581 | void MainWindow::slotFlush() { | 581 | void MainWindow::slotFlush() { |
582 | m_syncing = FALSE; | 582 | m_syncing = FALSE; |
583 | m_todoMgr.save(); | 583 | m_todoMgr.save(); |
584 | } | 584 | } |
585 | void MainWindow::slotShowDetails() { | 585 | void MainWindow::slotShowDetails() { |
586 | slotShow( currentView()->current() ); | 586 | slotShow( currentView()->current() ); |
587 | } | 587 | } |
588 | /* | 588 | /* |
589 | * populate the Categories | 589 | * populate the Categories |
590 | * Menu | 590 | * Menu |
591 | */ | 591 | */ |
592 | void MainWindow::populateCategories() { | 592 | void MainWindow::populateCategories() { |
593 | m_todoMgr.load(); | 593 | m_todoMgr.load(); |
594 | 594 | ||
595 | m_catMenu->clear(); | 595 | m_catMenu->clear(); |
596 | int id, rememberId; | 596 | int id, rememberId; |
597 | id = 1; | 597 | id = 1; |
598 | rememberId = 1; | 598 | rememberId = 1; |
599 | 599 | ||
600 | m_catMenu->insertItem( tr( "All Categories" ), id++ ); | 600 | m_catMenu->insertItem( tr( "All Categories" ), id++ ); |
601 | m_catMenu->insertSeparator(); | 601 | m_catMenu->insertSeparator(); |
602 | QStringList categories = m_todoMgr.categories(); | 602 | QStringList categories = m_todoMgr.categories(); |
603 | categories.append( tr( "Unfiled" ) ); | 603 | categories.append( tr( "Unfiled" ) ); |
604 | for ( QStringList::Iterator it = categories.begin(); | 604 | for ( QStringList::Iterator it = categories.begin(); |
605 | it != categories.end(); ++it ) { | 605 | it != categories.end(); ++it ) { |
606 | m_catMenu->insertItem( *it, id ); | 606 | m_catMenu->insertItem( *it, id ); |
607 | if ( *it == currentCategory() ) | 607 | if ( *it == currentCategory() ) |
608 | rememberId = id; | 608 | rememberId = id; |
609 | ++id; | 609 | ++id; |
610 | } | 610 | } |
611 | setCategory( rememberId ); | 611 | setCategory( rememberId ); |
612 | } | 612 | } |
613 | bool MainWindow::showCompleted()const { | 613 | bool MainWindow::showCompleted()const { |
614 | return m_completed; | 614 | return m_completed; |
615 | } | 615 | } |
616 | bool MainWindow::showDeadline()const { | 616 | bool MainWindow::showDeadline()const { |
617 | return m_deadline; | 617 | return m_deadline; |
618 | } | 618 | } |
619 | QString MainWindow::currentCategory()const { | 619 | QString MainWindow::currentCategory()const { |
620 | return m_curCat; | 620 | return m_curCat; |
621 | } | 621 | } |
622 | int MainWindow::currentCatId() { | 622 | int MainWindow::currentCatId() { |
623 | return m_todoMgr.catId( m_curCat ); | 623 | return m_todoMgr.catId( m_curCat ); |
624 | } | 624 | } |
625 | ViewBase* MainWindow::currentView() { | 625 | ViewBase* MainWindow::currentView() { |
626 | return m_curView; | 626 | return m_curView; |
627 | } | 627 | } |
628 | void MainWindow::raiseCurrentView() { | 628 | void MainWindow::raiseCurrentView() { |
629 | m_stack->raiseWidget( m_curView->widget() ); | 629 | m_stack->raiseWidget( m_curView->widget() ); |
630 | } | 630 | } |
631 | void MainWindow::slotShowDue(bool ov) { | 631 | void MainWindow::slotShowDue(bool ov) { |
632 | m_overdue = ov; | 632 | m_overdue = ov; |
633 | currentView()->showOverDue( ov ); | 633 | currentView()->showOverDue( ov ); |
634 | raiseCurrentView(); | 634 | raiseCurrentView(); |
635 | } | 635 | } |
636 | void MainWindow::slotShow( int uid ) { | 636 | void MainWindow::slotShow( int uid ) { |
637 | qWarning("slotShow"); | 637 | qWarning("slotShow"); |
638 | currentShow()->slotShow( event( uid ) ); | 638 | currentShow()->slotShow( event( uid ) ); |
639 | m_stack->raiseWidget( currentShow()->widget() ); | 639 | m_stack->raiseWidget( currentShow()->widget() ); |
640 | } | 640 | } |
641 | void MainWindow::slotEdit( int uid ) { | 641 | void MainWindow::slotEdit( int uid ) { |
642 | if(m_syncing) { | 642 | if(m_syncing) { |
643 | QMessageBox::warning(this, tr("Todo"), | 643 | QMessageBox::warning(this, tr("Todo"), |
644 | tr("Can not edit data, currently syncing")); | 644 | tr("Can not edit data, currently syncing")); |
645 | return; | 645 | return; |
646 | } | 646 | } |
647 | 647 | ||
648 | OTodo todo = m_todoMgr.event( uid ); | 648 | OTodo todo = m_todoMgr.event( uid ); |
649 | 649 | ||
650 | todo = currentEditor()->edit(this, todo ); | 650 | todo = currentEditor()->edit(this, todo ); |
651 | 651 | ||
652 | /* if completed */ | 652 | /* if completed */ |
653 | if ( currentEditor()->accepted() ) { | 653 | if ( currentEditor()->accepted() ) { |
654 | qWarning("Replacing now" ); | 654 | qWarning("Replacing now" ); |
655 | m_todoMgr.update( todo.uid(), todo ); | 655 | m_todoMgr.update( todo.uid(), todo ); |
656 | currentView()->replaceEvent( todo ); | 656 | currentView()->replaceEvent( todo ); |
657 | /* a Category might have changed */ | 657 | /* a Category might have changed */ |
658 | populateCategories(); | 658 | populateCategories(); |
659 | } | 659 | } |
660 | 660 | ||
661 | raiseCurrentView(); | 661 | raiseCurrentView(); |
662 | } | 662 | } |
663 | /* | 663 | /* |
664 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { | 664 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { |
665 | m_todoMgr.update( uid, ev ); | 665 | m_todoMgr.update( uid, ev ); |
666 | } | 666 | } |
667 | */ | 667 | */ |
668 | void MainWindow::updateTodo( const OTodo& ev) { | 668 | void MainWindow::updateTodo( const OTodo& ev) { |
669 | m_todoMgr.update( ev.uid() , ev ); | 669 | m_todoMgr.update( ev.uid() , ev ); |
670 | } | 670 | } |
671 | /* The view changed it's configuration | 671 | /* The view changed it's configuration |
672 | * update the view menu | 672 | * update the view menu |
673 | */ | 673 | */ |
674 | void MainWindow::slotUpdate3( QWidget* ) { | 674 | void MainWindow::slotUpdate3( QWidget* ) { |
675 | 675 | ||
676 | } | 676 | } |
677 | void MainWindow::updateList() { | 677 | void MainWindow::updateList() { |
678 | m_todoMgr.updateList(); | 678 | m_todoMgr.updateList(); |
679 | } | 679 | } |
680 | void MainWindow::setReadAhead( uint count ) { | ||
681 | if (m_todoMgr.todoDB() ) | ||
682 | m_todoMgr.todoDB()->setReadAhead( count ); | ||
683 | } | ||
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index 8d0c29f..5a18e64 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h | |||
@@ -1,176 +1,177 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 3 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef TODO_MAIN_WINDOW_H | 29 | #ifndef TODO_MAIN_WINDOW_H |
30 | #define TODO_MAIN_WINDOW_H | 30 | #define TODO_MAIN_WINDOW_H |
31 | 31 | ||
32 | #include <qlist.h> | 32 | #include <qlist.h> |
33 | #include <qmainwindow.h> | 33 | #include <qmainwindow.h> |
34 | 34 | ||
35 | #include <opie/otodoaccess.h> | 35 | #include <opie/otodoaccess.h> |
36 | #include <opie/otodo.h> | 36 | #include <opie/otodo.h> |
37 | 37 | ||
38 | #include "smalltodo.h" | 38 | #include "smalltodo.h" |
39 | #include "todoview.h" | 39 | #include "todoview.h" |
40 | #include "todomanager.h" | 40 | #include "todomanager.h" |
41 | 41 | ||
42 | class QPopupMenu; | 42 | class QPopupMenu; |
43 | class QMenuBar; | 43 | class QMenuBar; |
44 | class QToolBar; | 44 | class QToolBar; |
45 | class QAction; | 45 | class QAction; |
46 | class QWidgetStack; | 46 | class QWidgetStack; |
47 | class Ir; | 47 | class Ir; |
48 | 48 | ||
49 | 49 | ||
50 | namespace Todo { | 50 | namespace Todo { |
51 | typedef TodoView View; | 51 | typedef TodoView View; |
52 | class TemplateManager; | 52 | class TemplateManager; |
53 | class Editor; | 53 | class Editor; |
54 | class TodoShow; | 54 | class TodoShow; |
55 | class TemplateEditor; | 55 | class TemplateEditor; |
56 | 56 | ||
57 | class MainWindow : public QMainWindow { | 57 | class MainWindow : public QMainWindow { |
58 | Q_OBJECT | 58 | Q_OBJECT |
59 | public: | 59 | public: |
60 | MainWindow( QWidget *parent = 0, | 60 | MainWindow( QWidget *parent = 0, |
61 | const char* name = 0 ); | 61 | const char* name = 0 ); |
62 | ~MainWindow(); | 62 | ~MainWindow(); |
63 | 63 | ||
64 | /** return a context menu for an OTodo */ | 64 | /** return a context menu for an OTodo */ |
65 | QPopupMenu* contextMenu(int uid ); | 65 | QPopupMenu* contextMenu(int uid ); |
66 | QPopupMenu* options(); | 66 | QPopupMenu* options(); |
67 | QPopupMenu* edit(); | 67 | QPopupMenu* edit(); |
68 | QPopupMenu* view(); | 68 | QPopupMenu* view(); |
69 | QToolBar* toolbar(); | 69 | QToolBar* toolbar(); |
70 | 70 | ||
71 | 71 | ||
72 | void updateList(); | 72 | void updateList(); |
73 | OTodoAccess::List list()const; | 73 | OTodoAccess::List list()const; |
74 | OTodoAccess::List sorted( bool asc, int sortOrder ); | 74 | OTodoAccess::List sorted( bool asc, int sortOrder ); |
75 | OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); | 75 | OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); |
76 | 76 | ||
77 | OTodo event(int uid ); | 77 | OTodo event(int uid ); |
78 | 78 | ||
79 | bool isSyncing()const; | 79 | bool isSyncing()const; |
80 | bool showCompleted()const; | 80 | bool showCompleted()const; |
81 | bool showDeadline()const; | 81 | bool showDeadline()const; |
82 | bool showOverDue()const; | 82 | bool showOverDue()const; |
83 | QString currentCategory()const; | 83 | QString currentCategory()const; |
84 | int currentCatId(); | 84 | int currentCatId(); |
85 | TemplateManager* templateManager(); | 85 | TemplateManager* templateManager(); |
86 | 86 | ||
87 | void updateTodo( const OTodo& ); | 87 | void updateTodo( const OTodo& ); |
88 | void populateTemplates(); | 88 | void populateTemplates(); |
89 | Editor* currentEditor(); | 89 | Editor* currentEditor(); |
90 | void setReadAhead(uint count ); | ||
90 | private slots: | 91 | private slots: |
91 | void populateCategories(); | 92 | void populateCategories(); |
92 | void slotReload(); | 93 | void slotReload(); |
93 | void slotFlush(); | 94 | void slotFlush(); |
94 | 95 | ||
95 | protected: | 96 | protected: |
96 | void closeEvent( QCloseEvent* e ); | 97 | void closeEvent( QCloseEvent* e ); |
97 | 98 | ||
98 | private: | 99 | private: |
99 | void receiveFile( const QString& filename ); | 100 | void receiveFile( const QString& filename ); |
100 | void connectBase( ViewBase* ); | 101 | void connectBase( ViewBase* ); |
101 | void initUI(); | 102 | void initUI(); |
102 | void initActions(); | 103 | void initActions(); |
103 | void initConfig(); | 104 | void initConfig(); |
104 | void initViews(); | 105 | void initViews(); |
105 | void initEditor(); | 106 | void initEditor(); |
106 | void initShow(); | 107 | void initShow(); |
107 | void initTemplate(); | 108 | void initTemplate(); |
108 | void raiseCurrentView(); | 109 | void raiseCurrentView(); |
109 | ViewBase* currentView(); | 110 | ViewBase* currentView(); |
110 | ViewBase* m_curView; | 111 | ViewBase* m_curView; |
111 | Editor* m_curEdit; | 112 | Editor* m_curEdit; |
112 | TodoShow* currentShow(); | 113 | TodoShow* currentShow(); |
113 | TodoShow* m_curShow; | 114 | TodoShow* m_curShow; |
114 | TemplateEditor* currentTemplateEditor(); | 115 | TemplateEditor* currentTemplateEditor(); |
115 | TemplateEditor* m_curTempEd; | 116 | TemplateEditor* m_curTempEd; |
116 | 117 | ||
117 | QMenuBar* m_bar; | 118 | QMenuBar* m_bar; |
118 | QToolBar* m_tool; | 119 | QToolBar* m_tool; |
119 | QAction* m_editAction, | 120 | QAction* m_editAction, |
120 | *m_deleteAction, | 121 | *m_deleteAction, |
121 | *m_findAction, | 122 | *m_findAction, |
122 | *m_completedAction, | 123 | *m_completedAction, |
123 | *m_showDeadLineAction, | 124 | *m_showDeadLineAction, |
124 | *m_deleteAllAction, | 125 | *m_deleteAllAction, |
125 | *m_deleteCompleteAction, | 126 | *m_deleteCompleteAction, |
126 | *m_duplicateAction, | 127 | *m_duplicateAction, |
127 | *m_showOverDueAction, | 128 | *m_showOverDueAction, |
128 | *m_effectiveAction; | 129 | *m_effectiveAction; |
129 | QWidgetStack *m_stack; | 130 | QWidgetStack *m_stack; |
130 | QPopupMenu* m_catMenu, | 131 | QPopupMenu* m_catMenu, |
131 | *m_edit, | 132 | *m_edit, |
132 | *m_options, | 133 | *m_options, |
133 | *m_view, | 134 | *m_view, |
134 | *m_template; | 135 | *m_template; |
135 | 136 | ||
136 | bool m_syncing:1; | 137 | bool m_syncing:1; |
137 | bool m_deadline:1; | 138 | bool m_deadline:1; |
138 | bool m_completed:1; | 139 | bool m_completed:1; |
139 | bool m_overdue:1; | 140 | bool m_overdue:1; |
140 | TodoManager m_todoMgr; | 141 | TodoManager m_todoMgr; |
141 | QString m_curCat; | 142 | QString m_curCat; |
142 | QList<ViewBase> m_views; | 143 | QList<ViewBase> m_views; |
143 | uint m_counter; | 144 | uint m_counter; |
144 | TemplateManager* m_tempManager; | 145 | TemplateManager* m_tempManager; |
145 | 146 | ||
146 | private slots: | 147 | private slots: |
147 | void slotShow(int); | 148 | void slotShow(int); |
148 | void slotEdit(int); | 149 | void slotEdit(int); |
149 | private slots: | 150 | private slots: |
150 | void slotUpdate3( QWidget* ); | 151 | void slotUpdate3( QWidget* ); |
151 | void slotNewFromTemplate(int id ); | 152 | void slotNewFromTemplate(int id ); |
152 | void slotNew(); | 153 | void slotNew(); |
153 | void slotDuplicate(); | 154 | void slotDuplicate(); |
154 | void slotDelete(); | 155 | void slotDelete(); |
155 | void slotDeleteAll(); | 156 | void slotDeleteAll(); |
156 | void slotDeleteCompleted(); | 157 | void slotDeleteCompleted(); |
157 | 158 | ||
158 | void slotEdit(); | 159 | void slotEdit(); |
159 | void slotFind(); | 160 | void slotFind(); |
160 | 161 | ||
161 | void setCategory( int ); | 162 | void setCategory( int ); |
162 | 163 | ||
163 | void slotShowDeadLine( bool ); | 164 | void slotShowDeadLine( bool ); |
164 | void slotShowCompleted( bool ); | 165 | void slotShowCompleted( bool ); |
165 | 166 | ||
166 | void setDocument( const QString& ); | 167 | void setDocument( const QString& ); |
167 | 168 | ||
168 | 169 | ||
169 | void slotBeam(); | 170 | void slotBeam(); |
170 | void beamDone( Ir* ); | 171 | void beamDone( Ir* ); |
171 | void slotShowDetails(); | 172 | void slotShowDetails(); |
172 | void slotShowDue( bool ); | 173 | void slotShowDue( bool ); |
173 | }; | 174 | }; |
174 | }; | 175 | }; |
175 | 176 | ||
176 | #endif | 177 | #endif |
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index 5d82eb2..f4b898f 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp | |||
@@ -1,400 +1,450 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <qtimer.h> | 29 | #include <qtimer.h> |
30 | #include <qpoint.h> | 30 | #include <qpoint.h> |
31 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
32 | 32 | ||
33 | #include "mainwindow.h" | 33 | #include "mainwindow.h" |
34 | //#include "tableitems.h" | 34 | //#include "tableitems.h" |
35 | #include "tableview.h" | 35 | #include "tableview.h" |
36 | 36 | ||
37 | using namespace Todo; | 37 | using namespace Todo; |
38 | 38 | ||
39 | namespace { | 39 | namespace { |
40 | static const int BoxSize = 14; | 40 | static const int BoxSize = 14; |
41 | static const int RowHeight = 20; | 41 | static const int RowHeight = 20; |
42 | } | 42 | } |
43 | 43 | ||
44 | 44 | ||
45 | TableView::TableView( MainWindow* window, QWidget* wid ) | 45 | TableView::TableView( MainWindow* window, QWidget* wid ) |
46 | : QTable( wid ), TodoView( window ) { | 46 | : QTable( wid ), TodoView( window ) { |
47 | setUpdatesEnabled( false ); | 47 | setUpdatesEnabled( false ); |
48 | viewport()->setUpdatesEnabled( false ); | 48 | viewport()->setUpdatesEnabled( false ); |
49 | m_enablePaint = false; | 49 | m_enablePaint = false; |
50 | setNumRows(0); | 50 | setNumRows(0); |
51 | setNumCols(4); | 51 | setNumCols(4); |
52 | 52 | ||
53 | setSorting( TRUE ); | 53 | setSorting( TRUE ); |
54 | setSelectionMode( NoSelection ); | 54 | setSelectionMode( NoSelection ); |
55 | setColumnStretchable( 2, TRUE ); | 55 | setColumnStretchable( 2, TRUE ); |
56 | setColumnWidth(0, 20 ); | 56 | setColumnWidth(0, 20 ); |
57 | setColumnWidth(1, 35 ); | 57 | setColumnWidth(1, 35 ); |
58 | 58 | ||
59 | setLeftMargin( 0 ); | 59 | setLeftMargin( 0 ); |
60 | verticalHeader()->hide(); | 60 | verticalHeader()->hide(); |
61 | 61 | ||
62 | horizontalHeader()->setLabel(0, tr("C.") ); | 62 | horizontalHeader()->setLabel(0, tr("C.") ); |
63 | horizontalHeader()->setLabel(1, tr("Prior.") ); | 63 | horizontalHeader()->setLabel(1, tr("Prior.") ); |
64 | horizontalHeader()->setLabel(2, tr("Description" ) ); | 64 | horizontalHeader()->setLabel(2, tr("Description" ) ); |
65 | 65 | ||
66 | setColumnStretchable(3, FALSE ); | 66 | setColumnStretchable(3, FALSE ); |
67 | setColumnWidth(3, 20 ); | 67 | setColumnWidth(3, 20 ); |
68 | horizontalHeader()->setLabel(3, tr("Deadline") ); | 68 | horizontalHeader()->setLabel(3, tr("Deadline") ); |
69 | 69 | ||
70 | if ( todoWindow()->showDeadline() ) | 70 | if ( todoWindow()->showDeadline() ) |
71 | showColumn( 3); | 71 | showColumn( 3); |
72 | else | 72 | else |
73 | hideColumn(3 ); | 73 | hideColumn(3 ); |
74 | 74 | ||
75 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), | 75 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), |
76 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); | 76 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); |
77 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), | 77 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), |
78 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); | 78 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); |
79 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), | 79 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), |
80 | this, SLOT( slotValueChanged(int, int) ) ); | 80 | this, SLOT( slotValueChanged(int, int) ) ); |
81 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), | 81 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), |
82 | this, SLOT( slotCurrentChanged(int, int) ) ); | 82 | this, SLOT( slotCurrentChanged(int, int) ) ); |
83 | 83 | ||
84 | m_menuTimer = new QTimer( this ); | 84 | m_menuTimer = new QTimer( this ); |
85 | connect( m_menuTimer, SIGNAL(timeout()), | 85 | connect( m_menuTimer, SIGNAL(timeout()), |
86 | this, SLOT(slotShowMenu()) ); | 86 | this, SLOT(slotShowMenu()) ); |
87 | 87 | ||
88 | m_enablePaint = true; | 88 | m_enablePaint = true; |
89 | setUpdatesEnabled( true ); | 89 | setUpdatesEnabled( true ); |
90 | viewport()->setUpdatesEnabled( true ); | 90 | viewport()->setUpdatesEnabled( true ); |
91 | viewport()->update(); | 91 | viewport()->update(); |
92 | setSortOrder( 0 ); | 92 | setSortOrder( 0 ); |
93 | setAscending( TRUE ); | 93 | setAscending( TRUE ); |
94 | m_first = true; | 94 | m_first = true; |
95 | } | 95 | } |
96 | /* a new day has started | 96 | /* a new day has started |
97 | * update the day | 97 | * update the day |
98 | */ | 98 | */ |
99 | void TableView::newDay() { | 99 | void TableView::newDay() { |
100 | clear(); | 100 | clear(); |
101 | updateView(); | 101 | updateView(); |
102 | } | 102 | } |
103 | TableView::~TableView() { | 103 | TableView::~TableView() { |
104 | 104 | ||
105 | } | 105 | } |
106 | void TableView::slotShowMenu() { | 106 | void TableView::slotShowMenu() { |
107 | QPopupMenu *menu = todoWindow()->contextMenu( current() ); | 107 | QPopupMenu *menu = todoWindow()->contextMenu( current() ); |
108 | menu->exec(QCursor::pos() ); | 108 | menu->exec(QCursor::pos() ); |
109 | delete menu; | 109 | delete menu; |
110 | } | 110 | } |
111 | QString TableView::type() const { | 111 | QString TableView::type() const { |
112 | return QString::fromLatin1( tr("Table View") ); | 112 | return QString::fromLatin1( tr("Table View") ); |
113 | } | 113 | } |
114 | int TableView::current() { | 114 | int TableView::current() { |
115 | int uid = sorted().uidAt(currentRow() ); | 115 | int uid = sorted().uidAt(currentRow() ); |
116 | qWarning("uid %d", uid ); | 116 | qWarning("uid %d", uid ); |
117 | return uid; | 117 | return uid; |
118 | } | 118 | } |
119 | QString TableView::currentRepresentation() { | 119 | QString TableView::currentRepresentation() { |
120 | return text( currentRow(), 2); | 120 | return text( currentRow(), 2); |
121 | } | 121 | } |
122 | /* show overdue */ | 122 | /* show overdue */ |
123 | void TableView::showOverDue( bool ) { | 123 | void TableView::showOverDue( bool ) { |
124 | clear(); | 124 | clear(); |
125 | updateView(); | 125 | updateView(); |
126 | } | 126 | } |
127 | 127 | ||
128 | void TableView::updateView( ) { | 128 | void TableView::updateView( ) { |
129 | m_row = false; | ||
130 | startTimer( 2000 ); | ||
131 | /* FIXME we want one page to be read! | ||
132 | * | ||
133 | * Calculate that screensize | ||
134 | */ | ||
135 | todoWindow()->setReadAhead( 4 ); | ||
129 | sort(); | 136 | sort(); |
130 | OTodoAccess::List::Iterator it, end; | 137 | OTodoAccess::List::Iterator it, end; |
131 | it = sorted().begin(); | 138 | it = sorted().begin(); |
132 | end = sorted().end(); | 139 | end = sorted().end(); |
133 | 140 | ||
134 | qWarning("setTodos"); | 141 | qWarning("setTodos"); |
135 | QTime time; | 142 | QTime time; |
136 | time.start(); | 143 | time.start(); |
137 | m_enablePaint = false; | 144 | m_enablePaint = false; |
138 | setUpdatesEnabled( false ); | 145 | setUpdatesEnabled( false ); |
139 | viewport()->setUpdatesEnabled( false ); | 146 | viewport()->setUpdatesEnabled( false ); |
140 | 147 | ||
141 | QTime t; | 148 | QTime t; |
142 | t.start(); | 149 | t.start(); |
143 | setNumRows( it.count() ); | 150 | setNumRows( it.count() ); |
144 | int elc = time.elapsed(); | 151 | int elc = time.elapsed(); |
145 | qWarning("Adding took %d", elc/1000 ); | 152 | qWarning("Adding took %d", elc/1000 ); |
146 | setUpdatesEnabled( true ); | 153 | setUpdatesEnabled( true ); |
147 | viewport()->setUpdatesEnabled( true ); | 154 | viewport()->setUpdatesEnabled( true ); |
148 | viewport()->update(); | 155 | viewport()->update(); |
149 | 156 | ||
150 | m_enablePaint = true; | 157 | m_enablePaint = true; |
151 | int el = time.elapsed(); | 158 | int el = time.elapsed(); |
152 | qWarning("adding took %d", el/1000 ); | 159 | qWarning("adding took %d", el/1000 ); |
153 | } | 160 | } |
154 | void TableView::setTodo( int, const OTodo&) { | 161 | void TableView::setTodo( int, const OTodo&) { |
155 | sort(); | 162 | sort(); |
156 | 163 | ||
157 | /* repaint */ | 164 | /* repaint */ |
158 | QTable::update(); | 165 | QTable::update(); |
159 | } | 166 | } |
160 | void TableView::addEvent( const OTodo&) { | 167 | void TableView::addEvent( const OTodo&) { |
161 | sort(); | 168 | sort(); |
162 | 169 | ||
163 | QTable::update(); | 170 | /* fix problems of not showing the 'Haken' */ |
171 | QTable::repaint(); | ||
164 | } | 172 | } |
165 | /* | 173 | /* |
166 | * find the event | 174 | * find the event |
167 | * and then replace the complete row | 175 | * and then replace the complete row |
168 | */ | 176 | */ |
169 | void TableView::replaceEvent( const OTodo& ev) { | 177 | void TableView::replaceEvent( const OTodo& ev) { |
170 | addEvent( ev ); | 178 | addEvent( ev ); |
171 | } | 179 | } |
172 | /* | 180 | /* |
173 | * re aligning table can be slow too | 181 | * re aligning table can be slow too |
174 | * FIXME: look what performs better | 182 | * FIXME: look what performs better |
175 | * either this or the old align table | 183 | * either this or the old align table |
176 | */ | 184 | */ |
177 | void TableView::removeEvent( int ) { | 185 | void TableView::removeEvent( int ) { |
178 | updateView(); | 186 | updateView(); |
179 | } | 187 | } |
180 | void TableView::setShowCompleted( bool b) { | 188 | void TableView::setShowCompleted( bool b) { |
181 | qWarning("Show Completed %d" + b ); | 189 | qWarning("Show Completed %d" + b ); |
182 | updateView(); | 190 | updateView(); |
183 | } | 191 | } |
184 | void TableView::setShowDeadline( bool b) { | 192 | void TableView::setShowDeadline( bool b) { |
185 | qWarning("Show DeadLine %d" + b ); | 193 | qWarning("Show DeadLine %d" + b ); |
186 | if (b) | 194 | if (b) |
187 | showColumn(3 ); | 195 | showColumn(3 ); |
188 | else | 196 | else |
189 | hideColumn(3 ); | 197 | hideColumn(3 ); |
190 | } | 198 | } |
191 | void TableView::setShowCategory( const QString& str) { | 199 | void TableView::setShowCategory( const QString& str) { |
192 | qWarning("setShowCategory"); | 200 | qWarning("setShowCategory"); |
193 | if ( str != m_oleCat || m_first ) | 201 | if ( str != m_oleCat || m_first ) |
194 | updateView(); | 202 | updateView(); |
195 | 203 | ||
196 | m_oleCat = str; | 204 | m_oleCat = str; |
197 | m_first = false; | 205 | m_first = false; |
198 | 206 | ||
199 | } | 207 | } |
200 | void TableView::clear() { | 208 | void TableView::clear() { |
201 | setNumRows(0); | 209 | setNumRows(0); |
202 | } | 210 | } |
203 | void TableView::slotClicked(int row, int col, int, | 211 | void TableView::slotClicked(int row, int col, int, |
204 | const QPoint& point) { | 212 | const QPoint& point) { |
205 | if ( !cellGeometry(row, col ).contains(point ) ) | 213 | if ( !cellGeometry(row, col ).contains(point ) ) |
206 | return; | 214 | return; |
207 | 215 | ||
208 | int ui= sorted().uidAt( row ); | 216 | int ui= sorted().uidAt( row ); |
209 | 217 | ||
210 | 218 | ||
211 | switch( col ) { | 219 | switch( col ) { |
212 | case 0:{ | 220 | case 0:{ |
213 | int x = point.x() -columnPos( col ); | 221 | int x = point.x() -columnPos( col ); |
214 | int y = point.y() -rowPos( row ); | 222 | int y = point.y() -rowPos( row ); |
215 | int w = columnWidth( col ); | 223 | int w = columnWidth( col ); |
216 | int h = rowHeight( row ); | 224 | int h = rowHeight( row ); |
217 | if ( x >= ( w - BoxSize ) / 2 && | 225 | if ( x >= ( w - BoxSize ) / 2 && |
218 | x <= ( w - BoxSize ) / 2 + BoxSize && | 226 | x <= ( w - BoxSize ) / 2 + BoxSize && |
219 | y >= ( h - BoxSize ) / 2 && | 227 | y >= ( h - BoxSize ) / 2 && |
220 | y <= ( h - BoxSize ) / 2 + BoxSize ) { | 228 | y <= ( h - BoxSize ) / 2 + BoxSize ) { |
221 | OTodo todo = sorted()[row]; | 229 | OTodo todo = sorted()[row]; |
222 | todo.setCompleted( !todo.isCompleted() ); | 230 | todo.setCompleted( !todo.isCompleted() ); |
223 | TodoView::update( todo.uid(), todo ); | 231 | TodoView::update( todo.uid(), todo ); |
224 | updateView(); | 232 | updateView(); |
225 | } | 233 | } |
226 | } | 234 | } |
227 | break; | 235 | break; |
228 | 236 | ||
229 | case 1: | 237 | case 1: |
230 | break; | 238 | break; |
231 | 239 | ||
232 | case 2: { | 240 | case 2: { |
233 | m_menuTimer->stop(); | 241 | m_menuTimer->stop(); |
234 | showTodo( ui ); | 242 | showTodo( ui ); |
235 | break; | 243 | break; |
236 | } | 244 | } |
237 | case 3: { | 245 | case 3: { |
238 | m_menuTimer->stop(); | 246 | m_menuTimer->stop(); |
239 | TodoView::edit( ui ); | 247 | TodoView::edit( ui ); |
240 | break; | 248 | break; |
241 | } | 249 | } |
242 | } | 250 | } |
243 | 251 | ||
244 | 252 | ||
245 | } | 253 | } |
246 | void TableView::slotPressed(int row, int col, int, | 254 | void TableView::slotPressed(int row, int col, int, |
247 | const QPoint& point) { | 255 | const QPoint& point) { |
248 | 256 | ||
249 | /* TextColumn column */ | 257 | /* TextColumn column */ |
250 | if ( col == 2 && cellGeometry( row, col ).contains( point ) ) | 258 | if ( col == 2 && cellGeometry( row, col ).contains( point ) ) |
251 | m_menuTimer->start( 750, TRUE ); | 259 | m_menuTimer->start( 750, TRUE ); |
252 | } | 260 | } |
253 | void TableView::slotValueChanged( int, int ) { | 261 | void TableView::slotValueChanged( int, int ) { |
254 | qWarning("Value Changed"); | 262 | qWarning("Value Changed"); |
255 | } | 263 | } |
256 | void TableView::slotCurrentChanged(int, int ) { | 264 | void TableView::slotCurrentChanged(int, int ) { |
257 | m_menuTimer->stop(); | 265 | m_menuTimer->stop(); |
258 | } | 266 | } |
259 | QWidget* TableView::widget() { | 267 | QWidget* TableView::widget() { |
260 | return this; | 268 | return this; |
261 | } | 269 | } |
262 | /* | 270 | /* |
263 | * We need to overwrite sortColumn | 271 | * We need to overwrite sortColumn |
264 | * because we want to sort whole row | 272 | * because we want to sort whole row |
265 | * based | 273 | * based |
266 | * We event want to set the setOrder | 274 | * We event want to set the setOrder |
267 | * to a sort() and update() | 275 | * to a sort() and update() |
268 | */ | 276 | */ |
269 | void TableView::sortColumn( int col, bool asc, bool ) { | 277 | void TableView::sortColumn( int col, bool asc, bool ) { |
270 | qWarning("bool %d", asc ); | 278 | qWarning("bool %d", asc ); |
271 | setSortOrder( col ); | 279 | setSortOrder( col ); |
272 | setAscending( asc ); | 280 | setAscending( asc ); |
273 | updateView(); | 281 | updateView(); |
274 | } | 282 | } |
275 | void TableView::viewportPaintEvent( QPaintEvent* e) { | 283 | void TableView::viewportPaintEvent( QPaintEvent* e) { |
276 | qWarning("Paint event" ); | 284 | qWarning("Paint event" ); |
277 | if (m_enablePaint ) | 285 | if (m_enablePaint ) |
278 | QTable::viewportPaintEvent( e ); | 286 | QTable::viewportPaintEvent( e ); |
279 | } | 287 | } |
280 | /* | 288 | /* |
281 | * This segment is copyrighted by TT | 289 | * This segment is copyrighted by TT |
282 | * it was taken from their todolist | 290 | * it was taken from their todolist |
283 | * application this code is GPL | 291 | * application this code is GPL |
284 | */ | 292 | */ |
285 | void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { | 293 | void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { |
286 | const QColorGroup &cg = colorGroup(); | 294 | const QColorGroup &cg = colorGroup(); |
287 | 295 | ||
288 | p->save(); | 296 | p->save(); |
289 | 297 | ||
290 | OTodo task = sorted()[row]; | 298 | OTodo task = sorted()[row]; |
291 | 299 | ||
292 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 300 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
293 | 301 | ||
294 | QPen op = p->pen(); | 302 | QPen op = p->pen(); |
295 | p->setPen(cg.mid()); | 303 | p->setPen(cg.mid()); |
296 | p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); | 304 | p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); |
297 | p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); | 305 | p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); |
298 | p->setPen(op); | 306 | p->setPen(op); |
299 | 307 | ||
300 | QFont f = p->font(); | 308 | QFont f = p->font(); |
301 | QFontMetrics fm(f); | 309 | QFontMetrics fm(f); |
302 | 310 | ||
303 | switch(col) { | 311 | switch(col) { |
304 | case 0: | 312 | case 0: |
305 | { | 313 | { |
306 | // completed field | 314 | // completed field |
307 | int marg = ( cr.width() - BoxSize ) / 2; | 315 | int marg = ( cr.width() - BoxSize ) / 2; |
308 | int x = 0; | 316 | int x = 0; |
309 | int y = ( cr.height() - BoxSize ) / 2; | 317 | int y = ( cr.height() - BoxSize ) / 2; |
310 | p->setPen( QPen( cg.text() ) ); | 318 | p->setPen( QPen( cg.text() ) ); |
311 | p->drawRect( x + marg, y, BoxSize, BoxSize ); | 319 | p->drawRect( x + marg, y, BoxSize, BoxSize ); |
312 | p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); | 320 | p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); |
313 | p->setPen( darkGreen ); | 321 | p->setPen( darkGreen ); |
314 | x += 1; | 322 | x += 1; |
315 | y += 1; | 323 | y += 1; |
316 | if ( task.isCompleted() ) { | 324 | if ( task.isCompleted() ) { |
317 | QPointArray a( 9*2 ); | 325 | QPointArray a( 9*2 ); |
318 | int i, xx, yy; | 326 | int i, xx, yy; |
319 | xx = x+2+marg; | 327 | xx = x+2+marg; |
320 | yy = y+4; | 328 | yy = y+4; |
321 | for ( i=0; i<4; i++ ) { | 329 | for ( i=0; i<4; i++ ) { |
322 | a.setPoint( 2*i, xx, yy ); | 330 | a.setPoint( 2*i, xx, yy ); |
323 | a.setPoint( 2*i+1, xx, yy+2 ); | 331 | a.setPoint( 2*i+1, xx, yy+2 ); |
324 | xx++; yy++; | 332 | xx++; yy++; |
325 | } | 333 | } |
326 | yy -= 2; | 334 | yy -= 2; |
327 | for ( i=4; i<9; i++ ) { | 335 | for ( i=4; i<9; i++ ) { |
328 | a.setPoint( 2*i, xx, yy ); | 336 | a.setPoint( 2*i, xx, yy ); |
329 | a.setPoint( 2*i+1, xx, yy+2 ); | 337 | a.setPoint( 2*i+1, xx, yy+2 ); |
330 | xx++; yy--; | 338 | xx++; yy--; |
331 | } | 339 | } |
332 | p->drawLineSegments( a ); | 340 | p->drawLineSegments( a ); |
333 | } | 341 | } |
334 | } | 342 | } |
335 | break; | 343 | break; |
336 | case 1: | 344 | case 1: |
337 | // priority field | 345 | // priority field |
338 | { | 346 | { |
339 | QString text = QString::number(task.priority()); | 347 | QString text = QString::number(task.priority()); |
340 | p->drawText(2,2 + fm.ascent(), text); | 348 | p->drawText(2,2 + fm.ascent(), text); |
341 | } | 349 | } |
342 | break; | 350 | break; |
343 | case 2: | 351 | case 2: |
344 | // description field | 352 | // description field |
345 | { | 353 | { |
346 | QString text = task.summary().isEmpty() ? | 354 | QString text = task.summary().isEmpty() ? |
347 | task.description() : | 355 | task.description() : |
348 | task.summary(); | 356 | task.summary(); |
349 | p->drawText(2,2 + fm.ascent(), text); | 357 | p->drawText(2,2 + fm.ascent(), text); |
350 | } | 358 | } |
351 | break; | 359 | break; |
352 | case 3: | 360 | case 3: |
353 | { | 361 | { |
354 | QString text; | 362 | QString text; |
355 | if (task.hasDueDate()) { | 363 | if (task.hasDueDate()) { |
356 | text = "HAS"; | 364 | int off = QDate::currentDate().daysTo( task.dueDate() ); |
365 | text = QString::number(off) + tr(" day(s)"); | ||
366 | /* | ||
367 | * set color if not completed | ||
368 | */ | ||
369 | if (!task.isCompleted() ) { | ||
370 | QColor color = Qt::black; | ||
371 | if ( off < 0 ) | ||
372 | color = Qt::red; | ||
373 | else if ( off == 0 ) | ||
374 | color = Qt::yellow; | ||
375 | else if ( off > 0 ) | ||
376 | color = Qt::green; | ||
377 | p->setPen(color ); | ||
378 | } | ||
357 | } else { | 379 | } else { |
358 | text = tr("None"); | 380 | text = tr("None"); |
359 | } | 381 | } |
360 | p->drawText(2,2 + fm.ascent(), text); | 382 | p->drawText(2,2 + fm.ascent(), text); |
361 | } | 383 | } |
362 | break; | 384 | break; |
363 | } | 385 | } |
364 | p->restore(); | 386 | p->restore(); |
365 | } | 387 | } |
366 | QWidget* TableView::createEditor(int row, int col, bool )const { | 388 | QWidget* TableView::createEditor(int row, int col, bool )const { |
367 | switch( col ) { | 389 | switch( col ) { |
368 | case 1: { | 390 | case 1: { |
369 | /* the priority stuff */ | 391 | /* the priority stuff */ |
370 | QComboBox* combo = new QComboBox( viewport() ); | 392 | QComboBox* combo = new QComboBox( viewport() ); |
371 | combo->insertItem( "1" ); | 393 | combo->insertItem( "1" ); |
372 | combo->insertItem( "2" ); | 394 | combo->insertItem( "2" ); |
373 | combo->insertItem( "3" ); | 395 | combo->insertItem( "3" ); |
374 | combo->insertItem( "4" ); | 396 | combo->insertItem( "4" ); |
375 | combo->insertItem( "5" ); | 397 | combo->insertItem( "5" ); |
376 | combo->setCurrentItem( sorted()[row].priority()-1 ); | 398 | combo->setCurrentItem( sorted()[row].priority()-1 ); |
377 | return combo; | 399 | return combo; |
378 | } | 400 | } |
379 | case 0: | 401 | case 0: |
380 | default: | 402 | default: |
381 | return 0l; | 403 | return 0l; |
382 | } | 404 | } |
383 | } | 405 | } |
384 | void TableView::setCellContentFromEditor(int row, int col ) { | 406 | void TableView::setCellContentFromEditor(int row, int col ) { |
385 | if ( col == 1 ) { | 407 | if ( col == 1 ) { |
386 | QWidget* wid = cellWidget(row, 1 ); | 408 | QWidget* wid = cellWidget(row, 1 ); |
387 | if ( wid->inherits("QComboBox") ) { | 409 | if ( wid->inherits("QComboBox") ) { |
388 | int pri = ((QComboBox*)wid)->currentItem() + 1; | 410 | int pri = ((QComboBox*)wid)->currentItem() + 1; |
389 | OTodo todo = sorted()[row]; | 411 | OTodo todo = sorted()[row]; |
390 | if ( todo.priority() != pri ) { | 412 | if ( todo.priority() != pri ) { |
391 | todo.setPriority( pri ); | 413 | todo.setPriority( pri ); |
392 | TodoView::update( todo.uid(), todo ); | 414 | TodoView::update( todo.uid(), todo ); |
393 | updateView(); | 415 | updateView(); |
394 | } | 416 | } |
395 | } | 417 | } |
396 | } | 418 | } |
397 | } | 419 | } |
398 | void TableView::slotPriority() { | 420 | void TableView::slotPriority() { |
399 | setCellContentFromEditor( currentRow(), currentColumn() ); | 421 | setCellContentFromEditor( currentRow(), currentColumn() ); |
400 | } | 422 | } |
423 | /* | ||
424 | * We'll use the TimerEvent to read ahead or to keep the cahce always | ||
425 | * filled enough. | ||
426 | * We will try to read ahead 4 items in both ways | ||
427 | * up and down. On odd or even we will currentRow()+-4 or +-9 | ||
428 | * | ||
429 | */ | ||
430 | void TableView::timerEvent( QTimerEvent* ev ) { | ||
431 | int row = currentRow(); | ||
432 | qWarning("TimerEvent %d", row); | ||
433 | if ( m_row ) { | ||
434 | int ro = row-4; | ||
435 | if (ro < 0 ) ro = 0; | ||
436 | sorted()[ro]; | ||
437 | |||
438 | ro = row+4; | ||
439 | sorted()[ro]; | ||
440 | } else { | ||
441 | int ro = row + 8; | ||
442 | sorted()[ro]; | ||
443 | |||
444 | ro = row-8; | ||
445 | if (ro < 0 ) ro = 0; | ||
446 | sorted()[ro]; | ||
447 | } | ||
448 | |||
449 | m_row = !m_row; | ||
450 | } | ||
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h index bf41aea..fe65ca9 100644 --- a/core/pim/todo/tableview.h +++ b/core/pim/todo/tableview.h | |||
@@ -1,100 +1,103 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef OPIE_TABLE_VIEW_H | 29 | #ifndef OPIE_TABLE_VIEW_H |
30 | #define OPIE_TABLE_VIEW_H | 30 | #define OPIE_TABLE_VIEW_H |
31 | 31 | ||
32 | #include <qtable.h> | 32 | #include <qtable.h> |
33 | #include <qmap.h> | 33 | #include <qmap.h> |
34 | 34 | ||
35 | #include "tableitems.h" | 35 | #include "tableitems.h" |
36 | #include "todoview.h" | 36 | #include "todoview.h" |
37 | 37 | ||
38 | class QTimer; | 38 | class QTimer; |
39 | 39 | ||
40 | namespace Todo { | 40 | namespace Todo { |
41 | class CheckItem; | 41 | class CheckItem; |
42 | class DueTextItem; | 42 | class DueTextItem; |
43 | class TableView : public QTable, public TodoView { | 43 | class TableView : public QTable, public TodoView { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | TableView( MainWindow*, QWidget* parent ); | 46 | TableView( MainWindow*, QWidget* parent ); |
47 | ~TableView(); | 47 | ~TableView(); |
48 | 48 | ||
49 | 49 | ||
50 | QString type()const; | 50 | QString type()const; |
51 | int current(); | 51 | int current(); |
52 | QString currentRepresentation(); | 52 | QString currentRepresentation(); |
53 | 53 | ||
54 | void clear(); | 54 | void clear(); |
55 | void showOverDue( bool ); | 55 | void showOverDue( bool ); |
56 | void updateView(); | 56 | void updateView(); |
57 | void setTodo( int uid, const OTodo& ); | 57 | void setTodo( int uid, const OTodo& ); |
58 | void addEvent( const OTodo& event ); | 58 | void addEvent( const OTodo& event ); |
59 | void replaceEvent( const OTodo& ); | 59 | void replaceEvent( const OTodo& ); |
60 | void removeEvent( int uid ); | 60 | void removeEvent( int uid ); |
61 | void setShowCompleted( bool ); | 61 | void setShowCompleted( bool ); |
62 | void setShowDeadline( bool ); | 62 | void setShowDeadline( bool ); |
63 | 63 | ||
64 | void setShowCategory(const QString& =QString::null ); | 64 | void setShowCategory(const QString& =QString::null ); |
65 | void newDay(); | 65 | void newDay(); |
66 | QWidget* widget(); | 66 | QWidget* widget(); |
67 | void sortColumn(int, bool, bool ); | 67 | void sortColumn(int, bool, bool ); |
68 | 68 | ||
69 | /* | 69 | /* |
70 | * we do our drawing ourselves | 70 | * we do our drawing ourselves |
71 | * because we don't want to have | 71 | * because we don't want to have |
72 | * 40.000 QTableItems for 10.000 | 72 | * 40.000 QTableItems for 10.000 |
73 | * OTodos where we only show 10 at a time! | 73 | * OTodos where we only show 10 at a time! |
74 | */ | 74 | */ |
75 | void paintCell(QPainter* p, int row, int col, const QRect&, bool ); | 75 | void paintCell(QPainter* p, int row, int col, const QRect&, bool ); |
76 | private: | 76 | private: |
77 | /* reimplented for internal reasons */ | 77 | /* reimplented for internal reasons */ |
78 | void viewportPaintEvent( QPaintEvent* ); | 78 | void viewportPaintEvent( QPaintEvent* ); |
79 | QTimer *m_menuTimer; | 79 | QTimer *m_menuTimer; |
80 | bool m_enablePaint:1; | 80 | bool m_enablePaint:1; |
81 | QString m_oleCat; | 81 | QString m_oleCat; |
82 | bool m_first : 1; | 82 | bool m_first : 1; |
83 | 83 | ||
84 | protected: | 84 | protected: |
85 | void timerEvent( QTimerEvent* e ); | ||
85 | QWidget* createEditor(int row, int col, bool initFromCell )const; | 86 | QWidget* createEditor(int row, int col, bool initFromCell )const; |
86 | void setCellContentFromEditor( int row, int col ); | 87 | void setCellContentFromEditor( int row, int col ); |
87 | 88 | ||
88 | private slots: | 89 | private slots: |
89 | void slotShowMenu(); | 90 | void slotShowMenu(); |
90 | void slotClicked(int, int, int, | 91 | void slotClicked(int, int, int, |
91 | const QPoint& ); | 92 | const QPoint& ); |
92 | void slotPressed(int, int, int, | 93 | void slotPressed(int, int, int, |
93 | const QPoint& ); | 94 | const QPoint& ); |
94 | void slotValueChanged(int, int); | 95 | void slotValueChanged(int, int); |
95 | void slotCurrentChanged(int, int ); | 96 | void slotCurrentChanged(int, int ); |
96 | void slotPriority(); | 97 | void slotPriority(); |
98 | private: | ||
99 | bool m_row : 1; | ||
97 | }; | 100 | }; |
98 | }; | 101 | }; |
99 | 102 | ||
100 | #endif | 103 | #endif |