|
|
@ -6,25 +6,22 @@ |
|
|
|
* |
|
|
|
*/ |
|
|
|
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QLocale>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QSizePolicy>
|
|
|
|
#include <QTime>
|
|
|
|
|
|
|
|
#include "settings.h"
|
|
|
|
#include "zoneitem.h"
|
|
|
|
|
|
|
|
ZoneItem::ZoneItem(const QString &zoneName, QWidget *parent) : |
|
|
|
QWidget(parent) |
|
|
|
ZoneItem::ZoneItem(const QString &zoneName, QWidget *parent, Qt::WindowFlags f) : |
|
|
|
QLabel(parent, f) |
|
|
|
{ |
|
|
|
m_name = zoneName; |
|
|
|
m_zoneNameBtn.setText(zoneName); |
|
|
|
m_zoneNameBtn.setFlat(true); |
|
|
|
m_temperatureBtn.setFlat(true); |
|
|
|
m_hygroBtn.setFlat(true); |
|
|
|
m_heating_on = false; |
|
|
|
|
|
|
|
this->setText(zoneName); |
|
|
|
|
|
|
|
m_temperature_value = FORCE_OFF; |
|
|
|
m_hygro_value = FORCE_OFF; |
|
|
@ -34,31 +31,44 @@ ZoneItem::ZoneItem(const QString &zoneName, QWidget *parent) : |
|
|
|
m_boost.temperature = 0; |
|
|
|
m_boost.end_date = QDateTime(); |
|
|
|
|
|
|
|
/*
|
|
|
|
* Layout for the left part of the window |
|
|
|
*/ |
|
|
|
QVBoxLayout *topLayout = new QVBoxLayout; |
|
|
|
topLayout->addWidget(&m_zoneNameBtn); |
|
|
|
topLayout->addWidget(&m_temperatureBtn); |
|
|
|
topLayout->addWidget(&m_hygroBtn); |
|
|
|
QSizePolicy *szPolicy = new QSizePolicy(QSizePolicy::Minimum, |
|
|
|
QSizePolicy::MinimumExpanding, |
|
|
|
QSizePolicy::PushButton); |
|
|
|
|
|
|
|
this->setLayout(topLayout); |
|
|
|
this->setSizePolicy(*szPolicy); |
|
|
|
} |
|
|
|
|
|
|
|
ZoneItem::~ZoneItem() |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
void ZoneItem::mouseReleaseEvent(QMouseEvent* event) { |
|
|
|
(void)event; |
|
|
|
emit clicked(); |
|
|
|
} |
|
|
|
|
|
|
|
void ZoneItem::refresh(void) |
|
|
|
{ |
|
|
|
QString text; |
|
|
|
|
|
|
|
/* Zone name */ |
|
|
|
text += QString("<center><b>") + m_name + QString("</b></center><br/>"); |
|
|
|
|
|
|
|
/* Temperature */ |
|
|
|
text += QString("<center><b>"); |
|
|
|
if (m_heating_on) { |
|
|
|
text += QString("<font color='red'>"); |
|
|
|
} else { |
|
|
|
text += QString("<font color='black'>"); |
|
|
|
} |
|
|
|
if ((m_temperature_value == FORCE_OFF) || !m_available) |
|
|
|
text += QString("-"); |
|
|
|
else |
|
|
|
text += QString::number(m_temperature_value); |
|
|
|
text += QString("°C / "); |
|
|
|
text += QString("°C").toHtmlEscaped(); |
|
|
|
text += QString("</font>"); |
|
|
|
|
|
|
|
text += QString(" / ").toHtmlEscaped(); |
|
|
|
if (m_target_temperature == FORCE_OFF) { |
|
|
|
text += QString("-"); |
|
|
|
} else if (m_target_temperature == FORCE_ON) { |
|
|
@ -66,16 +76,19 @@ void ZoneItem::refresh(void) |
|
|
|
} else { |
|
|
|
text += QString::number(m_target_temperature); |
|
|
|
} |
|
|
|
text += QString("°C"); |
|
|
|
|
|
|
|
m_temperatureBtn.setText(text); |
|
|
|
text += QString("°C").toHtmlEscaped(); |
|
|
|
text += QString("</b></center><br/>"); |
|
|
|
|
|
|
|
/* hygrometry */ |
|
|
|
text += QString("<center><b>"); |
|
|
|
if ((m_hygro_value == FORCE_OFF) || !m_available) |
|
|
|
text = QString("-"); |
|
|
|
text += QString("-"); |
|
|
|
else |
|
|
|
text = QString::number(m_hygro_value); |
|
|
|
text += QString("%h"); |
|
|
|
m_hygroBtn.setText(text); |
|
|
|
text += QString::number(m_hygro_value); |
|
|
|
text += QString("%h").toHtmlEscaped(); |
|
|
|
text += QString("</b></center><br/>"); |
|
|
|
|
|
|
|
this->setText(text); |
|
|
|
} |
|
|
|
|
|
|
|
/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */ |