|
|
@ -9,6 +9,7 @@ |
|
|
|
#include <QTranslator>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QString>
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include "settings.h"
|
|
|
|
|
|
|
@ -46,6 +47,7 @@ Settings::Settings(QObject *parent) : QSettings(parent) |
|
|
|
{ |
|
|
|
struct Room room; |
|
|
|
struct Heater heater; |
|
|
|
struct Program program; |
|
|
|
int nb_rooms; |
|
|
|
|
|
|
|
nb_rooms = this->beginReadArray("rooms"); |
|
|
@ -60,6 +62,7 @@ Settings::Settings(QObject *parent) : QSettings(parent) |
|
|
|
nb_rooms = MAX_NB_ZONES; |
|
|
|
} |
|
|
|
|
|
|
|
// TODO: handle unset values in a better way
|
|
|
|
for (int i = 0; i < nb_rooms; ++i) { |
|
|
|
this->setArrayIndex(i); |
|
|
|
room.name = this->value("name", default_room_names[i]).toString(); |
|
|
@ -73,6 +76,20 @@ Settings::Settings(QObject *parent) : QSettings(parent) |
|
|
|
room.heaters << heater; |
|
|
|
} |
|
|
|
this->endArray(); |
|
|
|
room.default_temperature = this->value("default_temperature", 20).toDouble(); |
|
|
|
size = this->beginReadArray("temperature_schedule"); |
|
|
|
for (int j = 0; j < size; ++j) { |
|
|
|
this->setArrayIndex(j); |
|
|
|
program.temperature = this->value("temperature", 20).toDouble(); |
|
|
|
program.DoW = this->value("days_of_week", 127).toInt(); |
|
|
|
program.start_time = QTime::fromString(this->value("start_time", "").toString(), "H:m"); |
|
|
|
program.end_time = QTime::fromString(this->value("end_time", "").toString(), "H:m"); |
|
|
|
if (program.start_time.isValid() && program.end_time.isValid() && |
|
|
|
(program.DoW > 0) && (program.DoW < 128)) { |
|
|
|
room.progs << program; |
|
|
|
} |
|
|
|
} |
|
|
|
this->endArray(); |
|
|
|
m_rooms << room; |
|
|
|
} |
|
|
|
this->endArray(); |
|
|
|