mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-19 04:00:45 +00:00
Invalidate hour cache when enabling/disabling sessions
This commit is contained in:
parent
dac961d981
commit
5e8047f528
@ -791,7 +791,7 @@ qint64 Day::total_time(MachineType type)
|
|||||||
Session &sess = *(*it);
|
Session &sess = *(*it);
|
||||||
int slicesize = sess.m_slices.size();
|
int slicesize = sess.m_slices.size();
|
||||||
|
|
||||||
if ((sess.type() == type) && sess.enabled()) {
|
if (sess.enabled() && (sess.type() == type)) {
|
||||||
first = sess.first();
|
first = sess.first();
|
||||||
last = sess.last();
|
last = sess.last();
|
||||||
|
|
||||||
|
@ -1260,6 +1260,39 @@ EventDataType Profile::calcBelowThreshold(ChannelID code, EventDataType threshol
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Day * Profile::findSessionDay(Session * session)
|
||||||
|
{
|
||||||
|
MachineType mt = session->type();
|
||||||
|
|
||||||
|
QDate start = LastGoodDay(mt);
|
||||||
|
QDate end = LastGoodDay(mt);
|
||||||
|
|
||||||
|
QDate date = start;
|
||||||
|
|
||||||
|
if (date.isNull()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double val = 0;
|
||||||
|
int cnt = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
Day *day = FindGoodDay(date, mt);
|
||||||
|
|
||||||
|
if (day) {
|
||||||
|
for (int i=0; i<day->size(); i++) {
|
||||||
|
Session * s = day->sessions.at(i);
|
||||||
|
if (s == session) {
|
||||||
|
return day;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
date = date.addDays(1);
|
||||||
|
} while (date <= end);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EventDataType Profile::calcAvg(ChannelID code, MachineType mt, QDate start, QDate end)
|
EventDataType Profile::calcAvg(ChannelID code, MachineType mt, QDate start, QDate end)
|
||||||
{
|
{
|
||||||
|
@ -181,6 +181,7 @@ class Profile : public Preferences
|
|||||||
QDate start = QDate(), QDate end = QDate());
|
QDate start = QDate(), QDate end = QDate());
|
||||||
|
|
||||||
|
|
||||||
|
Day * findSessionDay(Session * session);
|
||||||
// XML load components
|
// XML load components
|
||||||
virtual void ExtraLoad(QDomElement &root);
|
virtual void ExtraLoad(QDomElement &root);
|
||||||
|
|
||||||
|
@ -86,6 +86,17 @@ void Session::TrashEvents()
|
|||||||
eventlist.squeeze();
|
eventlist.squeeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::setEnabled(bool b)
|
||||||
|
{
|
||||||
|
s_enabled = b;
|
||||||
|
// not so simple.. we have to invalidate the hours cache in the day record..
|
||||||
|
|
||||||
|
Day * day = p_profile->findSessionDay(this);
|
||||||
|
if (day) {
|
||||||
|
day->invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString Session::eventFile() const
|
QString Session::eventFile() const
|
||||||
{
|
{
|
||||||
return s_machine->getEventsPath()+QString().sprintf("%08lx.001", s_session);
|
return s_machine->getEventsPath()+QString().sprintf("%08lx.001", s_session);
|
||||||
|
@ -111,7 +111,7 @@ class Session
|
|||||||
inline bool enabled() const { return s_enabled; }
|
inline bool enabled() const { return s_enabled; }
|
||||||
|
|
||||||
//! \brief Sets whether or not session is being used.
|
//! \brief Sets whether or not session is being used.
|
||||||
void setEnabled(bool b) { s_enabled = b; }
|
void setEnabled(bool b);
|
||||||
|
|
||||||
inline qint64 realFirst() const { return s_first; }
|
inline qint64 realFirst() const { return s_first; }
|
||||||
inline qint64 realLast() const { return s_last; }
|
inline qint64 realLast() const { return s_last; }
|
||||||
|
Loading…
Reference in New Issue
Block a user