Noon Date Split option in View Menu

This commit is contained in:
Mark Watkins 2011-07-03 18:08:14 +10:00
parent e4be1f16fc
commit c9d3c5fbe7
4 changed files with 57 additions and 35 deletions

View File

@ -236,48 +236,50 @@ Day *Machine::AddSession(Session *s,Profile *p)
QDateTime d1,d2=QDateTime::fromMSecsSinceEpoch(s->first());
QDate date=d2.date();
date.addDays(-1);
//qint64 date=s->first()/86400000;
//date--; //=date.addDays(-1);
//date*=86400000;
// pref["NoonDateSplit"]=true;
const int hours_since_last_session=4;
const int hours_since_midnight=12;
if (pref["NoonDateSplit"].toBool()) {
if (d2.time().hour()<12) date.addDays(-1);
} else {
date.addDays(-1);
bool previous=false;
// Find what day session belongs to.
if (day.find(date)!=day.end()) {
// Previous day record exists...
const int hours_since_last_session=4;
const int hours_since_midnight=12;
// Calculate time since end of previous days last session
span=(s->first() - day[date]->last())/3600000.0;
bool previous=false;
// Find what day session belongs to.
if (day.find(date)!=day.end()) {
// Previous day record exists...
// less than n hours since last session yesterday?
if (span < hours_since_last_session) {
previous=true;
// Calculate time since end of previous days last session
span=(s->first() - day[date]->last())/3600000.0;
// less than n hours since last session yesterday?
if (span < hours_since_last_session) {
previous=true;
}
}
if (!previous) {
// Calculate Hours since midnight.
d1=d2;
d1.setTime(QTime(0,0,0));
float secsto=d1.secsTo(d2);
span=secsto/3600.0;
// Bedtime was late last night.
if (span < hours_since_midnight) {
previous=true;
}
}
if (!previous) {
// Revert to sessions original day.
date=date.addDays(1);
}
}
if (!previous) {
// Calculate Hours since midnight.
d1=d2;
d1.setTime(QTime(0,0,0));
float secsto=d1.secsTo(d2);
span=secsto/3600.0;
// Bedtime was late last night.
if (span < hours_since_midnight) {
previous=true;
}
}
if (!previous) {
// Revert to sessions original day.
date=date.addDays(1);
}
sessionlist[s->session()]=s;
if (!firstsession) {
@ -287,6 +289,7 @@ Day *Machine::AddSession(Session *s,Profile *p)
firstday=lastday=date;
firstsession=false;
}
if (day.find(date)==day.end()) {
//QString dstr=date.toString("yyyyMMdd");
//qDebug("Adding Profile Day %s",dstr.toAscii().data());

View File

@ -56,6 +56,9 @@ MainWindow::MainWindow(QWidget *parent) :
if (!pref.Exists("LinkGraphMovement")) pref["LinkGraphMovement"]=true;
else ui->action_Link_Graphs->setChecked(pref["LinkGraphMovement"].toBool());
if (!pref.Exists("NoonDateSplit")) pref["NoonDateSplit"]=false;
else ui->action_Noon_Date_Split->setChecked(pref["NoonDateSplit"].toBool());
if (!pref.Exists("fruitsalad")) pref["fruitsalad"]=true;
if (!pref.Exists("UseAntiAliasing")) pref["UseAntiAliasing"]=false;
@ -231,3 +234,8 @@ void MainWindow::on_actionUse_AntiAliasing_triggered(bool checked)
if (daily) daily->RedrawGraphs();
}
void MainWindow::on_action_Noon_Date_Split_toggled(bool checked)
{
pref["NoonDateSplit"]=checked;
}

View File

@ -60,6 +60,8 @@ private slots:
void on_actionUse_AntiAliasing_triggered(bool checked);
void on_action_Noon_Date_Split_toggled(bool );
private:
Ui::MainWindow *ui;
Daily * daily;

View File

@ -561,6 +561,7 @@
<addaction name="separator"/>
<addaction name="actionUse_AntiAliasing"/>
<addaction name="action_Link_Graphs"/>
<addaction name="action_Noon_Date_Split"/>
<addaction name="separator"/>
<addaction name="action_Fullscreen"/>
</widget>
@ -655,6 +656,14 @@
<string>&amp;Fullscreen Toggle</string>
</property>
</action>
<action name="action_Noon_Date_Split">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Noon Date Split</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>