author | zecke <zecke> | 2002-11-30 11:20:47 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-11-30 11:20:47 (UTC) |
commit | fdda15344fdf7f71fd9e1e4db15ecc5e12224ddb (patch) (unidiff) | |
tree | 32e68b5b483dd3ce8041542e7d95f0b6d8dbf644 /core/pim/todo/mainwindow.cpp | |
parent | bd692f7ebe04e23151cce39baf311b925ccf91b1 (diff) | |
download | opie-fdda15344fdf7f71fd9e1e4db15ecc5e12224ddb.zip opie-fdda15344fdf7f71fd9e1e4db15ecc5e12224ddb.tar.gz opie-fdda15344fdf7f71fd9e1e4db15ecc5e12224ddb.tar.bz2 |
Back from hospital with new power
This versions clean up m failure on templates with Qt... in todoview
Implements Recurrance( backends to not safe it yet )
OPimState and Maintainer mode in some ways
and much more
This one also implements the OPimMainWindow specs
and has a small Memu replacement to get the toolbar in one line
Diffstat (limited to 'core/pim/todo/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 213 |
1 files changed, 156 insertions, 57 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 9b2423b..b2b3b8f 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -35,40 +35,43 @@ | |||
35 | #include <qwidgetstack.h> | 35 | #include <qwidgetstack.h> |
36 | #include <qaction.h> | 36 | #include <qaction.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | #include <qvbox.h> | 38 | #include <qvbox.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | 40 | ||
41 | #include <qpe/applnk.h> | 41 | #include <qpe/applnk.h> |
42 | #include <qpe/config.h> | 42 | #include <qpe/config.h> |
43 | #include <qpe/ir.h> | 43 | #include <qpe/ir.h> |
44 | #include <qpe/resource.h> | 44 | #include <qpe/resource.h> |
45 | #include <qpe/qpemessagebox.h> | 45 | #include <qpe/qpemessagebox.h> |
46 | 46 | ||
47 | #include <opie/orecur.h> | ||
47 | #include <opie/otodoaccessvcal.h> | 48 | #include <opie/otodoaccessvcal.h> |
48 | 49 | ||
49 | #include "quickeditimpl.h" | 50 | #include "quickeditimpl.h" |
50 | #include "todotemplatemanager.h" | 51 | #include "todotemplatemanager.h" |
51 | #include "templateeditor.h" | 52 | #include "templateeditor.h" |
52 | #include "tableview.h" | 53 | #include "tableview.h" |
53 | 54 | ||
54 | #include "textviewshow.h" | 55 | #include "textviewshow.h" |
55 | #include "todoeditor.h" | 56 | #include "todoeditor.h" |
56 | #include "mainwindow.h" | 57 | #include "mainwindow.h" |
57 | 58 | ||
58 | 59 | ||
59 | using namespace Todo; | 60 | using namespace Todo; |
60 | 61 | ||
61 | MainWindow::MainWindow( QWidget* parent, | 62 | MainWindow::MainWindow( QWidget* parent, |
62 | const char* name ) { | 63 | const char* name ) |
64 | : OPimMainWindow("Todolist") | ||
65 | { | ||
63 | 66 | ||
64 | m_syncing = false; | 67 | m_syncing = false; |
65 | m_counter = 0; | 68 | m_counter = 0; |
66 | m_tempManager = new TemplateManager(); | 69 | m_tempManager = new TemplateManager(); |
67 | m_tempManager->load(); | 70 | m_tempManager->load(); |
68 | 71 | ||
69 | initUI(); | 72 | initUI(); |
70 | initConfig(); | 73 | initConfig(); |
71 | initViews(); | 74 | initViews(); |
72 | initActions(); | 75 | initActions(); |
73 | initEditor(); | 76 | initEditor(); |
74 | initShow(); | 77 | initShow(); |
@@ -168,31 +171,28 @@ void MainWindow::initActions() { | |||
168 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), | 171 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), |
169 | this, SLOT( slotShowDeadLine( bool ) ) ); | 172 | this, SLOT( slotShowDeadLine( bool ) ) ); |
170 | 173 | ||
171 | m_options->insertSeparator(); | 174 | m_options->insertSeparator(); |
172 | 175 | ||
173 | m_bar->insertItem( tr("Data") ,m_edit ); | 176 | m_bar->insertItem( tr("Data") ,m_edit ); |
174 | m_bar->insertItem( tr("Category"), m_catMenu ); | 177 | m_bar->insertItem( tr("Category"), m_catMenu ); |
175 | m_bar->insertItem( tr("Options"), m_options ); | 178 | m_bar->insertItem( tr("Options"), m_options ); |
176 | 179 | ||
177 | /* initialize the view menu */ | 180 | /* initialize the view menu */ |
178 | a = new QAction( QString::null, tr("Show only over due"), | 181 | a = new QAction( QString::null, tr("Show only over due"), |
179 | 0, this, 0, TRUE ); | 182 | 0, this, 0, TRUE ); |
180 | a->addTo( m_view ); | 183 | a->addTo( m_options ); |
181 | a->setOn( showOverDue() ); | 184 | a->setOn( showOverDue() ); |
182 | connect(a, SIGNAL(toggled(bool)), | 185 | connect(a, SIGNAL(toggled(bool)), |
183 | this, SLOT(slotShowDue(bool) ) ); | 186 | this, SLOT(slotShowDue(bool) ) ); |
184 | m_view->insertSeparator(); | ||
185 | |||
186 | m_bar->insertItem( tr("View"), m_view ); | ||
187 | 187 | ||
188 | /* templates */ | 188 | /* templates */ |
189 | m_edit->insertItem(tr("New from template"), m_template, | 189 | m_edit->insertItem(tr("New from template"), m_template, |
190 | -1, 0 ); | 190 | -1, 0 ); |
191 | 191 | ||
192 | } | 192 | } |
193 | /* m_curCat from Config */ | 193 | /* m_curCat from Config */ |
194 | void MainWindow::initConfig() { | 194 | void MainWindow::initConfig() { |
195 | Config config( "todo" ); | 195 | Config config( "todo" ); |
196 | config.setGroup( "View" ); | 196 | config.setGroup( "View" ); |
197 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); | 197 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); |
198 | m_curCat = config.readEntry( "Category", QString::null ); | 198 | m_curCat = config.readEntry( "Category", QString::null ); |
@@ -211,25 +211,24 @@ void MainWindow::initUI() { | |||
211 | setCentralWidget( m_mainBox ); | 211 | setCentralWidget( m_mainBox ); |
212 | 212 | ||
213 | setToolBarsMovable( FALSE ); | 213 | setToolBarsMovable( FALSE ); |
214 | 214 | ||
215 | m_tool = new QToolBar( this ); | 215 | m_tool = new QToolBar( this ); |
216 | m_tool->setHorizontalStretchable( TRUE ); | 216 | m_tool->setHorizontalStretchable( TRUE ); |
217 | 217 | ||
218 | m_bar = new QMenuBar( m_tool ); | 218 | m_bar = new QMenuBar( m_tool ); |
219 | 219 | ||
220 | /** QPopupMenu */ | 220 | /** QPopupMenu */ |
221 | m_edit = new QPopupMenu( this ); | 221 | m_edit = new QPopupMenu( this ); |
222 | m_options = new QPopupMenu( this ); | 222 | m_options = new QPopupMenu( this ); |
223 | m_view = new QPopupMenu( this ); | ||
224 | m_catMenu = new QPopupMenu( this ); | 223 | m_catMenu = new QPopupMenu( this ); |
225 | m_template = new QPopupMenu( this ); | 224 | m_template = new QPopupMenu( this ); |
226 | 225 | ||
227 | m_catMenu->setCheckable( TRUE ); | 226 | m_catMenu->setCheckable( TRUE ); |
228 | m_template->setCheckable( TRUE ); | 227 | m_template->setCheckable( TRUE ); |
229 | 228 | ||
230 | connect(m_catMenu, SIGNAL(activated(int) ), | 229 | connect(m_catMenu, SIGNAL(activated(int) ), |
231 | this, SLOT(setCategory(int) ) ); | 230 | this, SLOT(setCategory(int) ) ); |
232 | connect(m_template, SIGNAL(activated(int) ), | 231 | connect(m_template, SIGNAL(activated(int) ), |
233 | this, SLOT(slotNewFromTemplate(int) ) ); | 232 | this, SLOT(slotNewFromTemplate(int) ) ); |
234 | } | 233 | } |
235 | void MainWindow::initViews() { | 234 | void MainWindow::initViews() { |
@@ -245,54 +244,53 @@ void MainWindow::initViews() { | |||
245 | } | 244 | } |
246 | void MainWindow::initEditor() { | 245 | void MainWindow::initEditor() { |
247 | m_curEdit = new Editor(); | 246 | m_curEdit = new Editor(); |
248 | } | 247 | } |
249 | void MainWindow::initShow() { | 248 | void MainWindow::initShow() { |
250 | m_curShow = new TextViewShow(this); | 249 | m_curShow = new TextViewShow(this); |
251 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); | 250 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); |
252 | } | 251 | } |
253 | MainWindow::~MainWindow() { | 252 | MainWindow::~MainWindow() { |
254 | delete templateManager(); | 253 | delete templateManager(); |
255 | } | 254 | } |
256 | void MainWindow::connectBase( ViewBase* base) { | 255 | void MainWindow::connectBase( ViewBase* base) { |
257 | base->connectShow( this, SLOT(slotShow(int) ) ); | 256 | // once templates and signals mix we'll use it again |
258 | base->connectEdit( this, SLOT(slotEdit(int) ) ); | 257 | } |
259 | base->connectUpdateSmall( this, | 258 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { |
260 | SLOT(slotUpate1(int, const Todo::SmallTodo&) )); | ||
261 | base->connectUpdateBig( this, | ||
262 | SLOT(slotUpate2(int, const OTodo& ) ) ); | ||
263 | base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; | ||
264 | base->connectRemove(&m_todoMgr, | ||
265 | SLOT(remove(int)) ); | ||
266 | } | ||
267 | QPopupMenu* MainWindow::contextMenu( int uid ) { | ||
268 | QPopupMenu* menu = new QPopupMenu(); | 259 | QPopupMenu* menu = new QPopupMenu(); |
269 | 260 | ||
270 | m_editAction->addTo( menu ); | 261 | m_editAction->addTo( menu ); |
271 | m_deleteAction->addTo( menu ); | 262 | m_deleteAction->addTo( menu ); |
272 | m_duplicateAction->addTo( menu ); | 263 | m_duplicateAction->addTo( menu ); |
264 | |||
273 | menu->insertSeparator(); | 265 | menu->insertSeparator(); |
274 | 266 | ||
267 | /* | ||
268 | * if this event recurs we allow | ||
269 | * to detach it. | ||
270 | * remove all | ||
271 | */ | ||
272 | if ( recur ) { | ||
273 | ; // FIXME | ||
274 | } | ||
275 | |||
275 | return menu; | 276 | return menu; |
276 | } | 277 | } |
277 | QPopupMenu* MainWindow::options() { | 278 | QPopupMenu* MainWindow::options() { |
278 | qWarning("Options"); | 279 | qWarning("Options"); |
279 | return m_options; | 280 | return m_options; |
280 | } | 281 | } |
281 | QPopupMenu* MainWindow::edit() { | 282 | QPopupMenu* MainWindow::edit() { |
282 | return m_edit; | 283 | return m_edit; |
283 | } | 284 | } |
284 | QPopupMenu* MainWindow::view() { | ||
285 | return m_view; | ||
286 | } | ||
287 | QToolBar* MainWindow::toolbar() { | 285 | QToolBar* MainWindow::toolbar() { |
288 | return m_tool; | 286 | return m_tool; |
289 | } | 287 | } |
290 | OTodoAccess::List MainWindow::list()const { | 288 | OTodoAccess::List MainWindow::list()const { |
291 | return m_todoMgr.list(); | 289 | return m_todoMgr.list(); |
292 | } | 290 | } |
293 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 291 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
294 | int cat = 0; | 292 | int cat = 0; |
295 | if ( m_curCat != tr("All Categories") ) | 293 | if ( m_curCat != tr("All Categories") ) |
296 | cat = currentCatId(); | 294 | cat = currentCatId(); |
297 | 295 | ||
298 | int filter = 1; | 296 | int filter = 1; |
@@ -404,46 +402,25 @@ void MainWindow::slotNewFromTemplate( int id ) { | |||
404 | event ); | 402 | event ); |
405 | 403 | ||
406 | if ( currentEditor()->accepted() ) { | 404 | if ( currentEditor()->accepted() ) { |
407 | /* assign new todo */ | 405 | /* assign new todo */ |
408 | event.setUid( -1 ); | 406 | event.setUid( -1 ); |
409 | currentView()->addEvent( event ); | 407 | currentView()->addEvent( event ); |
410 | m_todoMgr.add( event ); | 408 | m_todoMgr.add( event ); |
411 | 409 | ||
412 | populateCategories(); | 410 | populateCategories(); |
413 | } | 411 | } |
414 | } | 412 | } |
415 | void MainWindow::slotNew() { | 413 | void MainWindow::slotNew() { |
416 | if(m_syncing) { | 414 | create(); |
417 | QMessageBox::warning(this, tr("Todo"), | ||
418 | tr("Can not edit data, currently syncing")); | ||
419 | return; | ||
420 | } | ||
421 | |||
422 | |||
423 | OTodo todo = currentEditor()->newTodo( currentCatId(), | ||
424 | this ); | ||
425 | |||
426 | if ( currentEditor()->accepted() ) { | ||
427 | //todo.assignUid(); | ||
428 | m_todoMgr.add( todo ); | ||
429 | currentView()->addEvent( todo ); | ||
430 | |||
431 | |||
432 | // I'm afraid we must call this every time now, otherwise | ||
433 | // spend expensive time comparing all these strings... | ||
434 | // but only call if we changed something -zecke | ||
435 | populateCategories(); | ||
436 | } | ||
437 | raiseCurrentView( ); | ||
438 | } | 415 | } |
439 | void MainWindow::slotDuplicate() { | 416 | void MainWindow::slotDuplicate() { |
440 | if(m_syncing) { | 417 | if(m_syncing) { |
441 | QMessageBox::warning(this, tr("Todo"), | 418 | QMessageBox::warning(this, tr("Todo"), |
442 | tr("Can not edit data, currently syncing")); | 419 | tr("Can not edit data, currently syncing")); |
443 | return; | 420 | return; |
444 | } | 421 | } |
445 | OTodo ev = m_todoMgr.event( currentView()->current() ); | 422 | OTodo ev = m_todoMgr.event( currentView()->current() ); |
446 | /* let's generate a new uid */ | 423 | /* let's generate a new uid */ |
447 | ev.setUid(-1); | 424 | ev.setUid(-1); |
448 | m_todoMgr.add( ev ); | 425 | m_todoMgr.add( ev ); |
449 | 426 | ||
@@ -465,46 +442,45 @@ void MainWindow::slotDelete() { | |||
465 | 442 | ||
466 | m_todoMgr.remove( currentView()->current() ); | 443 | m_todoMgr.remove( currentView()->current() ); |
467 | currentView()->removeEvent( currentView()->current() ); | 444 | currentView()->removeEvent( currentView()->current() ); |
468 | raiseCurrentView(); | 445 | raiseCurrentView(); |
469 | } | 446 | } |
470 | void MainWindow::slotDeleteAll() { | 447 | void MainWindow::slotDeleteAll() { |
471 | if(m_syncing) { | 448 | if(m_syncing) { |
472 | QMessageBox::warning(this, tr("Todo"), | 449 | QMessageBox::warning(this, tr("Todo"), |
473 | tr("Can not edit data, currently syncing")); | 450 | tr("Can not edit data, currently syncing")); |
474 | return; | 451 | return; |
475 | } | 452 | } |
476 | 453 | ||
477 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | ||
478 | 454 | ||
479 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) | 455 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) |
480 | return; | 456 | return; |
481 | 457 | ||
482 | m_todoMgr.removeAll(); | 458 | m_todoMgr.removeAll(); |
483 | currentView()->clear(); | 459 | currentView()->clear(); |
484 | 460 | ||
485 | raiseCurrentView(); | 461 | raiseCurrentView(); |
486 | } | 462 | } |
487 | void MainWindow::slotDeleteCompleted() { | 463 | void MainWindow::slotDeleteCompleted() { |
488 | if(m_syncing) { | 464 | if(m_syncing) { |
489 | QMessageBox::warning(this, tr("Todo"), | 465 | QMessageBox::warning(this, tr("Todo"), |
490 | tr("Can not edit data, currently syncing")); | 466 | tr("Can not edit data, currently syncing")); |
491 | return; | 467 | return; |
492 | } | 468 | } |
493 | 469 | ||
494 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) | 470 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) |
495 | return; | 471 | return; |
496 | 472 | ||
497 | // FIXME | 473 | |
498 | //m_todoMgr.remove( currentView()->completed() ); | 474 | m_todoMgr.removeCompleted(); |
499 | currentView()->updateView( ); | 475 | currentView()->updateView( ); |
500 | } | 476 | } |
501 | void MainWindow::slotFind() { | 477 | void MainWindow::slotFind() { |
502 | 478 | ||
503 | } | 479 | } |
504 | void MainWindow::slotEdit() { | 480 | void MainWindow::slotEdit() { |
505 | slotEdit( currentView()->current() ); | 481 | slotEdit( currentView()->current() ); |
506 | } | 482 | } |
507 | /* | 483 | /* |
508 | * set the category | 484 | * set the category |
509 | */ | 485 | */ |
510 | void MainWindow::setCategory( int c) { | 486 | void MainWindow::setCategory( int c) { |
@@ -543,36 +519,25 @@ bool MainWindow::showOverDue()const { | |||
543 | return m_overdue; | 519 | return m_overdue; |
544 | } | 520 | } |
545 | void MainWindow::setDocument( const QString& fi) { | 521 | void MainWindow::setDocument( const QString& fi) { |
546 | DocLnk doc(fi); | 522 | DocLnk doc(fi); |
547 | if (doc.isValid() ) | 523 | if (doc.isValid() ) |
548 | receiveFile(doc.file() ); | 524 | receiveFile(doc.file() ); |
549 | else | 525 | else |
550 | receiveFile(fi ); | 526 | receiveFile(fi ); |
551 | } | 527 | } |
552 | 528 | ||
553 | static const char *beamfile = "/tmp/opie-todo.vcs"; | 529 | static const char *beamfile = "/tmp/opie-todo.vcs"; |
554 | void MainWindow::slotBeam() { | 530 | void MainWindow::slotBeam() { |
555 | ::unlink( beamfile ); | 531 | beam( currentView()->current() ); |
556 | OTodo todo = event( currentView()->current() ); | ||
557 | OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); | ||
558 | OTodoAccess acc( cal ); | ||
559 | acc.load(); | ||
560 | acc.add( todo ); | ||
561 | acc.save(); | ||
562 | Ir* ir = new Ir(this ); | ||
563 | connect(ir, SIGNAL(done(Ir*) ), | ||
564 | this, SLOT(beamDone(Ir*) ) ); | ||
565 | ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); | ||
566 | |||
567 | } | 532 | } |
568 | void MainWindow::beamDone( Ir* ir) { | 533 | void MainWindow::beamDone( Ir* ir) { |
569 | delete ir; | 534 | delete ir; |
570 | ::unlink( beamfile ); | 535 | ::unlink( beamfile ); |
571 | } | 536 | } |
572 | void MainWindow::receiveFile( const QString& filename ) { | 537 | void MainWindow::receiveFile( const QString& filename ) { |
573 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); | 538 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); |
574 | OTodoAccess acc( cal ); | 539 | OTodoAccess acc( cal ); |
575 | acc.load(); | 540 | acc.load(); |
576 | OTodoAccess::List list = acc.allRecords(); | 541 | OTodoAccess::List list = acc.allRecords(); |
577 | 542 | ||
578 | QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); | 543 | QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); |
@@ -695,12 +660,146 @@ void MainWindow::slotQuickEntered() { | |||
695 | qWarning("entered"); | 660 | qWarning("entered"); |
696 | OTodo todo = quickEditor()->todo(); | 661 | OTodo todo = quickEditor()->todo(); |
697 | if (todo.isEmpty() ) | 662 | if (todo.isEmpty() ) |
698 | return; | 663 | return; |
699 | 664 | ||
700 | m_todoMgr.add( todo ); | 665 | m_todoMgr.add( todo ); |
701 | currentView()->addEvent( todo ); | 666 | currentView()->addEvent( todo ); |
702 | raiseCurrentView(); | 667 | raiseCurrentView(); |
703 | } | 668 | } |
704 | QuickEditBase* MainWindow::quickEditor() { | 669 | QuickEditBase* MainWindow::quickEditor() { |
705 | return m_curQuick; | 670 | return m_curQuick; |
706 | } | 671 | } |
672 | void MainWindow::slotComplete( int uid ) { | ||
673 | slotComplete( event(uid) ); | ||
674 | } | ||
675 | void MainWindow::slotComplete( const OTodo& todo ) { | ||
676 | OTodo to = todo; | ||
677 | to.setCompleted( !to.isCompleted() ); | ||
678 | to.setCompletedDate( QDate::currentDate() ); | ||
679 | |||
680 | /* | ||
681 | * if the item does recur | ||
682 | * we need to spin it off | ||
683 | * and update the items duedate to the next | ||
684 | * possible recurrance of this item... | ||
685 | * the spinned off one will loose the | ||
686 | */ | ||
687 | if ( to.recurrence().doesRecur() && to.isCompleted() ) { | ||
688 | OTodo to2( to ); | ||
689 | |||
690 | /* the spinned off one won't recur anymore */ | ||
691 | to.setRecurrence( ORecur() ); | ||
692 | |||
693 | ORecur rec = to2.recurrence(); | ||
694 | rec.setStart( to.dueDate() ); | ||
695 | to2.setRecurrence( rec ); | ||
696 | /* | ||
697 | * if there is a next occurence | ||
698 | * from the duedate of the last recurrance | ||
699 | */ | ||
700 | QDate date; | ||
701 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { | ||
702 | QDate inval; | ||
703 | /* generate a new uid for the old record */ | ||
704 | to.setUid( 1 ); | ||
705 | |||
706 | /* add the old one cause it has a new UID here cause it was spin off */ | ||
707 | m_todoMgr.add( to ); | ||
708 | |||
709 | /* | ||
710 | * update the due date | ||
711 | * start date | ||
712 | * and complete date | ||
713 | */ | ||
714 | to2.setDueDate( date ); | ||
715 | to2.setStartDate( inval ); | ||
716 | to2.setCompletedDate( inval ); | ||
717 | to2.setCompleted( false ); | ||
718 | updateTodo( to2 ); | ||
719 | }else | ||
720 | updateTodo( to ); | ||
721 | }else | ||
722 | updateTodo( to ); | ||
723 | |||
724 | currentView()->updateView(); | ||
725 | raiseCurrentView(); | ||
726 | } | ||
727 | void MainWindow::flush() { | ||
728 | slotFlush(); | ||
729 | } | ||
730 | void MainWindow::reload() { | ||
731 | slotReload(); | ||
732 | } | ||
733 | int MainWindow::create() { | ||
734 | int uid = 0; | ||
735 | if(m_syncing) { | ||
736 | QMessageBox::warning(this, tr("Todo"), | ||
737 | tr("Can not edit data, currently syncing")); | ||
738 | return uid; | ||
739 | } | ||
740 | |||
741 | |||
742 | OTodo todo = currentEditor()->newTodo( currentCatId(), | ||
743 | this ); | ||
744 | |||
745 | if ( currentEditor()->accepted() ) { | ||
746 | //todo.assignUid(); | ||
747 | uid = todo.uid(); | ||
748 | m_todoMgr.add( todo ); | ||
749 | currentView()->addEvent( todo ); | ||
750 | |||
751 | |||
752 | // I'm afraid we must call this every time now, otherwise | ||
753 | // spend expensive time comparing all these strings... | ||
754 | // but only call if we changed something -zecke | ||
755 | populateCategories(); | ||
756 | } | ||
757 | raiseCurrentView( ); | ||
758 | |||
759 | return uid; | ||
760 | } | ||
761 | /* delete it silently... */ | ||
762 | bool MainWindow::remove( int uid ) { | ||
763 | if (m_syncing) return false; | ||
764 | |||
765 | return m_todoMgr.remove( uid ); | ||
766 | } | ||
767 | void MainWindow::beam( int uid, int ) { | ||
768 | ::unlink( beamfile ); | ||
769 | OTodo todo = event( uid ); | ||
770 | OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); | ||
771 | OTodoAccess acc( cal ); | ||
772 | acc.load(); | ||
773 | acc.add( todo ); | ||
774 | acc.save(); | ||
775 | Ir* ir = new Ir(this ); | ||
776 | connect(ir, SIGNAL(done(Ir*) ), | ||
777 | this, SLOT(beamDone(Ir*) ) ); | ||
778 | ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); | ||
779 | } | ||
780 | void MainWindow::show( int uid ) { | ||
781 | slotShow( uid ); | ||
782 | } | ||
783 | void MainWindow::edit( int uid ) { | ||
784 | slotEdit( uid ); | ||
785 | } | ||
786 | void MainWindow::add( const OPimRecord& rec) { | ||
787 | if ( rec.rtti() != OTodo::rtti() ) return; | ||
788 | |||
789 | const OTodo& todo = static_cast<const OTodo&>(rec); | ||
790 | |||
791 | m_todoMgr.add(todo ); | ||
792 | currentView()->addEvent( todo ); | ||
793 | |||
794 | |||
795 | // I'm afraid we must call this every time now, otherwise | ||
796 | // spend expensive time comparing all these strings... | ||
797 | // but only call if we changed something -zecke | ||
798 | populateCategories(); | ||
799 | } | ||
800 | /* todo does not have the QDataStream<< and >> operators implemented :( | ||
801 | * FIXME | ||
802 | */ | ||
803 | OPimRecord* MainWindow::record( int rtti, const QByteArray& ) { | ||
804 | return 0l; | ||
805 | } | ||