14 * You should have received a copy of the GNU General Public License |
14 * You should have received a copy of the GNU General Public License |
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 */ |
16 */ |
17 #include "MoniSpindels.h" |
17 #include "MoniSpindels.h" |
18 #include "DetailiSpindel.h" |
18 #include "DetailiSpindel.h" |
|
19 #include "CalibrateiSpindel.h" |
19 #include "MainWindow.h" |
20 #include "MainWindow.h" |
20 #include "Utils.h" |
21 #include "Utils.h" |
21 #include "config.h" |
22 #include "config.h" |
22 |
23 |
23 |
24 |
73 void MoniSpindels::refreshTable() |
74 void MoniSpindels::refreshTable() |
74 { |
75 { |
75 QTableWidgetItem *item; |
76 QTableWidgetItem *item; |
76 |
77 |
77 QSqlQuery query("SELECT record,alias,node,online,mode,temperature,gravity,beercode,beername FROM mon_ispindels ORDER BY alias"); |
78 QSqlQuery query("SELECT record,alias,node,online,mode,temperature,gravity,beercode,beername FROM mon_ispindels ORDER BY alias"); |
78 const QStringList labels({tr("Unit"), tr("Node"), tr("Status"), tr("Beer"), tr("Temperature"), tr("SG"), tr("Details")}); |
79 const QStringList labels({tr("Unit"), tr("Node"), tr("Status"), tr("Beer"), tr("Temperature"), tr("SG"), tr("Cal"), tr("Details")}); |
79 |
80 |
80 this->tableiSpindels->setColumnCount(7); |
81 this->tableiSpindels->setColumnCount(8); |
81 this->tableiSpindels->setColumnWidth(0, 150); /* Alias */ |
82 this->tableiSpindels->setColumnWidth(0, 150); /* Alias */ |
82 this->tableiSpindels->setColumnWidth(1, 120); /* Node */ |
83 this->tableiSpindels->setColumnWidth(1, 120); /* Node */ |
83 this->tableiSpindels->setColumnWidth(2, 100); /* Status */ |
84 this->tableiSpindels->setColumnWidth(2, 100); /* Status */ |
84 this->tableiSpindels->setColumnWidth(3, 390); /* Beer */ |
85 this->tableiSpindels->setColumnWidth(3, 330); /* Beer */ |
85 this->tableiSpindels->setColumnWidth(4, 90); /* Temperature */ |
86 this->tableiSpindels->setColumnWidth(4, 90); /* Temperature */ |
86 this->tableiSpindels->setColumnWidth(5, 90); /* Gravity */ |
87 this->tableiSpindels->setColumnWidth(5, 90); /* Gravity */ |
87 this->tableiSpindels->setColumnWidth(6, 90); /* Edit button */ |
88 this->tableiSpindels->setColumnWidth(6, 60); /* Calibrate */ |
|
89 this->tableiSpindels->setColumnWidth(7, 90); /* Edit button */ |
88 this->tableiSpindels->setRowCount(query.size()); |
90 this->tableiSpindels->setRowCount(query.size()); |
89 this->tableiSpindels->setHorizontalHeaderLabels(labels); |
91 this->tableiSpindels->setHorizontalHeaderLabels(labels); |
90 this->tableiSpindels->verticalHeader()->hide(); |
92 this->tableiSpindels->verticalHeader()->hide(); |
91 /* Set the widget size to 1054 x 575 in the ui. */ |
93 /* Set the widget size to 1054 x 575 in the ui. */ |
92 |
94 |
122 } else { |
124 } else { |
123 this->tableiSpindels->setItem(i, 4, new QTableWidgetItem(QString(""))); |
125 this->tableiSpindels->setItem(i, 4, new QTableWidgetItem(QString(""))); |
124 this->tableiSpindels->setItem(i, 5, new QTableWidgetItem(QString(""))); |
126 this->tableiSpindels->setItem(i, 5, new QTableWidgetItem(QString(""))); |
125 } |
127 } |
126 |
128 |
127 /* Add the Edit button */ |
129 /* Add the Calibrate button */ |
|
130 QWidget* cWidget = new QWidget(); |
|
131 QPushButton* btn_cal = new QPushButton(); |
|
132 btn_cal->setObjectName(QString("%1").arg(query.value("record").toString())); /* Send record with the button */ |
|
133 btn_cal->setText(tr("Cal")); |
|
134 connect(btn_cal, SIGNAL(clicked()), this, SLOT(on_calButton_clicked())); |
|
135 QHBoxLayout* cLayout = new QHBoxLayout(cWidget); |
|
136 cLayout->addWidget(btn_cal); |
|
137 cLayout->setContentsMargins(5, 0, 5, 0); |
|
138 cWidget->setLayout(cLayout); |
|
139 this->tableiSpindels->setCellWidget(i, 6, cWidget); |
|
140 |
|
141 /* Add the Details button */ |
128 QWidget* pWidget = new QWidget(); |
142 QWidget* pWidget = new QWidget(); |
129 QPushButton* btn_edit = new QPushButton(); |
143 QPushButton* btn_edit = new QPushButton(); |
130 btn_edit->setObjectName(QString("%1").arg(query.value("record").toString())); /* Send record with the button */ |
144 btn_edit->setObjectName(QString("%1").arg(query.value("record").toString())); /* Send record with the button */ |
131 btn_edit->setText(tr("Details")); |
145 btn_edit->setText(tr("Details")); |
132 connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editButton_clicked())); |
146 connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editButton_clicked())); |
133 QHBoxLayout* pLayout = new QHBoxLayout(pWidget); |
147 QHBoxLayout* pLayout = new QHBoxLayout(pWidget); |
134 pLayout->addWidget(btn_edit); |
148 pLayout->addWidget(btn_edit); |
135 pLayout->setContentsMargins(5, 0, 5, 0); |
149 pLayout->setContentsMargins(5, 0, 5, 0); |
136 pWidget->setLayout(pLayout); |
150 pWidget->setLayout(pLayout); |
137 this->tableiSpindels->setCellWidget(i, 6, pWidget); |
151 this->tableiSpindels->setCellWidget(i, 7, pWidget); |
138 query.next(); |
152 query.next(); |
139 } |
153 } |
140 emit setStatus(QString(tr("Total items: %1")).arg(query.size())); |
154 emit setStatus(QString(tr("Total items: %1")).arg(query.size())); |
141 } |
155 } |
142 |
156 |