Implement clinican mode

This commit is contained in:
LoudSnorer 2023-05-26 17:29:56 -04:00
parent 0a40906c22
commit c82ace546f
4 changed files with 26 additions and 23 deletions

View File

@ -36,6 +36,7 @@
#include "profiles.h"
#include <algorithm>
#include "SleepLib/schema.h"
//#include "SleepLib/session.h"
#include "SleepLib/day.h"
#include "mainwindow.h"
@ -164,7 +165,7 @@ bool Machine::saveSessionInfo()
Session * sess = s.value();
if (sess->s_first != 0) {
out << (quint32) sess->session();
out << (bool)(sess->enabled());
out << (quint8)(sess->enabled(true));
} else {
qWarning() << "Machine::SaveSessionInfo discarding session" << sess->s_session
<< "["+QDateTime::fromTime_t(sess->s_session).toString("MMM dd, yyyy hh:mm:ss")+"]"
@ -197,9 +198,11 @@ bool Machine::loadSessionInfo()
Session * sess = s.value();
QHash<ChannelID, QVariant>::iterator it = sess->settings.find(SESSION_ENABLED);
bool b = true;
quint8 b = true;
b &= 0x1;
if (it != sess->settings.end()) {
b = it.value().toBool();
} else {
}
sess->setEnabled(b); // Extract from session settings and save..
}
@ -233,11 +236,12 @@ bool Machine::loadSessionInfo()
in >> size;
quint32 sid;
bool b;
quint8 b;
for (int i=0; i< size; ++i) {
in >> sid;
in >> b;
b &= 0x1;
s = sessionlist.find(sid);
@ -625,7 +629,7 @@ void Machine::setInfo(MachineInfo inf)
}
const QString Machine::getDataPath()
{
{
// TODO: Rework the underlying database so that file storage doesn't rely on consistent presence or absence of the serial number.
m_dataPath = p_pref->Get("{home}/Profiles/")+profile->user->userName()+"/"+info.loadername + "_"
+ (info.serial.isEmpty() ? hexid() : info.serial) + "/";
@ -1023,7 +1027,7 @@ bool Machine::LoadSummary(ProgressDialog * progress)
// if ((cnt % 100) == 0) {
// progress->setValue(cnt);
// //QApplication::processEvents();
// }
// }
*****************************************************************/
Session * sess = it.value();
if ( ! AddSession(sess, true)) {
@ -1084,7 +1088,7 @@ bool Machine::SaveSummaryCache()
el.setAttribute("id", (quint32)sess->session());
el.setAttribute("first", sess->realFirst());
el.setAttribute("last", sess->realLast());
el.setAttribute("enabled", sess->enabled() ? "1" : "0");
el.setAttribute("enabled", sess->enabled(true) ? "1" : "0");
el.setAttribute("events", sess->summaryOnly() ? "0" : "1");
QHash<ChannelID, QVector<EventList *> >::iterator ev;

View File

@ -91,6 +91,12 @@ void Session::TrashEvents()
eventlist.squeeze();
}
bool Session::enabled(bool realValues) const
{
if (!AppSetting->allowDisableSessions() && !realValues) return true;
return s_enabled;
}
void Session::setEnabled(bool b)
{
s_enabled = b;
@ -282,7 +288,7 @@ bool Session::Store(QString path)
// in >> s_summaryOnly;
//
// s_enabled = 1;
//}
//}
QDataStream & operator>>(QDataStream & in, SessionSlice & slice)
{
@ -1066,7 +1072,7 @@ void Session::updateCountSummary(ChannelID code)
{
QHash<ChannelID, QVector<EventList *> >::iterator ev = eventlist.find(code);
if (ev == eventlist.end()) {
if (ev == eventlist.end()) {
qDebug() << "No events for channel (hex)" << QString::number(code, 16);
return;
}
@ -1560,7 +1566,7 @@ bool Session::channelDataExists(ChannelID id)
}
bool Session::channelExists(ChannelID id)
{
if ( ! enabled()) {
if ( ! enabled()) {
return false;
}
@ -1577,7 +1583,7 @@ bool Session::channelExists(ChannelID id)
return false;
}
if (q.value() == 0) {
if (q.value() == 0) {
return false;
}
}

View File

@ -113,7 +113,7 @@ class Session
}
//! \brief Returns whether or not session is being used.
inline bool enabled() const { return s_enabled; }
bool enabled(bool realValues=false) const;
//! \brief Sets whether or not session is being used.
void setEnabled(bool b);
@ -362,7 +362,7 @@ class Session
EventDataType calcMiddle(ChannelID code);
EventDataType calcMax(ChannelID code);
EventDataType calcPercentile(ChannelID code);
//! \brief Returns true if the channel has events loaded, or a record of a count for when they are not
bool channelExists(ChannelID name);
@ -417,15 +417,6 @@ class Session
//! \brief Completely purges Session from memory and disk.
bool Destroy();
void wipeSummary() {
s_first = s_last = 0;
s_enabled = true;
m_cph.clear();
m_sum.clear();
m_cnt.clear();
}
QString eventFile() const;
//! \brief Returns DeviceType for this session
@ -433,7 +424,7 @@ class Session
#ifdef SESSION_DEBUG
#ifdef SESSION_DEBUG
QStringList session_files;
#endif
@ -456,7 +447,7 @@ protected:
bool s_summary_loaded;
bool s_events_loaded;
bool s_enabled;
quint8 s_enabled;
// for debugging
bool destroyed;

View File

@ -1413,6 +1413,8 @@ void MainWindow::on_action_Preferences_triggered()
if (profileSelector)
profileSelector->updateProfileList();
GenerateStatistics();
// These attempts to update calendar after a change to application font do NOT work, and I can find no QT documentation suggesting
// that changing the font after Calendar is created is even possible.
// qDebug() << "application font family set to" << QApplication::font().family() << "and font" << QApplication::font();