summaryrefslogtreecommitdiff
authorzecke <zecke>2002-04-13 19:58:17 (UTC)
committer zecke <zecke>2002-04-13 19:58:17 (UTC)
commit244495af9bd629fe565b5c753d066cc4fde684ae (patch) (side-by-side diff)
tree8f20084c688b627223a431f02875703418e6d999
parent84f5e0817231fa3721c781b0538659f5a7149349 (diff)
downloadopie-244495af9bd629fe565b5c753d066cc4fde684ae.zip
opie-244495af9bd629fe565b5c753d066cc4fde684ae.tar.gz
opie-244495af9bd629fe565b5c753d066cc4fde684ae.tar.bz2
Fix Stefan Eilers patch
Extend the due column better sorting and colors ;)
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
@@ -111,5 +111,4 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
table->setShowCompleted( complete );
- /* added 20.01.2k2 by se */
bool showdeadline = config.readBoolEntry("ShowDeadLine", true);
table->setShowDeadline (showdeadline);
@@ -182,5 +181,4 @@ 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 );
@@ -365,5 +363,5 @@ void TodoWindow::populateCategories()
showdeadlineAction->addTo( catMenu );
showdeadlineAction->setOn( table->showDeadline() );
-
+ catMenu->insertSeparator();
int id, rememberId;
id = 1;
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
@@ -161,7 +161,55 @@ QString ComboItem::text() const
return QTableItem::text();
}
-
-
-
+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 )
// #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR
@@ -248,11 +296,11 @@ void TodoTable::slotClicked( int row, int col, int, const QPoint &pos )
case 2:
// 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;
}
@@ -369,4 +417,5 @@ void TodoTable::load( const QString &fn )
QTable::sortColumn(0,TRUE,TRUE);
setCurrentCell( 0, 2 );
+ setSorting(true );
}
@@ -375,8 +424,5 @@ void TodoTable::updateVisible()
if ( !isUpdatesEnabled() )
return;
-
-// qDebug("--> updateVisible!");
-
- /* added 20.01.2k2 by se */
+
if (showDeadl){
showColumn (3);
@@ -401,5 +447,5 @@ void TodoTable::updateVisible()
hide = true;
} 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 ) {
hide = true;
@@ -467,5 +513,5 @@ void TodoTable::clear()
}
-void TodoTable::sortColumn( int col, bool /*ascending*/, bool /*wholeRows*/ )
+void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ )
{
// The default for wholeRows is false, however
@@ -473,5 +519,5 @@ void TodoTable::sortColumn( int col, bool /*ascending*/, bool /*wholeRows*/ )
// rows when sorting. Also, we always want ascending, since
// the values have a logical order.
- QTable::sortColumn( col, TRUE, TRUE );
+ QTable::sortColumn( col, ascending, TRUE );
updateVisible();
}
@@ -498,5 +544,5 @@ void TodoTable::updateJournal( const ToDoEvent &/*todo*/, journal_action action,
// todo.save( buf );
buf += " Action=\"" + QString::number( int(action) ) + "\"";
- buf += " Row=\"" + QString::number( row ) + "\"";
+ buf += " Row=\"" + QString::number( row ) + "\""; // better write the id
buf += "/>\n";
str = buf.utf8();
@@ -542,15 +588,6 @@ void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row )
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.");
- }
+ static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo );
}
@@ -566,15 +603,6 @@ void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row )
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.");
- }
+ 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
@@ -78,4 +78,17 @@ 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;
+
+};
@@ -99,5 +112,4 @@ public:
bool showCompleted() const { return showComp; }
- /* added 20.01.2k2 by se */
void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();}
bool showDeadline() const { return showDeadl;}
@@ -164,7 +176,5 @@ private:
Categories mCat;
int currFindRow;
-
- /* added 20.01.2k2 by se */
- bool showDeadl;
+ bool showDeadl:1;
};
@@ -182,17 +192,6 @@ inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row )
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);
+ DueTextItem *due = new DueTextItem(this, todo );
+ setItem( row, 3, due);
setItem( row, 0, chk );
@@ -206,7 +205,8 @@ inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row )
inline void TodoTable::realignTable( int row )
{
- QTableItem *ti1,
- *ti2,
- *ti3;
+ QTableItem *ti1,
+ *ti2,
+ *ti3,
+ *ti4;
int totalRows = numRows();
for ( int curr = row; curr < totalRows - 1; curr++ ) {
@@ -218,10 +218,13 @@ inline void TodoTable::realignTable( int row )
ti2 = item( curr + 1, 1 );
ti3 = item( curr + 1, 2 );
+ ti4 = item( curr + 1, 3 );
takeItem( ti1 );
takeItem( ti2 );
takeItem( ti3 );
+ takeItem( ti4 );
setItem( curr, 0, ti1 );
setItem( curr, 1, ti2 );
setItem( curr, 2, ti3 );
+ setItem( curr, 3, ti4 );
}
setNumRows( totalRows - 1 );