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
@@ -184,32 +184,35 @@ QString DueTextItem::key() const
184 }else{ 184 }else{
185 key.append("d"); 185 key.append("d");
186 } 186 }
187 return key; 187 return key;
188} 188}
189void DueTextItem::setToDoEvent( const ToDoEvent *ev ) 189void 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 ){
210 cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined 213 cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined
211 }else if( m_off > 0){ 214 }else if( m_off > 0){
212 cg2.setColor(QColorGroup::Text, QColor(green ) ); 215 cg2.setColor(QColorGroup::Text, QColor(green ) );
213 } 216 }
214 } 217 }
215 QTableItem::paint(p, cg2, cr, selected ); 218 QTableItem::paint(p, cg2, cr, selected );
@@ -252,24 +255,28 @@ TodoTable::TodoTable( QWidget *parent, const char *name )
252 255
253 connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ), 256 connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ),
254 this, SLOT( slotClicked( int, int, int, const QPoint & ) ) ); 257 this, SLOT( slotClicked( int, int, int, const QPoint & ) ) );
255 connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ), 258 connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ),
256 this, SLOT( slotPressed( int, int, int, const QPoint & ) ) ); 259 this, SLOT( slotPressed( int, int, int, const QPoint & ) ) );
257 connect( this, SIGNAL( valueChanged( int, int ) ), 260 connect( this, SIGNAL( valueChanged( int, int ) ),
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 );
270 updateJournal( todo, ACTION_ADD ); 277 updateJournal( todo, ACTION_ADD );
271 insertIntoTable( new ToDoEvent(todo), row ); 278 insertIntoTable( new ToDoEvent(todo), row );
272 setCurrentCell(row, currentColumn()); 279 setCurrentCell(row, currentColumn());
273 updateVisible(); 280 updateVisible();
274} 281}
275 282
@@ -412,24 +419,25 @@ bool TodoTable::save( const QString &fn )
412void TodoTable::load( const QString &fn ) 419void TodoTable::load( const QString &fn )
413{ 420{
414 if ( QFile::exists(journalFileName()) ) { 421 if ( QFile::exists(journalFileName()) ) {
415 applyJournal(); 422 applyJournal();
416 QFile::remove(journalFileName() ); 423 QFile::remove(journalFileName() );
417 } 424 }
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
430 if (showDeadl){ 438 if (showDeadl){
431 showColumn (3); 439 showColumn (3);
432 adjustColumn(3); 440 adjustColumn(3);
433 }else{ 441 }else{
434 hideColumn (3); 442 hideColumn (3);
435 adjustColumn(2); 443 adjustColumn(2);
@@ -772,24 +780,39 @@ void TodoTable::applyJournal()
772 break; 780 break;
773 case ACTION_REPLACE: 781 case ACTION_REPLACE:
774 tododb.replaceEvent( ev ); 782 tododb.replaceEvent( ev );
775 break; 783 break;
776 } 784 }
777 } 785 }
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;
790 int action; 813 int action;
791 dummy = el->attribute("Action" ); 814 dummy = el->attribute("Action" );
792 action = dummy.toInt(&ok ); 815 action = dummy.toInt(&ok );
793 ToDoEvent ev = xmlToEvent( el ); 816 ToDoEvent ev = xmlToEvent( el );
794 if( ok ){ 817 if( ok ){
795 switch( action ){ 818 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:
158 inline void realignTable( int row ); 158 inline void realignTable( int row );
159 void loadFile( const QString &strFile); 159 void loadFile( const QString &strFile);
160 160
161private slots: 161private slots:
162 void slotClicked( int row, int col, int button, const QPoint &pos ); 162 void slotClicked( int row, int col, int button, const QPoint &pos );
163 void slotPressed( int row, int col, int button, const QPoint &pos ); 163 void slotPressed( int row, int col, int button, const QPoint &pos );
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
185 188
186inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) 189inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row )
187{ 190{
188 QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') 191 QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A')
189 + todo->priority() ) 192 + todo->priority() )
190 + Qtopia::buildSortKey( todo->description() ); 193 + Qtopia::buildSortKey( todo->description() );