Testing svn, tabs added, misprint fixed
[toast/confclerk.git] / src / gui / daynavigatorwidget.cpp
1 #include "daynavigatorwidget.h"
2
3 #include <QDebug>
4
5 DayNavigatorWidget::DayNavigatorWidget(QWidget *aParent)
6     : QWidget(aParent)
7     , mStartDate(QDate())
8     , mEndDate(QDate())
9     , mCurDate(QDate())
10 {
11     setupUi(this);
12     connect(prevDayButton, SIGNAL(clicked()), SLOT(prevDayButtonClicked()));
13     connect(nextDayButton, SIGNAL(clicked()), SLOT(nextDayButtonClicked()));
14 }
15
16 void DayNavigatorWidget::setDates(const QDate &aStartDate, const QDate &aEndDate)
17 {
18     Q_ASSERT(aStartDate<=aEndDate);
19
20     //qDebug() << "DayNavigatorWidget::setDates(): " << aStartDate << ", " << aEndDate;
21     mStartDate = aStartDate;
22     mEndDate = aEndDate;
23     mCurDate = aStartDate;
24
25     currentDateLabel->setText(mCurDate.toString());
26     if(mStartDate==mEndDate) // only one day conference
27     {
28         prevDayButton->setDisabled(true);
29         nextDayButton->setDisabled(true);
30         emit(dateChanged(mCurDate));
31     }
32     else
33     {
34         // at least 2-days conference
35         prevDayButton->setDisabled(true);
36         nextDayButton->setDisabled(false);
37         emit(dateChanged(mCurDate));
38     }
39 }
40
41 void DayNavigatorWidget::prevDayButtonClicked()
42 {
43     //qDebug() << mStartDate << ":" << mCurDate << ":" << mEndDate;
44     if(mCurDate>mStartDate)
45     {
46         mCurDate = mCurDate.addDays(-1);
47         currentDateLabel->setText(mCurDate.toString());
48         // check start date
49         if(mCurDate==mStartDate || mStartDate==mEndDate)
50             prevDayButton->setDisabled(true);
51         else
52             prevDayButton->setDisabled(false);
53         // check end date
54         if(mCurDate==mEndDate || mStartDate==mEndDate)
55             nextDayButton->setDisabled(true);
56         else
57             nextDayButton->setDisabled(false);
58
59         emit(dateChanged(mCurDate));
60     }
61 }
62
63 void DayNavigatorWidget::nextDayButtonClicked()
64 {
65     //qDebug() << mStartDate << ":" << mCurDate << ":" << mEndDate;
66     if(mCurDate<mEndDate)
67     {
68         mCurDate = mCurDate.addDays(1);
69         currentDateLabel->setText(mCurDate.toString());
70         // check start date
71         if(mCurDate==mStartDate || mStartDate==mEndDate)
72             prevDayButton->setDisabled(true);
73         else
74             prevDayButton->setDisabled(false);
75         // check end date
76         if(mCurDate==mEndDate || mStartDate==mEndDate)
77             nextDayButton->setDisabled(true);
78         else
79             nextDayButton->setDisabled(false);
80
81         emit(dateChanged(mCurDate));
82     }
83 }
84