summaryrefslogtreecommitdiff
path: root/core
Side-by-side diff
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp213
-rw-r--r--core/pim/todo/mainwindow.h24
-rw-r--r--core/pim/todo/otaskeditor.cpp35
-rw-r--r--core/pim/todo/otaskeditor.h5
-rw-r--r--core/pim/todo/tableview.cpp27
-rw-r--r--core/pim/todo/taskeditoradvanced.ui8
-rw-r--r--core/pim/todo/taskeditoroverviewimpl.cpp55
-rw-r--r--core/pim/todo/taskeditoroverviewimpl.h1
-rw-r--r--core/pim/todo/todo.pro6
-rw-r--r--core/pim/todo/todomanager.cpp7
-rw-r--r--core/pim/todo/todomanager.h7
-rw-r--r--core/pim/todo/todoview.cpp55
-rw-r--r--core/pim/todo/todoview.h82
13 files changed, 310 insertions, 215 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 9b2423b..b2b3b8f 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,110 +1,113 @@
/*
               =. 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 <unistd.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qtoolbar.h>
#include <qpopupmenu.h>
#include <qwidgetstack.h>
#include <qaction.h>
#include <qtimer.h>
#include <qvbox.h>
#include <qlineedit.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
#include <qpe/ir.h>
#include <qpe/resource.h>
#include <qpe/qpemessagebox.h>
+#include <opie/orecur.h>
#include <opie/otodoaccessvcal.h>
#include "quickeditimpl.h"
#include "todotemplatemanager.h"
#include "templateeditor.h"
#include "tableview.h"
#include "textviewshow.h"
#include "todoeditor.h"
#include "mainwindow.h"
using namespace Todo;
MainWindow::MainWindow( QWidget* parent,
- const char* name ) {
+ const char* name )
+ : OPimMainWindow("Todolist")
+{
m_syncing = false;
m_counter = 0;
m_tempManager = new TemplateManager();
m_tempManager->load();
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() ) );
@@ -132,203 +135,198 @@ void MainWindow::initActions() {
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 only over due"),
0, this, 0, TRUE );
- a->addTo( m_view );
+ a->addTo( m_options );
a->setOn( showOverDue() );
connect(a, SIGNAL(toggled(bool)),
this, SLOT(slotShowDue(bool) ) );
- m_view->insertSeparator();
-
- m_bar->insertItem( tr("View"), m_view );
/* templates */
m_edit->insertItem(tr("New from template"), m_template,
-1, 0 );
}
/* 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_mainBox = new QVBox(this, "main box ");
m_curQuick = new QuickEditImpl(this, m_mainBox );
m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
m_quickEdit.append( m_curQuick );
m_stack = new QWidgetStack(m_mainBox, "main stack");
setCentralWidget( m_mainBox );
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, m_stack );
m_stack->addWidget( tableView, m_counter++ );
m_views.append( tableView );
m_curView = tableView;
connectBase( tableView );
/* 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 ) {
+ // once templates and signals mix we'll use it again
+}
+QPopupMenu* MainWindow::contextMenu( int , bool recur ) {
QPopupMenu* menu = new QPopupMenu();
m_editAction->addTo( menu );
m_deleteAction->addTo( menu );
m_duplicateAction->addTo( menu );
+
menu->insertSeparator();
+ /*
+ * if this event recurs we allow
+ * to detach it.
+ * remove all
+ */
+ if ( recur ) {
+ ; // FIXME
+ }
+
return menu;
}
QPopupMenu* MainWindow::options() {
qWarning("Options");
return m_options;
}
QPopupMenu* MainWindow::edit() {
return m_edit;
}
-QPopupMenu* MainWindow::view() {
- return m_view;
-}
QToolBar* MainWindow::toolbar() {
return m_tool;
}
OTodoAccess::List MainWindow::list()const {
return m_todoMgr.list();
}
OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
int cat = 0;
if ( m_curCat != tr("All Categories") )
cat = currentCatId();
int filter = 1;
if (!m_completed )
filter |= 4;
if (m_overdue)
filter |= 2;
return m_todoMgr.sorted( asc, sortOrder, filter, cat );
}
OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
int cat = 0;
if ( m_curCat != tr("All Categories") )
cat = currentCatId();
return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
}
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()->updateView( );
raiseCurrentView();
}
void MainWindow::closeEvent( QCloseEvent* e ) {
@@ -368,247 +366,214 @@ void MainWindow::closeEvent( QCloseEvent* e ) {
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();
- m_todoMgr.add( todo );
- currentView()->addEvent( todo );
-
-
- // I'm afraid we must call this every time now, otherwise
- // spend expensive time comparing all these strings...
- // but only call if we changed something -zecke
- populateCategories();
- }
- raiseCurrentView( );
+ create();
}
void MainWindow::slotDuplicate() {
if(m_syncing) {
QMessageBox::warning(this, tr("Todo"),
tr("Can not edit data, currently syncing"));
return;
}
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;
- // FIXME
- //m_todoMgr.remove( currentView()->completed() );
+
+ m_todoMgr.removeCompleted();
currentView()->updateView( );
}
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& fi) {
DocLnk doc(fi);
if (doc.isValid() )
receiveFile(doc.file() );
else
receiveFile(fi );
}
static const char *beamfile = "/tmp/opie-todo.vcs";
void MainWindow::slotBeam() {
- ::unlink( beamfile );
- OTodo todo = event( currentView()->current() );
- OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) );
- OTodoAccess acc( cal );
- acc.load();
- acc.add( todo );
- acc.save();
- Ir* ir = new Ir(this );
- connect(ir, SIGNAL(done(Ir*) ),
- this, SLOT(beamDone(Ir*) ) );
- ir->send( beamfile, todo.summary(), "text/x-vCalendar" );
-
+ beam( currentView()->current() );
}
void MainWindow::beamDone( Ir* ir) {
delete ir;
::unlink( beamfile );
}
void MainWindow::receiveFile( const QString& filename ) {
OTodoAccessVCal* cal = new OTodoAccessVCal(filename );
OTodoAccess acc( cal );
acc.load();
OTodoAccess::List list = acc.allRecords();
QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
if ( QMessageBox::information(this, tr("New Tasks"),
message, QMessageBox::Ok,
QMessageBox::Cancel ) == QMessageBox::Ok ) {
OTodoAccess::List::Iterator it;
for ( it = list.begin(); it != list.end(); ++it )
m_todoMgr.add( (*it) );
currentView()->updateView();
}
}
void MainWindow::slotFlush() {
m_syncing = FALSE;
m_todoMgr.save();
}
void MainWindow::slotShowDetails() {
slotShow( currentView()->current() );
}
/*
* populate the Categories
* Menu
*/
void MainWindow::populateCategories() {
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();
@@ -659,48 +624,182 @@ void MainWindow::slotEdit( int uid ) {
todo = currentEditor()->edit(this, todo );
/* if completed */
if ( currentEditor()->accepted() ) {
qWarning("Replacing now" );
m_todoMgr.update( todo.uid(), todo );
currentView()->replaceEvent( todo );
/* a Category might have changed */
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();
}
void MainWindow::setReadAhead( uint count ) {
if (m_todoMgr.todoDB() )
m_todoMgr.todoDB()->setReadAhead( count );
}
void MainWindow::slotQuickEntered() {
qWarning("entered");
OTodo todo = quickEditor()->todo();
if (todo.isEmpty() )
return;
m_todoMgr.add( todo );
currentView()->addEvent( todo );
raiseCurrentView();
}
QuickEditBase* MainWindow::quickEditor() {
return m_curQuick;
}
+void MainWindow::slotComplete( int uid ) {
+ slotComplete( event(uid) );
+}
+void MainWindow::slotComplete( const OTodo& todo ) {
+ OTodo to = todo;
+ to.setCompleted( !to.isCompleted() );
+ to.setCompletedDate( QDate::currentDate() );
+
+ /*
+ * if the item does recur
+ * we need to spin it off
+ * and update the items duedate to the next
+ * possible recurrance of this item...
+ * the spinned off one will loose the
+ */
+ if ( to.recurrence().doesRecur() && to.isCompleted() ) {
+ OTodo to2( to );
+
+ /* the spinned off one won't recur anymore */
+ to.setRecurrence( ORecur() );
+
+ ORecur rec = to2.recurrence();
+ rec.setStart( to.dueDate() );
+ to2.setRecurrence( rec );
+ /*
+ * if there is a next occurence
+ * from the duedate of the last recurrance
+ */
+ QDate date;
+ if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) {
+ QDate inval;
+ /* generate a new uid for the old record */
+ to.setUid( 1 );
+
+ /* add the old one cause it has a new UID here cause it was spin off */
+ m_todoMgr.add( to );
+
+ /*
+ * update the due date
+ * start date
+ * and complete date
+ */
+ to2.setDueDate( date );
+ to2.setStartDate( inval );
+ to2.setCompletedDate( inval );
+ to2.setCompleted( false );
+ updateTodo( to2 );
+ }else
+ updateTodo( to );
+ }else
+ updateTodo( to );
+
+ currentView()->updateView();
+ raiseCurrentView();
+}
+void MainWindow::flush() {
+ slotFlush();
+}
+void MainWindow::reload() {
+ slotReload();
+}
+int MainWindow::create() {
+ int uid = 0;
+ if(m_syncing) {
+ QMessageBox::warning(this, tr("Todo"),
+ tr("Can not edit data, currently syncing"));
+ return uid;
+ }
+
+
+ OTodo todo = currentEditor()->newTodo( currentCatId(),
+ this );
+
+ if ( currentEditor()->accepted() ) {
+ //todo.assignUid();
+ uid = todo.uid();
+ m_todoMgr.add( todo );
+ currentView()->addEvent( todo );
+
+
+ // I'm afraid we must call this every time now, otherwise
+ // spend expensive time comparing all these strings...
+ // but only call if we changed something -zecke
+ populateCategories();
+ }
+ raiseCurrentView( );
+
+ return uid;
+}
+/* delete it silently... */
+bool MainWindow::remove( int uid ) {
+ if (m_syncing) return false;
+
+ return m_todoMgr.remove( uid );
+}
+void MainWindow::beam( int uid, int ) {
+ ::unlink( beamfile );
+ OTodo todo = event( uid );
+ OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) );
+ OTodoAccess acc( cal );
+ acc.load();
+ acc.add( todo );
+ acc.save();
+ Ir* ir = new Ir(this );
+ connect(ir, SIGNAL(done(Ir*) ),
+ this, SLOT(beamDone(Ir*) ) );
+ ir->send( beamfile, todo.summary(), "text/x-vCalendar" );
+}
+void MainWindow::show( int uid ) {
+ slotShow( uid );
+}
+void MainWindow::edit( int uid ) {
+ slotEdit( uid );
+}
+void MainWindow::add( const OPimRecord& rec) {
+ if ( rec.rtti() != OTodo::rtti() ) return;
+
+ const OTodo& todo = static_cast<const OTodo&>(rec);
+
+ m_todoMgr.add(todo );
+ currentView()->addEvent( todo );
+
+
+ // I'm afraid we must call this every time now, otherwise
+ // spend expensive time comparing all these strings...
+ // but only call if we changed something -zecke
+ populateCategories();
+}
+/* todo does not have the QDataStream<< and >> operators implemented :(
+ * FIXME
+ */
+OPimRecord* MainWindow::record( int rtti, const QByteArray& ) {
+ return 0l;
+}
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
index 270cbd1..14cfa82 100644
--- a/core/pim/todo/mainwindow.h
+++ b/core/pim/todo/mainwindow.h
@@ -1,191 +1,203 @@
/*
               =. 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 <opie/opimmainwindow.h>
#include "smalltodo.h"
#include "todoview.h"
#include "quickedit.h"
#include "todomanager.h"
class QPopupMenu;
class QMenuBar;
class QToolBar;
class QAction;
class QWidgetStack;
class Ir;
class QVBox;
namespace Todo {
typedef TodoView View;
class TemplateManager;
class Editor;
class TodoShow;
class TemplateEditor;
struct QuickEditBase;
- class MainWindow : public QMainWindow {
+ class MainWindow : public OPimMainWindow {
Q_OBJECT
+ friend class TodoView; // avoid QObject here....
public:
MainWindow( QWidget *parent = 0,
const char* name = 0 );
~MainWindow();
/** return a context menu for an OTodo */
- QPopupMenu* contextMenu(int uid );
+ QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE );
QPopupMenu* options();
QPopupMenu* edit();
- QPopupMenu* view();
QToolBar* toolbar();
void updateList();
OTodoAccess::List list()const;
OTodoAccess::List sorted( bool asc, int sortOrder );
OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter );
OTodo event(int uid );
bool isSyncing()const;
bool showCompleted()const;
bool showDeadline()const;
bool showOverDue()const;
QString currentCategory()const;
int currentCatId();
TemplateManager* templateManager();
QuickEditBase* quickEditor();
void updateTodo( const OTodo& );
void populateTemplates();
Editor* currentEditor();
void setReadAhead(uint count );
private slots:
void slotQuickEntered();
void populateCategories();
void slotReload();
void slotFlush();
protected:
void closeEvent( QCloseEvent* e );
private:
void receiveFile( const QString& filename );
void connectBase( ViewBase* );
void initUI();
void initActions();
void initConfig();
void initViews();
void initEditor();
void initShow();
void initTemplate();
void raiseCurrentView();
ViewBase* currentView();
ViewBase* m_curView;
QuickEditBase* m_curQuick;
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;
/* box with two rows
* top will be the quick edit
* this will bite my ass once
* we want to have all parts
* exchangeable
*/
QVBox* m_mainBox;
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;
QList<QuickEditBase> m_quickEdit;
uint m_counter;
TemplateManager* m_tempManager;
private slots:
void slotShow(int);
void slotEdit(int);
-private slots:
void slotUpdate3( QWidget* );
+ void slotComplete( int uid );
+ void slotComplete( const OTodo& ev );
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 );
+ /* reimplementation from opimmainwindow */
+ protected slots:
+ void flush();
+ void reload();
+ int create();
+ bool remove( int uid );
+ void beam(int uid, int transport = IrDa );
+ void show( int uid );
+ void edit( int uid );
+ void add( const OPimRecord& );
+ OPimRecord* record( int rtti, const QByteArray& );
};
};
#endif
diff --git a/core/pim/todo/otaskeditor.cpp b/core/pim/todo/otaskeditor.cpp
index 8b261de..eeb3c0c 100644
--- a/core/pim/todo/otaskeditor.cpp
+++ b/core/pim/todo/otaskeditor.cpp
@@ -1,91 +1,100 @@
#include <qdatetime.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qmultilineedit.h>
+#include <qscrollview.h>
#include <opie/orecurrancewidget.h>
#include "taskeditoroverviewimpl.h"
-#include "taskeditoradvanced.h"
+#include "taskeditoradvancedimpl.h"
#include "taskeditoralarms.h"
#include "otaskeditor.h"
OTaskEditor::OTaskEditor(int cur)
: QDialog(0, 0, TRUE ) {
init();
init( cur );
}
OTaskEditor::OTaskEditor( const OTodo& to)
: QDialog(0, 0, TRUE ) {
init();
init( to );
}
OTaskEditor::~OTaskEditor() {
}
void OTaskEditor::init( int cur ) {
OTodo to;
if ( cur != 0 )
to.setCategories( cur );
load(to);
m_uid = 1; // generate a new one
}
void OTaskEditor::init( const OTodo& to ) {
load( to );
m_uid = to.uid();
}
OTodo OTaskEditor::todo()const{
qWarning("saving!");
OTodo to;
to.setUid(m_uid );
m_overView->save( to );
- to.setDescription( m_line->text() );
+ m_adv->save( to );
+ to.setRecurrence( m_rec->recurrence() );
return to;
}
void OTaskEditor::load(const OTodo& to) {
m_overView->load( to );
- m_line->setText( to.description() );
+ m_adv->load( to );
+ m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() );
}
void OTaskEditor::init() {
- QVBoxLayout* lay = new QVBoxLayout(this);
+ QVBoxLayout* lay = new QVBoxLayout(this );
+ QScrollView* view = new QScrollView( this );
+ view->setResizePolicy( QScrollView::AutoOneFit );
+ lay->addWidget( view );
+
setCaption("Task Editor");
- m_tab = new OTabWidget(this);
+ QWidget* container = new QWidget( view->viewport() );
+ view->addChild( container );
+ QVBoxLayout* layo = new QVBoxLayout( container );
+ m_tab = new OTabWidget(container );
+ layo->addWidget( m_tab );
/*
* Add the Widgets
*/
m_overView = new TaskEditorOverViewImpl(m_tab );
m_tab->addTab( m_overView, QString::null, tr("Overview") );
- m_adv = new TaskEditorAdvanced( m_tab );
- m_line = new QMultiLineEdit(m_adv );
- m_line->setWordWrap( QMultiLineEdit::WidgetWidth );
- QLabel* label = new QLabel(m_adv );
- label->setText( tr("Description") );
- ((QGridLayout*) m_adv->layout() )->addWidget( label,3, 0 );
- ((QGridLayout*) m_adv->layout())->addWidget( m_line,4,0 );
+ m_adv = new TaskEditorAdvancedImpl( m_tab );
m_tab->addTab( m_adv, QString::null, tr("Advanced") );
m_alarm = new TaskEditorAlarms( m_tab );
m_tab->addTab( m_alarm, QString::null, tr("Alarms") );
m_remind = new TaskEditorAlarms( m_tab );
m_tab->addTab( m_remind, QString::null, tr("Reminders") );
QLabel* lbl = new QLabel(m_tab );
lbl->setText( tr("X-Ref") );
m_tab->addTab( lbl, QString::null, tr("X-Ref") );
m_rec = new ORecurranceWidget( true, QDate::currentDate(), this );
m_tab->addTab( m_rec, QString::null, tr("Recurrance") );
- lay->addWidget(m_tab );
/* signal and slots */
connect(m_overView, SIGNAL(recurranceEnabled(bool) ),
m_rec, SLOT(setEnabled(bool) ) );
+ /* connect due date changed to the recurrence tab */
+ connect(m_overView, SIGNAL(dueDateChanged(const QDate&) ),
+ m_rec, SLOT(setStartDate(const QDate& ) ) );
+
+
m_tab->setCurrentTab( m_overView );
}
diff --git a/core/pim/todo/otaskeditor.h b/core/pim/todo/otaskeditor.h
index bcbd543..b43abbf 100644
--- a/core/pim/todo/otaskeditor.h
+++ b/core/pim/todo/otaskeditor.h
@@ -1,44 +1,43 @@
#ifndef OPIE_TASK_EDITOR_H
#define OPIE_TASK_EDITOR_H
#include <qdialog.h>
#include <opie/otodo.h>
#include <opie/otabwidget.h>
class TaskEditorOverViewImpl;
-class TaskEditorAdvanced;
+class TaskEditorAdvancedImpl;
class TaskEditorAlarms;
class ORecurranceWidget;
class QMultiLineEdit;
class OTaskEditor : public QDialog {
Q_OBJECT
public:
OTaskEditor(int cur);
OTaskEditor( const OTodo& todo );
~OTaskEditor();
/*
* same as the c'tor but this gives us the
* power to 'preload' the dialog
*/
void init( int cur );
void init( const OTodo& todo );
OTodo todo()const;
private:
void load( const OTodo& );
void init();
OTabWidget *m_tab;
TaskEditorOverViewImpl* m_overView;
- TaskEditorAdvanced *m_adv;
+ TaskEditorAdvancedImpl *m_adv;
TaskEditorAlarms *m_alarm;
TaskEditorAlarms* m_remind;
ORecurranceWidget* m_rec;
- QMultiLineEdit* m_line;
int m_uid;
};
#endif
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index ded2dbd..0f683c9 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -1,296 +1,296 @@
/*
               =. This file is part of the OPIE Project
             .=l. Copyright (c) 2002 <zecke>
           .>+-=
 _;:,     .>    :=|. 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 <stdlib.h>
#include <cmath>
#include <qlineedit.h>
#include <qtimer.h>
#include <qpoint.h>
#include <qpopupmenu.h>
#include <qpe/config.h>
+#include <opie/orecur.h>
+
#include "mainwindow.h"
//#include "tableitems.h"
#include "tableview.h"
using namespace Todo;
namespace {
static const int BoxSize = 14;
static const int RowHeight = 20;
}
void TableView::initConfig() {
Config config( "todo" );
config.setGroup( "Options" );
m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 );
}
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 );
setColumnStretchable( 3, FALSE );
setColumnWidth(0, 20 );
setColumnWidth(1, 35 );
setColumnWidth(3, 18 );
setLeftMargin( 0 );
verticalHeader()->hide();
horizontalHeader()->setLabel(0, tr("C.") );
horizontalHeader()->setLabel(1, tr("Prior.") );
horizontalHeader()->setLabel(2, tr("Description" ) );
// setColumnStretchable(3, FALSE );
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();
setSortOrder( 0 );
setAscending( TRUE );
m_first = true;
/* now let's init the config */
initConfig();
}
/* a new day has started
* update the day
*/
void TableView::newDay() {
clear();
updateView();
}
TableView::~TableView() {
}
void TableView::slotShowMenu() {
- QPopupMenu *menu = todoWindow()->contextMenu( current() );
+ QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() );
menu->exec(QCursor::pos() );
delete menu;
}
QString TableView::type() const {
return QString::fromLatin1( tr("Table View") );
}
int TableView::current() {
int uid = sorted().uidAt(currentRow() );
- qWarning("uid %d", uid );
+
return uid;
}
QString TableView::currentRepresentation() {
- return text( currentRow(), 2);
+ OTodo to = sorted()[currentRow()];
+ return to.summary().isEmpty() ? to.description().left(20) : to.summary() ;
}
/* show overdue */
void TableView::showOverDue( bool ) {
clear();
updateView();
}
void TableView::updateView( ) {
qWarning("update view");
m_row = false;
static int id;
- id = startTimer(2000 );
+ id = startTimer(4000 );
/* FIXME we want one page to be read!
*
* Calculate that screensize
*/
todoWindow()->setReadAhead( 4 );
sort();
OTodoAccess::List::Iterator it, end;
it = sorted().begin();
end = sorted().end();
qWarning("setTodos");
QTime time;
time.start();
m_enablePaint = false;
setUpdatesEnabled( false );
viewport()->setUpdatesEnabled( false );
setNumRows( it.count() );
if ( it.count() == 0 )
killTimer(id);
int elc = time.elapsed();
setUpdatesEnabled( true );
viewport()->setUpdatesEnabled( true );
viewport()->update();
m_enablePaint = true;
int el = time.elapsed();
}
void TableView::setTodo( int, const OTodo&) {
sort();
/* repaint */
repaint();
}
void TableView::addEvent( const OTodo&) {
/* fix problems of not showing the 'Haken' */
updateView();
}
/*
* find the event
* and then replace the complete row
*/
void TableView::replaceEvent( const OTodo& ev) {
addEvent( ev );
}
/*
* re aligning table can be slow too
* FIXME: look what performs better
* either this or the old align table
*/
void TableView::removeEvent( int ) {
updateView();
}
void TableView::setShowCompleted( bool b) {
qWarning("Show Completed %d" + b );
updateView();
}
void TableView::setShowDeadline( bool b) {
qWarning("Show DeadLine %d" + b );
if (b)
showColumn(3 );
else
hideColumn(3 );
}
void TableView::setShowCategory( const QString& str) {
qWarning("setShowCategory");
if ( str != m_oleCat || m_first )
updateView();
m_oleCat = str;
m_first = false;
}
void TableView::clear() {
setNumRows(0);
}
void TableView::slotClicked(int row, int col, int,
const QPoint& point) {
if ( !cellGeometry(row, col ).contains(point ) )
return;
int ui= sorted().uidAt( row );
switch( col ) {
case 0:{
int x = point.x() -columnPos( col );
int y = point.y() -rowPos( row );
int w = columnWidth( col );
int h = rowHeight( row );
if ( x >= ( w - BoxSize ) / 2 &&
x <= ( w - BoxSize ) / 2 + BoxSize &&
y >= ( h - BoxSize ) / 2 &&
y <= ( h - BoxSize ) / 2 + BoxSize ) {
- OTodo todo = sorted()[row];
- todo.setCompleted( !todo.isCompleted() );
- TodoView::update( todo.uid(), todo );
- updateView();
+ TodoView::complete(sorted()[row] );
}
}
break;
case 1:
break;
case 2: {
m_menuTimer->stop();
showTodo( ui );
break;
}
case 3: {
m_menuTimer->stop();
TodoView::edit( ui );
break;
}
}
}
void TableView::slotPressed(int row, int col, int,
const QPoint& point) {
qWarning("pressed row %d col %d x:%d+y:%d", row,col,point.x(),point.y() );
m_prevP = 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();
}
QWidget* TableView::widget() {
return this;
}
/*
* We need to overwrite sortColumn
* because we want to sort whole row
* based
* We event want to set the setOrder
* to a sort() and update()
*/
void TableView::sortColumn( int col, bool asc, bool ) {
qWarning("bool %d", asc );
@@ -324,204 +324,201 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
QFont f = p->font();
QFontMetrics fm(f);
switch(col) {
case 0:
{
// completed field
int marg = ( cr.width() - BoxSize ) / 2;
int x = 0;
int y = ( cr.height() - BoxSize ) / 2;
p->setPen( QPen( cg.text() ) );
p->drawRect( x + marg, y, BoxSize, BoxSize );
p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
p->setPen( darkGreen );
x += 1;
y += 1;
if ( task.isCompleted() ) {
QPointArray a( 9*2 );
int i, xx, yy;
xx = x+2+marg;
yy = y+4;
for ( i=0; i<4; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy++;
}
yy -= 2;
for ( i=4; i<9; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy--;
}
p->drawLineSegments( a );
}
}
break;
case 1:
// priority field
{
QString text = QString::number(task.priority());
p->drawText(2,2 + fm.ascent(), text);
}
break;
case 2:
// description field
{
QString text = task.summary().isEmpty() ?
- task.description() :
+ task.description().left(20) :
task.summary();
p->drawText(2,2 + fm.ascent(), text);
}
break;
case 3:
{
QString text;
if (task.hasDueDate()) {
int off = QDate::currentDate().daysTo( task.dueDate() );
text = QString::number(off) + tr(" day(s)");
/*
* set color if not completed
*/
if (!task.isCompleted() ) {
QColor color = Qt::black;
if ( off < 0 )
color = Qt::red;
else if ( off == 0 )
color = Qt::yellow;
else if ( off > 0 )
color = Qt::green;
p->setPen(color );
}
} else {
text = tr("None");
}
p->drawText(2,2 + fm.ascent(), text);
}
break;
}
p->restore();
}
QWidget* TableView::createEditor(int row, int col, bool )const {
switch( col ) {
case 1: {
/* the priority stuff */
QComboBox* combo = new QComboBox( viewport() );
combo->insertItem( "1" );
combo->insertItem( "2" );
combo->insertItem( "3" );
combo->insertItem( "4" );
combo->insertItem( "5" );
combo->setCurrentItem( sorted()[row].priority()-1 );
return combo;
}
/* summary */
case 2:{
QLineEdit* edit = new QLineEdit( viewport() );
edit->setText( sorted()[row].summary() );
return edit;
}
case 0:
default:
return 0l;
}
}
void TableView::setCellContentFromEditor(int row, int col ) {
if ( col == 1 ) {
QWidget* wid = cellWidget(row, 1 );
if ( wid->inherits("QComboBox") ) {
int pri = ((QComboBox*)wid)->currentItem() + 1;
OTodo todo = sorted()[row];
if ( todo.priority() != pri ) {
todo.setPriority( pri );
TodoView::update( todo.uid(), todo );
updateView();
}
}
}else if ( col == 2) {
QWidget* wid = cellWidget(row, 2);
if ( wid->inherits("QLineEdit") ) {
QString text = ((QLineEdit*)wid)->text();
OTodo todo = sorted()[row];
if ( todo.summary() != text ) {
todo.setSummary( text );
TodoView::update( todo.uid(), todo );
updateView();
}
}
}
}
void TableView::slotPriority() {
setCellContentFromEditor( currentRow(), currentColumn() );
}
/*
* We'll use the TimerEvent to read ahead or to keep the cahce always
* filled enough.
* We will try to read ahead 4 items in both ways
* up and down. On odd or even we will currentRow()+-4 or +-9
*
*/
void TableView::timerEvent( QTimerEvent* ev ) {
- qWarning("sorted %d", sorted().count() );
+// qWarning("sorted %d", sorted().count() );
if (sorted().count() == 0 )
return;
int row = currentRow();
if ( m_row ) {
int ro = row-4;
if (ro < 0 ) ro = 0;
sorted()[ro];
ro = row+4;
sorted()[ro];
} else {
int ro = row + 8;
sorted()[ro];
ro = row-8;
if (ro < 0 ) ro = 0;
sorted()[ro];
}
m_row = !m_row;
}
// We want a strike through completed ;)
// durchstreichen to complete
/*
* MouseTracking is off this mean we only receive
* these events if the mouse button is pressed
* We've the previous point saved
* We check if the previous and current Point are
* in the same row.
* Then we check if they're some pixel horizontal away
* if the distance between the two points is greater than
* 8 we mark the underlying todo as completed and do a repaint
*
* BUG: When clicking on the Due column and it's scrollable
* the todo is marked as completed...
* REASON: QTable is doing auto scrolling which leads to a move
* in the x coordinate and this way it's able to pass the
* m_completeStrokeWidth criteria
* WORKAROUND: strike through needs to strike through the same
* row and two columns!
*/
void TableView::contentsMouseReleaseEvent( QMouseEvent* e) {
int row = rowAt(m_prevP.y());
int colOld = columnAt(m_prevP.x() );
int colNew = columnAt(e->x() );
qWarning("colNew: %d colOld: %d", colNew, colOld );
if ( row == rowAt( e->y() ) && row != -1 &&
colOld != colNew ) {
- OTodo todo = sorted()[row];
- todo.setCompleted( !todo.isCompleted() );
- TodoView::update( todo.uid(), todo );
- updateView();
- return;
+ TodoView::complete( sorted()[row] );
+ return;
}
QTable::contentsMouseReleaseEvent( e );
}
void TableView::contentsMouseMoveEvent( QMouseEvent* e ) {
m_menuTimer->stop();
QTable::contentsMouseMoveEvent( e );
}
diff --git a/core/pim/todo/taskeditoradvanced.ui b/core/pim/todo/taskeditoradvanced.ui
index 3ea1346..6160712 100644
--- a/core/pim/todo/taskeditoradvanced.ui
+++ b/core/pim/todo/taskeditoradvanced.ui
@@ -1,62 +1,62 @@
<!DOCTYPE UI><UI>
<class>TaskEditorAdvanced</class>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>TaskEditorAdvanced</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>236</width>
+ <width>232</width>
<height>307</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Form2</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>8</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget row="0" column="0" >
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout13</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>lblState</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>State:</string>
</property>
</widget>
@@ -150,73 +150,79 @@
<number>6</number>
</property>
<widget>
<class>QToolButton</class>
<property stdset="1">
<name>name</name>
<cstring>tbtMaintainer</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>...</string>
</property>
</widget>
</vbox>
</widget>
</hbox>
</widget>
<widget row="1" column="0" >
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout4</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>txtMode</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Maintain Mode:</string>
</property>
</widget>
<widget>
<class>QComboBox</class>
<item>
<property>
<name>text</name>
+ <string>Nothing</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
<string>Responsible</string>
</property>
</item>
<item>
<property>
<name>text</name>
<string>Done By</string>
</property>
</item>
<item>
<property>
<name>text</name>
<string>Coordinating</string>
</property>
</item>
<property stdset="1">
<name>name</name>
<cstring>cmbMode</cstring>
</property>
</widget>
</hbox>
</widget>
</grid>
</widget>
</UI>
diff --git a/core/pim/todo/taskeditoroverviewimpl.cpp b/core/pim/todo/taskeditoroverviewimpl.cpp
index 24b3386..aef3b1d 100644
--- a/core/pim/todo/taskeditoroverviewimpl.cpp
+++ b/core/pim/todo/taskeditoroverviewimpl.cpp
@@ -1,182 +1,221 @@
#include <qapplication.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qpopupmenu.h>
#include <qpe/datebookmonth.h>
#include <qpe/categoryselect.h>
#include <qpe/timestring.h>
+#include <opie/orecur.h>
+
#include "taskeditoroverviewimpl.h"
/*
* we need to hack
*/
TaskEditorOverViewImpl::TaskEditorOverViewImpl( QWidget* parent, const char* name )
: TaskEditorOverView( parent, name ) {
init();
}
TaskEditorOverViewImpl::~TaskEditorOverViewImpl() {
}
void TaskEditorOverViewImpl::load( const OTodo& todo) {
- /*
+ /*
* now that we're 'preloaded' we
* need to disable the buttons
* holding the dat
*/
btnDue-> setEnabled( FALSE );
btnComp-> setEnabled( FALSE );
btnStart->setEnabled( FALSE );
-
+ /*
+ * get some basic dateinfos for now
+ */
QDate date = QDate::currentDate();
QString str = TimeString::longDateString( date );
- emit recurranceEnabled( FALSE );
- ckbStart->setChecked( FALSE );
- btnStart->setText( str );
+ CheckBox7->setChecked( todo.recurrence().doesRecur() );
+ emit recurranceEnabled( todo.recurrence().doesRecur() );
+
- ckbComp->setChecked( FALSE );
- btnComp->setText( str );
+ ckbStart->setChecked( todo.hasStartDate() );
+ btnStart->setEnabled( todo.hasStartDate() );
+ if ( todo.hasStartDate() ) {
+ m_start = todo.startDate();
+ btnStart->setText( TimeString::longDateString( m_start ) );
+ } else
+ btnStart->setText( str );
+
+ ckbComp->setChecked( todo.hasCompletedDate() );
+ btnComp->setEnabled( todo.hasCompletedDate() );
+ if ( todo.hasCompletedDate() ) {
+ m_comp = todo.completedDate();
+ btnComp->setText( TimeString::longDateString( m_comp ) );
+ }else
+ btnComp->setText( str );
cmbProgress->setCurrentItem( todo.progress()/20 );
cmbSum->insertItem( todo.summary(), 0 );
cmbSum->setCurrentItem( 0 );
ckbDue->setChecked( todo.hasDueDate() );
btnDue->setText( TimeString::longDateString( todo.dueDate() ) );
btnDue->setEnabled( todo.hasDueDate() );
+ m_due = todo.dueDate();
cmbPrio->setCurrentItem( todo.priority() -1 );
ckbCompleted->setChecked( todo.isCompleted() );
comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") );
}
void TaskEditorOverViewImpl::save( OTodo& to) {
- qWarning("save it now");
+ /* a invalid date */
+ QDate inval;
+ /* save our info back */
+
+ /* due date */
if ( ckbDue->isChecked() ) {
to.setDueDate( m_due );
to.setHasDueDate( true );
}else
to.setHasDueDate( false );
+
+ /* start date */
+ if ( ckbStart->isChecked() ) {
+ to.setStartDate( m_start );
+ }else
+ to.setStartDate( inval );
+
+ /* comp date */
+ if ( ckbComp->isChecked() ) {
+ qWarning("completed checked");
+ to.setCompletedDate( m_comp );
+ }else
+ to.setCompletedDate( inval );
+
+
if ( comboCategory->currentCategory() != -1 ) {
QArray<int> arr = comboCategory->currentCategories();
to.setCategories( arr );
}
to.setPriority( cmbPrio->currentItem() + 1 );
to.setCompleted( ckbCompleted->isChecked() );
to.setSummary( cmbSum->currentText() );
to.setProgress( cmbProgress->currentItem() * 20 );
}
/*
* here we will init the basic view
* one Popup for each Date Button
* and some other signal and slots connection
*/
void TaskEditorOverViewImpl::init() {
QDate curDate = QDate::currentDate();
m_start = m_comp = m_due = curDate;
QString str = TimeString::longDateString( curDate );
/* Start Date Picker */
m_startPop = new QPopupMenu(this);
m_startBook = new DateBookMonth(m_startPop, 0, TRUE );
m_startPop->insertItem( m_startBook );
connect( m_startBook, SIGNAL( dateClicked(int, int, int) ),
this, SLOT(slotStartChanged(int, int, int) ) );
/* Due Date Picker */
m_duePop = new QPopupMenu(this);
m_dueBook = new DateBookMonth(m_duePop, 0, TRUE );
m_duePop->insertItem( m_dueBook );
connect( m_dueBook, SIGNAL( dateClicked(int, int, int) ),
this, SLOT(slotDueChanged(int, int, int) ) );
m_compPop = new QPopupMenu(this);
m_compBook = new DateBookMonth(m_compPop, 0, TRUE );
m_compPop->insertItem(m_compBook );
connect( m_compBook, SIGNAL(dateClicked(int, int, int) ),
this, SLOT(slotCompletedChanged(int, int, int) ) );
/*
* another part of the hack
* it's deprecated in Qt2 but
* still available in my qt-copy of Qt3.1beta2
*/
btnDue->setIsMenuButton( TRUE );
btnStart->setIsMenuButton( TRUE );
btnComp->setIsMenuButton( TRUE );
/* now connect the hack */
connect(btnDue, SIGNAL(clicked() ),
this, SLOT(hackySlotHack2() ) );
connect(btnStart, SIGNAL(clicked() ),
this, SLOT(hackySlotHack1() ) );
connect(btnComp, SIGNAL(clicked() ),
this, SLOT(hackySlotHack3() ) );
/* recurrance */
connect(CheckBox7, SIGNAL(clicked() ),
this, SLOT(slotRecClicked() ) );
}
void TaskEditorOverViewImpl::slotStartChecked() {
qWarning("slotStartChecked");
btnStart->setEnabled( ckbStart->isChecked() );
}
void TaskEditorOverViewImpl::slotStartChanged(int y, int m, int d) {
m_start.setYMD( y, m, d );
btnStart->setText( TimeString::longDateString( m_start ) );
}
void TaskEditorOverViewImpl::slotDueChecked() {
btnDue->setEnabled( ckbDue->isChecked() );
+ emit dueDateChanged( m_due );
qWarning("slotDueChecked");
}
void TaskEditorOverViewImpl::slotDueChanged(int y, int m, int d ) {
m_due.setYMD(y, m, d );
btnDue->setText( TimeString::longDateString( m_due ) );
+ emit dueDateChanged( m_due );
}
void TaskEditorOverViewImpl::slotCompletedChecked() {
btnComp->setEnabled( ckbComp->isChecked() );
qWarning("slotCompletedChecked");
}
void TaskEditorOverViewImpl::slotCompletedChanged(int y, int m, int d) {
m_comp.setYMD( y, m, d );
btnComp->setText( TimeString::longDateString( m_comp ) );
}
/*
* called by a button pressed event...
* three slots to avoid ugly name() tests
* to sender()
*/
void TaskEditorOverViewImpl::hackySlotHack1() {
btnStart->setDown( FALSE );
popup( btnStart, m_startPop );
}
void TaskEditorOverViewImpl::hackySlotHack2() {
btnDue->setDown( FALSE );
popup( btnDue, m_duePop );
}
void TaskEditorOverViewImpl::hackySlotHack3() {
btnComp->setDown( FALSE );
popup( btnComp, m_compPop );
}
void TaskEditorOverViewImpl::slotRecClicked() {
qWarning("enabled recurrance");
emit recurranceEnabled( CheckBox7->isChecked() );
}
/*
* GPL from TT QPushButton code
*/
void TaskEditorOverViewImpl::popup( QPushButton* pu, QPopupMenu* pop) {
if ( pu->mapToGlobal( QPoint(0, pu->rect().bottom() ) ).y() + pop->sizeHint().height() <= qApp->desktop()->height() )
pop->exec( pu->mapToGlobal( pu->rect().bottomLeft() ) );
else
pop->exec( pu->mapToGlobal( pu->rect().topLeft() - QPoint(0, pu->sizeHint().height() ) ) );
}
diff --git a/core/pim/todo/taskeditoroverviewimpl.h b/core/pim/todo/taskeditoroverviewimpl.h
index 4fab381..5ee985e 100644
--- a/core/pim/todo/taskeditoroverviewimpl.h
+++ b/core/pim/todo/taskeditoroverviewimpl.h
@@ -1,54 +1,55 @@
#ifndef OPIE_TASK_EDITOR_VIEW_IMPL_H
#define OPIE_TASK_EDITOR_VIEW_IMPL_H
#include <qsize.h>
#include <opie/otodo.h>
#include "taskeditoroverview.h"
class DateBookMonth;
class QPushButton;
class QPopupMenu;
class TaskEditorOverViewImpl : public TaskEditorOverView {
Q_OBJECT
public:
TaskEditorOverViewImpl(QWidget* parent, const char* name = 0);
~TaskEditorOverViewImpl();
void load( const OTodo& );
void save( OTodo& );
signals:
void recurranceEnabled( bool );
+ void dueDateChanged( const QDate& date );
private:
void init();
void popup(QPushButton*, QPopupMenu*);
DateBookMonth* m_dueBook;
DateBookMonth* m_startBook;
DateBookMonth* m_compBook;
QDate m_start;
QDate m_comp;
QDate m_due;
QPopupMenu* m_startPop;
QPopupMenu* m_compPop;
QPopupMenu* m_duePop;
bool m_bDue : 1;
private slots:
void slotStartChecked();
void slotStartChanged(int, int, int );
void slotDueChecked();
void slotDueChanged(int, int, int );
void slotCompletedChecked();
void slotCompletedChanged(int, int, int );
void hackySlotHack1();
void hackySlotHack2();
void hackySlotHack3();
void slotRecClicked();
};
#endif
diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro
index 8f21416..40a5f28 100644
--- a/core/pim/todo/todo.pro
+++ b/core/pim/todo/todo.pro
@@ -1,61 +1,63 @@
TEMPLATE = app
CONFIG = qt warn_on release
DESTDIR = $(OPIEDIR)/bin
HEADERS = smalltodo.h \
todomanager.h \
mainwindow.h \
todoview.h \
tableview.h \
tableitems.h \
todotemplatemanager.h \
todoeditor.h \
todoshow.h \
textviewshow.h \
templateeditor.h \
templatedialog.h \
templatedialogimpl.h \
quickedit.h \
quickeditimpl.h \
otaskeditor.h \
- taskeditoroverviewimpl.h
+ taskeditoroverviewimpl.h \
+ taskeditoradvancedimpl.h
SOURCES = smalltodo.cpp \
todomanager.cpp \
mainwindow.cpp \
main.cpp \
tableview.cpp \
tableitems.cpp \
todoview.cpp \
todotemplatemanager.cpp \
todoeditor.cpp \
todoshow.cpp \
textviewshow.cpp \
templateeditor.cpp \
templatedialog.cpp \
templatedialogimpl.cpp \
quickeditimpl.cpp \
quickedit.cpp \
otaskeditor.cpp \
- taskeditoroverviewimpl.cpp
+ taskeditoroverviewimpl.cpp \
+ taskeditoradvancedimpl.cpp
INTERFACES = taskeditoradvanced.ui taskeditoralarms.ui taskeditoroverview.ui
TARGET = todolist
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie
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/todomanager.cpp b/core/pim/todo/todomanager.cpp
index 1f81539..b5b87de 100644
--- a/core/pim/todo/todomanager.cpp
+++ b/core/pim/todo/todomanager.cpp
@@ -40,87 +40,90 @@ TodoManager::TodoManager( QObject *obj )
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() {
qWarning("update list");
m_list = m_db->allRecords();
}
OTodoAccess::List TodoManager::list() const{
return m_list;
}
OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) {
return m_db->sorted( asc, so, f, cat );
}
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 );
+bool TodoManager::remove( int uid ) {
+ return m_db->remove( uid );
}
void TodoManager::removeAll() {
m_db->clear();
}
+void TodoManager::removeCompleted() {
+ m_db->removeAllCompleted();
+}
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) {
qWarning("loading!");
m_db = new OTodoAccess();
m_db->load();
}
}
diff --git a/core/pim/todo/todomanager.h b/core/pim/todo/todomanager.h
index b03b598..8544277 100644
--- a/core/pim/todo/todomanager.h
+++ b/core/pim/todo/todomanager.h
@@ -37,70 +37,75 @@
#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 list()const;
OTodoAccess::List sorted( bool asc, int so, int f, int cat );
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 );
+ bool remove( int uid );
void remove( const QArray<int>& );
+
+ /**
+ * remove all completed
+ */
+ void removeCompleted();
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/todoview.cpp b/core/pim/todo/todoview.cpp
index 4cf7d30..3e808e7 100644
--- a/core/pim/todo/todoview.cpp
+++ b/core/pim/todo/todoview.cpp
@@ -1,79 +1,66 @@
#include "mainwindow.h"
#include "todoview.h"
using namespace Todo;
+
+
+
TodoView::TodoView( MainWindow* win )
: m_main( win )
{
- hack = new InternQtHack;
m_asc = false;
m_sortOrder = -1;
}
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 ); }
+OTodo TodoView::event(int uid ) {
+ return m_main->event( uid );
+}
OTodoAccess::List TodoView::list(){
todoWindow()->updateList();
return todoWindow()->list();
}
OTodoAccess::List TodoView::sorted()const{
return m_sort;
}
void TodoView::sort() {
m_sort = todoWindow()->sorted(m_asc,m_sortOrder );
qWarning("m_sort.count() = %d", m_sort.count() );
}
void TodoView::sort(int sort) {
m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort );
}
void TodoView::setSortOrder( int order ) {
m_sortOrder = order;
}
void TodoView::setAscending( bool b ) {
qWarning("setAscending %d", b );
m_asc = b;
}
void TodoView::update(int, const SmallTodo& ) {
//m_main->slotUpate1( uid, to );
}
void TodoView::update(int , const OTodo& ev ) {
m_main->updateTodo( ev );
}
+void TodoView::showTodo( int uid ) {
+ m_main->slotShow( uid );
+}
+void TodoView::edit( int uid ) {
+ m_main->slotEdit( uid );
+}
+void TodoView::remove( int uid ) {
+ m_main->m_todoMgr.remove( uid );
+}
+void TodoView::complete( int uid ) {
+ m_main->slotComplete( uid );
+}
+void TodoView::complete( const OTodo& ev ) {
+ m_main->slotComplete( ev );
+}
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h
index e5c77f9..e73e808 100644
--- a/core/pim/todo/todoview.h
+++ b/core/pim/todo/todoview.h
@@ -1,188 +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 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 {
+ struct ViewBase {
public:
virtual QWidget* widget() = 0;
virtual QString type()const = 0;
virtual int current() = 0;
virtual QString currentRepresentation() = 0;
virtual void showOverDue( bool ) = 0;
/*
* update the view
*/
virtual void updateView() = 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 list();
OTodoAccess::List sorted()const;
void sort();
void sort(int sort );
void setSortOrder( int order );
void setAscending( bool );
/*
- 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); }
+ * These things needs to be implemented
+ * in a implementation
+ */
+ void showTodo( int uid );
+ void edit( int uid );
void update(int uid, const SmallTodo& to );
void update(int uid, const OTodo& ev);
- void remove( int uid ) {
- hack->emitRemove( uid );
- }
+ void remove( int uid );
+ void complete( int uid );
+ void complete( const OTodo& ev );
private:
- InternQtHack* hack;
MainWindow *m_main;
OTodoAccess::List m_sort;
bool m_asc : 1;
int m_sortOrder;
};
};
#endif