From 7e83064c735248d441b58dcea81ef744a5884034 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Tue, 5 Dec 2017 09:06:13 +0100 Subject: [PATCH] Improved error handling for longer Kontierung than Buchung --- mainwindow.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index b8d5c43..651c2eb 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -983,9 +983,18 @@ void MainWindow::validateEntries() { if(kontierungenIter == m_kontierungenModel->constEnd()) { - errorMessage = tr("Missing Kontierung! Time not filled: %0 - %1") - .arg(m_kontierungTime.toString("HH:mm:ss")) - .arg(buchungTimespan.toString("HH:mm:ss")); + errorMessage = tr("Missing Kontierung! Missing: %0h") + .arg(timeBetween(m_kontierungTime, buchungTimespan).toString("HH:mm:ss")); + + { + auto label = new QLabel(errorMessage, ui->scrollAreaWidgetContents); + ui->verticalLayout2->addWidget(label); + label->setMinimumHeight(20); + label->setMaximumHeight(20); + } + + ui->verticalLayout2->addWidget(new BuchungStrip(endBuchung.id, endBuchung.time, endBuchung.type, m_settings, ui->scrollAreaWidgetContents)); + goto after; } @@ -1035,7 +1044,11 @@ void MainWindow::validateEntries() if(m_kontierungTime > buchungTimespan) { - auto label = new QLabel(tr("Kontierung timespan too long!"), ui->scrollAreaWidgetContents); + errorMessage = tr("Kontierung time longer than Buchung time! Kontierung: %0 Buchung: %1") + .arg(m_kontierungTime.toString("HH:mm:ss")) + .arg(buchungTimespan.toString("HH:mm:ss")); + + auto label = new QLabel(errorMessage, ui->scrollAreaWidgetContents); ui->verticalLayout2->addWidget(label); label->setMinimumHeight(20); label->setMaximumHeight(20); @@ -1044,13 +1057,7 @@ void MainWindow::validateEntries() ui->verticalLayout2->addWidget(new BuchungStrip(endBuchung.id, endBuchung.time, endBuchung.type, m_settings, ui->scrollAreaWidgetContents)); if(m_kontierungTime > buchungTimespan) - { - errorMessage = tr("The Kontierung timespan is longer than the Kommen-Gehen timespan. " - "The tool does not support this yet!\nKontierung: %0\nBuchung: %1") - .arg(m_kontierungTime.toString("HH:mm:ss")) - .arg(buchungTimespan.toString("HH:mm:ss")); goto after; - } else ui->verticalLayout2->addSpacing(17); }