summaryrefslogtreecommitdiffabout
path: root/microkde/kdatetbl.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kdatetbl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdatetbl.cpp28
1 files changed, 20 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
@@ -86,24 +86,25 @@ KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f)
{
date_=QDate::currentDate();
}
setFocusPolicy( QWidget::StrongFocus );
setNumRows(7); // 6 weeks max + headline
setNumCols(7); // 7 days a week
setHScrollBarMode(AlwaysOff);
setVScrollBarMode(AlwaysOff);
viewport()->setBackgroundColor(QColor(220,245,255));
#if 0
viewport()->setEraseColor(lightGray);
#endif
+ mMarkCurrent = false;
setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth
}
void
KDateTable::paintCell(QPainter *painter, int row, int col)
{
QRect rect;
QString text;
QPen pen;
int w=cellWidth();
int h=cellHeight();
int pos;
@@ -161,38 +162,47 @@ KDateTable::paintCell(QPainter *painter, int row, int col)
} else { // following month
text.setNum(pos-firstday-numdays+1);
}
painter->setPen(gray);
} else { // paint a day of the current month
text.setNum(pos-firstday+1);
painter->setPen(black);
}
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);
}
if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width());
if(rect.height()>maxCell.height()) maxCell.setHeight(rect.height());
}
void
KDateTable::keyPressEvent( QKeyEvent *e )
{
/*
@@ -348,35 +358,37 @@ KDateTable::contentsMousePressEvent(QMouseEvent *e)
setDate(QDate(date.year(), date.month(), pos-firstday+dayoff));
updateCell(temp/7+1, temp%7); // Update the previously selected cell
updateCell(row, col); // Update the selected cell
// assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
emit(tableClicked());
}
bool
KDateTable::setDate(const QDate& date_)
{
bool changed=false;
QDate temp;
+ mMarkCurrent = false;
// -----
if(!date_.isValid())
{
kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl;
return false;
}
if(date!=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;
numdays=date.daysInMonth();
if(date.month()==1)
{ // set to december of previous year
temp.setYMD(date.year()-1, 12, 1);
} else { // set to previous month
temp.setYMD(date.year(), date.month()-1, 1);
}
numDaysPrevMonth=temp.daysInMonth();
if(changed)