summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp4
-rw-r--r--core/pim/todo/todotable.cpp98
-rw-r--r--core/pim/todo/todotable.h43
3 files changed, 87 insertions, 58 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 33f13aa..a34bcf2 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -112,3 +112,2 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
- /* added 20.01.2k2 by se */
bool showdeadline = config.readBoolEntry("ShowDeadLine", true);
@@ -183,3 +182,2 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
- /* added 20.01.2k2 by se */
showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE );
@@ -366,3 +364,3 @@ void TodoWindow::populateCategories()
showdeadlineAction->setOn( table->showDeadline() );
-
+ catMenu->insertSeparator();
int id, rememberId;
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp
index 3cd0c0e..2acd03c 100644
--- a/core/pim/todo/todotable.cpp
+++ b/core/pim/todo/todotable.cpp
@@ -162,5 +162,53 @@ QString ComboItem::text() const
}
-
-
-
+DueTextItem::DueTextItem( QTable *t, ToDoEvent *ev )
+ : QTableItem(t, Never, QString::null )
+{
+ setToDoEvent( ev );
+}
+QString DueTextItem::key() const
+{
+ QString key;
+ if( m_hasDate ){
+ if(m_off == 0 ){
+ key.append("b");
+ }else if( m_off > 0 ){
+ key.append("c");
+ }else if( m_off < 0 ){
+ key.append("a");
+ }
+ key.append(QString::number(m_off ) );
+ }else{
+ key.append("d");
+ }
+ return key;
+}
+void DueTextItem::setToDoEvent( const ToDoEvent *ev )
+{
+ m_hasDate = ev->hasDate();
+ m_completed = ev->isCompleted();
+ if( ev->hasDate() ){
+ QDate today = QDate::currentDate();
+ m_off = today.daysTo(ev->date() );
+ setText( QString::number(m_off) + " day(s) " );
+ }else{
+ setText("n.d." );
+ m_off = 0;
+ }
+}
+void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected )
+{
+ QColorGroup cg2(cg);
+ QColor text = cg.text();
+ if( m_hasDate && !m_completed ){
+ if( m_off < 0 ){
+ cg2.setColor(QColorGroup::Text, QColor(red ) );
+ }else if( m_off == 0 ){
+ cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined
+ }else if( m_off > 0){
+ cg2.setColor(QColorGroup::Text, QColor(green ) );
+ }
+ }
+ QTableItem::paint(p, cg2, cr, selected );
+ cg2.setColor(QColorGroup::Text, text );
+}
TodoTable::TodoTable( QWidget *parent, const char *name )
@@ -249,9 +297,9 @@ void TodoTable::slotClicked( int row, int col, int, const QPoint &pos )
// may as well edit it...
- menuTimer->stop();
+ // menuTimer->stop();
// emit signalEdit();
- break;
- case 3: /* added 20.01.2k2 by se */
+ // fall through
+ case 3:
// may as well edit it...
menuTimer->stop();
- emit signalEdit();
+ // emit signalEdit();
break;
@@ -370,2 +418,3 @@ void TodoTable::load( const QString &fn )
setCurrentCell( 0, 2 );
+ setSorting(true );
}
@@ -376,6 +425,3 @@ void TodoTable::updateVisible()
return;
-
-// qDebug("--> updateVisible!");
-
- /* added 20.01.2k2 by se */
+
if (showDeadl){
@@ -402,3 +448,3 @@ void TodoTable::updateVisible()
} else {
- // do some comparing, we have to reverse our idea here...
+ // do some comparing, we have to reverse our idea here... which idea - zecke
if ( !hide ) {
@@ -468,3 +514,3 @@ void TodoTable::clear()
-void TodoTable::sortColumn( int col, bool /*ascending*/, bool /*wholeRows*/ )
+void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ )
{
@@ -474,3 +520,3 @@ void TodoTable::sortColumn( int col, bool /*ascending*/, bool /*wholeRows*/ )
// the values have a logical order.
- QTable::sortColumn( col, TRUE, TRUE );
+ QTable::sortColumn( col, ascending, TRUE );
updateVisible();
@@ -499,3 +545,3 @@ void TodoTable::updateJournal( const ToDoEvent &/*todo*/, journal_action action,
buf += " Action=\"" + QString::number( int(action) ) + "\"";
- buf += " Row=\"" + QString::number( row ) + "\"";
+ buf += " Row=\"" + QString::number( row ) + "\""; // better write the id
buf += "/>\n";
@@ -543,13 +589,4 @@ void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row )
- /* 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.");
- }
+ static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo );
}
@@ -567,13 +604,4 @@ void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row )
- /* 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.");
- }
+ static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo );
}
diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h
index 288ff90..32df514 100644
--- a/core/pim/todo/todotable.h
+++ b/core/pim/todo/todotable.h
@@ -79,2 +79,15 @@ public:
+class DueTextItem : public QTableItem
+{
+ public:
+ DueTextItem( QTable *t, ToDoEvent *ev );
+ QString key() const;
+ void setToDoEvent( const ToDoEvent *ev );
+ void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected );
+ private:
+ int m_off;
+ bool m_hasDate:1;
+ bool m_completed:1;
+
+};
@@ -100,3 +113,2 @@ public:
- /* added 20.01.2k2 by se */
void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();}
@@ -165,5 +177,3 @@ private:
int currFindRow;
-
- /* added 20.01.2k2 by se */
- bool showDeadl;
+ bool showDeadl:1;
};
@@ -183,15 +193,4 @@ inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row )
- /* 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);
+ DueTextItem *due = new DueTextItem(this, todo );
+ setItem( row, 3, due);
@@ -207,5 +206,6 @@ inline void TodoTable::realignTable( int row )
{
- QTableItem *ti1,
- *ti2,
- *ti3;
+ QTableItem *ti1,
+ *ti2,
+ *ti3,
+ *ti4;
int totalRows = numRows();
@@ -219,2 +219,3 @@ inline void TodoTable::realignTable( int row )
ti3 = item( curr + 1, 2 );
+ ti4 = item( curr + 1, 3 );
takeItem( ti1 );
@@ -222,2 +223,3 @@ inline void TodoTable::realignTable( int row )
takeItem( ti3 );
+ takeItem( ti4 );
setItem( curr, 0, ti1 );
@@ -225,2 +227,3 @@ inline void TodoTable::realignTable( int row )
setItem( curr, 2, ti3 );
+ setItem( curr, 3, ti4 );
}