-rw-r--r-- | core/pim/todo/todotable.cpp | 23 | ||||
-rw-r--r-- | core/pim/todo/todotable.h | 3 |
2 files changed, 26 insertions, 0 deletions
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index 96cd860..d0bc61c 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp @@ -184,32 +184,35 @@ QString DueTextItem::key() const }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() ); + //qWarning("DueText m_off=%d", m_off ); setText( QString::number(m_off) + " day(s) " ); }else{ setText("n.d." ); m_off = 0; } + //qWarning("m_off=%d", m_off ); } void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ) { + //qWarning ("paint m_off=%d", m_off ); 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 ); @@ -252,24 +255,28 @@ TodoTable::TodoTable( QWidget *parent, const char *name ) 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 ) ) ); connect( this, SIGNAL( currentChanged( int, int ) ), this, SLOT( slotCurrentChanged( int, int ) ) ); menuTimer = new QTimer( this ); connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); + + mDayTimer = new QTimer( this ); + connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) ); + mDay = QDate::currentDate(); } void TodoTable::addEntry( const ToDoEvent &todo ) { int row = numRows(); setNumRows( row + 1 ); updateJournal( todo, ACTION_ADD ); insertIntoTable( new ToDoEvent(todo), row ); setCurrentCell(row, currentColumn()); updateVisible(); } @@ -412,24 +419,25 @@ bool TodoTable::save( const QString &fn ) void TodoTable::load( const QString &fn ) { if ( QFile::exists(journalFileName()) ) { applyJournal(); QFile::remove(journalFileName() ); } loadFile( fn ); // QTable::sortColumn(2,TRUE,TRUE); // QTable::sortColumn(1,TRUE,TRUE); QTable::sortColumn(0,TRUE,TRUE); setCurrentCell( 0, 2 ); setSorting(true ); + mDayTimer->start( 60 * 1000 ); // gone in 60 seconds? } void TodoTable::updateVisible() { if ( !isUpdatesEnabled() ) return; if (showDeadl){ showColumn (3); adjustColumn(3); }else{ hideColumn (3); adjustColumn(2); @@ -772,24 +780,39 @@ void TodoTable::applyJournal() break; case ACTION_REPLACE: tododb.replaceEvent( ev ); break; } } el = el->nextChild(); } QFile::remove(journalFileName()+ "_new" ); tododb.save(); } } +void TodoTable::slotCheckDay() +{ + QDate date = QDate::currentDate(); + if( mDay.daysTo(date )!= 0 ){ + setPaintingEnabled( FALSE ); + for(int i=0; i < numRows(); i++ ){ + ToDoEvent *t = todoList[static_cast<CheckItem*>(item(i, 0))]; + static_cast<DueTextItem*>(item(i, 3) )->setToDoEvent( t ); + + } + setPaintingEnabled( TRUE ); + mDay = date; + } + mDayTimer->start( 60 * 1000 ); // 60 seconds +} // check Action and decide /* void TodoTable::doApply(XMLElement *el ) { QString dummy; bool ok; int action; dummy = el->attribute("Action" ); action = dummy.toInt(&ok ); ToDoEvent ev = xmlToEvent( el ); if( ok ){ switch( action ){ diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h index 6e371e8..458e07a 100644 --- a/core/pim/todo/todotable.h +++ b/core/pim/todo/todotable.h @@ -158,33 +158,36 @@ private: inline void realignTable( int row ); void loadFile( const QString &strFile); private slots: void slotClicked( int row, int col, int button, const QPoint &pos ); void slotPressed( int row, int col, int button, const QPoint &pos ); void slotCheckPriority(int row, int col ); void slotCurrentChanged(int row, int col ); void slotDoFind( const QString &findString, bool caseSensetive, bool backwards, int category ); void slotShowMenu(); void rowHeightChanged( int row ); + void slotCheckDay(); // check the day private: friend class TodoWindow; QMap<CheckItem*, ToDoEvent *> todoList; QStringList categoryList; bool showComp; QString showCat; QTimer *menuTimer; + QDate mDay; + QTimer *mDayTimer; // see if the day changed bool enablePainting; Categories mCat; int currFindRow; bool showDeadl:1; }; inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) { QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') + todo->priority() ) + Qtopia::buildSortKey( todo->description() ); |