From 978fb416943760adbf3006f07a637125970cd79d Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Tue, 5 Dec 2017 20:28:12 +0100 Subject: [PATCH] Breaks and working hours are now shown --- mainwindow.cpp | 32 +++++++++++++++++++++++++++++--- mainwindow.h | 1 + 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 651c2eb..a901a4a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -102,6 +102,7 @@ MainWindow::MainWindow(ZeiterfassungSettings &settings, Zeiterfassung &erfassung connect(ui->treeViewKontierungen, &QWidget::customContextMenuRequested, this, &MainWindow::contextMenuKontierung); + ui->statusbar->addPermanentWidget(m_kontierungLabel = new QLabel(ui->statusbar)); ui->statusbar->addPermanentWidget(m_auswertungLabel = new QLabel(ui->statusbar)); refresh(true); @@ -151,6 +152,8 @@ void MainWindow::refresh(bool forceAuswertung) ui->treeViewBuchungen->setEnabled(false); ui->treeViewKontierungen->setEnabled(false); + m_kontierungLabel->setText(tr("Kontierung time: ???")); + auto waitForBuchugen = m_buchungenModel->refresh(m_userInfo.userId, ui->dateEditDate->date(), ui->dateEditDate->date()); if(waitForBuchugen) { @@ -841,6 +844,9 @@ void MainWindow::validateEntries() m_kontierungTime = QTime(0, 0); auto buchungTimespan = QTime(0, 0); + const Zeiterfassung::Buchung *lastBuchung = Q_NULLPTR; + const Zeiterfassung::Kontierung *lastKontierung = Q_NULLPTR; + QString errorMessage; while(true) @@ -866,6 +872,16 @@ void MainWindow::validateEntries() goto after; } + if(lastBuchung) + { + auto label = new QLabel(tr("Pause: %0h").arg(timeBetween(lastBuchung->time, startBuchung.time).toString(QStringLiteral("HH:mm"))), ui->scrollAreaWidgetContents); + ui->verticalLayout2->addWidget(label); + label->setMinimumHeight(20); + label->setMaximumHeight(20); + } + + lastBuchung = &startBuchung; + m_lastKontierungStart = startBuchung.time; ui->verticalLayout2->addWidget(new BuchungStrip(startBuchung.id, startBuchung.time, startBuchung.type, m_settings, ui->scrollAreaWidgetContents)); @@ -885,6 +901,8 @@ void MainWindow::validateEntries() goto after; } + lastKontierung = &kontierung; + ui->verticalLayout2->addWidget(new KontierungStrip(kontierung.id, kontierung.timespan, buildProjektString(kontierung.projekt), kontierung.subprojekt, kontierung.workpackage, kontierung.text, m_settings, ui->scrollAreaWidgetContents)); @@ -938,6 +956,8 @@ void MainWindow::validateEntries() goto after; } + lastKontierung = &kontierung; + ui->verticalLayout2->addWidget(new KontierungStrip(kontierung.id, kontierung.timespan, buildProjektString(kontierung.projekt), kontierung.subprojekt, kontierung.workpackage, kontierung.text, m_settings, ui->scrollAreaWidgetContents)); @@ -976,6 +996,8 @@ void MainWindow::validateEntries() goto after; } + lastBuchung = &endBuchung; + buchungTimespan = timeAdd(buchungTimespan, timeBetween(startBuchung.time, endBuchung.time)); ui->timeEditTime->setMinimumTime(timeAdd(endBuchung.time, QTime(0, 1))); @@ -1008,6 +1030,8 @@ void MainWindow::validateEntries() goto after; } + lastKontierung = &kontierung; + ui->verticalLayout2->addWidget(new KontierungStrip(kontierung.id, kontierung.timespan, buildProjektString(kontierung.projekt), kontierung.subprojekt, kontierung.workpackage, kontierung.text, m_settings, ui->scrollAreaWidgetContents)); @@ -1058,15 +1082,17 @@ void MainWindow::validateEntries() if(m_kontierungTime > buchungTimespan) goto after; - else - ui->verticalLayout2->addSpacing(17); } } } after: - if(!errorMessage.isEmpty()) + if(errorMessage.isEmpty()) + m_kontierungLabel->setText(tr("Kontierung time: %0h").arg(m_kontierungTime.toString(QStringLiteral("HH:mm")))); + else { + m_kontierungLabel->setText(tr("Kontierung time: ???")); + auto label = new QLabel(tr("Strip rendering aborted due error."), ui->scrollAreaWidgetContents); ui->verticalLayout2->addWidget(label); label->setMinimumHeight(20); diff --git a/mainwindow.h b/mainwindow.h index c14c816..386db8b 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -51,6 +51,7 @@ private: QMap m_projekte; QDate m_auswertungDate; QByteArray m_auswertung; + QLabel *m_kontierungLabel; QLabel *m_auswertungLabel; BuchungenModel *m_buchungenModel;