summaryrefslogtreecommitdiff
Side-by-side diff
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,5 +1,7 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
+ Copyright (C) 2002 zecke
+ Copyright (C) 2002 Stefan Eilers
**
** This file is part of Qtopia Environment.
**
@@ -107,6 +109,11 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
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 );
@@ -174,6 +181,9 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
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();
@@ -195,6 +205,7 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
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 ) ) );
@@ -351,6 +362,8 @@ void TodoWindow::populateCategories()
completedAction->addTo( catMenu );
completedAction->setOn( table->showCompleted() );
+ showdeadlineAction->addTo( catMenu );
+ showdeadlineAction->setOn( table->showDeadline() );
int id, rememberId;
id = 1;
@@ -402,6 +415,8 @@ void TodoWindow::closeEvent( QCloseEvent *e )
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"
@@ -473,3 +488,11 @@ 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
@@ -47,6 +47,10 @@ protected slots:
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();
@@ -64,8 +68,9 @@ private:
TodoTable *table;
QAction *editAction,
*deleteAction,
- *findAction,
- * completedAction;
+ *findAction,
+ * completedAction,
+ *showdeadlineAction ;
QPopupMenu *contextMenu, *catMenu;
bool syncing;
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
@@ -48,7 +48,7 @@ NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent,
todo( task )
{
qWarning("setting category" );
- todo.setCategory( task.category() );
+ todo.setCategories( task.allCategories() );
if ( todo.hasDate() )
date = todo.date();
else
@@ -128,10 +128,10 @@ ToDoEvent NewTaskDialog::todoEntry()
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() );
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
@@ -17,7 +17,8 @@
** not clear to you.
**
**********************************************************************/
-
+/* Show Deadline was added by Stefan Eilers (se, eilers.stefan@epost.de)
+ */
#include "todotable.h"
#include <opie/tododb.h>
@@ -38,6 +39,8 @@
#include <errno.h>
#include <stdlib.h>
+#include <stdio.h>
+
static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category );
@@ -164,12 +167,13 @@ 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 );
@@ -177,11 +181,23 @@ TodoTable::TodoTable( QWidget *parent, const char *name )
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 & ) ),
@@ -234,6 +250,11 @@ void TodoTable::slotClicked( int row, int col, int, const QPoint &pos )
menuTimer->stop();
// emit signalEdit();
break;
+ case 3: /* added 20.01.2k2 by se */
+ // may as well edit it...
+ menuTimer->stop();
+ emit signalEdit();
+ break;
}
}
@@ -265,6 +286,8 @@ void TodoTable::internalAddEntries( QList<ToDoEvent> &list )
ToDoEvent TodoTable::currentEntry() const
{
+ printf ("in currentEntry\n");
+
QTableItem *i = item( currentRow(), 0 );
if ( !i || rowHeight( currentRow() ) <= 0 )
return ToDoEvent();
@@ -354,6 +377,15 @@ void TodoTable::updateVisible()
// 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++ ) {
@@ -455,7 +487,7 @@ void TodoTable::slotCheckPriority(int row, int col )
}
-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) )
@@ -508,6 +540,20 @@ void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int 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;
}
}
@@ -518,6 +564,20 @@ void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row )
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) );
}
}
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
@@ -98,6 +98,10 @@ public:
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;
@@ -159,6 +163,9 @@ private:
bool enablePainting;
Categories mCat;
int currFindRow;
+
+ /* added 20.01.2k2 by se */
+ bool showDeadl;
};
@@ -174,10 +181,25 @@ inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row )
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 );
}