summaryrefslogtreecommitdiff
authorzecke <zecke>2002-04-13 16:28:40 (UTC)
committer zecke <zecke>2002-04-13 16:28:40 (UTC)
commit1eb54898047fab3963debe51fa3e570b361a1215 (patch) (side-by-side diff)
tree7ba017af1f2807d9710577817e4a13876900a0a7
parentdef870c6fcccf2b20d7ce3821055391b18243a24 (diff)
downloadopie-1eb54898047fab3963debe51fa3e570b361a1215.zip
opie-1eb54898047fab3963debe51fa3e570b361a1215.tar.gz
opie-1eb54898047fab3963debe51fa3e570b361a1215.tar.bz2
move to multiple categories + patch from Stefan Eilers to show the due date
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp23
-rw-r--r--core/pim/todo/mainwindow.h9
-rw-r--r--core/pim/todo/todoentryimpl.cpp8
-rw-r--r--core/pim/todo/todotable.cpp68
-rw-r--r--core/pim/todo/todotable.h22
5 files changed, 120 insertions, 10 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index f3afa5f..33f13aa 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,8 +1,10 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
+ Copyright (C) 2002 zecke
+ Copyright (C) 2002 Stefan Eilers
**
** 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
@@ -104,12 +106,17 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
// qDebug("after load: t=%d", t.elapsed() );
Config config( "todo" );
config.setGroup( "View" );
bool complete = config.readBoolEntry( "ShowComplete", true );
table->setShowCompleted( complete );
+
+ /* added 20.01.2k2 by se */
+ bool showdeadline = config.readBoolEntry("ShowDeadLine", true);
+ table->setShowDeadline (showdeadline);
+
QString category = config.readEntry( "Category", QString::null );
table->setShowCategory( category );
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
@@ -171,12 +178,15 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
//a->setEnabled( FALSE );
findAction = a;
// qDebug("mainwindow #2: t=%d", t.elapsed() );
completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE );
+ /* added 20.01.2k2 by se */
+ showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE );
+
catMenu->setCheckable( true );
populateCategories();
mb->insertItem( tr( "Task" ), edit );
mb->insertItem( tr( "View" ), catMenu );
@@ -192,12 +202,13 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
table->updateVisible();
table->setUpdatesEnabled( TRUE );
table->setPaintingEnabled( TRUE );
table->viewport()->setUpdatesEnabled( TRUE );
connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) );
+ connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) );
connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) );
connect( table, SIGNAL( currentChanged( int, int ) ),
this, SLOT( currentEntryChanged( int, int ) ) );
// qDebug("done: t=%d", t.elapsed() );
}
@@ -348,12 +359,14 @@ void TodoWindow::setCategory( int c )
void TodoWindow::populateCategories()
{
catMenu->clear();
completedAction->addTo( catMenu );
completedAction->setOn( table->showCompleted() );
+ showdeadlineAction->addTo( catMenu );
+ showdeadlineAction->setOn( table->showDeadline() );
int id, rememberId;
id = 1;
catMenu->insertItem( tr( "All Categories" ), id++ );
// catMenu->insertSeparator();
QStringList categories = table->categories();
@@ -399,12 +412,14 @@ void TodoWindow::closeEvent( QCloseEvent *e )
// error, but I feel that it is "ok" for us to exit
// espically since we aren't told if the write succeeded...
Config config( "todo" );
config.setGroup( "View" );
config.writeEntry( "ShowComplete", table->showCompleted() );
config.writeEntry( "Category", table->showCategory() );
+ /* added 20.01.2k2 by se */
+ config.writeEntry( "ShowDeadLine", table->showDeadline());
} 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"
@@ -470,6 +485,14 @@ void TodoWindow::slotBeam()
void TodoWindow::beamDone( Ir *ir )
{
delete ir;
unlink( beamfile );
}
+
+/* added 20.01.2k2 by se */
+void TodoWindow::showDeadline( bool s )
+{
+ table->setPaintingEnabled( false );
+ table->setShowDeadline( s );
+ table->setPaintingEnabled( true );
+}
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
index 856dcb4..a81c27c 100644
--- a/core/pim/todo/mainwindow.h
+++ b/core/pim/todo/mainwindow.h
@@ -44,12 +44,16 @@ public slots:
protected slots:
void slotNew();
void slotDelete();
void slotEdit();
void slotShowPopup( const QPoint & );
void showCompleted( bool );
+
+ /* added 20.01.2k2 by se */
+ void showDeadline( bool );
+
void currentEntryChanged( int r, int c );
void setCategory( int );
void slotFind();
void setDocument( const QString & );
void slotBeam();
void beamDone( Ir * );
@@ -61,14 +65,15 @@ private:
void populateCategories();
private:
TodoTable *table;
QAction *editAction,
*deleteAction,
- *findAction,
- * completedAction;
+ *findAction,
+ * completedAction,
+ *showdeadlineAction ;
QPopupMenu *contextMenu, *catMenu;
bool syncing;
};
#endif
diff --git a/core/pim/todo/todoentryimpl.cpp b/core/pim/todo/todoentryimpl.cpp
index 1dc1d44..f938d61 100644
--- a/core/pim/todo/todoentryimpl.cpp
+++ b/core/pim/todo/todoentryimpl.cpp
@@ -45,13 +45,13 @@
NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent,
const char *name, bool modal, WFlags fl )
: NewTaskDialogBase( parent, name, modal, fl ),
todo( task )
{
qWarning("setting category" );
- todo.setCategory( task.category() );
+ todo.setCategories( task.allCategories() );
if ( todo.hasDate() )
date = todo.date();
else
date = QDate::currentDate();
init();
@@ -125,16 +125,16 @@ ToDoEvent NewTaskDialog::todoEntry()
}else{
todo.setHasDate( false );
}
qWarning("todoEntry::category()" );
if ( comboCategory->currentCategory() != -1 ) {
QArray<int> arr = comboCategory->currentCategories();
- int id = arr[0];
- qWarning("id 0: %d",id );
- todo.setCategory( Qtopia::Record::idsToString( arr ) );
+ QStringList list;
+ list = QStringList::split(";", Qtopia::Record::idsToString( arr )) ;
qWarning("saving category");
+ todo.setCategories( list );
}
todo.setPriority( comboPriority->currentItem() + 1 );
todo.setCompleted( checkCompleted->isChecked() );
todo.setDescription( txtTodo->text() );
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp
index 2bb95a2..3cd0c0e 100644
--- a/core/pim/todo/todotable.cpp
+++ b/core/pim/todo/todotable.cpp
@@ -14,13 +14,14 @@
** 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.
**
**********************************************************************/
-
+/* Show Deadline was added by Stefan Eilers (se, eilers.stefan@epost.de)
+ */
#include "todotable.h"
#include <opie/tododb.h>
#include <qpe/categoryselect.h>
#include <qpe/xmlreader.h>
@@ -35,12 +36,14 @@
#include <qcursor.h>
#include <qregexp.h>
#include <errno.h>
#include <stdlib.h>
+#include <stdio.h>
+
static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category );
static QString journalFileName();
@@ -161,30 +164,43 @@ QString ComboItem::text() const
TodoTable::TodoTable( QWidget *parent, const char *name )
// #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR
// : QTable( 0, 3, parent, name, TRUE ),
// #else
- : QTable( 0, 3, parent, name ),
+ : QTable( 0, 4, parent, name ),
// #endif
showComp( true ),
enablePainting( true ),
mCat( 0 ),
- currFindRow( -2 )
+ currFindRow( -2 ),
+ showDeadl( true)
{
mCat.load( categoryFileName() );
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 (showDeadl){
+ showColumn (3);
+ }else{
+ hideColumn (3);
+ }
+
connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ),
this, SLOT( slotClicked( int, int, int, const QPoint & ) ) );
connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ),
this, SLOT( slotPressed( int, int, int, const QPoint & ) ) );
connect( this, SIGNAL( valueChanged( int, int ) ),
this, SLOT( slotCheckPriority( int, int ) ) );
@@ -231,12 +247,17 @@ void TodoTable::slotClicked( int row, int col, int, const QPoint &pos )
break;
case 2:
// may as well edit it...
menuTimer->stop();
// emit signalEdit();
break;
+ case 3: /* added 20.01.2k2 by se */
+ // may as well edit it...
+ menuTimer->stop();
+ emit signalEdit();
+ break;
}
}
void TodoTable::slotPressed( int row, int col, int, const QPoint &pos )
{
if ( col == 2 && cellGeometry( row, col ).contains(pos) )
@@ -262,12 +283,14 @@ void TodoTable::internalAddEntries( QList<ToDoEvent> &list )
insertIntoTable( it, row++ );
}
ToDoEvent TodoTable::currentEntry() const
{
+ printf ("in currentEntry\n");
+
QTableItem *i = item( currentRow(), 0 );
if ( !i || rowHeight( currentRow() ) <= 0 )
return ToDoEvent();
ToDoEvent *todo = todoList[(CheckItem*)i];
todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() );
todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() );
@@ -351,12 +374,21 @@ void TodoTable::updateVisible()
{
if ( !isUpdatesEnabled() )
return;
// qDebug("--> updateVisible!");
+ /* added 20.01.2k2 by se */
+ if (showDeadl){
+ showColumn (3);
+ adjustColumn(3);
+ }else{
+ hideColumn (3);
+ adjustColumn(2);
+ }
+
int visible = 0;
int id = mCat.id( "Todo List", showCat );
for ( int row = 0; row < numRows(); row++ ) {
CheckItem *ci = (CheckItem *)item( row, 0 );
ToDoEvent *t = todoList[ci];
QArray<int> vlCats = t->categories();
@@ -452,13 +484,13 @@ void TodoTable::slotCheckPriority(int row, int col )
ComboItem* i = static_cast<ComboItem*>( item( row, col ) );
emit signalPriorityChanged( i->text().toInt() );
}
}
-void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action, int row )
+void TodoTable::updateJournal( const ToDoEvent &/*todo*/, journal_action action, int row )
{
QFile f( journalFileName() );
if ( !f.open(IO_WriteOnly|IO_Append) )
return;
QString buf;
QCString str;
@@ -505,22 +537,50 @@ void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row )
for ( it = todoList.begin(); it != todoList.end(); ++it ) {
if ( *(*it) == todo ) {
row = it.key()->row();
it.key()->setChecked( todo.isCompleted() );
static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) );
item( row, 2 )->setText( strTodo );
+
+ /* added 20.01.2k2 by se */
+ if (showDeadl){
+ if (todo.hasDate()){
+ QDate *today = new QDate (QDate::currentDate());
+ if (today){
+ item (row, 3)->setText (tr ("%1").arg(today->daysTo(todo.date())));
+ delete (today);
+ }
+ }else{
+ item (row, 3)->setText ("n.d.");
+ }
+ }
+
*(*it) = todo;
}
}
} else {
ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))];
todoList.remove( static_cast<CheckItem*>(item(row, 0)) );
delete t;
static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() );
static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) );
item( row, 2 )->setText( strTodo );
+
+ /* added 20.01.2k2 by se */
+ if (showDeadl){
+ if (todo.hasDate()){
+ QDate *today = new QDate (QDate::currentDate());
+ if (today){
+ item (row, 3)->setText (tr ("%1").arg(today->daysTo(todo.date())));
+ delete (today);
+ }
+ }else{
+ item (row, 3)->setText ("n.d.");
+ }
+ }
+
todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) );
}
}
void TodoTable::journalFreeRemoveEntry( int row )
{
diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h
index 2746ce7..288ff90 100644
--- a/core/pim/todo/todotable.h
+++ b/core/pim/todo/todotable.h
@@ -95,12 +95,16 @@ public:
QStringList categories();
void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); }
bool showCompleted() const { return showComp; }
+ /* added 20.01.2k2 by se */
+ void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();}
+ bool showDeadline() const { return showDeadl;}
+
void setShowCategory( const QString &c ) { showCat = c; updateVisible(); }
const QString &showCategory() const { return showCat; }
int showCategoryId() const;
bool save( const QString &fn );
void load( const QString &fn );
@@ -156,12 +160,15 @@ private:
bool showComp;
QString showCat;
QTimer *menuTimer;
bool enablePainting;
Categories mCat;
int currFindRow;
+
+ /* added 20.01.2k2 by se */
+ bool showDeadl;
};
inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row )
{
QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A')
@@ -171,16 +178,31 @@ inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row )
chk->setChecked( todo->isCompleted() );
ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent );
cmb->setText( QString::number( todo->priority() ) );
QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() );
ti->setReplaceable( false );
+ /* added 20.01.2k2 by se */
+ QTableItem *dl = NULL;
+ if (todo->hasDate()){
+ QDate *today = new QDate (QDate::currentDate());
+ if (today){
+ dl = new TodoTextItem (this, tr ("%1").
+ arg(today->daysTo(todo->date())));
+ delete (today);
+ }
+ }else{
+ dl = new TodoTextItem (this,"n.d.");
+ }
+ setItem( row, 3, dl);
+
setItem( row, 0, chk );
setItem( row, 1, cmb );
setItem( row, 2, ti );
+
todoList.insert( chk, todo );
}
inline void TodoTable::realignTable( int row )
{
QTableItem *ti1,