summaryrefslogtreecommitdiff
path: root/core/pim/todo/mainwindow.cpp
authorzecke <zecke>2002-11-30 11:20:47 (UTC)
committer zecke <zecke>2002-11-30 11:20:47 (UTC)
commitfdda15344fdf7f71fd9e1e4db15ecc5e12224ddb (patch) (unidiff)
tree32e68b5b483dd3ce8041542e7d95f0b6d8dbf644 /core/pim/todo/mainwindow.cpp
parentbd692f7ebe04e23151cce39baf311b925ccf91b1 (diff)
downloadopie-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.cpp213
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
@@ -44,6 +44,7 @@
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"
@@ -59,7 +60,9 @@
59using namespace Todo; 60using namespace Todo;
60 61
61MainWindow::MainWindow( QWidget* parent, 62MainWindow::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;
@@ -177,13 +180,10 @@ void MainWindow::initActions() {
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,
@@ -220,7 +220,6 @@ void MainWindow::initUI() {
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
@@ -254,24 +253,26 @@ MainWindow::~MainWindow() {
254 delete templateManager(); 253 delete templateManager();
255} 254}
256void MainWindow::connectBase( ViewBase* base) { 255void 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, 258QPopupMenu* 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}
267QPopupMenu* 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}
277QPopupMenu* MainWindow::options() { 278QPopupMenu* MainWindow::options() {
@@ -281,9 +282,6 @@ QPopupMenu* MainWindow::options() {
281QPopupMenu* MainWindow::edit() { 282QPopupMenu* MainWindow::edit() {
282 return m_edit; 283 return m_edit;
283} 284}
284QPopupMenu* MainWindow::view() {
285 return m_view;
286}
287QToolBar* MainWindow::toolbar() { 285QToolBar* MainWindow::toolbar() {
288 return m_tool; 286 return m_tool;
289} 287}
@@ -413,28 +411,7 @@ void MainWindow::slotNewFromTemplate( int id ) {
413 } 411 }
414} 412}
415void MainWindow::slotNew() { 413void 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}
439void MainWindow::slotDuplicate() { 416void MainWindow::slotDuplicate() {
440 if(m_syncing) { 417 if(m_syncing) {
@@ -474,7 +451,6 @@ void MainWindow::slotDeleteAll() {
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;
@@ -494,8 +470,8 @@ void MainWindow::slotDeleteCompleted() {
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}
501void MainWindow::slotFind() { 477void MainWindow::slotFind() {
@@ -552,18 +528,7 @@ void MainWindow::setDocument( const QString& fi) {
552 528
553static const char *beamfile = "/tmp/opie-todo.vcs"; 529static const char *beamfile = "/tmp/opie-todo.vcs";
554void MainWindow::slotBeam() { 530void 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}
568void MainWindow::beamDone( Ir* ir) { 533void MainWindow::beamDone( Ir* ir) {
569 delete ir; 534 delete ir;
@@ -704,3 +669,137 @@ void MainWindow::slotQuickEntered() {
704QuickEditBase* MainWindow::quickEditor() { 669QuickEditBase* MainWindow::quickEditor() {
705 return m_curQuick; 670 return m_curQuick;
706} 671}
672void MainWindow::slotComplete( int uid ) {
673 slotComplete( event(uid) );
674}
675void 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}
727void MainWindow::flush() {
728 slotFlush();
729}
730void MainWindow::reload() {
731 slotReload();
732}
733int 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... */
762bool MainWindow::remove( int uid ) {
763 if (m_syncing) return false;
764
765 return m_todoMgr.remove( uid );
766}
767void 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}
780void MainWindow::show( int uid ) {
781 slotShow( uid );
782}
783void MainWindow::edit( int uid ) {
784 slotEdit( uid );
785}
786void 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 */
803OPimRecord* MainWindow::record( int rtti, const QByteArray& ) {
804 return 0l;
805}