Commit 666fbbc0 authored by Hugo Hörnquist's avatar Hugo Hörnquist

Start adding past drainage view.

parent 34744f27
......@@ -316,7 +316,28 @@ MainWindow::MainWindow(QWidget *parent) :
updateCurrentDrainageStatus();
// TODO past drainages
// TODO default values in drainage table are wrong!
/* PAST DRAINAGES */
// TODO show how much was sold during a drainage, and how much we lost during it
QSqlQueryModel* pastDrainageModel = new QSqlQueryModel();
pastDrainageModel->setQuery("SELECT id, "
// " datetime(start_time, 'localtime') AS Starttid, "
// " datetime(end_time, 'localtime') AS Sluttid, "
" decrease as [Kr/Tid], "
" how_often_minutes AS [Hur ofta], "
" min_price as [Minimipris] "
"FROM drainage "
"WHERE strftime('%s', end_time) < strftime('%s', 'now') "
"ORDER BY start_time");
ui->drainagePastView->setModel(pastDrainageModel);
ui->drainagePastView->hideColumn(0);
ui->drainagePastView->setItemDelegateForColumn(3, monDel);
ui->drainagePastView->setItemDelegateForColumn(1, monDel);
ui->drainagePastView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
// ============= Money ==============================
......@@ -723,10 +744,10 @@ void MainWindow::updateCurrentDrainageStatus()
"LIMIT 1");
if (currentDrainageQuery.next()) {
QString startStr = currentDrainageQuery.value(0).toString();
QString endStr = currentDrainageQuery.value(1).toString();
QString startStr = currentDrainageQuery.value(0).toString();
QString endStr = currentDrainageQuery.value(1).toString();
double decreaseStr = currentDrainageQuery.value(2).toDouble();
QString minutesStr = currentDrainageQuery.value(3).toString();
QString minutesStr = currentDrainageQuery.value(3).toString();
double minStr = currentDrainageQuery.value(4).toDouble();
ui->drainageLabel->setText(QString("%1 kr/%2 min, ner till %3 kr\nMellan %4 och %5 lokal tid")
.arg(decreaseStr, 0, 'f', 2)
......
......@@ -697,20 +697,54 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Kommande Tömningar (lokal tid):</string>
<widget class="QSplitter" name="splitter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QTreeView" name="drainageView">
<property name="alternatingRowColors">
<bool>true</bool>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="rootIsDecorated">
<property name="childrenCollapsible">
<bool>false</bool>
</property>
<widget class="QWidget" name="layoutWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_15">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Kommande Tömningar (lokal tid):</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeView" name="drainageView">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_17">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Gånga tömmningar</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeView" name="drainagePastView"/>
</item>
</layout>
</widget>
</widget>
</item>
<item>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment