summaryrefslogtreecommitdiff
path: root/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.cpp
blob: 24a68edbdd8aaefb02ccd19154ad576a12011156 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "datebookweeklstdayhdr.h"

#include "namespace_hack.h"

DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
                         QWidget* parent,
                         const char* name,
                         WFlags fl )
    : DateBookWeekLstDayHdrBase(parent, name, fl) {

    date=d;

    static const QString wdays=tr("MTWTFSSM",  "Week days");
    char day=wdays[d.dayOfWeek()-1];

    //dont use dayOfWeek() to save space !
    label->setText( QString(QString(QChar(day))) + " " +QString::number(d.day()) );

     add->setText("+");

    if (d == QDate::currentDate()) {
        QPalette pal=label->palette();
        pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
        label->setPalette(pal);

        /*
        QFont f=label->font();
        f.setItalic(true);
        label->setFont(f);
        label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
        */
    } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
        QPalette pal=label->palette();
        pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
        label->setPalette(pal);
    }

    connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
    connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
}

void DateBookWeekLstDayHdr::showDay() {
    emit showDate(date.year(), date.month(), date.day());
}

void DateBookWeekLstDayHdr::newEvent() {
    QDateTime start, stop;
    start=stop=date;
    start.setTime(QTime(10,0));
    stop.setTime(QTime(12,0));

    emit addEvent(start,stop,"",0);
}