Express some profiles.h functions in terms of helper functions.

Gets rid of nasty string duplication and pointer logic.

Signed-off-by: Mark Watkins <jedimark@users.sourceforge.net>
This commit is contained in:
Sean Stangl 2014-04-19 22:25:09 -07:00 committed by Mark Watkins
parent 0421a5c4e2
commit 868a61c27b
2 changed files with 333 additions and 407 deletions

View File

@ -30,31 +30,16 @@ Preferences *p_pref;
Preferences *p_layout; Preferences *p_layout;
Profile *p_profile; Profile *p_profile;
Profile::Profile()
: Preferences(), is_first_day(true)
{
p_name = STR_GEN_Profile;
p_path = PREF.Get("{home}/Profiles");
machlist.clear();
doctor = new DoctorInfo(this);
user = new UserInfo(this);
cpap = new CPAPSettings(this);
oxi = new OxiSettings(this);
appearance = new AppearanceSettings(this);
session = new SessionSettings(this);
general = new UserSettings(this);
}
Profile::Profile(QString path) Profile::Profile(QString path)
: Preferences(), is_first_day(true) : is_first_day(true)
{ {
p_name = STR_GEN_Profile; p_name = STR_GEN_Profile;
if (path.isEmpty()) { if (path.isEmpty()) {
p_path = GetAppRoot(); p_path = GetAppRoot();
} else { p_path = path; } } else {
p_path = path;
}
(*this)[STR_GEN_DataFolder] = p_path; (*this)[STR_GEN_DataFolder] = p_path;
path = path.replace("\\", "/"); path = path.replace("\\", "/");
@ -74,11 +59,6 @@ Profile::Profile(QString path)
session = NULL; session = NULL;
general = NULL; general = NULL;
} }
bool Profile::Save(QString filename)
{
return Preferences::Save(filename);
}
Profile::~Profile() Profile::~Profile()
{ {
@ -95,6 +75,11 @@ Profile::~Profile()
} }
} }
bool Profile::Save(QString filename)
{
return Preferences::Save(filename);
}
bool Profile::Open(QString filename) bool Profile::Open(QString filename)
{ {
bool b = Preferences::Open(filename); bool b = Preferences::Open(filename);

View File

@ -15,6 +15,7 @@
#include <QString> #include <QString>
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QThread> #include <QThread>
#include "machine.h" #include "machine.h"
#include "machine_loader.h" #include "machine_loader.h"
#include "preferences.h" #include "preferences.h"
@ -35,8 +36,6 @@ class CPAPSettings;
class AppearanceSettings; class AppearanceSettings;
class SessionSettings; class SessionSettings;
/*! /*!
\class Profile \class Profile
\author Mark Watkins \author Mark Watkins
@ -46,11 +45,9 @@ class SessionSettings;
class Profile : public Preferences class Profile : public Preferences
{ {
public: public:
//! \brief Creates a new Profile object 'name' (which is usually just set to "Profile", the XML filename is derived from this) //! \brief Loads a new Profile from the given path.
Profile(QString name); Profile(QString path);
//! \brief Create a new empty Profile object
Profile();
virtual ~Profile(); virtual ~Profile();
virtual bool Open(QString filename = ""); virtual bool Open(QString filename = "");
@ -58,11 +55,6 @@ class Profile: public Preferences
//! \brief Save Profile object (This is an extension to Preference::Save(..)) //! \brief Save Profile object (This is an extension to Preference::Save(..))
virtual bool Save(QString filename = ""); virtual bool Save(QString filename = "");
bool is_first_day;
//! \brief List of machines, indexed by MachineID
QHash<MachineID, Machine *> machlist;
//! \brief Add machine to this profiles machlist //! \brief Add machine to this profiles machlist
void AddMachine(Machine *m); void AddMachine(Machine *m);
@ -89,10 +81,10 @@ class Profile: public Preferences
//! \brief Get Day record if data available for date and machine type, else return NULL //! \brief Get Day record if data available for date and machine type, else return NULL
Day *GetDay(QDate date, MachineType type = MT_UNKNOWN); Day *GetDay(QDate date, MachineType type = MT_UNKNOWN);
//! \brief Get Day record if data available for date and machine type, and has enabled session data, else return NULL //! \brief Get Day record if data available for date and machine type,
// and has enabled session data, else return NULL
Day *GetGoodDay(QDate date, MachineType type); Day *GetGoodDay(QDate date, MachineType type);
//! \brief Returns a list of all machines of type t //! \brief Returns a list of all machines of type t
QList<Machine *> GetMachines(MachineType t = MT_UNKNOWN); QList<Machine *> GetMachines(MachineType t = MT_UNKNOWN);
@ -132,7 +124,6 @@ class Profile: public Preferences
virtual void ExtraLoad(QDomElement &root); virtual void ExtraLoad(QDomElement &root);
virtual QDomElement ExtraSave(QDomDocument &doc); virtual QDomElement ExtraSave(QDomDocument &doc);
QMap<QDate, QList<Day *> > daylist;
QDate FirstDay(MachineType mt = MT_UNKNOWN); QDate FirstDay(MachineType mt = MT_UNKNOWN);
QDate LastDay(MachineType mt = MT_UNKNOWN); QDate LastDay(MachineType mt = MT_UNKNOWN);
@ -141,6 +132,12 @@ class Profile: public Preferences
QString dataFolder() { return (*this).Get("{DataFolder}"); } QString dataFolder() { return (*this).Get("{DataFolder}"); }
public:
QMap<QDate, QList<Day *> > daylist; // Red-Black tree of Days (iterates in order).
QHash<MachineID, Machine *> machlist; // List of machines, indexed by MachineID.
bool is_first_day;
UserInfo *user; UserInfo *user;
CPAPSettings *cpap; CPAPSettings *cpap;
OxiSettings *oxi; OxiSettings *oxi;
@ -149,10 +146,9 @@ class Profile: public Preferences
UserSettings *general; UserSettings *general;
SessionSettings *session; SessionSettings *session;
protected: protected:
QDate m_first, m_last; QDate m_first;
QDate m_last;
}; };
class MachineLoader; class MachineLoader;
@ -258,475 +254,420 @@ const QString STR_US_PrefCalcMax = "PrefCalcMax";
const QString STR_US_TooltipTimeout = "TooltipTimeout"; const QString STR_US_TooltipTimeout = "TooltipTimeout";
const QString STR_US_ScrollDampening = "ScrollDampening"; const QString STR_US_ScrollDampening = "ScrollDampening";
// Parent class for subclasses that manipulate the profile.
class DoctorInfo class ProfileSettings
{ {
public: public:
DoctorInfo(Profile *p) : m_profile(p) { ProfileSettings(Profile *profile)
if (!m_profile->contains(STR_DI_Name)) { (*m_profile)[STR_DI_Name] = QString(); } : m_profile(profile)
{ }
if (!m_profile->contains(STR_DI_Phone)) { (*m_profile)[STR_DI_Phone] = QString(); } void setPref(QString name, QVariant value) {
(*m_profile)[name] = value;
if (!m_profile->contains(STR_DI_Email)) { (*m_profile)[STR_DI_Email] = QString(); }
if (!m_profile->contains(STR_DI_Practice)) { (*m_profile)[STR_DI_Practice] = QString(); }
if (!m_profile->contains(STR_DI_Address)) { (*m_profile)[STR_DI_Address] = QString(); }
if (!m_profile->contains(STR_DI_PatientID)) { (*m_profile)[STR_DI_PatientID] = QString(); }
} }
~DoctorInfo() {}
void setProfile(Profile *p) { m_profile = p; }
const QString name() { return (*m_profile)[STR_DI_Name].toString(); } void initPref(QString name, QVariant value) {
const QString phone() { return (*m_profile)[STR_DI_Phone].toString(); } if (!m_profile->contains(name)) {
const QString email() { return (*m_profile)[STR_DI_Email].toString(); } setPref(name, value);
const QString practiceName() { return (*m_profile)[STR_DI_Practice].toString(); } }
const QString address() { return (*m_profile)[STR_DI_Address].toString(); } }
const QString patientID() { return (*m_profile)[STR_DI_PatientID].toString(); }
void setName(QString name) { (*m_profile)[STR_DI_Name] = name; } QVariant getPref(QString name) const {
void setPhone(QString phone) { (*m_profile)[STR_DI_Phone] = phone; } return (*m_profile)[name];
void setEmail(QString phone) { (*m_profile)[STR_DI_Email] = phone; } }
void setPracticeName(QString practice) { (*m_profile)[STR_DI_Practice] = practice; }
void setAddress(QString address) { (*m_profile)[STR_DI_Address] = address; }
void setPatientID(QString pid) { (*m_profile)[STR_DI_PatientID] = pid; }
void setProfile(Profile *profile) {
m_profile = profile;
}
public:
Profile *m_profile; Profile *m_profile;
}; };
class DoctorInfo : public ProfileSettings
{
public:
DoctorInfo(Profile *profile)
: ProfileSettings(profile)
{
initPref(STR_DI_Name, QString());
initPref(STR_DI_Phone, QString());
initPref(STR_DI_Email, QString());
initPref(STR_DI_Practice, QString());
initPref(STR_DI_Address, QString());
initPref(STR_DI_PatientID, QString());
}
const QString name() const { return getPref(STR_DI_Name).toString(); }
const QString phone() const { return getPref(STR_DI_Phone).toString(); }
const QString email() const { return getPref(STR_DI_Email).toString(); }
const QString practiceName() const { return getPref(STR_DI_Practice).toString(); }
const QString address() const { return getPref(STR_DI_Address).toString(); }
const QString patientID() const { return getPref(STR_DI_PatientID).toString(); }
void setName(QString name) { setPref(STR_DI_Name, name); }
void setPhone(QString phone) { setPref(STR_DI_Phone, phone); }
void setEmail(QString phone) { setPref(STR_DI_Email, phone); }
void setPracticeName(QString practice) { setPref(STR_DI_Practice, practice); }
void setAddress(QString address) { setPref(STR_DI_Address, address); }
void setPatientID(QString pid) { setPref(STR_DI_PatientID, pid); }
};
/*! \class UserInfo /*! \class UserInfo
\brief Profile Options relating to the User Information \brief Profile Options relating to the User Information
*/ */
class UserInfo class UserInfo : public ProfileSettings
{ {
public: public:
//! \brief Create UserInfo object given Profile *p, and initialize the defaults UserInfo(Profile *profile)
UserInfo(Profile *p) : m_profile(p) { : ProfileSettings(profile)
if (!m_profile->contains(STR_UI_DOB)) { (*m_profile)[STR_UI_DOB] = QDate(1970, 1, 1); } {
initPref(STR_UI_DOB, QDate(1970, 1, 1));
if (!m_profile->contains(STR_UI_FirstName)) { (*m_profile)[STR_UI_FirstName] = QString(); } initPref(STR_UI_FirstName, QString());
initPref(STR_UI_LastName, QString());
if (!m_profile->contains(STR_UI_LastName)) { (*m_profile)[STR_UI_LastName] = QString(); } initPref(STR_UI_UserName, QString());
initPref(STR_UI_Password, QString());
if (!m_profile->contains(STR_UI_UserName)) { (*m_profile)[STR_UI_UserName] = QString(); } initPref(STR_UI_Address, QString());
initPref(STR_UI_Phone, QString());
if (!m_profile->contains(STR_UI_Password)) { (*m_profile)[STR_UI_Password] = QString(); } initPref(STR_UI_EmailAddress, QString());
initPref(STR_UI_Country, QString());
if (!m_profile->contains(STR_UI_Address)) { (*m_profile)[STR_UI_Address] = QString(); } initPref(STR_UI_Height, 0.0);
initPref(STR_UI_Gender, (int)GenderNotSpecified);
if (!m_profile->contains(STR_UI_Phone)) { (*m_profile)[STR_UI_Phone] = QString(); } initPref(STR_UI_TimeZone, QString());
initPref(STR_UI_DST, false);
if (!m_profile->contains(STR_UI_EmailAddress)) { (*m_profile)[STR_UI_EmailAddress] = QString(); }
if (!m_profile->contains(STR_UI_Country)) { (*m_profile)[STR_UI_Country] = QString(); }
if (!m_profile->contains(STR_UI_Height)) { (*m_profile)[STR_UI_Height] = 0.0; }
if (!m_profile->contains(STR_UI_Gender)) { (*m_profile)[STR_UI_Gender] = (int)GenderNotSpecified; }
if (!m_profile->contains(STR_UI_TimeZone)) { (*m_profile)[STR_UI_TimeZone] = QString(); }
if (!m_profile->contains(STR_UI_DST)) { (*m_profile)[STR_UI_DST] = false; }
} }
~UserInfo() {}
void setProfile(Profile *p) { m_profile = p; } QDate DOB() const { return getPref(STR_UI_DOB).toDate(); }
const QString firstName() const { return getPref(STR_UI_FirstName).toString(); }
const QString lastName() const { return getPref(STR_UI_LastName).toString(); }
const QString userName() const { return getPref(STR_UI_UserName).toString(); }
const QString address() const { return getPref(STR_UI_Address).toString(); }
const QString phone() const { return getPref(STR_UI_Phone).toString(); }
const QString email() const { return getPref(STR_UI_EmailAddress).toString(); }
double height() const { return getPref(STR_UI_Height).toDouble(); }
const QString country() const { return getPref(STR_UI_Country).toString(); }
Gender gender() const { return (Gender)getPref(STR_UI_Gender).toInt(); }
const QString timeZone() const { return getPref(STR_UI_TimeZone).toString(); }
bool daylightSaving() const { return getPref(STR_UI_DST).toBool(); }
QDate DOB() { return (*m_profile)[STR_UI_DOB].toDate(); } void setDOB(QDate date) { setPref(STR_UI_DOB, date); }
const QString firstName() { return (*m_profile)[STR_UI_FirstName].toString(); } void setFirstName(QString name) { setPref(STR_UI_FirstName, name); }
const QString lastName() { return (*m_profile)[STR_UI_LastName].toString(); } void setLastName(QString name) { setPref(STR_UI_LastName, name); }
const QString userName() { return (*m_profile)[STR_UI_UserName].toString(); } void setUserName(QString username) { setPref(STR_UI_UserName, username); }
const QString address() { return (*m_profile)[STR_UI_Address].toString(); } void setAddress(QString address) { setPref(STR_UI_Address, address); }
const QString phone() { return (*m_profile)[STR_UI_Phone].toString(); } void setPhone(QString phone) { setPref(STR_UI_Phone, phone); }
const QString email() { return (*m_profile)[STR_UI_EmailAddress].toString(); } void setEmail(QString email) { setPref(STR_UI_EmailAddress, email); }
double height() { return (*m_profile)[STR_UI_Height].toDouble(); } void setHeight(double height) { setPref(STR_UI_Height, height); }
const QString country() { return (*m_profile)[STR_UI_Country].toString(); } void setCountry(QString country) { setPref(STR_UI_Country, country); }
Gender gender() { return (Gender)(*m_profile)[STR_UI_Gender].toInt(); } void setGender(Gender g) { setPref(STR_UI_Gender, (int)g); }
const QString timeZone() { return (*m_profile)[STR_UI_TimeZone].toString(); } void setTimeZone(QString tz) { setPref(STR_UI_TimeZone, tz); }
bool daylightSaving() { return (*m_profile)[STR_UI_DST].toBool(); } void setDaylightSaving(bool ds) { setPref(STR_UI_DST, ds); }
void setDOB(QDate date) { (*m_profile)[STR_UI_DOB] = date; } bool hasPassword() { return !getPref(STR_UI_Password).toString().isEmpty(); }
void setFirstName(QString name) { (*m_profile)[STR_UI_FirstName] = name; }
void setLastName(QString name) { (*m_profile)[STR_UI_LastName] = name; }
void setUserName(QString username) { (*m_profile)[STR_UI_UserName] = username; }
void setAddress(QString address) { (*m_profile)[STR_UI_Address] = address; }
void setPhone(QString phone) { (*m_profile)[STR_UI_Phone] = phone; }
void setEmail(QString email) { (*m_profile)[STR_UI_EmailAddress] = email; }
void setHeight(double height) { (*m_profile)[STR_UI_Height] = height; }
void setCountry(QString country) { (*m_profile)[STR_UI_Country] = country; }
void setGender(Gender g) { (*m_profile)[STR_UI_Gender] = (int)g; }
void setTimeZone(QString tz) { (*m_profile)[STR_UI_TimeZone] = tz; }
void setDaylightSaving(bool ds) { (*m_profile)[STR_UI_DST] = ds; }
bool hasPassword() {
return !((*m_profile)[STR_UI_Password].toString().isEmpty());
}
bool checkPassword(QString password) { bool checkPassword(QString password) {
QByteArray ba = password.toUtf8(); QByteArray ba = password.toUtf8();
return ((*m_profile)[STR_UI_Password].toString() == QString(QCryptographicHash::hash(ba, QString hashedPass = QString(QCryptographicHash::hash(ba, QCryptographicHash::Sha1).toHex());
QCryptographicHash::Sha1).toHex())); return getPref(STR_UI_Password).toString() == hashedPass;
} }
void setPassword(QString password) { void setPassword(QString password) {
QByteArray ba = password.toUtf8(); QByteArray ba = password.toUtf8();
// Hash me. QString hashedPass = QString(QCryptographicHash::hash(ba, QCryptographicHash::Sha1).toHex());
(*m_profile)[STR_UI_Password] = QString(QCryptographicHash::hash(ba, setPref(STR_UI_Password, hashedPass);
QCryptographicHash::Sha1).toHex());
} }
Profile *m_profile;
}; };
/*! \class OxiSettings /*! \class OxiSettings
\brief Profile Options relating to the Oximetry settings \brief Profile Options relating to the Oximetry settings
*/ */
class OxiSettings class OxiSettings : public ProfileSettings
{ {
public: public:
//! \brief Create OxiSettings object given Profile *p, and initialize the defaults //! \brief Create OxiSettings object given Profile *p, and initialize the defaults
OxiSettings(Profile *p) : m_profile(p) { OxiSettings(Profile *profile)
if (!m_profile->contains(STR_OS_EnableOximetry)) { (*m_profile)[STR_OS_EnableOximetry] = false; } : ProfileSettings(profile)
{
if (!m_profile->contains(STR_OS_SyncOximetry)) { (*m_profile)[STR_OS_SyncOximetry] = true; } initPref(STR_OS_EnableOximetry, false);
initPref(STR_OS_SyncOximetry, true);
if (!m_profile->contains(STR_OS_OximeterType)) { (*m_profile)[STR_OS_OximeterType] = "CMS50"; } initPref(STR_OS_OximeterType, "CMS50");
initPref(STR_OS_OxiDiscardThreshold, 0.0);
if (!m_profile->contains(STR_OS_OxiDiscardThreshold)) { (*m_profile)[STR_OS_OxiDiscardThreshold] = 0.0; } initPref(STR_OS_SPO2DropDuration, 8.0);
initPref(STR_OS_SPO2DropPercentage, 3.0);
if (!m_profile->contains(STR_OS_SPO2DropDuration)) { (*m_profile)[STR_OS_SPO2DropDuration] = 8.0; } initPref(STR_OS_PulseChangeDuration, 8.0);
initPref(STR_OS_PulseChangeBPM, 5.0);
if (!m_profile->contains(STR_OS_SPO2DropPercentage)) { (*m_profile)[STR_OS_SPO2DropPercentage] = 3.0; }
if (!m_profile->contains(STR_OS_PulseChangeDuration)) { (*m_profile)[STR_OS_PulseChangeDuration] = 8.0; }
if (!m_profile->contains(STR_OS_PulseChangeBPM)) { (*m_profile)[STR_OS_PulseChangeBPM] = 5.0; }
} }
~OxiSettings() {}
void setProfile(Profile *p) { m_profile = p; } bool oximetryEnabled() const { return getPref(STR_OS_EnableOximetry).toBool(); }
bool syncOximetry() const { return getPref(STR_OS_SyncOximetry).toBool(); }
QString oximeterType() const { return getPref(STR_OS_OximeterType).toString(); }
double oxiDiscardThreshold() const { return getPref(STR_OS_OxiDiscardThreshold).toDouble(); }
double spO2DropDuration() const { return getPref(STR_OS_SPO2DropDuration).toDouble(); }
double spO2DropPercentage() const { return getPref(STR_OS_SPO2DropPercentage).toDouble(); }
double pulseChangeDuration() const { return getPref(STR_OS_PulseChangeDuration).toDouble(); }
double pulseChangeBPM() const { return getPref(STR_OS_PulseChangeBPM).toDouble(); }
bool oximetryEnabled() { return (*m_profile)[STR_OS_EnableOximetry].toBool(); } void setOximetryEnabled(bool enabled) { setPref(STR_OS_EnableOximetry, enabled); }
bool syncOximetry() { return (*m_profile)[STR_OS_SyncOximetry].toBool(); } void setSyncOximetry(bool synced) { setPref(STR_OS_SyncOximetry, synced); }
QString oximeterType() { return (*m_profile)[STR_OS_OximeterType].toString(); } void setOximeterType(QString oxitype) { setPref(STR_OS_OximeterType, oxitype); }
double oxiDiscardThreshold() { return (*m_profile)[STR_OS_OxiDiscardThreshold].toDouble(); } void setOxiDiscardThreshold(double thresh) { setPref(STR_OS_OxiDiscardThreshold, thresh); }
double spO2DropDuration() { return (*m_profile)[STR_OS_SPO2DropDuration].toDouble(); } void setSpO2DropDuration(double duration) { setPref(STR_OS_SPO2DropDuration, duration); }
double spO2DropPercentage() { return (*m_profile)[STR_OS_SPO2DropPercentage].toDouble(); } void setPulseChangeBPM(double bpm) { setPref(STR_OS_PulseChangeBPM, bpm); }
double pulseChangeDuration() { return (*m_profile)[STR_OS_PulseChangeDuration].toDouble(); } void setSpO2DropPercentage(double percentage) {
double pulseChangeBPM() { return (*m_profile)[STR_OS_PulseChangeBPM].toDouble(); } setPref(STR_OS_SPO2DropPercentage, percentage);
}
void setOximetryEnabled(bool enabled) { (*m_profile)[STR_OS_EnableOximetry] = enabled; } void setPulseChangeDuration(double duration) {
void setSyncOximetry(bool synced) { (*m_profile)[STR_OS_SyncOximetry] = synced; } setPref(STR_OS_PulseChangeDuration, duration);
void setOximeterType(QString oxitype) { (*m_profile)[STR_OS_OximeterType] = oxitype; } }
void setOxiDiscardThreshold(double thresh) { (*m_profile)[STR_OS_OxiDiscardThreshold] = thresh; }
void setSpO2DropDuration(double duration) { (*m_profile)[STR_OS_SPO2DropDuration] = duration; }
void setSpO2DropPercentage(double percentage) { (*m_profile)[STR_OS_SPO2DropPercentage] = percentage; }
void setPulseChangeDuration(double duration) { (*m_profile)[STR_OS_PulseChangeDuration] = duration; }
void setPulseChangeBPM(double bpm) { (*m_profile)[STR_OS_PulseChangeBPM] = bpm; }
Profile *m_profile;
}; };
/*! \class CPAPSettings /*! \class CPAPSettings
\brief Profile Options relating to the CPAP settings \brief Profile Options relating to the CPAP settings
*/ */
class CPAPSettings class CPAPSettings : public ProfileSettings
{ {
public: public:
//! \brief Create CPAPSettings object given Profile *p, and initialize the defaults CPAPSettings(Profile *profile)
CPAPSettings(Profile *p) : m_profile(p) { : ProfileSettings(profile)
if (!m_profile->contains(STR_CS_ComplianceHours)) { (*m_profile)[STR_CS_ComplianceHours] = 4; } {
initPref(STR_CS_ComplianceHours, 4);
initPref(STR_CS_ShowCompliance, true);
initPref(STR_CS_ShowLeaksMode, 0);
// TODO: jedimark: Check if this date is initiliazed yet
initPref(STR_CS_MaskStartDate, QDate());
initPref(STR_CS_MaskDescription, QString());
initPref(STR_CS_MaskType, Mask_Unknown);
initPref(STR_CS_PrescribedMode, MODE_UNKNOWN);
initPref(STR_CS_PrescribedMinPressure, 0.0);
initPref(STR_CS_PrescribedMaxPressure, 0.0);
initPref(STR_CS_UntreatedAHI, 0.0);
initPref(STR_CS_Notes, QString());
initPref(STR_CS_DateDiagnosed, QDate());
initPref(STR_CS_UserFlowRestriction, 20.0);
initPref(STR_CS_UserEventDuration, 10.0);
initPref(STR_CS_UserEventDuplicates, false);
initPref(STR_CS_UserEventFlagging, false);
initPref(STR_CS_AHIWindow, 60.0);
initPref(STR_CS_AHIReset, false);
if (!m_profile->contains(STR_CS_ShowCompliance)) { (*m_profile)[STR_CS_ShowCompliance] = true; } initPref(STR_CS_ClockDrift, (int)0);
m_clock_drift = getPref(STR_CS_ClockDrift).toInt();
if (!m_profile->contains(STR_CS_ShowLeaksMode)) { (*m_profile)[STR_CS_ShowLeaksMode] = 0; }
// TODO: Check if this date is initiliazed yet
if (!m_profile->contains(STR_CS_MaskStartDate)) { (*m_profile)[STR_CS_MaskStartDate] = QDate(); }
if (!m_profile->contains(STR_CS_MaskDescription)) { (*m_profile)[STR_CS_MaskDescription] = QString(); }
if (!m_profile->contains(STR_CS_MaskType)) { (*m_profile)[STR_CS_MaskType] = Mask_Unknown; }
if (!m_profile->contains(STR_CS_PrescribedMode)) { (*m_profile)[STR_CS_PrescribedMode] = MODE_UNKNOWN; }
if (!m_profile->contains(STR_CS_PrescribedMinPressure)) { (*m_profile)[STR_CS_PrescribedMinPressure] = 0.0; }
if (!m_profile->contains(STR_CS_PrescribedMaxPressure)) { (*m_profile)[STR_CS_PrescribedMaxPressure] = 0.0; }
if (!m_profile->contains(STR_CS_UntreatedAHI)) { (*m_profile)[STR_CS_UntreatedAHI] = 0.0; }
if (!m_profile->contains(STR_CS_Notes)) { (*m_profile)[STR_CS_Notes] = QString(); }
if (!m_profile->contains(STR_CS_DateDiagnosed)) { (*m_profile)[STR_CS_DateDiagnosed] = QDate(); }
if (!m_profile->contains(STR_CS_UserFlowRestriction)) { (*m_profile)[STR_CS_UserFlowRestriction] = 20.0; }
if (!m_profile->contains(STR_CS_UserEventDuration)) { (*m_profile)[STR_CS_UserEventDuration] = 10.0; }
if (!m_profile->contains(STR_CS_UserEventDuplicates)) { (*m_profile)[STR_CS_UserEventDuplicates] = false; }
if (!m_profile->contains(STR_CS_UserEventFlagging)) { (*m_profile)[STR_CS_UserEventFlagging] = false; }
if (!m_profile->contains(STR_CS_AHIWindow)) { (*m_profile)[STR_CS_AHIWindow] = 60.0; }
if (!m_profile->contains(STR_CS_AHIReset)) { (*m_profile)[STR_CS_AHIReset] = false; }
if (!m_profile->contains(STR_CS_ClockDrift)) { (*m_profile)[STR_CS_ClockDrift] = m_clock_drift = (int)0; }
else { m_clock_drift = (*m_profile)[STR_CS_ClockDrift].toInt(); }
} }
~CPAPSettings() { }
void setProfile(Profile *p) { m_profile = p; }
//Getters //Getters
double complianceHours() { return (*m_profile)[STR_CS_ComplianceHours].toDouble(); } double complianceHours() const { return getPref(STR_CS_ComplianceHours).toDouble(); }
bool showComplianceInfo() { return (*m_profile)[STR_CS_ShowCompliance].toBool(); } bool showComplianceInfo() const { return getPref(STR_CS_ShowCompliance).toBool(); }
int leakMode() { return (*m_profile)[STR_CS_ShowLeaksMode].toInt(); } int leakMode() const { return getPref(STR_CS_ShowLeaksMode).toInt(); }
QDate maskStartDate() { return (*m_profile)[STR_CS_MaskStartDate].toDate(); } QDate maskStartDate() const { return getPref(STR_CS_MaskStartDate).toDate(); }
QString maskDescription() { return (*m_profile)[STR_CS_MaskDescription].toString(); } QString maskDescription() const { return getPref(STR_CS_MaskDescription).toString(); }
MaskType maskType() { return (MaskType)(*m_profile)[STR_CS_MaskType].toInt(); } MaskType maskType() const { return (MaskType)getPref(STR_CS_MaskType).toInt(); }
CPAPMode mode() { return CPAPMode((*m_profile)[STR_CS_PrescribedMode].toInt()); } CPAPMode mode() const { return CPAPMode(getPref(STR_CS_PrescribedMode).toInt()); }
double minPressure() { return (*m_profile)[STR_CS_PrescribedMinPressure].toDouble(); } double minPressure() const { return getPref(STR_CS_PrescribedMinPressure).toDouble(); }
double maxPressure() { return (*m_profile)[STR_CS_PrescribedMaxPressure].toDouble(); } double maxPressure() const { return getPref(STR_CS_PrescribedMaxPressure).toDouble(); }
double untreatedAHI() { return (*m_profile)[STR_CS_UntreatedAHI].toDouble(); } double untreatedAHI() const { return getPref(STR_CS_UntreatedAHI).toDouble(); }
const QString notes() { return (*m_profile)[STR_CS_Notes].toString(); } const QString notes() const { return getPref(STR_CS_Notes).toString(); }
QDate dateDiagnosed() { return (*m_profile)[STR_CS_DateDiagnosed].toDate(); } QDate dateDiagnosed() const { return getPref(STR_CS_DateDiagnosed).toDate(); }
double userFlowRestriction() { return (*m_profile)[STR_CS_UserFlowRestriction].toDouble(); } double userFlowRestriction() const { return getPref(STR_CS_UserFlowRestriction).toDouble(); }
double userEventDuration() { return (*m_profile)[STR_CS_UserEventDuration].toDouble(); } double userEventDuration() const { return getPref(STR_CS_UserEventDuration).toDouble(); }
bool userEventDuplicates() { return (*m_profile)[STR_CS_UserEventDuplicates].toBool(); } bool userEventDuplicates() const { return getPref(STR_CS_UserEventDuplicates).toBool(); }
double AHIWindow() { return (*m_profile)[STR_CS_AHIWindow].toDouble(); } double AHIWindow() const { return getPref(STR_CS_AHIWindow).toDouble(); }
bool AHIReset() { return (*m_profile)[STR_CS_AHIReset].toBool(); } bool AHIReset() const { return getPref(STR_CS_AHIReset).toBool(); }
bool userEventFlagging() { return (*m_profile)[STR_CS_UserEventFlagging].toBool(); } bool userEventFlagging() const { return getPref(STR_CS_UserEventFlagging).toBool(); }
int clockDrift() { return m_clock_drift; } int clockDrift() const { return m_clock_drift; }
//Setters //Setters
void setMode(CPAPMode mode) { (*m_profile)[STR_CS_PrescribedMode] = (int)mode; } void setMode(CPAPMode mode) { setPref(STR_CS_PrescribedMode, (int)mode); }
void setMinPressure(double pressure) { (*m_profile)[STR_CS_PrescribedMinPressure] = pressure; } void setMinPressure(double pressure) { setPref(STR_CS_PrescribedMinPressure, pressure); }
void setMaxPressure(double pressure) { (*m_profile)[STR_CS_PrescribedMaxPressure] = pressure; } void setMaxPressure(double pressure) { setPref(STR_CS_PrescribedMaxPressure, pressure); }
void setUntreatedAHI(double ahi) { (*m_profile)[STR_CS_UntreatedAHI] = ahi; } void setUntreatedAHI(double ahi) { setPref(STR_CS_UntreatedAHI, ahi); }
void setNotes(QString notes) { (*m_profile)[STR_CS_Notes] = notes; } void setNotes(QString notes) { setPref(STR_CS_Notes, notes); }
void setDateDiagnosed(QDate date) { (*m_profile)[STR_CS_DateDiagnosed] = date; } void setDateDiagnosed(QDate date) { setPref(STR_CS_DateDiagnosed, date); }
void setComplianceHours(double hours) { (*m_profile)[STR_CS_ComplianceHours] = hours; } void setComplianceHours(double hours) { setPref(STR_CS_ComplianceHours, hours); }
void setShowComplianceInfo(bool b) { (*m_profile)[STR_CS_ShowCompliance] = b; } void setShowComplianceInfo(bool b) { setPref(STR_CS_ShowCompliance, b); }
void setLeakMode(int leakmode) { (*m_profile)[STR_CS_ShowLeaksMode] = (int)leakmode; } void setLeakMode(int leakmode) { setPref(STR_CS_ShowLeaksMode, (int)leakmode); }
void setMaskStartDate(QDate date) { (*m_profile)[STR_CS_MaskStartDate] = date; } void setMaskStartDate(QDate date) { setPref(STR_CS_MaskStartDate, date); }
void setMaskDescription(QString description) { (*m_profile)[STR_CS_MaskDescription] = description; } void setMaskType(MaskType masktype) { setPref(STR_CS_MaskType, (int)masktype); }
void setMaskType(MaskType masktype) { (*m_profile)[STR_CS_MaskType] = (int)masktype; } void setUserFlowRestriction(double flow) { setPref(STR_CS_UserFlowRestriction, flow); }
void setUserFlowRestriction(double flow) { (*m_profile)[STR_CS_UserFlowRestriction] = flow; } void setUserEventDuration(double duration) { setPref(STR_CS_UserEventDuration, duration); }
void setUserEventDuration(double duration) { (*m_profile)[STR_CS_UserEventDuration] = duration; } void setAHIWindow(double window) { setPref(STR_CS_AHIWindow, window); }
void setAHIWindow(double window) { (*m_profile)[STR_CS_AHIWindow] = window; } void setAHIReset(bool reset) { setPref(STR_CS_AHIReset, reset); }
void setAHIReset(bool reset) { (*m_profile)[STR_CS_AHIReset] = reset; } void setUserEventFlagging(bool flagging) { setPref(STR_CS_UserEventFlagging, flagging); }
void setUserEventFlagging(bool flagging) { (*m_profile)[STR_CS_UserEventFlagging] = flagging; } void setUserEventDuplicates(bool dup) { setPref(STR_CS_UserEventDuplicates, dup); }
void setUserEventDuplicates(bool dup) { (*m_profile)[STR_CS_UserEventDuplicates] = dup; } void setMaskDescription(QString description) {
void setClockDrift(int seconds) { (*m_profile)[STR_CS_ClockDrift] = m_clock_drift = (int)seconds; } setPref(STR_CS_MaskDescription, description);
}
Profile *m_profile; void setClockDrift(int seconds) {
setPref(STR_CS_ClockDrift, m_clock_drift = (int)seconds);
}
public:
int m_clock_drift; int m_clock_drift;
}; };
/*! \class ImportSettings /*! \class ImportSettings
\brief Profile Options relating to the Import process \brief Profile Options relating to the Import process
*/ */
class SessionSettings class SessionSettings : public ProfileSettings
{ {
public: public:
//! \brief Create ImportSettings object given Profile *p, and initialize the defaults SessionSettings(Profile *profile)
SessionSettings(Profile *p) : m_profile(p) { : ProfileSettings(profile)
if (!m_profile->contains(STR_IS_DaySplitTime)) { (*m_profile)[STR_IS_DaySplitTime] = QTime(12, 0, 0); } {
initPref(STR_IS_DaySplitTime, QTime(12, 0, 0));
if (!m_profile->contains(STR_IS_CacheSessions)) { (*m_profile)[STR_IS_CacheSessions] = false; } initPref(STR_IS_CacheSessions, false);
initPref(STR_IS_CombineCloseSessions, 240);
if (!m_profile->contains(STR_IS_CombineCloseSessions)) { (*m_profile)[STR_IS_CombineCloseSessions] = 240; } initPref(STR_IS_IgnoreShorterSessions, 5);
initPref(STR_IS_Multithreading, QThread::idealThreadCount() > 1);
if (!m_profile->contains(STR_IS_IgnoreShorterSessions)) { (*m_profile)[STR_IS_IgnoreShorterSessions] = 5; } initPref(STR_IS_BackupCardData, true);
initPref(STR_IS_CompressBackupData, false);
if (!m_profile->contains(STR_IS_Multithreading)) { (*m_profile)[STR_IS_Multithreading] = QThread::idealThreadCount() > 1; } initPref(STR_IS_CompressSessionData, false);
if (!m_profile->contains(STR_IS_BackupCardData)) { (*m_profile)[STR_IS_BackupCardData] = true; }
if (!m_profile->contains(STR_IS_CompressBackupData)) { (*m_profile)[STR_IS_CompressBackupData] = false; }
if (!m_profile->contains(STR_IS_CompressSessionData)) { (*m_profile)[STR_IS_CompressSessionData] = false; }
} }
~SessionSettings() {}
void setProfile(Profile *p) { m_profile = p; } QTime daySplitTime() const { return getPref(STR_IS_DaySplitTime).toTime(); }
bool cacheSessions() const { return getPref(STR_IS_CacheSessions).toBool(); }
double combineCloseSessions() const { return getPref(STR_IS_CombineCloseSessions).toDouble(); }
double ignoreShortSessions() const { return getPref(STR_IS_IgnoreShorterSessions).toDouble(); }
bool multithreading() const { return getPref(STR_IS_Multithreading).toBool(); }
bool compressSessionData() const { return getPref(STR_IS_CompressSessionData).toBool(); }
bool compressBackupData() const { return getPref(STR_IS_CompressBackupData).toBool(); }
bool backupCardData() const { return getPref(STR_IS_BackupCardData).toBool(); }
QTime daySplitTime() { return (*m_profile)[STR_IS_DaySplitTime].toTime(); } void setDaySplitTime(QTime time) { setPref(STR_IS_DaySplitTime, time); }
bool cacheSessions() { return (*m_profile)[STR_IS_CacheSessions].toBool(); } void setCacheSessions(bool c) { setPref(STR_IS_CacheSessions, c); }
double combineCloseSessions() { return (*m_profile)[STR_IS_CombineCloseSessions].toDouble(); } void setCombineCloseSessions(double val) { setPref(STR_IS_CombineCloseSessions, val); }
double ignoreShortSessions() { return (*m_profile)[STR_IS_IgnoreShorterSessions].toDouble(); } void setIgnoreShortSessions(double val) { setPref(STR_IS_IgnoreShorterSessions, val); }
bool multithreading() { return (*m_profile)[STR_IS_Multithreading].toBool(); } void setMultithreading(bool enabled) { setPref(STR_IS_Multithreading, enabled); }
bool compressSessionData() { return (*m_profile)[STR_IS_CompressSessionData].toBool(); } void setBackupCardData(bool enabled) { setPref(STR_IS_BackupCardData, enabled); }
bool compressBackupData() { return (*m_profile)[STR_IS_CompressBackupData].toBool(); } void setCompressBackupData(bool enabled) { setPref(STR_IS_CompressBackupData, enabled); }
bool backupCardData() { return (*m_profile)[STR_IS_BackupCardData].toBool(); } void setCompressSessionData(bool enabled) { setPref(STR_IS_CompressSessionData, enabled); }
void setDaySplitTime(QTime time) { (*m_profile)[STR_IS_DaySplitTime] = time; }
void setCacheSessions(bool c) { (*m_profile)[STR_IS_CacheSessions] = c; }
void setCombineCloseSessions(double val) { (*m_profile)[STR_IS_CombineCloseSessions] = val; }
void setIgnoreShortSessions(double val) { (*m_profile)[STR_IS_IgnoreShorterSessions] = val; }
void setMultithreading(bool enabled) { (*m_profile)[STR_IS_Multithreading] = enabled; }
void setBackupCardData(bool enabled) { (*m_profile)[STR_IS_BackupCardData] = enabled; }
void setCompressBackupData(bool enabled) { (*m_profile)[STR_IS_CompressBackupData] = enabled; }
void setCompressSessionData(bool enabled) { (*m_profile)[STR_IS_CompressSessionData] = enabled; }
Profile *m_profile;
}; };
/*! \class AppearanceSettings /*! \class AppearanceSettings
\brief Profile Options relating to Visual Appearance \brief Profile Options relating to Visual Appearance
*/ */
class AppearanceSettings class AppearanceSettings : public ProfileSettings
{ {
public: public:
//! \brief Create AppearanceSettings object given Profile *p, and initialize the defaults //! \brief Create AppearanceSettings object given Profile *p, and initialize the defaults
AppearanceSettings(Profile *p) : m_profile(p) { AppearanceSettings(Profile *profile)
if (!m_profile->contains(STR_AS_GraphHeight)) { (*m_profile)[STR_AS_GraphHeight] = 180.0; } : ProfileSettings(profile)
{
if (!m_profile->contains(STR_AS_AntiAliasing)) { (*m_profile)[STR_AS_AntiAliasing] = false; } // i think it's ugly initPref(STR_AS_GraphHeight, 180.0);
initPref(STR_AS_AntiAliasing, false); // I think it's ugly.
if (!m_profile->contains(STR_AS_GraphSnapshots)) { (*m_profile)[STR_AS_GraphSnapshots] = true; } initPref(STR_AS_GraphSnapshots, true);
initPref(STR_AS_Animations, true);
if (!m_profile->contains(STR_AS_Animations)) { (*m_profile)[STR_AS_Animations] = true; } initPref(STR_AS_SquareWave, false);
initPref(STR_AS_AllowYAxisScaling, true);
if (!m_profile->contains(STR_AS_SquareWave)) { (*m_profile)[STR_AS_SquareWave] = false; } initPref(STR_AS_GraphTooltips, true);
initPref(STR_AS_UsePixmapCaching, true);
if (!m_profile->contains(STR_AS_AllowYAxisScaling)) { (*m_profile)[STR_AS_AllowYAxisScaling] = true; } initPref(STR_AS_OverlayType, ODT_Bars);
initPref(STR_AS_OverviewLinechartMode, OLC_Bartop);
if (!m_profile->contains(STR_AS_GraphTooltips)) { (*m_profile)[STR_AS_GraphTooltips] = true; }
if (!m_profile->contains(STR_AS_UsePixmapCaching)) { (*m_profile)[STR_AS_UsePixmapCaching] = true; }
if (!m_profile->contains(STR_AS_OverlayType)) { (*m_profile)[STR_AS_OverlayType] = ODT_Bars; }
if (!m_profile->contains(STR_AS_OverviewLinechartMode)) { (*m_profile)[STR_AS_OverviewLinechartMode] = OLC_Bartop; }
} }
~AppearanceSettings() {}
void setProfile(Profile *p) { m_profile = p; }
//! \brief Returns the normal (unscaled) height of a graph //! \brief Returns the normal (unscaled) height of a graph
int graphHeight() { return (*m_profile)[STR_AS_GraphHeight].toInt(); } int graphHeight() const { return getPref(STR_AS_GraphHeight).toInt(); }
//! \brief Returns true if AntiAliasing (the graphical smoothing method) is enabled //! \brief Returns true if AntiAliasing (the graphical smoothing method) is enabled
bool antiAliasing() { return (*m_profile)[STR_AS_AntiAliasing].toBool(); } bool antiAliasing() const { return getPref(STR_AS_AntiAliasing).toBool(); }
//! \brief Returns true if renderPixmap function is in use, which takes snapshots of graphs //! \brief Returns true if renderPixmap function is in use, which takes snapshots of graphs
bool graphSnapshots() { return (*m_profile)[STR_AS_GraphSnapshots].toBool(); } bool graphSnapshots() const { return getPref(STR_AS_GraphSnapshots).toBool(); }
//! \brief Returns true if Graphical animations & Transitions will be drawn //! \brief Returns true if Graphical animations & Transitions will be drawn
bool animations() { return (*m_profile)[STR_AS_Animations].toBool(); } bool animations() const { return getPref(STR_AS_Animations).toBool(); }
//! \brief Returns true if PixmapCaching acceleration will be used //! \brief Returns true if PixmapCaching acceleration will be used
bool usePixmapCaching() { return (*m_profile)[STR_AS_UsePixmapCaching].toBool(); } bool usePixmapCaching() const { return getPref(STR_AS_UsePixmapCaching).toBool(); }
//! \brief Returns true if Square Wave plots are preferred (where possible) //! \brief Returns true if Square Wave plots are preferred (where possible)
bool squareWavePlots() { return (*m_profile)[STR_AS_SquareWave].toBool(); } bool squareWavePlots() const { return getPref(STR_AS_SquareWave).toBool(); }
//! \brief Whether to allow double clicking on Y-Axis labels to change vertical scaling mode //! \brief Whether to allow double clicking on Y-Axis labels to change vertical scaling mode
bool allowYAxisScaling() { return (*m_profile)[STR_AS_AllowYAxisScaling].toBool(); } bool allowYAxisScaling() const { return getPref(STR_AS_AllowYAxisScaling).toBool(); }
//! \brief Whether to show graph tooltips //! \brief Whether to show graph tooltips
bool graphTooltips() { return (*m_profile)[STR_AS_GraphTooltips].toBool(); } bool graphTooltips() const { return getPref(STR_AS_GraphTooltips).toBool(); }
//! \brief Returns the type of overlay flags (which are displayed over the Flow Waveform) //! \brief Returns the type of overlay flags (which are displayed over the Flow Waveform)
OverlayDisplayType overlayType() { return (OverlayDisplayType)(*m_profile)[STR_AS_OverlayType].toInt(); } OverlayDisplayType overlayType() const {
return (OverlayDisplayType)getPref(STR_AS_OverlayType).toInt();
}
//! \brief Returns the display type of Overview pages linechart //! \brief Returns the display type of Overview pages linechart
OverviewLinechartModes overviewLinechartMode() { return (OverviewLinechartModes)(*m_profile)[STR_AS_OverviewLinechartMode].toInt(); } OverviewLinechartModes overviewLinechartMode() const {
return (OverviewLinechartModes)getPref(STR_AS_OverviewLinechartMode).toInt();
}
//! \brief Set the normal (unscaled) height of a graph. //! \brief Set the normal (unscaled) height of a graph.
void setGraphHeight(int height) { (*m_profile)[STR_AS_GraphHeight] = height; } void setGraphHeight(int height) { setPref(STR_AS_GraphHeight, height); }
//! \brief Set to true to turn on AntiAliasing (the graphical smoothing method) //! \brief Set to true to turn on AntiAliasing (the graphical smoothing method)
void setAntiAliasing(bool aa) { (*m_profile)[STR_AS_AntiAliasing] = aa; } void setAntiAliasing(bool aa) { setPref(STR_AS_AntiAliasing, aa); }
//! \brief Set to true if renderPixmap functions are in use, which takes snapshots of graphs. //! \brief Set to true if renderPixmap functions are in use, which takes snapshots of graphs.
void setGraphSnapshots(bool gs) { (*m_profile)[STR_AS_GraphSnapshots] = gs; } void setGraphSnapshots(bool gs) { setPref(STR_AS_GraphSnapshots, gs); }
//! \brief Set to true if Graphical animations & Transitions will be drawn //! \brief Set to true if Graphical animations & Transitions will be drawn
void setAnimations(bool anim) { (*m_profile)[STR_AS_Animations] = anim; } void setAnimations(bool anim) { setPref(STR_AS_Animations, anim); }
//! \brief Set to true to use Pixmap Caching of Text and other graphics caching speedup techniques //! \brief Set to true to use Pixmap Caching of Text and other graphics caching speedup techniques
void setUsePixmapCaching(bool b) { (*m_profile)[STR_AS_UsePixmapCaching] = b; } void setUsePixmapCaching(bool b) { setPref(STR_AS_UsePixmapCaching, b); }
//! \brief Set whether or not to useSquare Wave plots (where possible) //! \brief Set whether or not to useSquare Wave plots (where possible)
void setSquareWavePlots(bool sw) { (*m_profile)[STR_AS_SquareWave] = sw; } void setSquareWavePlots(bool sw) { setPref(STR_AS_SquareWave, sw); }
//! \brief Sets the type of overlay flags (which are displayed over the Flow Waveform) //! \brief Sets the type of overlay flags (which are displayed over the Flow Waveform)
void setOverlayType(OverlayDisplayType od) { (*m_profile)[STR_AS_OverlayType] = (int)od; } void setOverlayType(OverlayDisplayType od) { setPref(STR_AS_OverlayType, (int)od); }
//! \brief Sets whether to allow double clicking on Y-Axis labels to change vertical scaling mode
void setAllowYAxisScaling(bool b) { setPref(STR_AS_AllowYAxisScaling, b); }
//! \brief Sets whether to allow double clicking on Y-Axis labels to change vertical scaling mode
void setGraphTooltips(bool b) { setPref(STR_AS_GraphTooltips, b); }
//! \brief Sets the type of overlay flags (which are displayed over the Flow Waveform) //! \brief Sets the type of overlay flags (which are displayed over the Flow Waveform)
void setOverviewLinechartMode(OverviewLinechartModes od) { (*m_profile)[STR_AS_OverviewLinechartMode] = (int)od; } void setOverviewLinechartMode(OverviewLinechartModes od) {
//! \brief Sets whether to allow double clicking on Y-Axis labels to change vertical scaling mode setPref(STR_AS_OverviewLinechartMode, (int)od);
void setAllowYAxisScaling(bool b) { (*m_profile)[STR_AS_AllowYAxisScaling] = b; } }
//! \brief Sets whether to allow double clicking on Y-Axis labels to change vertical scaling mode
void setGraphTooltips(bool b) { (*m_profile)[STR_AS_GraphTooltips] = b; }
Profile *m_profile;
}; };
/*! \class UserSettings /*! \class UserSettings
\brief Profile Options relating to General User Settings \brief Profile Options relating to General User Settings
*/ */
class UserSettings class UserSettings : public ProfileSettings
{ {
public: public:
//! \brief Create UserSettings object given Profile *p, and initialize the defaults UserSettings(Profile *profile)
UserSettings(Profile *p) : m_profile(p) { : ProfileSettings(profile)
if (!m_profile->contains(STR_US_UnitSystem)) { (*m_profile)[STR_US_UnitSystem] = US_Metric; } {
initPref(STR_US_UnitSystem, US_Metric);
if (!m_profile->contains(STR_US_EventWindowSize)) { (*m_profile)[STR_US_EventWindowSize] = 4.0; } initPref(STR_US_EventWindowSize, 4.0);
initPref(STR_US_SkipEmptyDays, true);
if (!m_profile->contains(STR_US_SkipEmptyDays)) { (*m_profile)[STR_US_SkipEmptyDays] = true; } initPref(STR_US_RebuildCache, false); // FIXME: jedimark: can't remember...
initPref(STR_US_ShowDebug, false);
if (!m_profile->contains(STR_US_RebuildCache)) { (*m_profile)[STR_US_RebuildCache] = false; } // can't remember.. initPref(STR_US_LinkGroups, true); // FIXME: jedimark: can't remember...
initPref(STR_US_CalculateRDI, false);
if (!m_profile->contains(STR_US_ShowDebug)) { (*m_profile)[STR_US_ShowDebug] = false; } initPref(STR_US_ShowSerialNumbers, false);
initPref(STR_US_PrefCalcMiddle, (int)0);
if (!m_profile->contains(STR_US_LinkGroups)) { (*m_profile)[STR_US_LinkGroups] = true; } // can't remember.. initPref(STR_US_PrefCalcPercentile, (double)95.0);
initPref(STR_US_PrefCalcMax, (int)0);
if (!m_profile->contains(STR_US_CalculateRDI)) { (*m_profile)[STR_US_CalculateRDI] = false; } initPref(STR_US_TooltipTimeout, (int)2500);
initPref(STR_US_ScrollDampening, (int)50);
if (!m_profile->contains(STR_US_ShowSerialNumbers)) { (*m_profile)[STR_US_ShowSerialNumbers] = false; }
if (!m_profile->contains(STR_US_PrefCalcMiddle)) { (*m_profile)[STR_US_PrefCalcMiddle] = (int)0; }
if (!m_profile->contains(STR_US_PrefCalcPercentile)) { (*m_profile)[STR_US_PrefCalcPercentile] = (double)95.0; }
if (!m_profile->contains(STR_US_PrefCalcMax)) { (*m_profile)[STR_US_PrefCalcMax] = (int)0; }
if (!m_profile->contains(STR_US_TooltipTimeout)) { (*m_profile)[STR_US_TooltipTimeout] = (int)2500; }
if (!m_profile->contains(STR_US_ScrollDampening)) { (*m_profile)[STR_US_ScrollDampening] = (int)50; }
} }
~UserSettings() {}
void setProfile(Profile *p) { m_profile = p; } UnitSystem unitSystem() const { return (UnitSystem)getPref(STR_US_UnitSystem).toInt(); }
double eventWindowSize() const { return getPref(STR_US_EventWindowSize).toDouble(); }
UnitSystem unitSystem() { return (UnitSystem)(*m_profile)[STR_US_UnitSystem].toInt(); } bool skipEmptyDays() const { return getPref(STR_US_SkipEmptyDays).toBool(); }
double eventWindowSize() { return (*m_profile)[STR_US_EventWindowSize].toDouble(); } bool rebuildCache() const { return getPref(STR_US_RebuildCache).toBool(); }
bool skipEmptyDays() { return (*m_profile)[STR_US_SkipEmptyDays].toBool(); } bool showDebug() const { return getPref(STR_US_ShowDebug).toBool(); }
bool rebuildCache() { return (*m_profile)[STR_US_RebuildCache].toBool(); } bool linkGroups() const { return getPref(STR_US_LinkGroups).toBool(); }
bool showDebug() { return (*m_profile)[STR_US_ShowDebug].toBool(); } bool calculateRDI() const { return getPref(STR_US_CalculateRDI).toBool(); }
bool linkGroups() { return (*m_profile)[STR_US_LinkGroups].toBool(); } bool showSerialNumbers() const { return getPref(STR_US_ShowSerialNumbers).toBool(); }
bool calculateRDI() { return (*m_profile)[STR_US_CalculateRDI].toBool(); } int prefCalcMiddle() const { return getPref(STR_US_PrefCalcMiddle).toInt(); }
bool showSerialNumbers() { return (*m_profile)[STR_US_ShowSerialNumbers].toBool(); } double prefCalcPercentile() const { return getPref(STR_US_PrefCalcPercentile).toDouble(); }
int prefCalcMiddle() { return (*m_profile)[STR_US_PrefCalcMiddle].toInt(); } int prefCalcMax() const { return getPref(STR_US_PrefCalcMax).toInt(); }
double prefCalcPercentile() { return (*m_profile)[STR_US_PrefCalcPercentile].toDouble(); } int tooltipTimeout() const { return getPref(STR_US_TooltipTimeout).toInt(); }
int prefCalcMax() { return (*m_profile)[STR_US_PrefCalcMax].toInt(); } int scrollDampening() const { return getPref(STR_US_ScrollDampening).toInt(); }
int tooltipTimeout() { return (*m_profile)[STR_US_TooltipTimeout].toInt(); }
int scrollDampening() { return (*m_profile)[STR_US_ScrollDampening].toInt(); }
void setUnitSystem(UnitSystem us) { (*m_profile)[STR_US_UnitSystem] = (int)us; } void setUnitSystem(UnitSystem us) { setPref(STR_US_UnitSystem, (int)us); }
void setEventWindowSize(double size) { (*m_profile)[STR_US_EventWindowSize] = size; } void setEventWindowSize(double size) { setPref(STR_US_EventWindowSize, size); }
void setSkipEmptyDays(bool skip) { (*m_profile)[STR_US_SkipEmptyDays] = skip; } void setSkipEmptyDays(bool skip) { setPref(STR_US_SkipEmptyDays, skip); }
void setRebuildCache(bool rebuild) { (*m_profile)[STR_US_RebuildCache] = rebuild; } void setRebuildCache(bool rebuild) { setPref(STR_US_RebuildCache, rebuild); }
void setShowDebug(bool b) { (*m_profile)[STR_US_ShowDebug] = b; } void setShowDebug(bool b) { setPref(STR_US_ShowDebug, b); }
void setLinkGroups(bool link) { (*m_profile)[STR_US_LinkGroups] = link; } void setLinkGroups(bool link) { setPref(STR_US_LinkGroups, link); }
void setCalculateRDI(bool rdi) { (*m_profile)[STR_US_CalculateRDI] = rdi; } void setCalculateRDI(bool rdi) { setPref(STR_US_CalculateRDI, rdi); }
void setShowSerialNumbers(bool enabled) { (*m_profile)[STR_US_ShowSerialNumbers] = enabled; } void setShowSerialNumbers(bool enabled) { setPref(STR_US_ShowSerialNumbers, enabled); }
void setPrefCalcMiddle(int i) { (*m_profile)[STR_US_PrefCalcMiddle] = i; } void setPrefCalcMiddle(int i) { setPref(STR_US_PrefCalcMiddle, i); }
void setPrefCalcPercentile(double p) { (*m_profile)[STR_US_PrefCalcPercentile] = p; } void setPrefCalcPercentile(double p) { setPref(STR_US_PrefCalcPercentile, p); }
void setPrefCalcMax(int i) { (*m_profile)[STR_US_PrefCalcMax] = i; } void setPrefCalcMax(int i) { setPref(STR_US_PrefCalcMax, i); }
void setTooltipTimeout(int i) { (*m_profile)[STR_US_TooltipTimeout] = i; } void setTooltipTimeout(int i) { setPref(STR_US_TooltipTimeout, i); }
void setScrollDampening(int i) { (*m_profile)[STR_US_ScrollDampening] = i; } void setScrollDampening(int i) { setPref(STR_US_ScrollDampening, i); }
Profile *m_profile;
}; };
namespace Profiles { namespace Profiles {
extern QMap<QString, Profile *> profiles; extern QMap<QString, Profile *> profiles;