Browse Source

thermostat: edit_dlg: remove program - WIP

master
Richard Genoud 4 years ago
parent
commit
25d9a2a570
2 changed files with 44 additions and 9 deletions
  1. +5
    -2
      soft/thermostat/inc/edit_dlg.h
  2. +39
    -7
      soft/thermostat/src/edit_dlg.cpp

+ 5
- 2
soft/thermostat/inc/edit_dlg.h View File

@ -9,11 +9,13 @@
#ifndef EDITDLG_H
#define EDITDLG_H
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QVector>
#include <QWidget>
#include <QObject>
#include <QSpinBox>
#include <QDateTime>
#include <QGridLayout>
#include <QDoubleSpinBox>
class EditDlg : public QWidget
{
@ -28,6 +30,7 @@ private:
void set_font(QWidget *widget);
QDoubleSpinBox m_default_temperature;
QGridLayout *m_progLayout;
QVector<struct Program> m_progs;
int m_idx; // room index


+ 39
- 7
soft/thermostat/src/edit_dlg.cpp View File

@ -89,7 +89,7 @@ EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent,
topLayout->addLayout(upperLayout);
QGridLayout *progLayout = new QGridLayout;
m_progLayout = new QGridLayout;
for (int i = 0; i < m_progs.count(); i++) {
p = &(m_progs.at(i));
@ -108,7 +108,7 @@ EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent,
QLabel *prog_temperature = new QLabel(QString(text));
set_font(prog_temperature);
progLayout->addWidget(prog_temperature, i, 1, Qt::AlignHCenter);
m_progLayout->addWidget(prog_temperature, i, 0, Qt::AlignHCenter);
text = QString("");
if (p->DoW == 0) {
@ -137,7 +137,7 @@ EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent,
}
QLabel *prog_DoW = new QLabel(QString(text));
set_font(prog_DoW);
progLayout->addWidget(prog_DoW, i, 2, Qt::AlignHCenter);
m_progLayout->addWidget(prog_DoW, i, 1, Qt::AlignHCenter);
text = QString("");
text += p->start_time.toString(QString(" HH:mm"));
@ -145,7 +145,7 @@ EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent,
QLabel *prog_time= new QLabel(QString(text));
set_font(prog_time);
progLayout->addWidget(prog_time, i, 3, Qt::AlignHCenter);
m_progLayout->addWidget(prog_time, i, 2, Qt::AlignHCenter);
QPushButton *edit_btn = new QPushButton(tr("Edit"), this);
QPushButton *delete_btn = new QPushButton(tr("Delete"), this);
@ -161,10 +161,10 @@ EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent,
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);
m_progLayout->addWidget(edit_btn, i, 3, Qt::AlignHCenter);
m_progLayout->addWidget(delete_btn, i, 4, Qt::AlignHCenter);
topLayout->addLayout(progLayout);
topLayout->addLayout(m_progLayout);
}
topLayout->addLayout(btnLayout);
@ -202,6 +202,38 @@ void EditDlg::reject(void)
void EditDlg::delete_prog_clicked(void)
{
QLayoutItem *item;
QObject* obj = sender();
QVariant v;
QWidget *w;
int idx;
v = obj->property("idx");
if (!v.isValid())
return;
idx = v.toInt();
if (idx >= m_progLayout->rowCount()) {
// TODO ERROR: index mismatch
return;
}
m_progs.remove(idx);
for (int i = 0; i < m_progLayout->columnCount(); i++) {
item = m_progLayout->itemAtPosition(idx, i);
if (item && item->widget()) {
w = item->widget();
m_progLayout->removeWidget(w);
w->hide();
delete w;
}
}
for (int j = idx; j < (m_progLayout->rowCount() - 1); j++) {
}
}
EditDlg::~EditDlg()


Loading…
Cancel
Save