From 877e3d4899013687a0a16caefadabf86703bcf27 Mon Sep 17 00:00:00 2001 From: zecke Date: Thu, 18 Apr 2002 20:43:35 +0000 Subject: on day change the deadline gets changed I use QDate and a Timer for that. Does anyone know a better way? --- 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 @@ -193,14 +193,17 @@ void DueTextItem::setToDoEvent( const ToDoEvent *ev ) 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 ){ @@ -261,6 +264,10 @@ TodoTable::TodoTable( QWidget *parent, const char *name ) 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 ) @@ -421,6 +428,7 @@ void TodoTable::load( const QString &fn ) QTable::sortColumn(0,TRUE,TRUE); setCurrentCell( 0, 2 ); setSorting(true ); + mDayTimer->start( 60 * 1000 ); // gone in 60 seconds? } void TodoTable::updateVisible() { @@ -781,6 +789,21 @@ void TodoTable::applyJournal() 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(item(i, 0))]; + static_cast(item(i, 3) )->setToDoEvent( t ); + + } + setPaintingEnabled( TRUE ); + mDay = date; + } + mDayTimer->start( 60 * 1000 ); // 60 seconds +} // check Action and decide /* void TodoTable::doApply(XMLElement *el ) 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 @@ -167,6 +167,7 @@ private slots: bool backwards, int category ); void slotShowMenu(); void rowHeightChanged( int row ); + void slotCheckDay(); // check the day private: friend class TodoWindow; @@ -176,6 +177,8 @@ private: bool showComp; QString showCat; QTimer *menuTimer; + QDate mDay; + QTimer *mDayTimer; // see if the day changed bool enablePainting; Categories mCat; int currFindRow; -- cgit v0.9.0.2