summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/TODO27
-rw-r--r--core/pim/todo/main.cpp44
-rw-r--r--core/pim/todo/mainwindow.cpp621
-rw-r--r--core/pim/todo/mainwindow.h175
-rw-r--r--core/pim/todo/opie-todo.control9
-rw-r--r--core/pim/todo/smalltodo.cpp114
-rw-r--r--core/pim/todo/smalltodo.h70
-rw-r--r--core/pim/todo/tableitems.cpp181
-rw-r--r--core/pim/todo/tableitems.h124
-rw-r--r--core/pim/todo/tableview.cpp362
-rw-r--r--core/pim/todo/tableview.h120
-rw-r--r--core/pim/todo/templatedialog.cpp60
-rw-r--r--core/pim/todo/templatedialog.h44
-rw-r--r--core/pim/todo/templatedialogimpl.cpp119
-rw-r--r--core/pim/todo/templatedialogimpl.h33
-rw-r--r--core/pim/todo/templateeditor.cpp39
-rw-r--r--core/pim/todo/templateeditor.h31
-rw-r--r--core/pim/todo/textviewshow.cpp19
-rw-r--r--core/pim/todo/textviewshow.h17
-rw-r--r--core/pim/todo/todo.pro55
-rw-r--r--core/pim/todo/todoeditor.cpp53
-rw-r--r--core/pim/todo/todoeditor.h25
-rw-r--r--core/pim/todo/todoentry.ui481
-rw-r--r--core/pim/todo/todoentryimpl.cpp189
-rw-r--r--core/pim/todo/todoentryimpl.h65
-rw-r--r--core/pim/todo/todomanager.cpp125
-rw-r--r--core/pim/todo/todomanager.h107
-rw-r--r--core/pim/todo/todoshow.cpp9
-rw-r--r--core/pim/todo/todoshow.h53
-rw-r--r--core/pim/todo/todotemplatemanager.cpp75
-rw-r--r--core/pim/todo/todotemplatemanager.h32
-rw-r--r--core/pim/todo/todoview.cpp62
-rw-r--r--core/pim/todo/todoview.h178
33 files changed, 3718 insertions, 0 deletions
diff --git a/core/pim/todo/TODO b/core/pim/todo/TODO
new file mode 100644
index 0000000..a7b430a
--- a/dev/null
+++ b/core/pim/todo/TODO
@@ -0,0 +1,27 @@
+05.09.2002
+-Implement a ProjectView
+-Implement Templates
+-Implement Template COnfig
+-Implement MoreConfig
+-Implement beaming again
+-Implement setDocument
+-Implement ViewMenu
+-Implement OFontMenu again
+
+
+
+older
+HI,
+this is the Todo for the TODO Application.
+
+I started a small rewrite of the whole application.
+The idea is to have only the necessary bits
+in memory at once.
+It's meant to be extandable and exchangable.
+I've TodoView as a Baseclass for all Views representationg
+todos. So you could have a QTable or QListView todo
+
+What's missing is:
+Implementation of the views.
+The MainWindow Implementation
+The connection between the Parts \ No newline at end of file
diff --git a/core/pim/todo/main.cpp b/core/pim/todo/main.cpp
new file mode 100644
index 0000000..73977c2
--- a/dev/null
+++ b/core/pim/todo/main.cpp
@@ -0,0 +1,44 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "mainwindow.h"
+
+
+#include <qdatetime.h>
+
+#include <qpe/qpeapplication.h>
+
+int main( int argc, char **argv )
+{
+ QPEApplication a( argc, argv );
+
+ QTime time;
+ time.start();
+ Todo::MainWindow mw;
+ int t = time.elapsed();
+ qWarning("QTime %d", t/1000 );
+ mw.setCaption("Opie Todolist");
+ QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) );
+ QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) );
+
+ a.showMainWidget(&mw);
+
+ return a.exec();
+}
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
new file mode 100644
index 0000000..a8f4c9c
--- a/dev/null
+++ b/core/pim/todo/mainwindow.cpp
@@ -0,0 +1,621 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 <>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#include <qmenubar.h>
+#include <qmessagebox.h>
+#include <qtoolbar.h>
+#include <qpopupmenu.h>
+#include <qwidgetstack.h>
+#include <qaction.h>
+#include <qtimer.h>
+
+#include <qpe/config.h>
+#include <qpe/ir.h>
+#include <qpe/resource.h>
+#include <qpe/qpemessagebox.h>
+
+
+#include "todotemplatemanager.h"
+#include "templateeditor.h"
+#include "todoentryimpl.h"
+#include "tableview.h"
+
+#include "textviewshow.h"
+#include "todoeditor.h"
+#include "mainwindow.h"
+
+
+using namespace Todo;
+
+MainWindow::MainWindow( QWidget* parent,
+ const char* name ) {
+
+ m_syncing = false;
+ m_counter = 0;
+ m_tempManager = new TemplateManager();
+ m_tempManager->load();
+
+ initUI();
+ initConfig();
+ initViews();
+ initActions();
+ initEditor();
+ initShow();
+ initTemplate();
+
+ populateTemplates();
+ raiseCurrentView();
+ QTimer::singleShot(0, this, SLOT(populateCategories() ) );
+}
+void MainWindow::initTemplate() {
+ m_curTempEd = new TemplateEditor( this, templateManager() );
+}
+void MainWindow::initActions() {
+ QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ),
+ QString::null, 0, this, 0 );
+ connect(a, SIGNAL( activated() ),
+ this, SLOT( slotNew() ) );
+ a->addTo(m_tool );
+ a->addTo(m_edit );
+
+ a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ),
+ QString::null, 0, this, 0 );
+ connect(a, SIGNAL(activated() ),
+ this, SLOT( slotEdit() ) );
+ a->addTo( m_tool );
+ a->addTo( m_edit );
+ m_editAction = a;
+
+ a = new QAction( QString::null, tr("View Task"), 0, this, 0 );
+ connect(a, SIGNAL( activated() ),
+ this, SLOT( slotShowDetails() ) );
+ a->addTo( m_edit );
+
+ m_edit->insertSeparator();
+
+ a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ),
+ QString::null, 0, this, 0 );
+ connect(a, SIGNAL(activated() ),
+ this, SLOT(slotDelete() ) );
+ a->addTo( m_tool );
+ a->addTo( m_edit );
+ m_deleteAction = a;
+
+ a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 );
+ connect(a, SIGNAL( activated() ),
+ this, SLOT( slotDeleteAll() ) );
+ a->addTo(m_edit );
+ m_deleteAllAction = a;
+
+ a = new QAction( QString::null, tr("Delete completed"),
+ 0, this, 0 );
+ connect(a, SIGNAL( activated() ),
+ this, SLOT( slotDeleteCompleted() ) );
+ a->addTo(m_edit );
+ a->setEnabled( TRUE );
+ m_deleteCompleteAction = a;
+
+ m_edit->insertSeparator();
+
+ a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 );
+ connect(a, SIGNAL( activated() ),
+ this, SLOT( slotDuplicate() ) );
+ a->addTo(m_edit );
+ m_duplicateAction = a;
+
+ m_edit->insertSeparator();
+
+ if ( Ir::supported() ) {
+ a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
+ QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ),
+ this, SLOT( slotBeam() ) );
+ a->addTo( m_edit );
+ a->addTo( m_tool );
+ }
+
+ a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ),
+ QString::null, 0, this, 0 );
+ connect(a, SIGNAL( activated() ),
+ this, SLOT( slotFind() ) );
+ a->addTo( m_options );
+ m_findAction = a;
+
+ m_options->insertSeparator();
+
+ m_completedAction = new QAction( QString::null, tr("Completed tasks"),
+ 0, this, 0, TRUE );
+ m_completedAction->addTo( m_options );
+ m_completedAction->setOn( showCompleted() );
+ connect(m_completedAction, SIGNAL( toggled(bool) ),
+ this, SLOT(slotShowCompleted(bool) ) );
+
+ m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"),
+ 0, this, 0, TRUE );
+ m_showDeadLineAction->addTo( m_options );
+ m_showDeadLineAction->setOn( showDeadline() );
+ connect(m_showDeadLineAction, SIGNAL(toggled(bool) ),
+ this, SLOT( slotShowDeadLine( bool ) ) );
+
+ m_options->insertSeparator();
+
+ m_bar->insertItem( tr("Data") ,m_edit );
+ 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 over due"),
+ 0, this, 0, TRUE );
+ a->addTo( m_view );
+ 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 );
+
+}
+/* m_curCat from Config */
+void MainWindow::initConfig() {
+ Config config( "todo" );
+ config.setGroup( "View" );
+ m_completed = config.readBoolEntry( "ShowComplete", TRUE );
+ m_curCat = config.readEntry( "Category", QString::null );
+ m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
+ m_overdue = config.readBoolEntry("ShowOverDue", TRUE );
+}
+void MainWindow::initUI() {
+ m_stack = new QWidgetStack(this, "main stack");
+ setCentralWidget( m_stack );
+
+ setToolBarsMovable( FALSE );
+
+ m_tool = new QToolBar( this );
+ m_tool->setHorizontalStretchable( TRUE );
+
+ 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 );
+
+ connect(m_catMenu, SIGNAL(activated(int) ),
+ this, SLOT(setCategory(int) ) );
+ connect(m_template, SIGNAL(activated(int) ),
+ this, SLOT(slotNewFromTemplate(int) ) );
+}
+void MainWindow::initViews() {
+ TableView* tableView = new TableView( this, this );
+ m_stack->addWidget( tableView, m_counter++ );
+ m_views.append( tableView );
+ m_curView = tableView;
+ connectBase( tableView );
+// tableView->setTodos( begin(), end() ); we call populateCategories
+
+ /* add QString type + QString configname to
+ * the View menu
+ * and subdirs for multiple views
+ */
+}
+void MainWindow::initEditor() {
+ m_curEdit = new Editor();
+}
+void MainWindow::initShow() {
+ m_curShow = new TextViewShow(this);
+ 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 ) {
+ QPopupMenu* menu = new QPopupMenu();
+
+ m_editAction->addTo( menu );
+ m_deleteAction->addTo( menu );
+ m_duplicateAction->addTo( menu );
+ menu->insertSeparator();
+
+ 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::Iterator MainWindow::begin() {
+ return m_todoMgr.begin();
+}
+OTodoAccess::List::Iterator MainWindow::end() {
+ return m_todoMgr.end();
+}
+OTodo MainWindow::event( int uid ) {
+ return m_todoMgr.event( uid );
+}
+bool MainWindow::isSyncing()const {
+ return m_syncing;
+}
+TemplateManager* MainWindow::templateManager() {
+ return m_tempManager;
+}
+Editor* MainWindow::currentEditor() {
+ return m_curEdit;
+}
+TodoShow* MainWindow::currentShow() {
+ return m_curShow;
+}
+void MainWindow::slotReload() {
+ m_todoMgr.reload();
+ currentView()->setTodos( begin(), end() );
+ raiseCurrentView();
+}
+void MainWindow::closeEvent( QCloseEvent* e ) {
+ if (m_stack->visibleWidget() == currentShow()->widget() ) {
+ raiseCurrentView();
+ e->ignore();
+ return;
+ }
+ /*
+ * we should have flushed and now we're still saving
+ * so there is no need to flush
+ */
+ if (m_syncing ) {
+ e->accept();
+ return;
+ }
+ bool quit = false;
+ if ( m_todoMgr.saveAll() ){
+ qWarning("saved");
+ quit = true;
+ }else {
+ if ( QMessageBox::critical( this, tr("Out of space"),
+ tr("Todo was unable\n"
+ "to save your changes.\n"
+ "Free up some space\n"
+ "and try again.\n"
+ "\nQuit Anyway?"),
+ QMessageBox::Yes|QMessageBox::Escape,
+ QMessageBox::No|QMessageBox::Default)
+ != QMessageBox::No ) {
+ e->accept();
+ quit = true;
+ }else
+ e->ignore();
+
+ }
+
+ if (quit ) {
+ Config config( "todo" );
+ config.setGroup( "View" );
+ config.writeEntry( "ShowComplete", showCompleted() );
+ config.writeEntry( "Category", currentCategory() );
+ config.writeEntry( "ShowDeadLine", showDeadline());
+ config.writeEntry( "ShowOverDue", showOverDue() );
+ /* svae templates */
+ templateManager()->save();
+ e->accept();
+ }
+}
+void MainWindow::populateTemplates() {
+ m_template->clear();
+ QStringList list = templateManager()->templates();
+ QStringList::Iterator it;
+ for ( it = list.begin(); it != list.end(); ++it ) {
+ m_template->insertItem( (*it) );
+ }
+}
+/*
+ * slotNewFromTemplate
+ * We use the edit widget to do
+ * the config but we setUid(-1)
+ * to get a new uid
+ */
+/*
+ * first we get the name of the template
+ * then we will use the TemplateManager
+ */
+void MainWindow::slotNewFromTemplate( int id ) {
+ QString name = m_template->text( id );
+
+ OTodo event = templateManager()->templateEvent( name );
+ event = currentEditor()->edit(this,
+ event );
+
+ if ( currentEditor()->accepted() ) {
+ /* assign new todo */
+ event.setUid( -1 );
+ currentView()->addEvent( event );
+ 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();
+ currentView()->addEvent( todo );
+ m_todoMgr.add( 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( );
+}
+void MainWindow::slotDuplicate() {
+ if(m_syncing) {
+ QMessageBox::warning(this, tr("Todo"),
+ tr("Can not edit data, currently syncing"));
+ return;
+ }
+ OTodo ev = m_todoMgr.event( currentView()->current() );
+ /* let's generate a new uid */
+ ev.setUid(-1);
+ m_todoMgr.add( ev );
+
+ currentView()->addEvent( ev );
+ raiseCurrentView();
+}
+void MainWindow::slotDelete() {
+ if (!currentView()->current() )
+ return;
+
+ if(m_syncing) {
+ QMessageBox::warning(this, tr("Todo"),
+ tr("Can not edit data, currently syncing"));
+ return;
+ }
+ QString strName = currentView()->currentRepresentation();
+ if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) )
+ return;
+
+ m_todoMgr.remove( currentView()->current() );
+ currentView()->removeEvent( currentView()->current() );
+ raiseCurrentView();
+}
+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();
+
+ raiseCurrentView();
+}
+void MainWindow::slotDeleteCompleted() {
+ if(m_syncing) {
+ QMessageBox::warning(this, tr("Todo"),
+ tr("Can not edit data, currently syncing"));
+ return;
+ }
+
+ if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) )
+ return;
+
+ m_todoMgr.remove( currentView()->completed() );
+ currentView()->setTodos( begin(), end() );
+}
+void MainWindow::slotFind() {
+
+}
+void MainWindow::slotEdit() {
+ slotEdit( currentView()->current() );
+}
+/*
+ * set the category
+ */
+void MainWindow::setCategory( int c) {
+ if ( c <= 0 ) return;
+
+ qWarning("Iterating over cats %d", c );
+ for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
+ m_catMenu->setItemChecked(i, c == (int)i );
+
+ if (c == 1 ) {
+ m_curCat = QString::null;
+ setCaption( tr("Todo") + " - " + tr("All Categories" ) );
+
+ }else if ( c == (int)m_catMenu->count() - 1 ) {
+ m_curCat = tr("Unfiled");
+ setCaption( tr("Todo") + " - " + tr("Unfiled") );
+ }else {
+ m_curCat = m_todoMgr.categories()[c-2];
+ setCaption( tr("Todo") + " - " + m_curCat );
+ }
+ m_catMenu->setItemChecked( c, true );
+ currentView()->setShowCategory( m_curCat );
+ raiseCurrentView();
+}
+void MainWindow::slotShowDeadLine( bool dead) {
+ m_deadline = dead;
+ currentView()->setShowDeadline( dead );
+}
+void MainWindow::slotShowCompleted( bool show) {
+ m_completed = show;
+ currentView()->setShowCompleted( m_completed );
+}
+bool MainWindow::showOverDue()const {
+ return m_overdue;
+}
+void MainWindow::setDocument( const QString& ) {
+
+}
+void MainWindow::slotBeam() {
+
+}
+void MainWindow::beamDone( Ir* ) {
+
+}
+
+void MainWindow::slotFlush() {
+ m_syncing = FALSE;
+ m_todoMgr.save();
+}
+void MainWindow::slotShowDetails() {
+ slotShow( currentView()->current() );
+}
+/*
+ * populate the Categories
+ * Menu
+ */
+void MainWindow::populateCategories() {
+ if (m_todoMgr.isLoaded() )
+ m_todoMgr.load();
+
+ m_catMenu->clear();
+ int id, rememberId;
+ id = 1;
+ rememberId = 1;
+
+ m_catMenu->insertItem( tr( "All Categories" ), id++ );
+ m_catMenu->insertSeparator();
+ QStringList categories = m_todoMgr.categories();
+ categories.append( tr( "Unfiled" ) );
+ for ( QStringList::Iterator it = categories.begin();
+ it != categories.end(); ++it ) {
+ m_catMenu->insertItem( *it, id );
+ if ( *it == currentCategory() )
+ rememberId = id;
+ ++id;
+ }
+ setCategory( rememberId );
+}
+bool MainWindow::showCompleted()const {
+ return m_completed;
+}
+bool MainWindow::showDeadline()const {
+ return m_deadline;
+}
+QString MainWindow::currentCategory()const {
+ return m_curCat;
+}
+int MainWindow::currentCatId() {
+ return m_todoMgr.catId( m_curCat );
+}
+ViewBase* MainWindow::currentView() {
+ return m_curView;
+}
+void MainWindow::raiseCurrentView() {
+ m_stack->raiseWidget( m_curView->widget() );
+}
+void MainWindow::slotShowDue(bool ov) {
+ m_overdue = ov;
+ currentView()->showOverDue( ov );
+ raiseCurrentView();
+}
+void MainWindow::slotShow( int uid ) {
+ qWarning("slotShow");
+ currentShow()->slotShow( event( uid ) );
+ m_stack->raiseWidget( currentShow()->widget() );
+}
+void MainWindow::slotEdit( int uid ) {
+ if(m_syncing) {
+ QMessageBox::warning(this, tr("Todo"),
+ tr("Can not edit data, currently syncing"));
+ return;
+ }
+
+ OTodo todo = m_todoMgr.event( uid );
+
+ todo = currentEditor()->edit(this, todo );
+
+ /* if completed */
+ if ( currentEditor()->accepted() ) {
+ qWarning("Replacing now" );
+ m_todoMgr.update( todo.uid(), todo );
+ currentView()->replaceEvent( todo );
+ populateCategories();
+ }
+
+ raiseCurrentView();
+}
+/*
+void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
+ m_todoMgr.update( uid, ev );
+}
+*/
+void MainWindow::updateTodo( const OTodo& ev) {
+ m_todoMgr.update( ev.uid() , ev );
+}
+/* The view changed it's configuration
+ * update the view menu
+ */
+void MainWindow::slotUpdate3( QWidget* ) {
+
+}
+void MainWindow::updateList() {
+ m_todoMgr.updateList();
+}
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
new file mode 100644
index 0000000..43666f0
--- a/dev/null
+++ b/core/pim/todo/mainwindow.h
@@ -0,0 +1,175 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef TODO_MAIN_WINDOW_H
+#define TODO_MAIN_WINDOW_H
+
+#include <qlist.h>
+#include <qmainwindow.h>
+
+#include <opie/otodoaccess.h>
+#include <opie/otodo.h>
+
+#include "smalltodo.h"
+#include "todoview.h"
+#include "todomanager.h"
+
+class QPopupMenu;
+class QMenuBar;
+class QToolBar;
+class QAction;
+class QWidgetStack;
+class Ir;
+
+
+namespace Todo {
+ typedef TodoView View;
+ class TemplateManager;
+ class Editor;
+ class TodoShow;
+ class TemplateEditor;
+
+ class MainWindow : public QMainWindow {
+ Q_OBJECT
+ public:
+ MainWindow( QWidget *parent = 0,
+ const char* name = 0 );
+ ~MainWindow();
+
+ /** return a context menu for an OTodo */
+ QPopupMenu* contextMenu(int uid );
+ QPopupMenu* options();
+ QPopupMenu* edit();
+ QPopupMenu* view();
+ QToolBar* toolbar();
+
+
+ void updateList();
+ OTodoAccess::List::Iterator begin();
+ OTodoAccess::List::Iterator end();
+// OTodoAccess::List::Iterator &iterator();
+
+ OTodo event(int uid );
+
+ bool isSyncing()const;
+ bool showCompleted()const;
+ bool showDeadline()const;
+ bool showOverDue()const;
+ QString currentCategory()const;
+ int currentCatId();
+ TemplateManager* templateManager();
+
+ void updateTodo( const OTodo& );
+ void populateTemplates();
+ Editor* currentEditor();
+private slots:
+ void populateCategories();
+ void slotReload();
+ void slotFlush();
+
+ protected:
+ void closeEvent( QCloseEvent* e );
+
+ private:
+ void connectBase( ViewBase* );
+ void initUI();
+ void initActions();
+ void initConfig();
+ void initViews();
+ void initEditor();
+ void initShow();
+ void initTemplate();
+ void raiseCurrentView();
+ ViewBase* currentView();
+ ViewBase* m_curView;
+ Editor* m_curEdit;
+ TodoShow* currentShow();
+ TodoShow* m_curShow;
+ TemplateEditor* currentTemplateEditor();
+ TemplateEditor* m_curTempEd;
+
+ QMenuBar* m_bar;
+ QToolBar* m_tool;
+ QAction* m_editAction,
+ *m_deleteAction,
+ *m_findAction,
+ *m_completedAction,
+ *m_showDeadLineAction,
+ *m_deleteAllAction,
+ *m_deleteCompleteAction,
+ *m_duplicateAction,
+ *m_showOverDueAction,
+ *m_effectiveAction;
+ QWidgetStack *m_stack;
+ QPopupMenu* m_catMenu,
+ *m_edit,
+ *m_options,
+ *m_view,
+ *m_template;
+
+ bool m_syncing:1;
+ bool m_deadline:1;
+ bool m_completed:1;
+ bool m_overdue:1;
+ TodoManager m_todoMgr;
+ QString m_curCat;
+ QList<ViewBase> m_views;
+ uint m_counter;
+ TemplateManager* m_tempManager;
+
+ private slots:
+ void slotShow(int);
+ void slotEdit(int);
+private slots:
+ void slotUpdate3( QWidget* );
+ void slotNewFromTemplate(int id );
+ void slotNew();
+ void slotDuplicate();
+ void slotDelete();
+ void slotDeleteAll();
+ void slotDeleteCompleted();
+
+ void slotEdit();
+ void slotFind();
+
+ void setCategory( int );
+
+ void slotShowDeadLine( bool );
+ void slotShowCompleted( bool );
+
+ void setDocument( const QString& );
+
+
+ void slotBeam();
+ void beamDone( Ir* );
+ void slotShowDetails();
+ void slotShowDue( bool );
+ };
+};
+
+#endif
diff --git a/core/pim/todo/opie-todo.control b/core/pim/todo/opie-todo.control
new file mode 100644
index 0000000..71929af
--- a/dev/null
+++ b/core/pim/todo/opie-todo.control
@@ -0,0 +1,9 @@
+Files: bin/todolist apps/Applications/todo.desktop
+Priority: optional
+Section: opie/applications
+Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org>
+Architecture: arm
+Version: $QPE_VERSION-$SUB_VERSION
+Depends: opie-base ($QPE_VERSION)
+Description: TODO-list manager
+ A Todo-list manager for the Opie environment.
diff --git a/core/pim/todo/smalltodo.cpp b/core/pim/todo/smalltodo.cpp
new file mode 100644
index 0000000..412fe9e
--- a/dev/null
+++ b/core/pim/todo/smalltodo.cpp
@@ -0,0 +1,114 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 <zecke@handhelds.org>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+#include <qshared.h>
+
+#include "smalltodo.h"
+
+using namespace Todo;
+
+struct SmallTodo::SmallTodoPrivate : public QShared{
+
+ SmallTodoPrivate() : QShared(), uid(-1) {};
+ QString name;
+ QStringList categories; // as real Names
+ int uid;
+ bool complete:1;
+ QDate date;
+
+
+ void deleteSelf() { delete this; };
+};
+
+SmallTodo::SmallTodo(int uid,
+ bool comp,
+ const QDate& date,
+ const QString& name,
+ const QStringList& cats) {
+ d = new SmallTodoPrivate();
+ d->name = name;
+ d->uid = uid;
+ d->categories = cats;
+ d->complete = comp;
+ d->date = date;
+}
+SmallTodo::SmallTodo( const SmallTodo& s ) : d(s.d) {
+ d->ref();
+}
+SmallTodo::~SmallTodo() {
+ /* deref and if last one delete */
+ if ( d->deref() ) {
+ d->deleteSelf();
+ }
+}
+bool SmallTodo::operator==( const SmallTodo& todo ) {
+ if ( d->complete != todo.d->complete ) return false;
+ if ( d->name != todo.d->name ) return false;
+ if ( d->uid != todo.d->uid ) return false;
+ if ( d->categories != todo.d->categories ) return false;
+ if ( d->date != todo.d->date ) return false;
+
+ return true;
+}
+bool SmallTodo::operator==( const SmallTodo& todo ) const{
+ if ( d->complete != todo.d->complete ) return false;
+ if ( d->uid != todo.d->uid ) return false;
+ if ( d->name != todo.d->name ) return false;
+ if ( d->categories != todo.d->categories ) return false;
+ if ( d->date != todo.d->date ) return false;
+
+ return true;
+}
+SmallTodo &SmallTodo::operator=( const SmallTodo& todo ) {
+ todo.d->ref();
+ deref();
+
+ d = todo.d;
+
+ return *this;
+}
+void SmallTodo::deref() {
+ if ( d->deref() ) {
+ delete d;
+ d = 0;
+ }
+}
+QString SmallTodo::name() const {
+ return d->name;
+}
+QStringList SmallTodo::categories()const {
+ return d->categories;
+}
+int SmallTodo::uid()const {
+ return d->uid;
+}
+bool SmallTodo::isCompleted()const {
+ return d->complete;
+}
+QDate SmallTodo::date()const {
+ return d->date;
+}
diff --git a/core/pim/todo/smalltodo.h b/core/pim/todo/smalltodo.h
new file mode 100644
index 0000000..952ed04
--- a/dev/null
+++ b/core/pim/todo/smalltodo.h
@@ -0,0 +1,70 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 <zecke@handhelds.org>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef TODO_SMALL_TODO_H
+#define TODO_SMALL_TODO_H
+
+#include <qdatetime.h>
+#include <qstring.h>
+#include <qstringlist.h>
+
+
+namespace Todo {
+ /**
+ * SmallTodo holds everything necessary
+ * to represent a OTodo without holding
+ * everything from a OTodo
+ */
+ class SmallTodo {
+ public:
+ SmallTodo(int uid = 0,
+ bool comp = false,
+ const QDate& date = QDate::currentDate(),
+ const QString& = QString::null,
+ const QStringList& = QStringList() );
+ SmallTodo( const SmallTodo& );
+ ~SmallTodo();
+
+ bool operator==( const SmallTodo& );
+ bool operator==( const SmallTodo& ) const;
+
+ SmallTodo &operator=( const SmallTodo& );
+ QString name()const;
+ QStringList categories()const;
+ int uid()const;
+ bool isCompleted()const;
+ QDate date()const;
+
+ private:
+ struct SmallTodoPrivate;
+ SmallTodoPrivate* d;
+ void deref();
+ };
+};
+
+#endif
diff --git a/core/pim/todo/tableitems.cpp b/core/pim/todo/tableitems.cpp
new file mode 100644
index 0000000..ebfefc8
--- a/dev/null
+++ b/core/pim/todo/tableitems.cpp
@@ -0,0 +1,181 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 <>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+#include "tableview.h"
+
+#include "tableitems.h"
+#include <string.h>
+
+using namespace Todo;
+
+CheckItem::CheckItem( QTable* t,
+ const QString& sortKey,
+ int uid,
+ const QArray<int>& lis)
+ : OCheckItem(t, sortKey), m_uid(uid ), m_cat( lis )
+{
+}
+CheckItem::~CheckItem() {
+}
+void CheckItem::setChecked( bool b ) {
+ OCheckItem::setChecked(b);
+}
+void CheckItem::toggle() {
+ TableView* view = static_cast<TableView*>( table() );
+ OTodo ev = view->find( view->current() );
+ ev.setCompleted(!isChecked() );
+ view->updateFromTable( ev );
+
+ OCheckItem::toggle();
+ table()->updateCell( row(), col() );
+}
+int CheckItem::uid() const {
+ return m_uid;
+}
+QArray<int> CheckItem::cats() {
+ return m_cat;
+}
+
+/* ComboItem */
+ComboItem::ComboItem( QTable* t, EditType et )
+ : QTableItem( t, et, "3" ), m_cb(0)
+{
+ setReplaceable( FALSE );
+}
+ComboItem::~ComboItem() {
+
+}
+QWidget* ComboItem::createEditor()const {
+ qWarning( "create editor");
+ QString txt = text();
+
+ ( (ComboItem*)this)-> m_cb = new QComboBox( table()->viewport() );
+
+ m_cb->insertItem( "1" );
+ m_cb->insertItem( "2" );
+ m_cb->insertItem( "3" );
+ m_cb->insertItem( "4" );
+ m_cb->insertItem( "5" );
+ m_cb->setCurrentItem( txt.toInt() - 1 );
+
+ return m_cb;
+}
+void ComboItem::setContentFromEditor( QWidget* w) {
+ TableView* view = static_cast<TableView*>( table() );
+ OTodo ev = view->find( view->current() );
+
+ if ( w->inherits( "QComboBox" ) )
+ setText( ( (QComboBox*)w )->currentText() );
+ else
+ QTableItem::setContentFromEditor( w );
+
+ ev.setPriority( text().toInt() );
+ view->updateFromTable( ev );
+}
+void ComboItem::setText( const QString& s ) {
+ if ( m_cb )
+ m_cb->setCurrentItem( s.toInt()-1 );
+
+ QTableItem::setText( s );
+}
+QString ComboItem::text()const {
+ if ( m_cb)
+ return m_cb->currentText();
+
+ return QTableItem::text();
+}
+
+/* TodoTextItem */
+TodoTextItem::~TodoTextItem() {
+
+}
+TodoTextItem::TodoTextItem( QTable* t,
+ const QString& string )
+ : QTableItem( t, QTableItem::Never, string )
+{}
+
+/* DueTextItem */
+DueTextItem::DueTextItem( QTable* t, const OTodo& ev)
+ : QTableItem(t, Never, QString::null )
+{
+ setToDoEvent( ev );
+}
+DueTextItem::~DueTextItem() {
+
+}
+QString DueTextItem::key() const {
+ QString key;
+
+ if( m_hasDate ){
+ if(m_off == 0 ){
+ key.append("b");
+ }else if( m_off > 0 ){
+ key.append("c");
+ }else if( m_off < 0 ){
+ key.append("a");
+ }
+ key.append(QString::number(m_off ) );
+ }else{
+ key.append("d");
+ }
+ return key;
+}
+void DueTextItem::setCompleted( bool comp ) {
+ m_completed = comp;
+ table()->updateCell( row(), col() );
+}
+void DueTextItem::setToDoEvent( const OTodo& ev ) {
+ m_hasDate = ev.hasDueDate();
+ m_completed = ev.isCompleted();
+
+ if( ev.hasDueDate() ){
+ QDate today = QDate::currentDate();
+ m_off = today.daysTo(ev.dueDate() );
+ setText( QString::number(m_off) + " day(s) " );
+ }else{
+ setText("n.d." );
+ m_off = 0;
+ }
+}
+void DueTextItem::paint( QPainter* p, const QColorGroup &cg,
+ const QRect& cr, bool selected ) {
+ QColorGroup cg2(cg);
+
+ QColor text = cg.text();
+ if( m_hasDate && !m_completed ){
+ if( m_off < 0 ){
+ cg2.setColor(QColorGroup::Text, QColor(red ) );
+ }else if( m_off == 0 ){
+ cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined
+ }else if( m_off > 0){
+ cg2.setColor(QColorGroup::Text, QColor(green ) );
+ }
+ }
+ QTableItem::paint(p, cg2, cr, selected );
+ /* restore default color */
+ cg2.setColor(QColorGroup::Text, text );
+}
diff --git a/core/pim/todo/tableitems.h b/core/pim/todo/tableitems.h
new file mode 100644
index 0000000..33ae814
--- a/dev/null
+++ b/core/pim/todo/tableitems.h
@@ -0,0 +1,124 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 <>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef OPIE_TODO_TABLE_ITEMS_H
+#define OPIE_TODO_TABLE_ITEMS_H
+
+#include <qarray.h>
+#include <qguardedptr.h>
+#include <qcombobox.h>
+#include <qtable.h>
+
+#include <qpe/stringutil.h>
+
+#include <opie/ocheckitem.h>
+#include <opie/otodo.h>
+
+
+namespace Todo {
+
+ /**
+ * We need to reimplement OCheckItem here
+ * we need to update on change
+ * You can check a checkItem
+ */
+ class CheckItem : public OCheckItem {
+ public:
+ CheckItem( QTable* t, const QString& sortKey,
+ int uid,
+ const QArray<int>& );
+ ~CheckItem();
+ virtual void setChecked( bool b );
+ virtual void toggle();
+ int uid()const;
+ QArray<int> cats();
+ private:
+ int m_uid;
+ QArray<int> m_cat;
+ };
+
+ /**
+ * creates a QComboBox if neccessary
+ * to edit inline
+ */
+ class ComboItem : public QTableItem {
+ public:
+ ComboItem( QTable* t, EditType et );
+ ~ComboItem();
+ QWidget* createEditor()const;
+ void setContentFromEditor( QWidget* w );
+ void setText( const QString& s );
+ int alignment() const;
+
+ QString text()const;
+
+ private:
+ QGuardedPtr<QComboBox> m_cb;
+ };
+
+ /* implement inline */
+ inline int ComboItem::alignment()const {
+ return Qt::AlignCenter;
+ }
+
+ /**
+ * TodoTextItem builds a better specialised
+ * sortkey
+ */
+ class TodoTextItem : public QTableItem {
+ public:
+ TodoTextItem( QTable* t, const QString& str );
+ ~TodoTextItem();
+ QString key()const;
+ };
+
+
+ inline QString TodoTextItem::key() const {
+ return Qtopia::buildSortKey( text() );
+ }
+
+ class DueTextItem : public QTableItem {
+ public:
+ DueTextItem( QTable* t, const OTodo& );
+ ~DueTextItem();
+
+ QString key()const;
+ void setToDoEvent( const OTodo& ev );
+ void setCompleted( bool comp );
+ void paint( QPainter *p, const QColorGroup &cg,
+ const QRect& cr, bool selected );
+ private:
+ int m_off;
+ bool m_hasDate:1;
+ bool m_completed:1;
+ };
+
+
+};
+
+#endif
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
new file mode 100644
index 0000000..39f0d72
--- a/dev/null
+++ b/core/pim/todo/tableview.cpp
@@ -0,0 +1,362 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 <>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#include <qtimer.h>
+#include <qpoint.h>
+#include <qpopupmenu.h>
+
+#include "mainwindow.h"
+//#include "tableitems.h"
+#include "tableview.h"
+
+using namespace Todo;
+
+
+TableView::TableView( MainWindow* window, QWidget* wid )
+ : QTable( wid ), TodoView( window ) {
+ setUpdatesEnabled( false );
+ viewport()->setUpdatesEnabled( false );
+ m_enablePaint = false;
+ setNumRows(0);
+ setNumCols(4);
+
+ setSorting( TRUE );
+ setSelectionMode( NoSelection );
+ setColumnStretchable( 2, TRUE );
+ setColumnWidth(0, 20 );
+ setColumnWidth(1, 35 );
+
+ setLeftMargin( 0 );
+ verticalHeader()->hide();
+
+ horizontalHeader()->setLabel(0, tr("C.") );
+ horizontalHeader()->setLabel(1, tr("Prior.") );
+ horizontalHeader()->setLabel(2, tr("Description" ) );
+
+ setColumnStretchable(3, FALSE );
+ setColumnWidth(3, 20 );
+ horizontalHeader()->setLabel(3, tr("Deadline") );
+
+ if ( todoWindow()->showDeadline() )
+ showColumn( 3);
+ else
+ hideColumn(3 );
+
+ connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ),
+ this, SLOT( slotClicked(int, int, int, const QPoint& ) ) );
+ connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ),
+ this, SLOT( slotPressed(int, int, int, const QPoint& ) ) );
+ connect((QTable*)this, SIGNAL(valueChanged(int, int) ),
+ this, SLOT( slotValueChanged(int, int) ) );
+ connect((QTable*)this, SIGNAL(currentChanged(int, int) ),
+ this, SLOT( slotCurrentChanged(int, int) ) );
+
+ m_menuTimer = new QTimer( this );
+ connect( m_menuTimer, SIGNAL(timeout()),
+ this, SLOT(slotShowMenu()) );
+
+ m_enablePaint = true;
+ setUpdatesEnabled( true );
+ viewport()->setUpdatesEnabled( true );
+ viewport()->update();
+}
+/* a new day has started
+ * update the day
+ */
+void TableView::newDay() {
+ clear();
+ setTodos( begin(),end() );
+}
+TableView::~TableView() {
+
+}
+void TableView::slotShowMenu() {
+ QPopupMenu *menu = todoWindow()->contextMenu( current() );
+ menu->exec(QCursor::pos() );
+ delete menu;
+}
+OTodo TableView::find(int uid ) {
+ OTodo ev = TodoView::event( uid );
+ return ev;
+}
+void TableView::updateFromTable( const OTodo& ev, CheckItem* item ) {
+ TodoView::update( ev.uid(), ev );
+
+ /* update the other columns */
+ /* if completed or not we need to update
+ * the table
+ *
+ * We've two cases
+ * either item or !item
+ * this makes cases more easy
+ */
+ if ( !item ) {
+ item = m_cache[ev.uid()];
+ }
+ DueTextItem *due = dueItem( item->row() );
+ due->setCompleted( ev.isCompleted() );
+}
+QString TableView::type() const {
+ return QString::fromLatin1( tr("Table View") );
+}
+int TableView::current() {
+ int cur = 0;
+ CheckItem* i = checkItem( currentRow() );
+ if (i )
+ cur = i->uid();
+
+ return cur;
+}
+QString TableView::currentRepresentation() {
+ return text( currentRow(), 2);
+}
+/* show overdue */
+void TableView::showOverDue( bool ) {
+ clear();
+ setTodos( begin(), end() );
+}
+
+void TableView::setTodos( OTodoAccess::List::Iterator it,
+ OTodoAccess::List::Iterator end ) {
+ qWarning("setTodos");
+ QTime time;
+ time.start();
+ m_enablePaint = false;
+ setUpdatesEnabled( false );
+ viewport()->setUpdatesEnabled( false );
+ clear();
+ QString currentCat = todoWindow()->currentCategory();
+ bool showCompleted = todoWindow()->currentCatId();
+ bool showOverDue = todoWindow()->showOverDue();
+ qWarning( "Current Category:" + todoWindow()->currentCategory() );
+ int id = todoWindow()->currentCatId();
+ QTime t;
+ t.start();
+ setNumRows( it.count() );
+ uint i = 0;
+ for (; it != end; ++it ) {
+ OTodo todo = (*it);
+ /* test if the categories match */
+ if ( !currentCat.isEmpty() &&
+ !todo.categories().contains( id ) ) {
+ continue;
+ }
+ /* the item is completed but we shouldn't show it */
+ if ( !showCompleted && todo.isCompleted() ) {
+ continue;
+ }
+ /* the item is not overdue but we should only show overdue */
+ if ( showOverDue && !todo.isOverdue() ) {
+ continue;
+ }
+ /* now it's fine to add it */
+ insertTodo( todo, i );
+ i++;
+ }
+ setNumRows( i );
+ int elc = time.elapsed();
+ qWarning("Adding took %d", elc/1000 );
+ setUpdatesEnabled( true );
+ viewport()->setUpdatesEnabled( true );
+ viewport()->update();
+ m_enablePaint = true;
+ int el = time.elapsed();
+ qWarning("adding took %d", el/1000 );
+}
+void TableView::setTodo( int uid, const OTodo& ev ) {
+ QMap<int, CheckItem*>::Iterator it = m_cache.find( uid );
+
+ if ( it != m_cache.end() ) {
+ int row = it.data()->row();
+
+ /* update checked */
+ CheckItem* check = checkItem(row );
+ if (check)
+ check->setChecked( ev.isCompleted() );
+
+ /* update the text */
+ QString sum = ev.summary();
+ setText(row, 2, sum.isEmpty() ?
+ ev.description().left(40).simplifyWhiteSpace() :
+ sum );
+
+ /* update priority */
+ setText(row, 1, QString::number( ev.priority() ) );
+
+ /* update DueDate */
+ DueTextItem *due = dueItem( row );
+ due->setToDoEvent( ev );
+ }
+}
+void TableView::addEvent( const OTodo& ev) {
+ int row= numRows();
+ setNumRows( row + 1 );
+ insertTodo( ev, row );
+}
+/*
+ * find the event
+ * and then replace the complete row
+ */
+void TableView::replaceEvent( const OTodo& ev) {
+ setTodo( ev.uid(), ev );
+}
+/*
+ * re aligning table can be slow too
+ * FIXME: look what performs better
+ * either this or the old align table
+ */
+void TableView::removeEvent( int ) {
+ clear();
+ setTodos( begin(), end() );
+}
+void TableView::setShowCompleted( bool b) {
+ qWarning("Show Completed %d" + b );
+ setTodos( begin(), end() );
+}
+void TableView::setShowDeadline( bool b) {
+ qWarning("Show DeadLine %d" + b );
+ if (b)
+ showColumn(3 );
+ else
+ hideColumn(3 );
+}
+void TableView::setShowCategory( const QString& ) {
+ qWarning("setShowCategory");
+ setTodos( begin(), end() );
+}
+void TableView::clear() {
+ m_cache.clear();
+ int rows = numRows();
+ for (int r = 0; r < rows; r++ ) {
+ for (int c = 0; c < numCols(); c++ ) {
+ if ( cellWidget(r, c) )
+ clearCellWidget(r, c );
+ clearCell(r, c);
+ }
+ }
+ setNumRows( 0);
+}
+QArray<int> TableView::completed() {
+ int row = numRows();
+ QArray<int> ids( row );
+
+ int j=0;
+ for (int i = 0; i < row; i++ ) {
+ CheckItem* item = checkItem(i );
+ if (item->isChecked() ) {
+ ids[j] = item->uid();
+ j++;
+ }
+ }
+ ids.resize( j );
+ return ids;
+}
+void TableView::slotClicked(int row, int col, int,
+ const QPoint& point) {
+ if ( !cellGeometry(row, col ).contains(point ) )
+ return;
+
+
+ switch( col ) {
+ case 0: {
+ CheckItem* item = checkItem( row );
+ /*
+ * let's see if we centered clicked
+ */
+ if ( item ) {
+ int x = point.x() -columnPos( col );
+ int y = point.y() -rowPos( row );
+ int w = columnWidth( col );
+ int h = rowHeight( row );
+ if ( x >= ( w - OCheckItem::BoxSize ) / 2 &&
+ x <= ( w - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize &&
+ y >= ( h - OCheckItem::BoxSize ) / 2 &&
+ y <= ( h - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize )
+ item->toggle();
+ }
+ }
+ break;
+
+ case 1:
+ break;
+
+ case 2: {
+ m_menuTimer->stop();
+ showTodo( checkItem(row)->uid() );
+ break;
+ }
+ case 3: {
+ m_menuTimer->stop();
+ TodoView::edit( checkItem(row)->uid() );
+ break;
+ }
+ }
+
+
+}
+void TableView::slotPressed(int row, int col, int,
+ const QPoint& point) {
+
+ /* TextColumn column */
+ if ( col == 2 && cellGeometry( row, col ).contains( point ) )
+ m_menuTimer->start( 750, TRUE );
+}
+void TableView::slotValueChanged( int, int ) {
+ qWarning("Value Changed");
+}
+void TableView::slotCurrentChanged(int, int ) {
+ m_menuTimer->stop();
+}
+/*
+ * hardcode to column 0
+ */
+CheckItem* TableView::checkItem( int row ) {
+ CheckItem *i = static_cast<CheckItem*>( item( row, 0 ) );
+ return i;
+}
+DueTextItem* TableView::dueItem( int row ) {
+ DueTextItem* i = static_cast<DueTextItem*> ( item(row, 3 ) );
+ return i;
+}
+QWidget* TableView::widget() {
+ return this;
+}
+/*
+ * We need to overwrite sortColumn
+ * because we want to sort whole row
+ * based
+ */
+void TableView::sortColumn( int row, bool asc, bool ) {
+ QTable::sortColumn( row, asc, TRUE );
+
+}
+void TableView::viewportPaintEvent( QPaintEvent* e) {
+ qWarning("Paint event" );
+ if (m_enablePaint )
+ QTable::viewportPaintEvent( e );
+}
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h
new file mode 100644
index 0000000..721b40b
--- a/dev/null
+++ b/core/pim/todo/tableview.h
@@ -0,0 +1,120 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 <>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef OPIE_TABLE_VIEW_H
+#define OPIE_TABLE_VIEW_H
+
+#include <qtable.h>
+#include <qmap.h>
+
+#include "tableitems.h"
+#include "todoview.h"
+
+class QTimer;
+
+namespace Todo {
+ class CheckItem;
+ class DueTextItem;
+ class TableView : public QTable, public TodoView {
+ Q_OBJECT
+ public:
+ TableView( MainWindow*, QWidget* parent );
+ ~TableView();
+
+ void updateFromTable( const OTodo&, CheckItem* = 0 );
+ OTodo find(int uid);
+
+ QString type()const;
+ int current();
+ QString currentRepresentation();
+
+ void showOverDue( bool );
+ void setTodos( OTodoAccess::List::Iterator it,
+ OTodoAccess::List::Iterator end );
+ void setTodo( int uid, const OTodo& );
+ void addEvent( const OTodo& event );
+ void replaceEvent( const OTodo& );
+ void removeEvent( int uid );
+ void setShowCompleted( bool );
+ void setShowDeadline( bool );
+
+ void setShowCategory(const QString& =QString::null );
+ void clear();
+ void newDay();
+ QArray<int> completed();
+ QWidget* widget();
+ void sortColumn(int, bool, bool );
+ private:
+ /* reimplented for internal reasons */
+ void viewportPaintEvent( QPaintEvent* );
+ inline void insertTodo( const OTodo&, int row );
+ CheckItem* checkItem( int row );
+ DueTextItem* dueItem( int row );
+ QTimer *m_menuTimer;
+ QMap<int, CheckItem*> m_cache;
+ bool m_enablePaint:1;
+
+private slots:
+ void slotShowMenu();
+ void slotClicked(int, int, int,
+ const QPoint& );
+ void slotPressed(int, int, int,
+ const QPoint& );
+ void slotValueChanged(int, int);
+ void slotCurrentChanged(int, int );
+ };
+ inline void TableView::insertTodo( const OTodo& event, int row ) {
+
+
+ QString sortKey = (char) ( (event.isCompleted() ? 'a' : 'A' )
+ + event.priority() )
+ + Qtopia::buildSortKey( event.description() );
+ CheckItem *chk = new CheckItem( this, sortKey, event.uid(), event.categories() );
+ chk->setChecked( event.isCompleted() );
+
+ ComboItem *cmb = new ComboItem(this, QTableItem::WhenCurrent );
+ cmb->setText( QString::number( event.priority() ) );
+
+ QString sum = event.summary();
+ QTableItem* ti = new TodoTextItem( this, sum.isEmpty() ?
+ event.description().left(40).simplifyWhiteSpace() :
+ sum );
+ ti->setReplaceable( FALSE );
+
+ DueTextItem *due = new DueTextItem(this, event );
+
+ setItem( row, 0, chk );
+ setItem( row, 1, cmb );
+ setItem( row, 2, ti );
+ setItem( row, 3, due );
+
+ m_cache.insert( event.uid(), chk );
+ }
+};
+
+#endif
diff --git a/core/pim/todo/templatedialog.cpp b/core/pim/todo/templatedialog.cpp
new file mode 100644
index 0000000..ffcdc24
--- a/dev/null
+++ b/core/pim/todo/templatedialog.cpp
@@ -0,0 +1,60 @@
+#include <qpushbutton.h>
+#include <qhbox.h>
+#include <qlayout.h>
+#include <qlistview.h>
+#include <qlineedit.h>
+
+#include "templatedialog.h"
+
+
+using namespace Todo;
+
+TemplateDialog::TemplateDialog( QWidget* widget )
+ : QDialog( widget, "TemplateDialog", TRUE )
+{
+ setCaption( tr("Template Editor") );
+ m_main = new QVBoxLayout(this );
+
+ m_list = new QListView( this );
+ m_main->addWidget( m_list, 100 );
+
+ m_lne = new QLineEdit( this );
+ m_main->addWidget( m_lne );
+
+ m_btnBar = new QHBox( this );
+ m_add = new QPushButton( tr("Add"), m_btnBar );
+ m_edit = new QPushButton( tr("Edit"), m_btnBar );
+ m_rem = new QPushButton( tr("Remove"), m_btnBar );
+ m_main->addWidget( m_btnBar );
+
+ connect(m_add, SIGNAL(clicked() ),
+ this, SLOT(slotAdd() ) );
+ connect(m_edit, SIGNAL(clicked() ),
+ this, SLOT(slotEdit() ) );
+ connect(m_rem, SIGNAL(clicked() ),
+ this, SLOT(slotEdit() ) );
+ connect(m_lne, SIGNAL(returnPressed() ),
+ this, SLOT(slotReturn() ) );
+
+}
+TemplateDialog::~TemplateDialog() {
+ // Qt does delete our widgets
+}
+QListView* TemplateDialog::listView() {
+ return m_list;
+}
+QLineEdit* TemplateDialog::edit() {
+ return m_lne;
+}
+void TemplateDialog::slotAdd() {
+ qWarning("Not Implemented here");
+}
+void TemplateDialog::slotRemove() {
+ qWarning("Not Implemented here");
+}
+void TemplateDialog::slotEdit() {
+ qWarning("Not Implemented here");
+}
+void TemplateDialog::slotReturn() {
+ qWarning("Not Implemented here");
+}
diff --git a/core/pim/todo/templatedialog.h b/core/pim/todo/templatedialog.h
new file mode 100644
index 0000000..5886c34
--- a/dev/null
+++ b/core/pim/todo/templatedialog.h
@@ -0,0 +1,44 @@
+#ifndef OPIE_TEMPLATE_DIALOG_H
+#define OPIE_TEMPLATE_DIALOG_H
+
+#include <qdialog.h>
+#include <qstring.h>
+
+class QListView;
+class QPushButton;
+class QLabel;
+class QHBox;
+class QVBoxLayout;
+class QLineEdit;
+
+
+namespace Todo {
+ class TemplateDialog : public QDialog {
+ Q_OBJECT
+ public:
+ /* it'll be modal */
+ TemplateDialog( QWidget* parent );
+ virtual ~TemplateDialog();
+
+ protected:
+ QListView* listView();
+ QLineEdit* edit();
+private slots:
+ virtual void slotAdd();
+ virtual void slotRemove();
+ virtual void slotEdit();
+ virtual void slotReturn();
+
+ private:
+ QVBoxLayout* m_main;
+ QHBox* m_btnBar;
+ QListView* m_list;
+ QLineEdit *m_lne;
+ QPushButton* m_add;
+ QPushButton* m_rem;
+ QPushButton* m_edit;
+
+ };
+}
+
+#endif
diff --git a/core/pim/todo/templatedialogimpl.cpp b/core/pim/todo/templatedialogimpl.cpp
new file mode 100644
index 0000000..77c5363
--- a/dev/null
+++ b/core/pim/todo/templatedialogimpl.cpp
@@ -0,0 +1,119 @@
+#include <qlistview.h>
+#include <qlineedit.h>
+
+#include "mainwindow.h"
+#include "todoeditor.h"
+#include "todotemplatemanager.h"
+#include "templatedialogimpl.h"
+
+
+using namespace Todo;
+
+namespace {
+ class TemplateListItem : public QListViewItem {
+ public:
+ TemplateListItem( QListView*,
+ const QString& name,
+ const OTodo& );
+ ~TemplateListItem();
+
+ OTodo event()const;
+ QString text()const;
+ void setText(const QString& str );
+ void setEvent( const OTodo& );
+ private:
+ QString m_name;
+ OTodo m_ev;
+ };
+
+ /* implementation */
+ TemplateListItem::TemplateListItem( QListView* view,
+ const QString& text,
+ const OTodo& ev )
+ : QListViewItem( view ), m_name( text ), m_ev( ev )
+ {
+ QListViewItem::setText(0, m_name );
+ }
+ TemplateListItem::~TemplateListItem() {}
+ OTodo TemplateListItem::event() const {
+ return m_ev;
+ }
+ QString TemplateListItem::text()const {
+ return m_name;
+ }
+ void TemplateListItem::setText( const QString& str ) {
+ QListViewItem::setText(0, str );
+ m_name = str;
+ }
+ void TemplateListItem::setEvent( const OTodo& ev) {
+ m_ev = ev;
+ }
+}
+
+TemplateDialogImpl::TemplateDialogImpl( MainWindow* win,
+ TemplateManager* man )
+ : TemplateDialog( win ), m_win( win), m_man( man )
+{
+ /* fill the listview */
+ /* not the fastest way.... */
+ QStringList list = man->templates();
+ for (QStringList::Iterator it = list.begin();
+ it != list.end(); ++it ) {
+ new TemplateListItem( listView(), (*it), man->templateEvent( (*it) ) );
+ }
+ listView()->addColumn( tr("Name") );
+
+ connect( listView(), SIGNAL(clicked(QListViewItem*) ),
+ this, SLOT(slotClicked(QListViewItem*) ) );
+}
+TemplateDialogImpl::~TemplateDialogImpl() {
+
+}
+void TemplateDialogImpl::slotAdd() {
+ QString str = tr("New Template %1").arg( listView()->childCount() );
+ OTodo ev;
+ m_man->addEvent(str, ev);
+ new TemplateListItem( listView(), str, ev );
+}
+void TemplateDialogImpl::slotRemove() {
+ TemplateListItem* item = (TemplateListItem*) listView()->currentItem();
+ listView()->takeItem( item );
+
+ m_man->removeEvent( item->text() );
+
+ delete item;
+}
+void TemplateDialogImpl::slotEdit() {
+ TemplateListItem* item = (TemplateListItem*)listView()->currentItem();
+ OTodo ev = m_win->currentEditor()->edit( m_win, item->event() );
+ if ( m_win->currentEditor()->accepted() ) {
+ qWarning("accepted");
+ item->setEvent( ev );
+ qWarning("Priority %d", ev.priority() );
+ m_man->removeEvent( item->text() );
+ m_man->addEvent( item->text(), ev );
+ }
+}
+/*
+ * we need to update
+ * the text
+ */
+
+void TemplateDialogImpl::slotReturn() {
+ TemplateListItem* tbl = (TemplateListItem*)listView()->currentItem();
+
+ if (tbl->text() != edit()->text() ) {
+ m_man->removeEvent( tbl->text() );
+ tbl->setText( edit()->text() );
+ m_man->addEvent( tbl->text(), tbl->event() );
+ }
+}
+/* update the lineedit when changing */
+void TemplateDialogImpl::slotClicked( QListViewItem* item) {
+ if (!item)
+ return;
+
+ TemplateListItem* tbl = (TemplateListItem*)item;
+ edit()->setText( tbl->text() );
+}
+
diff --git a/core/pim/todo/templatedialogimpl.h b/core/pim/todo/templatedialogimpl.h
new file mode 100644
index 0000000..f366c9e
--- a/dev/null
+++ b/core/pim/todo/templatedialogimpl.h
@@ -0,0 +1,33 @@
+#ifndef OPIE_TEMPLATE_DIALOG_IMPL_H
+#define OPIE_TEMPLATE_DIALOG_IMPL_H
+
+#include <qlistview.h>
+
+#include <opie/otodo.h>
+
+#include "templatedialog.h"
+
+
+namespace Todo {
+
+ class MainWindow;
+ class TemplateManager;
+ class TemplateDialogImpl : public Todo::TemplateDialog {
+ Q_OBJECT
+ public:
+ TemplateDialogImpl( MainWindow* win, TemplateManager* );
+ ~TemplateDialogImpl();
+
+ private:
+ MainWindow* m_win;
+ TemplateManager* m_man;
+private slots:
+ void slotAdd();
+ void slotRemove();
+ void slotEdit();
+ void slotReturn();
+ void slotClicked(QListViewItem*);
+ };
+};
+
+#endif
diff --git a/core/pim/todo/templateeditor.cpp b/core/pim/todo/templateeditor.cpp
new file mode 100644
index 0000000..1b52d4f
--- a/dev/null
+++ b/core/pim/todo/templateeditor.cpp
@@ -0,0 +1,39 @@
+#include <qaction.h>
+#include <qpopupmenu.h>
+
+#include "mainwindow.h"
+#include "todotemplatemanager.h"
+
+#include "templatedialogimpl.h"
+#include "templateeditor.h"
+
+using namespace Todo;
+
+TemplateEditor::TemplateEditor( MainWindow* main,
+ TemplateManager* manager )
+ : QObject( main ), m_main( main ), m_man( manager )
+{
+ init();
+
+}
+TemplateEditor::~TemplateEditor() {
+
+}
+/* ok we add us to the Menubar */
+void TemplateEditor::init() {
+ QAction* a = new QAction( QString::null, tr("Configure Templates"),
+ 0, this, 0, FALSE );
+ connect(a, SIGNAL(activated() ),
+ this, SLOT(setUp() ) );
+
+ a->addTo( m_main->options() );
+}
+void TemplateEditor::setUp() {
+ qWarning("set up");
+ TemplateDialogImpl dlg(m_main, m_man );
+ int ret= dlg.exec();
+ if (QDialog::Accepted != ret ) {
+ m_man->load();
+ }else
+ m_main->populateTemplates();
+}
diff --git a/core/pim/todo/templateeditor.h b/core/pim/todo/templateeditor.h
new file mode 100644
index 0000000..e551328
--- a/dev/null
+++ b/core/pim/todo/templateeditor.h
@@ -0,0 +1,31 @@
+#ifndef OPIE_TEMPLATE_EDITOR_H
+#define OPIE_TEMPLATE_EDITOR_H
+
+#include <qobject.h>
+#include <qdialog.h>
+#include <qstring.h>
+
+namespace Todo {
+
+ class MainWindow;
+ class TemplateManager;
+ class TemplateEditor : public QObject{
+ Q_OBJECT
+ public:
+ TemplateEditor( MainWindow* win,
+ TemplateManager* man);
+ ~TemplateEditor();
+
+ signals:
+ void configChanged();
+ private:
+ void init();
+ MainWindow* m_main;
+ TemplateManager* m_man;
+private slots:
+ void setUp();
+
+ };
+};
+
+#endif
diff --git a/core/pim/todo/textviewshow.cpp b/core/pim/todo/textviewshow.cpp
new file mode 100644
index 0000000..24c8c0e
--- a/dev/null
+++ b/core/pim/todo/textviewshow.cpp
@@ -0,0 +1,19 @@
+#include "textviewshow.h"
+
+using namespace Todo;
+
+TextViewShow::TextViewShow( QWidget* parent)
+ : QTextView( parent ), TodoShow() {
+
+}
+TextViewShow::~TextViewShow() {
+}
+QString TextViewShow::type()const {
+ return QString::fromLatin1("TextViewShow");
+}
+void TextViewShow::slotShow( const OTodo& ev ) {
+ setText( ev.toRichText() );
+}
+QWidget* TextViewShow::widget() {
+ return this;
+}
diff --git a/core/pim/todo/textviewshow.h b/core/pim/todo/textviewshow.h
new file mode 100644
index 0000000..f58026b
--- a/dev/null
+++ b/core/pim/todo/textviewshow.h
@@ -0,0 +1,17 @@
+#include <qtextview.h>
+
+#include "todoshow.h"
+
+namespace Todo {
+
+ class TextViewShow : public QTextView, public TodoShow {
+ public:
+ TextViewShow( QWidget* parent );
+ ~TextViewShow();
+
+ QString type()const;
+ void slotShow( const OTodo& ev );
+ QWidget* widget();
+
+ };
+};
diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro
new file mode 100644
index 0000000..5108951
--- a/dev/null
+++ b/core/pim/todo/todo.pro
@@ -0,0 +1,55 @@
+TEMPLATE = app
+CONFIG = qt warn_on debug
+DESTDIR = $(OPIEDIR)/bin
+
+HEADERS = smalltodo.h \
+ todomanager.h \
+ mainwindow.h \
+ todoview.h \
+ todoentryimpl.h \
+ tableview.h \
+ tableitems.h \
+ todotemplatemanager.h \
+ todoeditor.h \
+ todoshow.h \
+ textviewshow.h \
+ templateeditor.h \
+ templatedialog.h \
+ templatedialogimpl.h
+
+SOURCES = smalltodo.cpp \
+ todomanager.cpp \
+ mainwindow.cpp \
+ main.cpp \
+ todoentryimpl.cpp \
+ tableview.cpp \
+ tableitems.cpp \
+ todoview.cpp \
+ todotemplatemanager.cpp \
+ todoeditor.cpp \
+ todoshow.cpp \
+ textviewshow.cpp \
+ templateeditor.cpp \
+ templatedialog.cpp \
+ templatedialogimpl.cpp
+
+INTERFACES = todoentry.ui
+TARGET = todolist
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe -lopie -lopiesql
+
+TRANSLATIONS = ../../../i18n/de/todolist.ts \
+ ../../../i18n/en/todolist.ts \
+ ../../../i18n/es/todolist.ts \
+ ../../../i18n/fr/todolist.ts \
+ ../../../i18n/hu/todolist.ts \
+ ../../../i18n/ja/todolist.ts \
+ ../../../i18n/ko/todolist.ts \
+ ../../../i18n/no/todolist.ts \
+ ../../../i18n/pl/todolist.ts \
+ ../../../i18n/pt/todolist.ts \
+ ../../../i18n/pt_BR/todolist.ts \
+ ../../../i18n/sl/todolist.ts \
+ ../../../i18n/zh_CN/todolist.ts \
+ ../../../i18n/zh_TW/todolist.ts
diff --git a/core/pim/todo/todoeditor.cpp b/core/pim/todo/todoeditor.cpp
new file mode 100644
index 0000000..c9ade20
--- a/dev/null
+++ b/core/pim/todo/todoeditor.cpp
@@ -0,0 +1,53 @@
+
+#include "todoentryimpl.h"
+#include "todoeditor.h"
+
+using namespace Todo;
+
+Editor::Editor() {
+ m_accepted = false;
+}
+Editor::~Editor() {
+}
+OTodo Editor::newTodo( int cur,
+ QWidget* par) {
+
+ NewTaskDialog e( cur, par, 0, TRUE );
+
+
+#if defined(Q_WS_QWS) || defined(_WS_QWS_)
+ e.showMaximized();
+#endif
+
+ int ret = e.exec();
+ if ( QDialog::Accepted == ret ) {
+ m_accepted = true;
+ }else
+ m_accepted = false;
+
+ OTodo ev = e.todoEntry();
+ ev.setUid(1);
+
+ return ev;
+}
+OTodo Editor::edit( QWidget *wid,
+ const OTodo& todo ) {
+ NewTaskDialog e( todo, wid, 0, TRUE );
+ e.setCaption( QObject::tr( "Edit Task" ) );
+
+#if defined(Q_WS_QWS) || defined(_WS_QWS_)
+ e.showMaximized();
+#endif
+ int ret = e.exec();
+
+ OTodo ev = e.todoEntry();
+ if ( ret == QDialog::Accepted )
+ m_accepted = true;
+ else
+ m_accepted = false;
+
+ return ev;
+}
+bool Editor::accepted()const {
+ return m_accepted;
+}
diff --git a/core/pim/todo/todoeditor.h b/core/pim/todo/todoeditor.h
new file mode 100644
index 0000000..bbfdcb5
--- a/dev/null
+++ b/core/pim/todo/todoeditor.h
@@ -0,0 +1,25 @@
+#ifndef OPIE_TODO_EDITOR_H
+#define OPIE_TODO_EDITOR_H
+
+#include <opie/otodo.h>
+
+
+namespace Todo {
+ class Editor {
+ public:
+ Editor();
+ ~Editor();
+
+ OTodo newTodo( int currentCatId,
+ QWidget* par );
+ OTodo edit( QWidget* par,
+ const OTodo& ev = OTodo() );
+
+
+ bool accepted()const;
+ private:
+ bool m_accepted: 1;
+ };
+};
+
+#endif
diff --git a/core/pim/todo/todoentry.ui b/core/pim/todo/todoentry.ui
new file mode 100644
index 0000000..60547f2
--- a/dev/null
+++ b/core/pim/todo/todoentry.ui
@@ -0,0 +1,481 @@
+<!DOCTYPE UI><UI>
+<class>NewTaskDialogBase</class>
+<comment>*********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+*********************************************************************</comment>
+<widget>
+ <class>QDialog</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>NewTaskDialogBase</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>239</width>
+ <height>320</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>New Task</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>4</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>4</number>
+ </property>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout19</cstring>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <grid>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>4</number>
+ </property>
+ <widget row="3" column="1" >
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout6</cstring>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>4</number>
+ </property>
+ <widget>
+ <class>QComboBox</class>
+ <item>
+ <property>
+ <name>text</name>
+ <string>0%</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>20%</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>40%</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>60%</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>80%</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>100%</string>
+ </property>
+ </item>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>cmbProg</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>32767</width>
+ <height>32767</height>
+ </size>
+ </property>
+ </widget>
+ <widget>
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>checkCompleted</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&amp;Completed</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget row="0" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Priority:</string>
+ </property>
+ </widget>
+ <widget row="4" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>buttonDate</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>false</bool>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>1 Jan 2001</string>
+ </property>
+ </widget>
+ <widget row="3" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>txtProg</cstring>
+ </property>
+ <property stdset="1">
+ <name>frameShape</name>
+ <enum>MShape</enum>
+ </property>
+ <property stdset="1">
+ <name>frameShadow</name>
+ <enum>MShadow</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Progress:</string>
+ </property>
+ </widget>
+ <widget row="2" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>selectGroupButton</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Select</string>
+ </property>
+ </widget>
+ <widget row="2" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>txtProg_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>frameShape</name>
+ <enum>MShape</enum>
+ </property>
+ <property stdset="1">
+ <name>frameShadow</name>
+ <enum>MShadow</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Group:</string>
+ </property>
+ </widget>
+ <widget row="4" column="0" >
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>checkDate</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>D&amp;ue</string>
+ </property>
+ </widget>
+ <widget row="1" column="1" >
+ <class>CategorySelect</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>comboCategory</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>minimumSize</name>
+ <size>
+ <width>60</width>
+ <height>20</height>
+ </size>
+ </property>
+ </widget>
+ <widget row="0" column="1" >
+ <class>QComboBox</class>
+ <item>
+ <property>
+ <name>text</name>
+ <string>1 - Very High</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>2 - High</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>3 - Normal</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>4 - Low</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>5 - Very Low</string>
+ </property>
+ </item>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>comboPriority</cstring>
+ </property>
+ <property stdset="1">
+ <name>currentItem</name>
+ <number>2</number>
+ </property>
+ </widget>
+ <widget row="5" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Summary:</string>
+ </property>
+ </widget>
+ <widget row="1" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel3</cstring>
+ </property>
+ <property stdset="1">
+ <name>frameShape</name>
+ <enum>NoFrame</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Category:</string>
+ </property>
+ </widget>
+ <widget row="5" column="1" >
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout8</cstring>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>4</number>
+ </property>
+ <widget>
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>lneSum</cstring>
+ </property>
+ </widget>
+ <widget>
+ <class>OClickableLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>lblDown</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>minimumSize</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ <widget>
+ <class>QMultiLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>txtTodo</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>wordWrap</name>
+ <enum>WidgetWidth</enum>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>CategorySelect</class>
+ <header location="global">qpe/categoryselect.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>7</hordata>
+ <verdata>1</verdata>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+ <customwidget>
+ <class>OClickableLabel</class>
+ <header location="global">opie/oclickablelabel.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ <signal>clicked()</signal>
+ <signal>toggled(bool)</signal>
+ <slot access="public">slotOn(bool)</slot>
+ </customwidget>
+</customwidgets>
+<images>
+ <image>
+ <name>image0</name>
+ <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>checkDate</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>buttonDate</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>lblDown</sender>
+ <signal>clicked()</signal>
+ <receiver>NewTaskDialogBase</receiver>
+ <slot>slotCopy()</slot>
+ </connection>
+ <slot access="protected">dateChanged( const QString &amp; )</slot>
+ <slot access="protected">dateChanged( int, int, int )</slot>
+ <slot access="protected">slotCopy()</slot>
+</connections>
+<tabstops>
+ <tabstop>comboPriority</tabstop>
+ <tabstop>comboCategory</tabstop>
+ <tabstop>selectGroupButton</tabstop>
+ <tabstop>cmbProg</tabstop>
+ <tabstop>checkCompleted</tabstop>
+ <tabstop>checkDate</tabstop>
+ <tabstop>buttonDate</tabstop>
+ <tabstop>lneSum</tabstop>
+ <tabstop>lblDown</tabstop>
+ <tabstop>txtTodo</tabstop>
+</tabstops>
+</UI>
diff --git a/core/pim/todo/todoentryimpl.cpp b/core/pim/todo/todoentryimpl.cpp
new file mode 100644
index 0000000..4211ae2
--- a/dev/null
+++ b/core/pim/todo/todoentryimpl.cpp
@@ -0,0 +1,189 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2002 zecke
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "todoentryimpl.h"
+
+#include <opie/oclickablelabel.h>
+#include <opie/otodo.h>
+
+#include <qpe/categoryselect.h>
+#include <qpe/datebookmonth.h>
+#include <qpe/global.h>
+#include <qpe/resource.h>
+#include <qpe/imageedit.h>
+#include <qpe/timestring.h>
+#include <qpe/palmtoprecord.h>
+
+#include <qlayout.h>
+#include <qmessagebox.h>
+#include <qpopupmenu.h>
+#include <qtoolbutton.h>
+#include <qcombobox.h>
+#include <qcheckbox.h>
+#include <qlineedit.h>
+#include <qmultilineedit.h>
+#include <qlabel.h>
+#include <qtimer.h>
+#include <qapplication.h>
+#include <qvaluelist.h>
+
+NewTaskDialog::NewTaskDialog( const OTodo& task, QWidget *parent,
+ const char *name, bool modal, WFlags fl )
+ : NewTaskDialogBase( parent, name, modal, fl ),
+ todo( task )
+{
+ todo.setCategories( task.categories() );
+ if ( todo.hasDueDate() )
+ date = todo.dueDate();
+ else
+ date = QDate::currentDate();
+
+ init();
+ comboPriority->setCurrentItem( task.priority() - 1 );
+
+ checkCompleted->setChecked( task.isCompleted() );
+ checkDate->setChecked( task.hasDueDate() );
+ buttonDate->setText( TimeString::longDateString( date ) );
+
+ txtTodo->setText( task.description() );
+ lneSum->setText( task.summary() );
+ cmbProg->setCurrentItem( task.progress()/20 );
+}
+
+/*
+ * Constructs a NewTaskDialog which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'
+ *
+ * The dialog will by default be modeless, unless you set 'modal' to
+ * TRUE to construct a modal dialog.
+ */
+NewTaskDialog::NewTaskDialog( int id, QWidget* parent, const char* name, bool modal,
+ WFlags fl )
+ : NewTaskDialogBase( parent, name, modal, fl ),
+ date( QDate::currentDate() )
+{
+ if ( id != -1 )
+ todo.setCategories( id );
+ init();
+}
+
+void NewTaskDialog::init()
+{
+ if( layout() != 0 ){
+ layout()->setMargin( 2 );
+ }
+ QPopupMenu *m1 = new QPopupMenu( this );
+ picker = new DateBookMonth( m1, 0, TRUE );
+ m1->insertItem( picker );
+ buttonDate->setPopup( m1 );
+ comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") );
+
+ connect( picker, SIGNAL( dateClicked( int, int, int ) ),
+ this, SLOT( dateChanged( int, int, int ) ) );
+
+ connect ( selectGroupButton, SIGNAL( clicked() ),
+ this, SLOT( groupButtonClicked () ) );
+
+ buttonDate->setText( TimeString::longDateString( date ) );
+ picker->setDate( date.year(), date.month(), date.day() );
+ lblDown->setPixmap(Resource::loadPixmap("down") );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+NewTaskDialog::~NewTaskDialog()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+void NewTaskDialog::dateChanged( int y, int m, int d )
+{
+ date = QDate( y, m, d );
+ buttonDate->setText( TimeString::longDateString( date ) );
+}
+void NewTaskDialog::groupButtonClicked ()
+{
+/* OContactSelectorDialog cd( this );
+ QArray<int> todo_relations = todo.relations ( "addressbook" );
+ QValueList<int> selectedContacts;
+
+ for ( uint i=0; i < todo_relations.size(); i++ ){
+ printf ("old: %d\n", todo_relations[i]);
+ selectedContacts.append( todo_relations[i] );
+ }
+ cd.setSelected (selectedContacts);
+ cd.showMaximized();
+ if ( cd.exec() == QDialog::Accepted ){
+ selectedContacts = cd.selected ();
+ QValueListIterator<int> it;
+ todo.clearRelated("addressbook");
+ for( it = selectedContacts.begin(); it != selectedContacts.end(); ++it ){
+ printf ("Adding: %d\n", (*it));
+ todo.addRelated( "addressbook", (*it) );
+ }
+
+ }
+*/
+}
+
+OTodo NewTaskDialog::todoEntry()
+{
+ if( checkDate->isChecked() ){
+ todo.setDueDate( date );
+ todo.setHasDueDate( true );
+ }else{
+ todo.setHasDueDate( false );
+ }
+ if ( comboCategory->currentCategory() != -1 ) {
+ QArray<int> arr = comboCategory->currentCategories();
+ QStringList list;
+ todo.setCategories( arr );
+ }
+ todo.setPriority( comboPriority->currentItem() + 1 );
+ todo.setCompleted( checkCompleted->isChecked() );
+
+ todo.setDescription( txtTodo->text() );
+ todo.setSummary( lneSum->text() );
+ QString text = cmbProg->currentText();
+ todo.setProgress( text.remove( text.length()-1, 1 ).toUShort() );
+ return todo;
+}
+void NewTaskDialog::slotCopy()
+{
+ txtTodo->clear();
+ txtTodo->setText( lneSum->text() );
+}
+
+/*!
+
+*/
+
+void NewTaskDialog::accept()
+{
+ QString strText = txtTodo->text();
+ QString strSumm = lneSum->text();
+ if ( strSumm.isEmpty() && strText.isEmpty() ) {
+ // hmm... just decline it then, the user obviously didn't care about it
+ QDialog::reject();
+ return;
+ }
+ QDialog::accept();
+}
diff --git a/core/pim/todo/todoentryimpl.h b/core/pim/todo/todoentryimpl.h
new file mode 100644
index 0000000..2dfdd22
--- a/dev/null
+++ b/core/pim/todo/todoentryimpl.h
@@ -0,0 +1,65 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef NEWTASKDIALOG_H
+#define NEWTASKDIALOG_H
+
+#include "todoentry.h"
+
+#include <opie/otodo.h>
+//#include <opie/ocontactselector.h>
+
+#include <qdatetime.h>
+#include <qpalette.h>
+
+class QLabel;
+class QTimer;
+class DateBookMonth;
+
+
+
+class NewTaskDialog : public NewTaskDialogBase
+{
+ Q_OBJECT
+
+public:
+ NewTaskDialog( const OTodo& task, QWidget *parent = 0, const char* name = 0,
+ bool modal = FALSE, WFlags fl = 0 );
+ NewTaskDialog( int id, QWidget* parent = 0, const char* name = 0,
+ bool modal = FALSE, WFlags fl = 0 );
+ ~NewTaskDialog();
+
+ OTodo todoEntry();
+
+protected slots:
+ void dateChanged( int y, int m, int d );
+ void groupButtonClicked ();
+ void slotCopy();
+protected:
+ virtual void accept();
+
+private:
+ void init();
+ OTodo todo;
+ QDate date;
+ DateBookMonth *picker;
+};
+
+#endif // NEWTASKDIALOG_H
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
new file mode 100644
index 0000000..8e3fa88
--- a/dev/null
+++ b/core/pim/todo/todomanager.cpp
@@ -0,0 +1,125 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 <>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+#include <qdatetime.h>
+#include <qpe/categoryselect.h>
+
+#include "todomanager.h"
+
+using namespace Todo;
+
+TodoManager::TodoManager( QObject *obj )
+ : QObject( obj ) {
+ m_db = 0l;
+ QTime time;
+ time.start();
+ int el = time.elapsed();
+ qWarning("QTimer for loading %d", el/1000 );
+}
+TodoManager::~TodoManager() {
+ delete m_db;
+}
+OTodo TodoManager::event(int uid ) {
+ return m_db->find( uid );
+}
+void TodoManager::updateList() {
+ m_list = m_db->allRecords();
+}
+OTodoAccess::List::Iterator TodoManager::begin() {
+ m_it = m_list.begin();
+ return m_it;
+}
+OTodoAccess::List::Iterator TodoManager::end() {
+ return m_list.end();
+}
+OTodoAccess::List::Iterator TodoManager::overDue() {
+ int filter = 2 & 1;
+ m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca );
+ m_it = m_list.begin();
+ return m_it;
+}
+OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start,
+ const QDate& end ) {
+ m_list = m_db->effectiveToDos( start, end );
+ m_it = m_list.begin();
+ return m_it;
+}
+OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) {
+ m_list = m_db->queryByExample( ev, query );
+ m_it = m_list.begin();
+ return m_it;
+}
+OTodoAccess* TodoManager::todoDB() {
+ return m_db;
+}
+void TodoManager::add( const OTodo& ev ) {
+ m_db->add( ev );
+}
+void TodoManager::update( int, const SmallTodo& ) {
+
+}
+void TodoManager::update( int, const OTodo& ev) {
+ m_db->replace( ev );
+}
+void TodoManager::remove( int uid ) {
+ m_db->remove( uid );
+}
+void TodoManager::removeAll() {
+ m_db->clear();
+}
+void TodoManager::save() {
+ m_db->save();
+}
+bool TodoManager::saveAll() {
+ return m_db->save();
+}
+void TodoManager::reload() {
+ m_db->reload();
+}
+QStringList TodoManager::categories() {
+ m_cat.load(categoryFileName() );
+ return m_cat.labels( "Todo List");
+}
+/*
+ * we rely on load beeing called from populateCategories
+ */
+int TodoManager::catId( const QString& cats ) {
+ return m_cat.id( "Todo List", cats );
+}
+void TodoManager::remove( const QArray<int>& ids) {
+ for (uint i=0; i < ids.size(); i++ )
+ remove( ids[i] );
+}
+bool TodoManager::isLoaded()const {
+ return (m_db == 0 );
+}
+void TodoManager::load() {
+ if (!m_db) {
+ m_db = new OTodoAccess();
+ m_db->load();
+ }
+}
diff --git a/core/pim/todo/todomanager.h b/core/pim/todo/todomanager.h
new file mode 100644
index 0000000..1f9e288
--- a/dev/null
+++ b/core/pim/todo/todomanager.h
@@ -0,0 +1,107 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 <>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef OPIE_TODO_MANAGER_H
+#define OPIE_TODO_MANAGER_H
+
+#include <qarray.h>
+#include <qobject.h>
+#include <qstring.h>
+
+#include <qpe/categories.h>
+
+#include <opie/otodo.h>
+#include <opie/otodoaccess.h>
+
+#include "smalltodo.h"
+
+
+namespace Todo {
+ class TodoManager : public QObject{
+ Q_OBJECT
+ public:
+ bool isLoaded()const;
+ void load();
+ TodoManager(QObject* obj = 0);
+ ~TodoManager();
+
+ QStringList categories()/*const*/;
+ int catId(const QString&);
+ OTodo event(int uid );
+
+ void updateList();
+ /** returns the iterator sorted if set sorted*/
+ OTodoAccess::List::Iterator begin();
+ OTodoAccess::List::Iterator end();
+ OTodoAccess::List& list();
+
+ OTodoAccess::List::Iterator overDue();
+ OTodoAccess::List::Iterator fromTo( const QDate& start,
+ const QDate& end );
+ OTodoAccess::List::Iterator query( const OTodo& ev, int query );
+
+ void setCategory( bool sort, int category = -1);
+ void setShowOverDue( bool show );
+ void setSortOrder( int sortOrder );
+ void setSortASC( bool );
+ void sort();
+
+ OTodoAccess* todoDB();
+ bool saveAll();
+
+
+ signals:
+ void update();
+ void updateCategories();
+
+ public slots:
+ void add( const OTodo& );
+ void update( int uid, const SmallTodo& );
+ void update( int uid, const OTodo& );
+ void remove( int uid );
+ void remove( const QArray<int>& );
+ void removeAll();
+ void reload();
+ void save();
+
+ private:
+ OTodoAccess* m_db;
+ OTodoAccess::List m_list;
+ OTodoAccess::List::Iterator m_it;
+ OTodoAccess::List m_sorted;
+ Categories m_cat;
+ int m_ca;
+ /* sort cat */
+ bool m_shCat;
+ int m_sortOrder;
+ bool m_asc;
+
+ };
+};
+
+#endif
diff --git a/core/pim/todo/todoshow.cpp b/core/pim/todo/todoshow.cpp
new file mode 100644
index 0000000..c84a08f
--- a/dev/null
+++ b/core/pim/todo/todoshow.cpp
@@ -0,0 +1,9 @@
+#include "todoshow.h"
+
+using namespace Todo;
+
+TodoShow::TodoShow() {
+}
+TodoShow::~TodoShow() {
+}
+
diff --git a/core/pim/todo/todoshow.h b/core/pim/todo/todoshow.h
new file mode 100644
index 0000000..198e9ae
--- a/dev/null
+++ b/core/pim/todo/todoshow.h
@@ -0,0 +1,53 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 <>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+#ifndef TODO_TODO_SHOW_H
+#define TODO_TODO_SHOW_H
+
+#include <qstring.h>
+#include <qwidget.h>
+
+#include <opie/otodo.h>
+
+namespace Todo {
+ /**
+ * TodoShow is the baseclass of
+ * of all TodoShows.
+ * The first implementation is a QTextView
+ * implementation showing the Todo as richtext
+ */
+ class TodoShow {
+ public:
+ TodoShow();
+ virtual ~TodoShow();
+ virtual QString type()const = 0;
+ virtual void slotShow( const OTodo& ev ) = 0;
+ virtual QWidget* widget() = 0;
+ };
+};
+
+#endif
diff --git a/core/pim/todo/todotemplatemanager.cpp b/core/pim/todo/todotemplatemanager.cpp
new file mode 100644
index 0000000..02941ac
--- a/dev/null
+++ b/core/pim/todo/todotemplatemanager.cpp
@@ -0,0 +1,75 @@
+#include <qpe/config.h>
+#include <qpe/global.h>
+
+#include <opie/otodoaccess.h>
+#include <opie/otodoaccessxml.h>
+
+#include "todotemplatemanager.h"
+
+
+using namespace Todo;
+
+TemplateManager::TemplateManager() {
+ m_path = Global::applicationFileName("todolist", "templates.xml");
+}
+TemplateManager::~TemplateManager() {
+
+}
+void TemplateManager::load() {
+ Config conf("todolist_templates");
+ OTodoAccessXML *xml = new OTodoAccessXML( QString::fromLatin1("template"),
+ m_path );
+ OTodoAccess todoDB(xml );
+ todoDB.load();
+
+ OTodoAccess::List::Iterator it;
+ OTodoAccess::List list = todoDB.allRecords();
+ for ( it = list.begin(); it != list.end(); ++it ) {
+ OTodo ev = (*it);
+ conf.setGroup( QString::number( ev.uid() ) );
+ QString str = conf.readEntry("Name", QString::null );
+ if (str.isEmpty() )
+ continue;
+
+ m_templates.insert( str,
+ ev );
+ }
+}
+void TemplateManager::save() {
+ Config conf("todolist_templates");
+
+ OTodoAccessXML *res = new OTodoAccessXML( "template",
+ m_path );
+ OTodoAccess db(res);
+
+
+ QMap<QString, OTodo>::Iterator it;
+ for ( it = m_templates.begin(); it != m_templates.end(); ++it ) {
+ OTodo ev = it.data();
+ conf.setGroup( QString::number( ev.uid() ) );
+ qWarning("Name" + it.key() );
+ conf.writeEntry("Name", it.key() );
+ db.add( ev );
+ }
+ db.save();
+}
+void TemplateManager::addEvent( const QString& str,
+ const OTodo& ev) {
+ qWarning("AddEvent"+ str );
+ m_templates.replace( str, ev );
+}
+void TemplateManager::removeEvent( const QString& str ) {
+ m_templates.remove( str );
+}
+QStringList TemplateManager::templates() const {
+ QStringList list;
+ QMap<QString, OTodo>::ConstIterator it;
+ for (it = m_templates.begin(); it != m_templates.end(); ++it ) {
+ list << it.key();
+ }
+
+ return list;
+}
+OTodo TemplateManager::templateEvent( const QString& templateName ) {
+ return m_templates[templateName];
+}
diff --git a/core/pim/todo/todotemplatemanager.h b/core/pim/todo/todotemplatemanager.h
new file mode 100644
index 0000000..387ced1
--- a/dev/null
+++ b/core/pim/todo/todotemplatemanager.h
@@ -0,0 +1,32 @@
+#ifndef OPIE_TODO_TEMPLATE_H
+#define OPIE_TODO_TEMPLATE_H
+
+#include <qstring.h>
+#include <qmap.h>
+
+#include <opie/otodo.h>
+
+
+namespace Todo {
+ class TemplateManager {
+ public:
+ TemplateManager();
+ ~TemplateManager();
+ void load();
+ void save();
+ QStringList templates()const;
+ OTodo templateEvent( const QString& templateName );
+
+ /* also replaces one */
+ void addEvent( const QString&, const OTodo& );
+ void removeEvent( const QString& );
+ private:
+ QString m_path;
+ QMap<QString, OTodo> m_templates;
+
+
+
+ };
+};
+
+#endif
diff --git a/core/pim/todo/todoview.cpp b/core/pim/todo/todoview.cpp
new file mode 100644
index 0000000..5362b23
--- a/dev/null
+++ b/core/pim/todo/todoview.cpp
@@ -0,0 +1,62 @@
+#include "mainwindow.h"
+
+#include "todoview.h"
+
+using namespace Todo;
+
+TodoView::TodoView( MainWindow* win )
+ : m_main( win )
+{
+ hack = new InternQtHack;
+}
+TodoView::~TodoView() {
+ delete hack;
+};
+
+void TodoView::connectShow(QObject* obj,
+ const char* slot ) {
+ QObject::connect( hack, SIGNAL(showTodo(int) ),
+ obj, slot );
+}
+void TodoView::connectEdit( QObject* obj,
+ const char* slot ) {
+ QObject::connect( hack, SIGNAL(edit(int) ),
+ obj, slot );
+}
+void TodoView::connectUpdateSmall( QObject* obj,
+ const char* slot ) {
+ QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ),
+ obj, slot );
+}
+void TodoView::connectUpdateBig( QObject* obj,
+ const char* slot ) {
+ QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ),
+ obj, slot );
+}
+void TodoView::connectUpdateView( QObject* obj,
+ const char* slot ) {
+ QObject::connect( hack, SIGNAL(update(QWidget*) ),
+ obj, slot );
+}
+void TodoView::connectRemove( QObject* obj,
+ const char* slot ) {
+ QObject::connect( hack, SIGNAL(remove(int) ),
+ obj, slot );
+}
+MainWindow* TodoView::todoWindow() {
+ return m_main;
+}
+
+OTodo TodoView::event(int uid ) { return m_main->event( uid ); }
+OTodoAccess::List::Iterator TodoView::begin() {
+ m_main->updateList();
+ return m_main->begin();
+}
+OTodoAccess::List::Iterator TodoView::end() { return m_main->end(); }
+
+void TodoView::update(int uid, const SmallTodo& to ) {
+ //m_main->slotUpate1( uid, to );
+}
+void TodoView::update(int uid, const OTodo& ev ) {
+ m_main->updateTodo( ev );
+}
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h
new file mode 100644
index 0000000..e4985a7
--- a/dev/null
+++ b/core/pim/todo/todoview.h
@@ -0,0 +1,178 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 <>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef TODO_VIEW_H
+#define TODO_VIEW_H
+
+#include <qarray.h>
+#include <qstring.h>
+#include <qvaluelist.h>
+#include <qwidget.h>
+
+#include <opie/otodoaccess.h>
+
+#include "smalltodo.h"
+
+
+namespace Todo {
+
+ /**
+ * According to tronical it's not possible
+ * to have Q_OBJECT in a template at all
+ * so this is a hack widget not meant
+ * to be public
+ */
+ class InternQtHack : public QObject {
+ Q_OBJECT
+ public:
+ InternQtHack() : QObject() {};
+ void emitShow(int uid) { emit showTodo(uid); }
+ void emitEdit(int uid) { emit edit(uid ); }
+ void emitUpdate( int uid,
+ const SmallTodo& to) {
+ emit update(uid, to );
+ }
+ void emitUpdate( int uid,
+ const OTodo& ev ){
+ emit update(uid, ev );
+ }
+ void emitRemove( int uid ) {
+ emit remove( uid );
+ }
+ void emitUpdate( QWidget* wid ) {
+ emit update( wid );
+ }
+ signals:
+ void showTodo(int uid );
+ void edit(int uid );
+ void update( int uid, const Todo::SmallTodo& );
+ void update( int uid, const OTodo& );
+ /* sorry you need to cast */;
+ void update( QWidget* wid );
+ void remove( int uid );
+
+ };
+ class MainWindow;
+
+ /**
+ * due to inheretince problems we need this base class
+ */
+ class ViewBase {
+ public:
+ virtual QWidget* widget() = 0;
+ virtual QString type()const = 0;
+ virtual int current() = 0;
+ virtual QString currentRepresentation() = 0;
+ virtual void showOverDue( bool ) = 0;
+ virtual void setTodos( OTodoAccess::List::Iterator it,
+ OTodoAccess::List::Iterator end ) = 0;
+
+ virtual void addEvent( const OTodo& ) = 0;
+ virtual void replaceEvent( const OTodo& ) = 0;
+ virtual void removeEvent( int uid ) = 0;
+ virtual void setShowCompleted( bool ) = 0;
+ virtual void setShowDeadline( bool ) = 0;
+ virtual void setShowCategory( const QString& = QString::null ) = 0;
+ virtual void clear() = 0;
+ virtual QArray<int> completed() = 0;
+ virtual void newDay() = 0;
+
+ virtual void connectShow( QObject*, const char* ) = 0;
+ virtual void connectEdit( QObject*, const char* ) = 0;
+ virtual void connectUpdateSmall( QObject*, const char* ) = 0;
+ virtual void connectUpdateBig( QObject*, const char* ) = 0;
+ virtual void connectUpdateView( QObject*, const char*) = 0;
+ virtual void connectRemove( QObject*, const char* ) = 0;
+
+ };
+
+ /**
+ * A base class for all TodoView which are showing
+ * a list of todos.
+ * Either in a QTable, QListView or any other QWidget
+ * derived class
+ * Through the MainWindow( dispatcher ) one can access
+ * the relevant informations
+ *
+ * It's not possible to have signal and slots from within
+ * templates this way you've to register for a signal
+ */
+ class TodoView : public ViewBase{
+
+ public:
+ /**
+ * c'tor
+ */
+ TodoView( MainWindow* win );
+
+ /**
+ *d'tor
+ */
+ virtual ~TodoView();
+
+ /* connect to the show signal */
+ void connectShow(QObject* obj,
+ const char* slot );
+
+ /* connect to edit */
+ void connectEdit( QObject* obj,
+ const char* slot );
+ void connectUpdateSmall( QObject* obj,
+ const char* slot );
+ void connectUpdateBig( QObject* obj,
+ const char* slot ) ;
+ void connectUpdateView( QObject* obj,
+ const char* slot );
+ void connectRemove( QObject* obj,
+ const char* slot );
+ protected:
+ MainWindow* todoWindow();
+ OTodo event(int uid );
+ OTodoAccess::List::Iterator begin();
+ OTodoAccess::List::Iterator end();
+
+ /*
+ These things needs to be implemented
+ in a implementation
+ signals:
+ */
+ protected:
+ void showTodo( int uid ) { hack->emitShow(uid); }
+ void edit( int uid ) { hack->emitEdit(uid); }
+ void update(int uid, const SmallTodo& to );
+ void update(int uid, const OTodo& ev);
+ void remove( int uid ) {
+ hack->emitRemove( uid );
+ }
+ private:
+ InternQtHack* hack;
+ MainWindow *m_main;
+ };
+};
+
+#endif