|
|
@ -11,6 +11,7 @@ |
|
|
|
#include <QPushButton>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QLocale>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QtMath>
|
|
|
@ -28,19 +29,13 @@ EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, |
|
|
|
{ |
|
|
|
Settings *s = Settings::getInstance(); |
|
|
|
const struct Room r = s->getRoom(idx); |
|
|
|
const struct Program *p = NULL; |
|
|
|
QString sheet; |
|
|
|
QString text; |
|
|
|
|
|
|
|
QLabel *room_name = new QLabel(QString(tr("%1 default target:").arg(r.name))); |
|
|
|
|
|
|
|
QFont font = room_name->font(); |
|
|
|
font.setPointSize(12); |
|
|
|
font.setBold(true); |
|
|
|
room_name->setFont(font); |
|
|
|
|
|
|
|
QSizePolicy *szQPolicy = new QSizePolicy(QSizePolicy::Minimum, |
|
|
|
QSizePolicy::MinimumExpanding, |
|
|
|
QSizePolicy::PushButton); |
|
|
|
room_name->setSizePolicy(*szQPolicy); |
|
|
|
set_font(room_name); |
|
|
|
|
|
|
|
m_idx = idx; |
|
|
|
m_default_temperature.setDecimals(1); |
|
|
@ -48,7 +43,7 @@ EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, |
|
|
|
m_default_temperature.setSingleStep(0.1); |
|
|
|
m_default_temperature.setSuffix(" °C"); |
|
|
|
|
|
|
|
m_default_temperature.setFont(font); |
|
|
|
set_font(&m_default_temperature); |
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO: setting size in pixels sucks |
|
|
@ -75,8 +70,8 @@ EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, |
|
|
|
QSizePolicy::MinimumExpanding, |
|
|
|
QSizePolicy::PushButton); |
|
|
|
|
|
|
|
ok_btn->setFont(font); |
|
|
|
cancel_btn->setFont(font); |
|
|
|
set_font(ok_btn); |
|
|
|
set_font(cancel_btn); |
|
|
|
|
|
|
|
ok_btn->setSizePolicy(*szPolicy); |
|
|
|
cancel_btn->setSizePolicy(*szPolicy); |
|
|
@ -92,11 +87,103 @@ EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, |
|
|
|
QVBoxLayout *topLayout = new QVBoxLayout; |
|
|
|
|
|
|
|
topLayout->addLayout(upperLayout); |
|
|
|
|
|
|
|
QGridLayout *progLayout = new QGridLayout; |
|
|
|
for (int i = 0; i < r.progs.count(); i++) { |
|
|
|
|
|
|
|
p = &(r.progs.at(i)); |
|
|
|
|
|
|
|
text = QString(""); |
|
|
|
if (p->temperature == FORCE_OFF) { |
|
|
|
text += QString("-"); |
|
|
|
} else { |
|
|
|
if (p->temperature == FORCE_ON) { |
|
|
|
text += QString("+"); |
|
|
|
} else { |
|
|
|
text += QString::number(p->temperature); |
|
|
|
} |
|
|
|
} |
|
|
|
text += QString("°C"); |
|
|
|
|
|
|
|
QLabel *prog_temperature = new QLabel(QString(text)); |
|
|
|
set_font(prog_temperature); |
|
|
|
progLayout->addWidget(prog_temperature, i, 1, Qt::AlignHCenter); |
|
|
|
|
|
|
|
text = QString(""); |
|
|
|
if (p->DoW == 0) { |
|
|
|
text += QString("-"); |
|
|
|
} else { |
|
|
|
bool isFirst = true; |
|
|
|
for (int j = 0; j < 7; j++) { |
|
|
|
if (p->DoW & (1 << j)) { |
|
|
|
if (isFirst) { |
|
|
|
isFirst = false; |
|
|
|
} else { |
|
|
|
text += QString("/"); |
|
|
|
} |
|
|
|
|
|
|
|
switch (j) { |
|
|
|
case 0: text += QString(tr("Mo")); break; |
|
|
|
case 1: text += QString(tr("Tu")); break; |
|
|
|
case 2: text += QString(tr("We")); break; |
|
|
|
case 3: text += QString(tr("Th")); break; |
|
|
|
case 4: text += QString(tr("Fr")); break; |
|
|
|
case 5: text += QString(tr("Sa")); break; |
|
|
|
case 6: text += QString(tr("Su")); break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
QLabel *prog_DoW = new QLabel(QString(text)); |
|
|
|
set_font(prog_DoW); |
|
|
|
progLayout->addWidget(prog_DoW, i, 2, Qt::AlignHCenter); |
|
|
|
|
|
|
|
text = QString(""); |
|
|
|
text += p->start_time.toString(QString(" HH:mm")); |
|
|
|
text += p->end_time.toString(QString("-HH:mm")); |
|
|
|
|
|
|
|
QLabel *prog_time= new QLabel(QString(text)); |
|
|
|
set_font(prog_time); |
|
|
|
progLayout->addWidget(prog_time, i, 3, Qt::AlignHCenter); |
|
|
|
|
|
|
|
QPushButton *edit_btn = new QPushButton(tr("Edit"), this); |
|
|
|
QPushButton *delete_btn = new QPushButton(tr("Delete"), this); |
|
|
|
|
|
|
|
set_font(edit_btn); |
|
|
|
set_font(delete_btn); |
|
|
|
|
|
|
|
edit_btn->setSizePolicy(*szPolicy); |
|
|
|
delete_btn->setSizePolicy(*szPolicy); |
|
|
|
|
|
|
|
edit_btn->setProperty("idx", i); |
|
|
|
delete_btn->setProperty("idx", i); |
|
|
|
|
|
|
|
connect(delete_btn, SIGNAL(clicked(void)), this, SLOT(delete_prog_clicked(void))); |
|
|
|
|
|
|
|
progLayout->addWidget(edit_btn, i, 4, Qt::AlignHCenter); |
|
|
|
progLayout->addWidget(delete_btn, i, 5, Qt::AlignHCenter); |
|
|
|
|
|
|
|
topLayout->addLayout(progLayout); |
|
|
|
} |
|
|
|
|
|
|
|
topLayout->addLayout(btnLayout); |
|
|
|
|
|
|
|
this->setLayout(topLayout); |
|
|
|
} |
|
|
|
|
|
|
|
void EditDlg::set_font(QWidget *widget) |
|
|
|
{ |
|
|
|
QFont font = widget->font(); |
|
|
|
font.setPointSize(12); |
|
|
|
font.setBold(true); |
|
|
|
widget->setFont(font); |
|
|
|
|
|
|
|
QSizePolicy *szQPolicy = new QSizePolicy(QSizePolicy::Minimum, |
|
|
|
QSizePolicy::MinimumExpanding, |
|
|
|
QSizePolicy::PushButton); |
|
|
|
widget->setSizePolicy(*szQPolicy); |
|
|
|
} |
|
|
|
|
|
|
|
void EditDlg::save(void) |
|
|
|
{ |
|
|
|
emit close_edit_dlg(); |
|
|
@ -107,6 +194,10 @@ void EditDlg::reject(void) |
|
|
|
emit close_edit_dlg(); |
|
|
|
} |
|
|
|
|
|
|
|
void EditDlg::delete_prog_clicked(void) |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
EditDlg::~EditDlg() |
|
|
|
{ |
|
|
|
} |
|
|
|