Added Everything and Custom to Overview Range combo and set date bounds.. Greyed out dates when not custom.

This commit is contained in:
Mark Watkins 2012-01-04 11:28:03 +10:00
parent 0b9238defe
commit 88fbc9d746
3 changed files with 37 additions and 11 deletions

View File

@ -787,13 +787,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Yay.. Empty space.. what for?</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">

View File

@ -401,7 +401,7 @@ void Overview::on_dateEnd_dateChanged(const QDate &date)
qint64 d1=qint64(QDateTime(ui->dateStart->date(),QTime(0,10,0),Qt::UTC).toTime_t())*1000L; qint64 d1=qint64(QDateTime(ui->dateStart->date(),QTime(0,10,0),Qt::UTC).toTime_t())*1000L;
qint64 d2=qint64(QDateTime(date,QTime(23,0,0),Qt::UTC).toTime_t())*1000L; qint64 d2=qint64(QDateTime(date,QTime(23,0,0),Qt::UTC).toTime_t())*1000L;
GraphView->SetXBounds(d1,d2); GraphView->SetXBounds(d1,d2);
ui->dateStart->setMaximumDate(date);
} }
void Overview::on_dateStart_dateChanged(const QDate &date) void Overview::on_dateStart_dateChanged(const QDate &date)
@ -409,7 +409,7 @@ void Overview::on_dateStart_dateChanged(const QDate &date)
qint64 d1=qint64(QDateTime(date,QTime(0,10,0),Qt::UTC).toTime_t())*1000L; qint64 d1=qint64(QDateTime(date,QTime(0,10,0),Qt::UTC).toTime_t())*1000L;
qint64 d2=qint64(QDateTime(ui->dateEnd->date(),QTime(23,0,0),Qt::UTC).toTime_t())*1000L; qint64 d2=qint64(QDateTime(ui->dateEnd->date(),QTime(23,0,0),Qt::UTC).toTime_t())*1000L;
GraphView->SetXBounds(d1,d2); GraphView->SetXBounds(d1,d2);
ui->dateEnd->setMinimumDate(date);
} }
void Overview::on_toolButton_clicked() void Overview::on_toolButton_clicked()
@ -464,8 +464,26 @@ void Overview::on_printDailyButton_clicked()
void Overview::on_rangeCombo_activated(int index) void Overview::on_rangeCombo_activated(int index)
{ {
ui->dateStart->setMinimumDate(PROFILE.FirstDay());
ui->dateEnd->setMaximumDate(PROFILE.LastDay());
QDate end=PROFILE.LastDay(); QDate end=PROFILE.LastDay();
QDate start; QDate start;
if (index==8) { // Custom
ui->dateStartLabel->setEnabled(true);
ui->dateEndLabel->setEnabled(true);
ui->dateEnd->setEnabled(true);
ui->dateStart->setEnabled(true);
ui->dateStart->setMaximumDate(ui->dateEnd->date());
ui->dateEnd->setMinimumDate(ui->dateStart->date());
return;
}
ui->dateEnd->setEnabled(false);
ui->dateStart->setEnabled(false);
ui->dateStartLabel->setEnabled(false);
ui->dateEndLabel->setEnabled(false);
if (index==0) { if (index==0) {
start=end.addDays(-6); start=end.addDays(-6);
} else if (index==1) { } else if (index==1) {
@ -480,12 +498,17 @@ void Overview::on_rangeCombo_activated(int index)
start=end.addMonths(-6).addDays(1); start=end.addMonths(-6).addDays(1);
} else if (index==6) { } else if (index==6) {
start=end.addYears(-1).addDays(1); start=end.addYears(-1).addDays(1);
} else if (index==7) { // Everything
start=PROFILE.FirstDay();
} }
if (start<PROFILE.FirstDay()) start=PROFILE.FirstDay(); if (start<PROFILE.FirstDay()) start=PROFILE.FirstDay();
setRange(start,end); setRange(start,end);
} }
void Overview::setRange(QDate start, QDate end) void Overview::setRange(QDate start, QDate end)
{ {
ui->dateStart->setMaximumDate(end);
ui->dateEnd->setMinimumDate(start);
ui->dateEnd->blockSignals(true); ui->dateEnd->blockSignals(true);
ui->dateStart->blockSignals(true); ui->dateStart->blockSignals(true);
ui->dateStart->setDate(start); ui->dateStart->setDate(start);

View File

@ -97,10 +97,20 @@
<string>Last Year</string> <string>Last Year</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Everything</string>
</property>
</item>
<item>
<property name="text">
<string>Custom</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="dateStartLabel">
<property name="text"> <property name="text">
<string>Start:</string> <string>Start:</string>
</property> </property>
@ -117,7 +127,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="dateEndLabel">
<property name="text"> <property name="text">
<string>End:</string> <string>End:</string>
</property> </property>