author | zecke <zecke> | 2002-11-30 11:20:47 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-11-30 11:20:47 (UTC) |
commit | fdda15344fdf7f71fd9e1e4db15ecc5e12224ddb (patch) (side-by-side diff) | |
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
-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 @@ -41,12 +41,13 @@ #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/ir.h> #include <qpe/resource.h> #include <qpe/qpemessagebox.h> +#include <opie/orecur.h> #include <opie/otodoaccessvcal.h> #include "quickeditimpl.h" #include "todotemplatemanager.h" #include "templateeditor.h" #include "tableview.h" @@ -56,13 +57,15 @@ #include "mainwindow.h" using namespace Todo; MainWindow::MainWindow( QWidget* parent, - const char* name ) { + const char* name ) + : OPimMainWindow("Todolist") +{ m_syncing = false; m_counter = 0; m_tempManager = new TemplateManager(); m_tempManager->load(); @@ -174,19 +177,16 @@ void MainWindow::initActions() { m_bar->insertItem( tr("Category"), m_catMenu ); m_bar->insertItem( tr("Options"), m_options ); /* initialize the view menu */ a = new QAction( QString::null, tr("Show only over due"), 0, this, 0, TRUE ); - a->addTo( m_view ); + a->addTo( m_options ); a->setOn( showOverDue() ); connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); - m_view->insertSeparator(); - - m_bar->insertItem( tr("View"), m_view ); /* templates */ m_edit->insertItem(tr("New from template"), m_template, -1, 0 ); } @@ -217,13 +217,12 @@ void MainWindow::initUI() { m_bar = new QMenuBar( m_tool ); /** QPopupMenu */ m_edit = new QPopupMenu( this ); m_options = new QPopupMenu( this ); - m_view = new QPopupMenu( this ); m_catMenu = new QPopupMenu( this ); m_template = new QPopupMenu( this ); m_catMenu->setCheckable( TRUE ); m_template->setCheckable( TRUE ); @@ -251,42 +250,41 @@ void MainWindow::initShow() { m_stack->addWidget( m_curShow->widget() , m_counter++ ); } MainWindow::~MainWindow() { delete templateManager(); } void MainWindow::connectBase( ViewBase* base) { - base->connectShow( this, SLOT(slotShow(int) ) ); - base->connectEdit( this, SLOT(slotEdit(int) ) ); - base->connectUpdateSmall( this, - SLOT(slotUpate1(int, const Todo::SmallTodo&) )); - base->connectUpdateBig( this, - SLOT(slotUpate2(int, const OTodo& ) ) ); - base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; - base->connectRemove(&m_todoMgr, - SLOT(remove(int)) ); -} -QPopupMenu* MainWindow::contextMenu( int uid ) { + // once templates and signals mix we'll use it again +} +QPopupMenu* MainWindow::contextMenu( int , bool recur ) { QPopupMenu* menu = new QPopupMenu(); m_editAction->addTo( menu ); m_deleteAction->addTo( menu ); m_duplicateAction->addTo( menu ); + menu->insertSeparator(); + /* + * if this event recurs we allow + * to detach it. + * remove all + */ + if ( recur ) { + ; // FIXME + } + return menu; } QPopupMenu* MainWindow::options() { qWarning("Options"); return m_options; } QPopupMenu* MainWindow::edit() { return m_edit; } -QPopupMenu* MainWindow::view() { - return m_view; -} QToolBar* MainWindow::toolbar() { return m_tool; } OTodoAccess::List MainWindow::list()const { return m_todoMgr.list(); } @@ -410,34 +408,13 @@ void MainWindow::slotNewFromTemplate( int id ) { m_todoMgr.add( event ); populateCategories(); } } void MainWindow::slotNew() { - if(m_syncing) { - QMessageBox::warning(this, tr("Todo"), - tr("Can not edit data, currently syncing")); - return; - } - - - OTodo todo = currentEditor()->newTodo( currentCatId(), - this ); - - if ( currentEditor()->accepted() ) { - //todo.assignUid(); - m_todoMgr.add( todo ); - currentView()->addEvent( todo ); - - - // I'm afraid we must call this every time now, otherwise - // spend expensive time comparing all these strings... - // but only call if we changed something -zecke - populateCategories(); - } - raiseCurrentView( ); + create(); } void MainWindow::slotDuplicate() { if(m_syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; @@ -471,13 +448,12 @@ void MainWindow::slotDeleteAll() { if(m_syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } - //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) return; m_todoMgr.removeAll(); currentView()->clear(); @@ -491,14 +467,14 @@ void MainWindow::slotDeleteCompleted() { return; } if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) return; - // FIXME - //m_todoMgr.remove( currentView()->completed() ); + + m_todoMgr.removeCompleted(); currentView()->updateView( ); } void MainWindow::slotFind() { } void MainWindow::slotEdit() { @@ -549,24 +525,13 @@ void MainWindow::setDocument( const QString& fi) { else receiveFile(fi ); } static const char *beamfile = "/tmp/opie-todo.vcs"; void MainWindow::slotBeam() { - ::unlink( beamfile ); - OTodo todo = event( currentView()->current() ); - OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); - OTodoAccess acc( cal ); - acc.load(); - acc.add( todo ); - acc.save(); - Ir* ir = new Ir(this ); - connect(ir, SIGNAL(done(Ir*) ), - this, SLOT(beamDone(Ir*) ) ); - ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); - + beam( currentView()->current() ); } void MainWindow::beamDone( Ir* ir) { delete ir; ::unlink( beamfile ); } void MainWindow::receiveFile( const QString& filename ) { @@ -701,6 +666,140 @@ void MainWindow::slotQuickEntered() { currentView()->addEvent( todo ); raiseCurrentView(); } QuickEditBase* MainWindow::quickEditor() { return m_curQuick; } +void MainWindow::slotComplete( int uid ) { + slotComplete( event(uid) ); +} +void MainWindow::slotComplete( const OTodo& todo ) { + OTodo to = todo; + to.setCompleted( !to.isCompleted() ); + to.setCompletedDate( QDate::currentDate() ); + + /* + * if the item does recur + * we need to spin it off + * and update the items duedate to the next + * possible recurrance of this item... + * the spinned off one will loose the + */ + if ( to.recurrence().doesRecur() && to.isCompleted() ) { + OTodo to2( to ); + + /* the spinned off one won't recur anymore */ + to.setRecurrence( ORecur() ); + + ORecur rec = to2.recurrence(); + rec.setStart( to.dueDate() ); + to2.setRecurrence( rec ); + /* + * if there is a next occurence + * from the duedate of the last recurrance + */ + QDate date; + if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { + QDate inval; + /* generate a new uid for the old record */ + to.setUid( 1 ); + + /* add the old one cause it has a new UID here cause it was spin off */ + m_todoMgr.add( to ); + + /* + * update the due date + * start date + * and complete date + */ + to2.setDueDate( date ); + to2.setStartDate( inval ); + to2.setCompletedDate( inval ); + to2.setCompleted( false ); + updateTodo( to2 ); + }else + updateTodo( to ); + }else + updateTodo( to ); + + currentView()->updateView(); + raiseCurrentView(); +} +void MainWindow::flush() { + slotFlush(); +} +void MainWindow::reload() { + slotReload(); +} +int MainWindow::create() { + int uid = 0; + if(m_syncing) { + QMessageBox::warning(this, tr("Todo"), + tr("Can not edit data, currently syncing")); + return uid; + } + + + OTodo todo = currentEditor()->newTodo( currentCatId(), + this ); + + if ( currentEditor()->accepted() ) { + //todo.assignUid(); + uid = todo.uid(); + m_todoMgr.add( todo ); + currentView()->addEvent( todo ); + + + // I'm afraid we must call this every time now, otherwise + // spend expensive time comparing all these strings... + // but only call if we changed something -zecke + populateCategories(); + } + raiseCurrentView( ); + + return uid; +} +/* delete it silently... */ +bool MainWindow::remove( int uid ) { + if (m_syncing) return false; + + return m_todoMgr.remove( uid ); +} +void MainWindow::beam( int uid, int ) { + ::unlink( beamfile ); + OTodo todo = event( uid ); + OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); + OTodoAccess acc( cal ); + acc.load(); + acc.add( todo ); + acc.save(); + Ir* ir = new Ir(this ); + connect(ir, SIGNAL(done(Ir*) ), + this, SLOT(beamDone(Ir*) ) ); + ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); +} +void MainWindow::show( int uid ) { + slotShow( uid ); +} +void MainWindow::edit( int uid ) { + slotEdit( uid ); +} +void MainWindow::add( const OPimRecord& rec) { + if ( rec.rtti() != OTodo::rtti() ) return; + + const OTodo& todo = static_cast<const OTodo&>(rec); + + m_todoMgr.add(todo ); + currentView()->addEvent( todo ); + + + // I'm afraid we must call this every time now, otherwise + // spend expensive time comparing all these strings... + // but only call if we changed something -zecke + populateCategories(); +} +/* todo does not have the QDataStream<< and >> operators implemented :( + * FIXME + */ +OPimRecord* MainWindow::record( int rtti, const QByteArray& ) { + return 0l; +} |