summaryrefslogtreecommitdiff
path: root/core/pim/todo/todotable.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/todo/todotable.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/todotable.cpp68
1 files changed, 64 insertions, 4 deletions
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 )
{