summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/todo/todotable.cpp23
-rw-r--r--core/pim/todo/todotable.h3
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
@@ -190,20 +190,23 @@ void DueTextItem::setToDoEvent( const ToDoEvent *ev )
190{ 190{
191 m_hasDate = ev->hasDate(); 191 m_hasDate = ev->hasDate();
192 m_completed = ev->isCompleted(); 192 m_completed = ev->isCompleted();
193 if( ev->hasDate() ){ 193 if( ev->hasDate() ){
194 QDate today = QDate::currentDate(); 194 QDate today = QDate::currentDate();
195 m_off = today.daysTo(ev->date() ); 195 m_off = today.daysTo(ev->date() );
196 //qWarning("DueText m_off=%d", m_off );
196 setText( QString::number(m_off) + " day(s) " ); 197 setText( QString::number(m_off) + " day(s) " );
197 }else{ 198 }else{
198 setText("n.d." ); 199 setText("n.d." );
199 m_off = 0; 200 m_off = 0;
200 } 201 }
202 //qWarning("m_off=%d", m_off );
201} 203}
202void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ) 204void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected )
203{ 205{
206 //qWarning ("paint m_off=%d", m_off );
204 QColorGroup cg2(cg); 207 QColorGroup cg2(cg);
205 QColor text = cg.text(); 208 QColor text = cg.text();
206 if( m_hasDate && !m_completed ){ 209 if( m_hasDate && !m_completed ){
207 if( m_off < 0 ){ 210 if( m_off < 0 ){
208 cg2.setColor(QColorGroup::Text, QColor(red ) ); 211 cg2.setColor(QColorGroup::Text, QColor(red ) );
209 }else if( m_off == 0 ){ 212 }else if( m_off == 0 ){
@@ -258,12 +261,16 @@ TodoTable::TodoTable( QWidget *parent, const char *name )
258 this, SLOT( slotCheckPriority( int, int ) ) ); 261 this, SLOT( slotCheckPriority( int, int ) ) );
259 connect( this, SIGNAL( currentChanged( int, int ) ), 262 connect( this, SIGNAL( currentChanged( int, int ) ),
260 this, SLOT( slotCurrentChanged( int, int ) ) ); 263 this, SLOT( slotCurrentChanged( int, int ) ) );
261 264
262 menuTimer = new QTimer( this ); 265 menuTimer = new QTimer( this );
263 connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); 266 connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) );
267
268 mDayTimer = new QTimer( this );
269 connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) );
270 mDay = QDate::currentDate();
264} 271}
265 272
266void TodoTable::addEntry( const ToDoEvent &todo ) 273void TodoTable::addEntry( const ToDoEvent &todo )
267{ 274{
268 int row = numRows(); 275 int row = numRows();
269 setNumRows( row + 1 ); 276 setNumRows( row + 1 );
@@ -418,12 +425,13 @@ void TodoTable::load( const QString &fn )
418 loadFile( fn ); 425 loadFile( fn );
419// QTable::sortColumn(2,TRUE,TRUE); 426// QTable::sortColumn(2,TRUE,TRUE);
420// QTable::sortColumn(1,TRUE,TRUE); 427// QTable::sortColumn(1,TRUE,TRUE);
421 QTable::sortColumn(0,TRUE,TRUE); 428 QTable::sortColumn(0,TRUE,TRUE);
422 setCurrentCell( 0, 2 ); 429 setCurrentCell( 0, 2 );
423 setSorting(true ); 430 setSorting(true );
431 mDayTimer->start( 60 * 1000 ); // gone in 60 seconds?
424} 432}
425void TodoTable::updateVisible() 433void TodoTable::updateVisible()
426{ 434{
427 if ( !isUpdatesEnabled() ) 435 if ( !isUpdatesEnabled() )
428 return; 436 return;
429 437
@@ -778,12 +786,27 @@ void TodoTable::applyJournal()
778 el = el->nextChild(); 786 el = el->nextChild();
779 } 787 }
780 QFile::remove(journalFileName()+ "_new" ); 788 QFile::remove(journalFileName()+ "_new" );
781 tododb.save(); 789 tododb.save();
782 } 790 }
783} 791}
792void TodoTable::slotCheckDay()
793{
794 QDate date = QDate::currentDate();
795 if( mDay.daysTo(date )!= 0 ){
796 setPaintingEnabled( FALSE );
797 for(int i=0; i < numRows(); i++ ){
798 ToDoEvent *t = todoList[static_cast<CheckItem*>(item(i, 0))];
799 static_cast<DueTextItem*>(item(i, 3) )->setToDoEvent( t );
800
801 }
802 setPaintingEnabled( TRUE );
803 mDay = date;
804 }
805 mDayTimer->start( 60 * 1000 ); // 60 seconds
806}
784// check Action and decide 807// check Action and decide
785/* 808/*
786void TodoTable::doApply(XMLElement *el ) 809void TodoTable::doApply(XMLElement *el )
787{ 810{
788 QString dummy; 811 QString dummy;
789 bool ok; 812 bool ok;
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
@@ -164,21 +164,24 @@ private slots:
164 void slotCheckPriority(int row, int col ); 164 void slotCheckPriority(int row, int col );
165 void slotCurrentChanged(int row, int col ); 165 void slotCurrentChanged(int row, int col );
166 void slotDoFind( const QString &findString, bool caseSensetive, 166 void slotDoFind( const QString &findString, bool caseSensetive,
167 bool backwards, int category ); 167 bool backwards, int category );
168 void slotShowMenu(); 168 void slotShowMenu();
169 void rowHeightChanged( int row ); 169 void rowHeightChanged( int row );
170 void slotCheckDay(); // check the day
170 171
171private: 172private:
172 friend class TodoWindow; 173 friend class TodoWindow;
173 174
174 QMap<CheckItem*, ToDoEvent *> todoList; 175 QMap<CheckItem*, ToDoEvent *> todoList;
175 QStringList categoryList; 176 QStringList categoryList;
176 bool showComp; 177 bool showComp;
177 QString showCat; 178 QString showCat;
178 QTimer *menuTimer; 179 QTimer *menuTimer;
180 QDate mDay;
181 QTimer *mDayTimer; // see if the day changed
179 bool enablePainting; 182 bool enablePainting;
180 Categories mCat; 183 Categories mCat;
181 int currFindRow; 184 int currFindRow;
182 bool showDeadl:1; 185 bool showDeadl:1;
183}; 186};
184 187