-rw-r--r-- | microkde/kdatetbl.cpp | 28 | ||||
-rw-r--r-- | microkde/kdatetbl.h | 1 |
2 files changed, 21 insertions, 8 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp index 0a2d1f5..146291b 100644 --- a/microkde/kdatetbl.cpp +++ b/microkde/kdatetbl.cpp @@ -95,6 +95,7 @@ KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) #if 0 viewport()->setEraseColor(lightGray); #endif + mMarkCurrent = false; setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth } @@ -170,20 +171,29 @@ KDateTable::paintCell(QPainter *painter, int row, int col) pen=painter->pen(); if(firstday+date.day()-1==pos) { + if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) + painter->setPen(green); + else + painter->setPen(red); if(hasFocus()) - { // draw the currently selected date - painter->setPen(red); - painter->setBrush(darkRed); - pen=white; + { + painter->setBrush(darkRed); + pen=white; } else { - painter->setPen(darkGray); painter->setBrush(darkGray); pen=white; } } else { - painter->setBrush(QColor(220,245,255)); - painter->setPen(QColor(220,245,255)); - } + if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) + { + painter->setPen(green); + painter->setBrush(darkGreen); + pen=white; + } else { + painter->setBrush(QColor(220,245,255)); + painter->setPen(QColor(220,245,255)); + } + } painter->drawRect(0, 0, w, h); painter->setPen(pen); painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); @@ -357,6 +367,7 @@ KDateTable::setDate(const QDate& date_) { bool changed=false; QDate temp; + mMarkCurrent = false; // ----- if(!date_.isValid()) { @@ -368,6 +379,7 @@ KDateTable::setDate(const QDate& date_) date=date_; changed=true; } + mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); temp.setYMD(date.year(), date.month(), 1); firstday=temp.dayOfWeek(); if(firstday==1) firstday=8; diff --git a/microkde/kdatetbl.h b/microkde/kdatetbl.h index df7b7ef..b4d3e16 100644 --- a/microkde/kdatetbl.h +++ b/microkde/kdatetbl.h @@ -245,6 +245,7 @@ public: protected: + bool mMarkCurrent; /** * Paint a cell. */ |