|
|
@ -97,7 +97,7 @@ EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, |
|
|
|
m_progsLayout = new QVBoxLayout; |
|
|
|
for (int i = 0; i < m_progs.count(); i++) { |
|
|
|
|
|
|
|
QHBoxLayout *progLayout = add_prog_layout(&(m_progs.at(i)), i); |
|
|
|
QHBoxLayout *progLayout = add_prog_layout(i); |
|
|
|
m_progsLayout->addLayout(progLayout); |
|
|
|
} |
|
|
|
|
|
|
@ -106,12 +106,13 @@ EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, |
|
|
|
topLayout->addLayout(btnLayout); |
|
|
|
|
|
|
|
this->setLayout(topLayout); |
|
|
|
|
|
|
|
refresh_progs(); |
|
|
|
} |
|
|
|
|
|
|
|
QHBoxLayout *EditDlg::add_prog_layout(const struct Program *p, int idx) |
|
|
|
QHBoxLayout *EditDlg::add_prog_layout(int idx) |
|
|
|
{ |
|
|
|
QString sheet; |
|
|
|
QString text; |
|
|
|
|
|
|
|
QHBoxLayout *progLayout = new QHBoxLayout; |
|
|
|
|
|
|
@ -119,56 +120,15 @@ QHBoxLayout *EditDlg::add_prog_layout(const struct Program *p, int idx) |
|
|
|
QSizePolicy::MinimumExpanding, |
|
|
|
QSizePolicy::PushButton); |
|
|
|
|
|
|
|
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)); |
|
|
|
QLabel *prog_temperature = new QLabel(); |
|
|
|
set_font(prog_temperature); |
|
|
|
progLayout->addWidget(prog_temperature, 0, 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("M")); break; |
|
|
|
case 1: text += QString(tr("Tu")); break; |
|
|
|
case 2: text += QString(tr("W")); break; |
|
|
|
case 3: text += QString(tr("Th")); break; |
|
|
|
case 4: text += QString(tr("F")); break; |
|
|
|
case 5: text += QString(tr("Sa")); break; |
|
|
|
case 6: text += QString(tr("Su")); break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
QLabel *prog_DoW = new QLabel(QString(text)); |
|
|
|
QLabel *prog_DoW = new QLabel(); |
|
|
|
set_font(prog_DoW); |
|
|
|
progLayout->addWidget(prog_DoW, 0, 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)); |
|
|
|
QLabel *prog_time = new QLabel(); |
|
|
|
set_font(prog_time); |
|
|
|
progLayout->addWidget(prog_time, 0, Qt::AlignHCenter); |
|
|
|
|
|
|
@ -208,6 +168,86 @@ void EditDlg::set_font(QWidget *widget) |
|
|
|
|
|
|
|
void EditDlg::refresh_progs(void) |
|
|
|
{ |
|
|
|
QLayoutItem *lineItem, *item; |
|
|
|
QLayout *layout; |
|
|
|
struct Program *p; |
|
|
|
QWidget *w; |
|
|
|
QLabel *l; |
|
|
|
QString text; |
|
|
|
|
|
|
|
if (m_progsLayout->count() != m_progs.count()) { |
|
|
|
// TODO ERROR: index mismatch
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < m_progsLayout->count(); i++) { |
|
|
|
lineItem = m_progsLayout->itemAt(i); |
|
|
|
if (lineItem && lineItem->layout()) { |
|
|
|
layout = lineItem->layout(); |
|
|
|
// temperature
|
|
|
|
item = layout->itemAt(0); |
|
|
|
w = item->widget(); |
|
|
|
l = qobject_cast<QLabel *>(w); |
|
|
|
p = &m_progs[i]; |
|
|
|
|
|
|
|
qDebug() << "temperature:" << p->temperature; |
|
|
|
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"); |
|
|
|
l->setText(QString(text)); |
|
|
|
|
|
|
|
// DoW
|
|
|
|
item = layout->itemAt(1); |
|
|
|
w = item->widget(); |
|
|
|
l = qobject_cast<QLabel *>(w); |
|
|
|
|
|
|
|
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("M")); break; |
|
|
|
case 1: text += QString(tr("Tu")); break; |
|
|
|
case 2: text += QString(tr("W")); break; |
|
|
|
case 3: text += QString(tr("Th")); break; |
|
|
|
case 4: text += QString(tr("F")); break; |
|
|
|
case 5: text += QString(tr("Sa")); break; |
|
|
|
case 6: text += QString(tr("Su")); break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
l->setText(QString(text)); |
|
|
|
|
|
|
|
|
|
|
|
// time
|
|
|
|
item = layout->itemAt(2); |
|
|
|
w = item->widget(); |
|
|
|
l = qobject_cast<QLabel *>(w); |
|
|
|
|
|
|
|
text = QString(""); |
|
|
|
text += p->start_time.toString(QString(" HH:mm")); |
|
|
|
text += p->end_time.toString(QString("-HH:mm")); |
|
|
|
l->setText(QString(text)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void EditDlg::save(void) |
|
|
@ -242,7 +282,7 @@ void EditDlg::add(void) |
|
|
|
p.end_time = QTime(0,0); |
|
|
|
m_progs << p; |
|
|
|
|
|
|
|
layout = add_prog_layout(&(m_progs.at(idx)), idx); |
|
|
|
layout = add_prog_layout(idx); |
|
|
|
m_progsLayout->addLayout(layout); |
|
|
|
} |
|
|
|
|
|
|
|