diff --git a/dialogs/bookingdialog.cpp b/dialogs/bookingdialog.cpp new file mode 100644 index 0000000..768e872 --- /dev/null +++ b/dialogs/bookingdialog.cpp @@ -0,0 +1,54 @@ +#include "bookingdialog.h" +#include "ui_bookingdialog.h" + +BookingDialog::BookingDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::BookingDialog) +{ + ui->setupUi(this); +} + +BookingDialog::~BookingDialog() +{ + delete ui; +} + +QTime BookingDialog::getTime() const +{ + return ui->timeEditTime->time(); +} + +void BookingDialog::setTime(const QTime &time) +{ + ui->timeEditTime->setTime(time); +} + +QTime BookingDialog::getTimespan() const +{ + return ui->timeEditTimespan->time(); +} + +void BookingDialog::setTimespan(const QTime ×pan) +{ + ui->timeEditTimespan->setTime(timespan); +} + +QString BookingDialog::getType() const +{ + return ui->comboBoxType->currentText(); +} + +void BookingDialog::setType(const QString &type) +{ + ui->comboBoxType->setCurrentText(type); +} + +QString BookingDialog::getText() const +{ + return ui->lineEditText->text(); +} + +void BookingDialog::setText(const QString &text) +{ + ui->lineEditText->setText(text); +} diff --git a/dialogs/buchungdialog.h b/dialogs/bookingdialog.h similarity index 59% rename from dialogs/buchungdialog.h rename to dialogs/bookingdialog.h index 5377f4a..fe13b24 100644 --- a/dialogs/buchungdialog.h +++ b/dialogs/bookingdialog.h @@ -1,18 +1,18 @@ -#ifndef BUCHUNGDIALOG_H -#define BUCHUNGDIALOG_H +#ifndef BOOKINGDIALOG_H +#define BOOKINGDIALOG_H #include #include -namespace Ui { class BuchungDialog; } +namespace Ui { class BookingDialog; } -class BuchungDialog : public QDialog +class BookingDialog : public QDialog { Q_OBJECT public: - explicit BuchungDialog(QWidget *parent = 0); - ~BuchungDialog(); + explicit BookingDialog(QWidget *parent = 0); + ~BookingDialog(); QTime getTime() const; void setTime(const QTime &time); @@ -27,7 +27,7 @@ public: void setText(const QString &text); private: - Ui::BuchungDialog *ui; + Ui::BookingDialog *ui; }; -#endif // BUCHUNGDIALOG_H +#endif // BOOKINGDIALOG_H diff --git a/dialogs/buchungdialog.ui b/dialogs/bookingdialog.ui similarity index 94% rename from dialogs/buchungdialog.ui rename to dialogs/bookingdialog.ui index fba2724..6e79a85 100644 --- a/dialogs/buchungdialog.ui +++ b/dialogs/bookingdialog.ui @@ -1,7 +1,7 @@ - BuchungDialog - + BookingDialog + 0 @@ -17,7 +17,7 @@ - Buchung + Booking @@ -28,7 +28,7 @@ - Buchung + Booking @@ -130,7 +130,7 @@ buttonBox accepted() - BuchungDialog + BookingDialog accept() @@ -146,7 +146,7 @@ buttonBox rejected() - BuchungDialog + BookingDialog reject() diff --git a/dialogs/buchungdialog.cpp b/dialogs/buchungdialog.cpp deleted file mode 100644 index 874b940..0000000 --- a/dialogs/buchungdialog.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "buchungdialog.h" -#include "ui_buchungdialog.h" - -BuchungDialog::BuchungDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::BuchungDialog) -{ - ui->setupUi(this); -} - -BuchungDialog::~BuchungDialog() -{ - delete ui; -} - -QTime BuchungDialog::getTime() const -{ - return ui->timeEditTime->time(); -} - -void BuchungDialog::setTime(const QTime &time) -{ - ui->timeEditTime->setTime(time); -} - -QTime BuchungDialog::getTimespan() const -{ - return ui->timeEditTimespan->time(); -} - -void BuchungDialog::setTimespan(const QTime ×pan) -{ - ui->timeEditTimespan->setTime(timespan); -} - -QString BuchungDialog::getType() const -{ - return ui->comboBoxType->currentText(); -} - -void BuchungDialog::setType(const QString &type) -{ - ui->comboBoxType->setCurrentText(type); -} - -QString BuchungDialog::getText() const -{ - return ui->lineEditText->text(); -} - -void BuchungDialog::setText(const QString &text) -{ - ui->lineEditText->setText(text); -} diff --git a/dialogs/settingsdialog.cpp b/dialogs/settingsdialog.cpp index 71903a7..4c8aa48 100644 --- a/dialogs/settingsdialog.cpp +++ b/dialogs/settingsdialog.cpp @@ -16,9 +16,9 @@ SettingsDialog::SettingsDialog(ZeiterfassungSettings &settings, QWidget *parent) ui->comboBoxLanguage->addItem(tr("German"), QLocale::German); ui->comboBoxLanguage->setCurrentIndex(ui->comboBoxLanguage->findData(settings.language())); - ui->lineEditBuchungStartBackgroundColor->setText(settings.buchungStartBackgroundColor()); - ui->lineEditBuchungEndBackgroundColor->setText(settings.buchungEndBackgroundColor()); - ui->lineEditBuchungOtherBackgroundColor->setText(settings.buchungOtherBackgroundColor()); + ui->lineEditBookingStartBackgroundColor->setText(settings.bookingStartBackgroundColor()); + ui->lineEditBookingEndBackgroundColor->setText(settings.bookingEndBackgroundColor()); + ui->lineEditBookingOtherBackgroundColor->setText(settings.bookingOtherBackgroundColor()); ui->lineEditTimeAssignmentBackgroundColor->setText(settings.timeAssignmentBackgroundColor()); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::submit); @@ -36,12 +36,12 @@ void SettingsDialog::submit() m_settings.setLanguage(ui->comboBoxLanguage->currentData().value()); QMessageBox::warning(this, tr("Restart required!"), tr("To apply the new language a restart is required!")); } - if(ui->lineEditBuchungStartBackgroundColor->text() != m_settings.buchungStartBackgroundColor()) - m_settings.setBuchungStartBackgroundColor(ui->lineEditBuchungStartBackgroundColor->text()); - if(ui->lineEditBuchungEndBackgroundColor->text() != m_settings.buchungEndBackgroundColor()) - m_settings.setBuchungEndBackgroundColor(ui->lineEditBuchungEndBackgroundColor->text()); - if(ui->lineEditBuchungOtherBackgroundColor->text() != m_settings.buchungOtherBackgroundColor()) - m_settings.setBuchungOtherBackgroundColor(ui->lineEditBuchungOtherBackgroundColor->text()); + if(ui->lineEditBookingStartBackgroundColor->text() != m_settings.bookingStartBackgroundColor()) + m_settings.setBookingStartBackgroundColor(ui->lineEditBookingStartBackgroundColor->text()); + if(ui->lineEditBookingEndBackgroundColor->text() != m_settings.bookingEndBackgroundColor()) + m_settings.setBookingEndBackgroundColor(ui->lineEditBookingEndBackgroundColor->text()); + if(ui->lineEditBookingOtherBackgroundColor->text() != m_settings.bookingOtherBackgroundColor()) + m_settings.setBookingOtherBackgroundColor(ui->lineEditBookingOtherBackgroundColor->text()); if(ui->lineEditTimeAssignmentBackgroundColor->text() != m_settings.timeAssignmentBackgroundColor()) m_settings.setTimeAssignmentBackgroundColor(ui->lineEditTimeAssignmentBackgroundColor->text()); diff --git a/dialogs/settingsdialog.ui b/dialogs/settingsdialog.ui index e55bad5..a5ceba3 100644 --- a/dialogs/settingsdialog.ui +++ b/dialogs/settingsdialog.ui @@ -45,32 +45,32 @@ - + - buchungStartBackgroundColor + bookingStartBackgroundColor - lineEditBuchungStartBackgroundColor + lineEditBookingStartBackgroundColor - + - buchungEndBackgroundColor + bookingEndBackgroundColor - lineEditBuchungEndBackgroundColor + lineEditBookingEndBackgroundColor - + - buchungOtherBackgroundColor + bookingOtherBackgroundColor - lineEditBuchungOtherBackgroundColor + lineEditBookingOtherBackgroundColor @@ -88,13 +88,13 @@ - + - + - + diff --git a/main.cpp b/main.cpp index 6be1bba..cde0d76 100755 --- a/main.cpp +++ b/main.cpp @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) { QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Invalid language selection!"), QCoreApplication::translate("main", "Invalid language selection!") % "\n\n" % - QCoreApplication::translate("main", "You did not select a valid language.")); + QCoreApplication::translate("main", "You did not select a valid language!")); goto again0; } diff --git a/mainwindow.cpp b/mainwindow.cpp index 0f6a92a..ada0553 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -17,12 +17,12 @@ #include "zeiterfassungsettings.h" #include "eventloopwithstatus.h" #include "dialogs/aboutmedialog.h" -#include "dialogs/buchungdialog.h" +#include "dialogs/bookingdialog.h" #include "dialogs/timeassignmentdialog.h" #include "dialogs/settingsdialog.h" -#include "strips/buchungstrip.h" +#include "strips/bookingstrip.h" #include "strips/timeassignmentstrip.h" -#include "models/buchungenmodel.h" +#include "models/bookingsmodel.h" #include "models/timeassignmentsmodel.h" MainWindow::MainWindow(ZeiterfassungSettings &settings, Zeiterfassung &erfassung, const Zeiterfassung::UserInfo &userInfo, QWidget *parent) : @@ -31,7 +31,7 @@ MainWindow::MainWindow(ZeiterfassungSettings &settings, Zeiterfassung &erfassung m_settings(settings), m_erfassung(erfassung), m_userInfo(userInfo), - m_buchungenModel(new BuchungenModel(erfassung, this)), + m_bookingsModel(new BookingsModel(erfassung, this)), m_timeAssignmentsModel(new TimeAssignmentsModel(erfassung, this)), m_flag(false) { @@ -93,11 +93,11 @@ MainWindow::MainWindow(ZeiterfassungSettings &settings, Zeiterfassung &erfassung connect(ui->pushButtonStart, &QAbstractButton::pressed, this, &MainWindow::pushButtonStartPressed); connect(ui->pushButtonEnd, &QAbstractButton::pressed, this, &MainWindow::pushButtonEndPressed); - ui->treeViewBuchungen->setModel(m_buchungenModel); + ui->treeViewBookings->setModel(m_bookingsModel); ui->treeViewTimeAssignments->setModel(m_timeAssignmentsModel); - connect(ui->treeViewBuchungen, &QWidget::customContextMenuRequested, - this, &MainWindow::contextMenuBuchung); + connect(ui->treeViewBookings, &QWidget::customContextMenuRequested, + this, &MainWindow::contextMenuBooking); connect(ui->treeViewTimeAssignments, &QWidget::customContextMenuRequested, this, &MainWindow::contextMenuTimeAssignment); @@ -155,16 +155,16 @@ void MainWindow::refresh(bool forceAuswertung) ui->comboBoxText->setEnabled(false); ui->pushButtonStart->setEnabled(false); ui->pushButtonEnd->setEnabled(false); - ui->treeViewBuchungen->setEnabled(false); + ui->treeViewBookings->setEnabled(false); ui->treeViewTimeAssignments->setEnabled(false); m_workingTimeLabel->setText(tr("%0: %1").arg(tr("Assigned time")).arg(tr("???"))); - auto waitForBuchugen = m_buchungenModel->refresh(m_userInfo.userId, ui->dateEditDate->date(), ui->dateEditDate->date()); - if(waitForBuchugen) + auto waitForBookings = m_bookingsModel->refresh(m_userInfo.userId, ui->dateEditDate->date(), ui->dateEditDate->date()); + if(waitForBookings) { - connect(m_buchungenModel, &BuchungenModel::refreshFinished, - this, &MainWindow::refreshBuchungenFinished); + connect(m_bookingsModel, &BookingsModel::refreshFinished, + this, &MainWindow::refreshBookingsFinished); } auto waitForTimeAssignments = m_timeAssignmentsModel->refresh(m_userInfo.userId, ui->dateEditDate->date(), ui->dateEditDate->date()); @@ -174,11 +174,11 @@ void MainWindow::refresh(bool forceAuswertung) this, &MainWindow::refreshTimeAssignmentsFinished); } - if(!waitForBuchugen || !waitForTimeAssignments) - QMessageBox::warning(this, tr("Unknown error occured."), tr("An unknown error occured.")); + if(!waitForBookings || !waitForTimeAssignments) + QMessageBox::warning(this, tr("Unknown error occured!"), tr("Unknown error occured!")); - if(waitForBuchugen || waitForTimeAssignments) - m_flag = waitForBuchugen == waitForTimeAssignments; + if(waitForBookings || waitForTimeAssignments) + m_flag = waitForBookings == waitForTimeAssignments; else { ui->actionToday->setEnabled(true); @@ -209,7 +209,7 @@ void MainWindow::refresh(bool forceAuswertung) else { m_auswertungDate = QDate(); - QMessageBox::warning(this, tr("Unknown error occured."), tr("An unknown error occured.")); + QMessageBox::warning(this, tr("Unknown error occured!"), tr("Unknown error occured!")); } } } @@ -221,7 +221,7 @@ void MainWindow::getProjekctsFinished(bool success, const QString &message, cons if(!success) { - QMessageBox::warning(this, tr("Could not load Buchungen!"), tr("Could not load Buchungen!") % "\n\n" % message); + QMessageBox::warning(this, tr("Could not load bookings!"), tr("Could not load bookings!") % "\n\n" % message); return; } @@ -280,13 +280,13 @@ void MainWindow::getAuswertungFinished(bool success, const QString &message, con m_holidaysLabel->setText(tr("%0: %1").arg(tr("Holidays")).arg(urlaubsAnspruch)); } -void MainWindow::refreshBuchungenFinished(bool success, const QString &message) +void MainWindow::refreshBookingsFinished(bool success, const QString &message) { - disconnect(m_buchungenModel, &BuchungenModel::refreshFinished, - this, &MainWindow::refreshBuchungenFinished); + disconnect(m_bookingsModel, &BookingsModel::refreshFinished, + this, &MainWindow::refreshBookingsFinished); if(success) - ui->treeViewBuchungen->setEnabled(true); + ui->treeViewBookings->setEnabled(true); if(m_flag) m_flag = false; @@ -294,7 +294,7 @@ void MainWindow::refreshBuchungenFinished(bool success, const QString &message) validateEntries(); if(!success) - QMessageBox::warning(Q_NULLPTR, tr("Could not refresh Buchungen!"), tr("Could not refresh Buchungen!") % "\n\n" % message); + QMessageBox::warning(Q_NULLPTR, tr("Could not load bookings!"), tr("Could not load bookings!") % "\n\n" % message); } void MainWindow::refreshTimeAssignmentsFinished(bool success, const QString &message) @@ -311,35 +311,35 @@ void MainWindow::refreshTimeAssignmentsFinished(bool success, const QString &mes validateEntries(); if(!success) - QMessageBox::warning(Q_NULLPTR, tr("Could not refresh time assignments!"), tr("Could not refresh time assignments!") % "\n\n" % message); + QMessageBox::warning(Q_NULLPTR, tr("Could not load time assignments!"), tr("Could not load time assignments!") % "\n\n" % message); } -void MainWindow::contextMenuBuchung(const QPoint &pos) +void MainWindow::contextMenuBooking(const QPoint &pos) { - auto index = ui->treeViewBuchungen->indexAt(pos); + auto index = ui->treeViewBookings->indexAt(pos); if(index.isValid()) { - auto buchung = m_buchungenModel->getBuchung(index); + auto booking = m_bookingsModel->getBooking(index); QMenu menu; - auto editAction = menu.addAction(tr("Edit")); - auto deleteAction = menu.addAction(tr("Delete")); - auto selectedAction = menu.exec(ui->treeViewBuchungen->viewport()->mapToGlobal(pos)); + auto editAction = menu.addAction(tr("Edit booking")); + auto deleteAction = menu.addAction(tr("Delete booking")); + auto selectedAction = menu.exec(ui->treeViewBookings->viewport()->mapToGlobal(pos)); if(selectedAction == editAction) { - BuchungDialog dialog(this); - dialog.setTime(buchung.time); - dialog.setTimespan(buchung.timespan); - dialog.setType(buchung.type); - dialog.setText(buchung.text); + BookingDialog dialog(this); + dialog.setTime(booking.time); + dialog.setTimespan(booking.timespan); + dialog.setType(booking.type); + dialog.setText(booking.text); again1: if(dialog.exec() == QDialog::Accepted) { EventLoopWithStatus eventLoop; - connect(&m_erfassung, &Zeiterfassung::updateBuchungFinished, &eventLoop, &EventLoopWithStatus::quitWithStatus); + connect(&m_erfassung, &Zeiterfassung::updateBookingFinished, &eventLoop, &EventLoopWithStatus::quitWithStatus); - m_erfassung.doUpdateBuchung(buchung.id, m_userInfo.userId, ui->dateEditDate->date(), + m_erfassung.doUpdateBooking(booking.id, m_userInfo.userId, ui->dateEditDate->date(), dialog.getTime(), dialog.getTimespan(), dialog.getType(), dialog.getText()); eventLoop.exec(); @@ -358,14 +358,14 @@ void MainWindow::contextMenuBuchung(const QPoint &pos) ui->comboBoxText->setEnabled(false); ui->pushButtonStart->setEnabled(false); ui->pushButtonEnd->setEnabled(false); - ui->treeViewBuchungen->setEnabled(false); + ui->treeViewBookings->setEnabled(false); clearStrips(); - if(m_buchungenModel->refresh(m_userInfo.userId, ui->dateEditDate->date(), ui->dateEditDate->date())) + if(m_bookingsModel->refresh(m_userInfo.userId, ui->dateEditDate->date(), ui->dateEditDate->date())) { - connect(m_buchungenModel, &BuchungenModel::refreshFinished, - this, &MainWindow::refreshBuchungenFinished); + connect(m_bookingsModel, &BookingsModel::refreshFinished, + this, &MainWindow::refreshBookingsFinished); m_flag = false; } else @@ -379,7 +379,7 @@ void MainWindow::contextMenuBuchung(const QPoint &pos) } else { - QMessageBox::warning(this, tr("Could not update Buchung!"), tr("Could not update Buchung!") % "\n\n" % eventLoop.message()); + QMessageBox::warning(this, tr("Could not edit booking!"), tr("Could not edit booking!") % "\n\n" % eventLoop.message()); goto again1; } } @@ -387,15 +387,15 @@ void MainWindow::contextMenuBuchung(const QPoint &pos) else if(selectedAction == deleteAction) { QMessageBox msgBox; - msgBox.setText("Do you really want to delete the Buchung?"); + msgBox.setText("Do you really want to delete the booking?"); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Cancel); if(msgBox.exec() == QMessageBox::Yes) { EventLoopWithStatus eventLoop; - connect(&m_erfassung, &Zeiterfassung::deleteBuchungFinished, &eventLoop, &EventLoopWithStatus::quitWithStatus); + connect(&m_erfassung, &Zeiterfassung::deleteBookingFinished, &eventLoop, &EventLoopWithStatus::quitWithStatus); - m_erfassung.doDeleteBuchung(buchung.id); + m_erfassung.doDeleteBooking(booking.id); eventLoop.exec(); if(eventLoop.success()) @@ -412,14 +412,14 @@ void MainWindow::contextMenuBuchung(const QPoint &pos) ui->comboBoxText->setEnabled(false); ui->pushButtonStart->setEnabled(false); ui->pushButtonEnd->setEnabled(false); - ui->treeViewBuchungen->setEnabled(false); + ui->treeViewBookings->setEnabled(false); clearStrips(); - if(m_buchungenModel->refresh(m_userInfo.userId, ui->dateEditDate->date(), ui->dateEditDate->date())) + if(m_bookingsModel->refresh(m_userInfo.userId, ui->dateEditDate->date(), ui->dateEditDate->date())) { - connect(m_buchungenModel, &BuchungenModel::refreshFinished, - this, &MainWindow::refreshBuchungenFinished); + connect(m_bookingsModel, &BookingsModel::refreshFinished, + this, &MainWindow::refreshBookingsFinished); m_flag = false; } else @@ -432,26 +432,26 @@ void MainWindow::contextMenuBuchung(const QPoint &pos) } } else - QMessageBox::warning(this, tr("Could not delete Buchung!"), tr("Could not delete Buchung!") % "\n\n" % eventLoop.message()); + QMessageBox::warning(this, tr("Could not delete booking!"), tr("Could not delete booking!") % "\n\n" % eventLoop.message()); } } } else { QMenu menu; - auto createAction = menu.addAction(tr("Create")); - auto selectedAction = menu.exec(ui->treeViewBuchungen->viewport()->mapToGlobal(pos)); + auto createAction = menu.addAction(tr("Create booking")); + auto selectedAction = menu.exec(ui->treeViewBookings->viewport()->mapToGlobal(pos)); if(selectedAction == createAction) { - BuchungDialog dialog(this); + BookingDialog dialog(this); dialog.setTime(timeNormalise(QTime::currentTime())); again2: if(dialog.exec() == QDialog::Accepted) { EventLoopWithStatus eventLoop; - connect(&m_erfassung, &Zeiterfassung::createBuchungFinished, &eventLoop, &EventLoopWithStatus::quitWithStatus); + connect(&m_erfassung, &Zeiterfassung::createBookingFinished, &eventLoop, &EventLoopWithStatus::quitWithStatus); - m_erfassung.doCreateBuchung(m_userInfo.userId, ui->dateEditDate->date(), + m_erfassung.doCreateBooking(m_userInfo.userId, ui->dateEditDate->date(), dialog.getTime(), dialog.getTimespan(), dialog.getType(), dialog.getText()); eventLoop.exec(); @@ -470,14 +470,14 @@ void MainWindow::contextMenuBuchung(const QPoint &pos) ui->comboBoxText->setEnabled(false); ui->pushButtonStart->setEnabled(false); ui->pushButtonEnd->setEnabled(false); - ui->treeViewBuchungen->setEnabled(false); + ui->treeViewBookings->setEnabled(false); clearStrips(); - if(m_buchungenModel->refresh(m_userInfo.userId, ui->dateEditDate->date(), ui->dateEditDate->date())) + if(m_bookingsModel->refresh(m_userInfo.userId, ui->dateEditDate->date(), ui->dateEditDate->date())) { - connect(m_buchungenModel, &BuchungenModel::refreshFinished, - this, &MainWindow::refreshBuchungenFinished); + connect(m_bookingsModel, &BookingsModel::refreshFinished, + this, &MainWindow::refreshBookingsFinished); m_flag = false; } else @@ -491,7 +491,7 @@ void MainWindow::contextMenuBuchung(const QPoint &pos) } else { - QMessageBox::warning(this, tr("Could not create Buchung!"), tr("Could not create Buchung!") % "\n\n" % eventLoop.message()); + QMessageBox::warning(this, tr("Could not create booking!"), tr("Could not create booking!") % "\n\n" % eventLoop.message()); goto again2; } } @@ -508,8 +508,8 @@ void MainWindow::contextMenuTimeAssignment(const QPoint &pos) auto timeAssignment = m_timeAssignmentsModel->getTimeAssignment(index); QMenu menu; - auto editAction = menu.addAction(tr("Edit")); - auto deleteAction = menu.addAction(tr("Delete")); + auto editAction = menu.addAction(tr("Edit time assignment")); + auto deleteAction = menu.addAction(tr("Delete time assignment")); auto selectedAction = menu.exec(ui->treeViewTimeAssignments->viewport()->mapToGlobal(pos)); if(selectedAction == editAction) { @@ -572,7 +572,7 @@ void MainWindow::contextMenuTimeAssignment(const QPoint &pos) } else { - QMessageBox::warning(this, tr("Could not update time assignment!"), tr("Could not update time assignment!") % "\n\n" % eventLoop.message()); + QMessageBox::warning(this, tr("Could not edit time assignment!"), tr("Could not edit time assignment!") % "\n\n" % eventLoop.message()); goto again1; } } @@ -632,7 +632,7 @@ void MainWindow::contextMenuTimeAssignment(const QPoint &pos) else { QMenu menu; - auto createAction = menu.addAction(tr("Create")); + auto createAction = menu.addAction(tr("Create time assignment")); auto selectedAction = menu.exec(ui->treeViewTimeAssignments->viewport()->mapToGlobal(pos)); if(selectedAction == createAction) { @@ -699,20 +699,20 @@ void MainWindow::contextMenuTimeAssignment(const QPoint &pos) void MainWindow::pushButtonStartPressed() { - if(m_buchungenModel->rbegin() == m_buchungenModel->rend() || - m_buchungenModel->rbegin()->type == QStringLiteral("G")) + if(m_bookingsModel->rbegin() == m_bookingsModel->rend() || + m_bookingsModel->rbegin()->type == QStringLiteral("G")) { EventLoopWithStatus eventLoop; - connect(&m_erfassung, &Zeiterfassung::createBuchungFinished, &eventLoop, &EventLoopWithStatus::quitWithStatus); + connect(&m_erfassung, &Zeiterfassung::createBookingFinished, &eventLoop, &EventLoopWithStatus::quitWithStatus); - m_erfassung.doCreateBuchung(m_userInfo.userId, ui->dateEditDate->date(), + m_erfassung.doCreateBooking(m_userInfo.userId, ui->dateEditDate->date(), timeNormalise(ui->timeEditTime->time()), QTime(0, 0), QStringLiteral("K"), QStringLiteral("")); eventLoop.exec(); if(!eventLoop.success()) { - QMessageBox::warning(this, tr("Could not create Buchung!"), tr("Could not create Buchung!") % "\n\n" % eventLoop.message()); + QMessageBox::warning(this, tr("Could not create booking!"), tr("Could not create booking!") % "\n\n" % eventLoop.message()); refresh(true); return; } @@ -738,7 +738,7 @@ void MainWindow::pushButtonStartPressed() m_timeAssignmentTime = timeAdd(m_timeAssignmentTime, timespan); else { - QMessageBox::warning(this, tr("Could not update time assignment!"), tr("Could not update time assignment!") % "\n\n" % eventLoop.message()); + QMessageBox::warning(this, tr("Could not edit time assignment!"), tr("Could not edit time assignment!") % "\n\n" % eventLoop.message()); refresh(true); return; } @@ -775,16 +775,16 @@ void MainWindow::pushButtonEndPressed() { { EventLoopWithStatus eventLoop; - connect(&m_erfassung, &Zeiterfassung::createBuchungFinished, &eventLoop, &EventLoopWithStatus::quitWithStatus); + connect(&m_erfassung, &Zeiterfassung::createBookingFinished, &eventLoop, &EventLoopWithStatus::quitWithStatus); - m_erfassung.doCreateBuchung(m_userInfo.userId, ui->dateEditDate->date(), + m_erfassung.doCreateBooking(m_userInfo.userId, ui->dateEditDate->date(), timeNormalise(ui->timeEditTime->time()), QTime(0, 0), QStringLiteral("G"), QStringLiteral("")); eventLoop.exec(); if(!eventLoop.success()) { - QMessageBox::warning(this, tr("Could not create Buchung!"), tr("Could not create Buchung!") % "\n\n" % eventLoop.message()); + QMessageBox::warning(this, tr("Could not create booking!"), tr("Could not create booking!") % "\n\n" % eventLoop.message()); refresh(true); return; } @@ -809,7 +809,7 @@ void MainWindow::pushButtonEndPressed() m_timeAssignmentTime = timeAdd(m_timeAssignmentTime, timespan); else { - QMessageBox::warning(this, tr("Could not update time assignment!"), tr("Could not update time assignment!") % "\n\n" % eventLoop.message()); + QMessageBox::warning(this, tr("Could not edit time assignment!"), tr("Could not edit time assignment!") % "\n\n" % eventLoop.message()); refresh(true); return; } @@ -828,65 +828,65 @@ void MainWindow::validateEntries() ui->pushButtonNext->setEnabled(true); ui->pushButtonStart->setText(tr("Start")); - if(!ui->treeViewBuchungen->isEnabled()) + if(!ui->treeViewBookings->isEnabled()) return; if(!ui->treeViewTimeAssignments->isEnabled()) return; - auto buchungenIter = m_buchungenModel->constBegin(); + auto bookingsIter = m_bookingsModel->constBegin(); auto timeAssignmentsIter = m_timeAssignmentsModel->constBegin(); m_timeAssignmentTime = QTime(0, 0); - auto buchungTimespan = QTime(0, 0); + auto bookingTimespan = QTime(0, 0); - const Zeiterfassung::Buchung *lastBuchung = Q_NULLPTR; + const Zeiterfassung::Booking *lastBooking = Q_NULLPTR; const Zeiterfassung::TimeAssignment *lastTimeAssignment = Q_NULLPTR; QString errorMessage; while(true) { - if(buchungenIter == m_buchungenModel->constEnd() && + if(bookingsIter == m_bookingsModel->constEnd() && timeAssignmentsIter == m_timeAssignmentsModel->constEnd()) { goto after; } - if(buchungenIter == m_buchungenModel->constEnd()) + if(bookingsIter == m_bookingsModel->constEnd()) { - errorMessage = tr("Missing Buchung."); + errorMessage = tr("Missing booking!"); goto after; } - auto startBuchung = *buchungenIter++; - if(startBuchung.type != QStringLiteral("K")) + auto startBooking = *bookingsIter++; + if(startBooking.type != QStringLiteral("K")) { - errorMessage = tr("Expected start Buchung, instead got type %0\nBuchung ID: %1") - .arg(startBuchung.type) - .arg(startBuchung.id); + errorMessage = tr("Expected start booking, instead got type %0\nBooking ID: %1") + .arg(startBooking.type) + .arg(startBooking.id); goto after; } - if(lastBuchung) + if(lastBooking) { auto label = new QLabel(tr("%0: %1") .arg(tr("Break")) - .arg(tr("%0h").arg(timeBetween(lastBuchung->time, startBuchung.time).toString(QStringLiteral("HH:mm")))), + .arg(tr("%0h").arg(timeBetween(lastBooking->time, startBooking.time).toString(QStringLiteral("HH:mm")))), ui->scrollAreaWidgetContents); ui->verticalLayout2->addWidget(label); label->setMinimumHeight(20); label->setMaximumHeight(20); } - lastBuchung = &startBuchung; + lastBooking = &startBooking; - m_lastTimeAssignmentStart = startBuchung.time; - ui->verticalLayout2->addWidget(new BuchungStrip(startBuchung.id, startBuchung.time, startBuchung.type, m_settings, ui->scrollAreaWidgetContents)); + m_lastTimeAssignmentStart = startBooking.time; + ui->verticalLayout2->addWidget(new BookingStrip(startBooking.id, startBooking.time, startBooking.type, m_settings, ui->scrollAreaWidgetContents)); if(timeAssignmentsIter == m_timeAssignmentsModel->constEnd()) { - errorMessage = tr("Missing time assignment."); + errorMessage = tr("Missing time assignment!"); goto after; } @@ -908,10 +908,10 @@ void MainWindow::validateEntries() if(timeAssignment.timespan == QTime(0, 0)) { - if(buchungenIter != m_buchungenModel->constEnd()) + if(bookingsIter != m_bookingsModel->constEnd()) { - errorMessage = tr("There is another Buchung after an unfinished time assignment.\nBuchung ID: %0\nTime assignment ID: %1") - .arg(buchungenIter->id) + errorMessage = tr("There is another booking after an unfinished time assignment.\nBooking ID: %0\nTime assignment ID: %1") + .arg(bookingsIter->id) .arg(timeAssignment.id); goto after; } @@ -934,13 +934,13 @@ void MainWindow::validateEntries() m_timeAssignmentTime = timeAdd(m_timeAssignmentTime, timeAssignment.timespan); m_lastTimeAssignmentStart = timeAdd(m_lastTimeAssignmentStart, timeAssignment.timespan); - if(buchungenIter == m_buchungenModel->constEnd()) + if(bookingsIter == m_bookingsModel->constEnd()) { while(true) { if(timeAssignmentsIter == m_timeAssignmentsModel->constEnd()) { - errorMessage = tr("The last time assignment is finished without end Buchung\nTime assignment ID: %0") + errorMessage = tr("The last time assignment is finished without end booking\nTime assignment ID: %0") .arg(timeAssignment.id); goto after; } @@ -986,26 +986,26 @@ void MainWindow::validateEntries() } else { - auto endBuchung = *buchungenIter++; - if(endBuchung.type != QStringLiteral("G")) + auto endBooking = *bookingsIter++; + if(endBooking.type != QStringLiteral("G")) { - errorMessage = tr("Expected end Buchung, instead got type %0\nBuchung ID: %1") - .arg(endBuchung.type) - .arg(endBuchung.id); + errorMessage = tr("Expected end booking, instead got type %0\nBooking ID: %1") + .arg(endBooking.type) + .arg(endBooking.id); goto after; } - lastBuchung = &endBuchung; + lastBooking = &endBooking; - buchungTimespan = timeAdd(buchungTimespan, timeBetween(startBuchung.time, endBuchung.time)); - ui->timeEditTime->setMinimumTime(timeAdd(endBuchung.time, QTime(0, 1))); + bookingTimespan = timeAdd(bookingTimespan, timeBetween(startBooking.time, endBooking.time)); + ui->timeEditTime->setMinimumTime(timeAdd(endBooking.time, QTime(0, 1))); - while(m_timeAssignmentTime < buchungTimespan) + while(m_timeAssignmentTime < bookingTimespan) { if(timeAssignmentsIter == m_timeAssignmentsModel->constEnd()) { - errorMessage = tr("Missing time assignment(s)! Missing: %0h") - .arg(timeBetween(m_timeAssignmentTime, buchungTimespan).toString("HH:mm:ss")); + errorMessage = tr("Missing time assignment! Missing: %0h") + .arg(timeBetween(m_timeAssignmentTime, bookingTimespan).toString("HH:mm:ss")); { auto label = new QLabel(errorMessage, ui->scrollAreaWidgetContents); @@ -1014,7 +1014,7 @@ void MainWindow::validateEntries() label->setMaximumHeight(20); } - ui->verticalLayout2->addWidget(new BuchungStrip(endBuchung.id, endBuchung.time, endBuchung.type, m_settings, ui->scrollAreaWidgetContents)); + ui->verticalLayout2->addWidget(new BookingStrip(endBooking.id, endBooking.time, endBooking.type, m_settings, ui->scrollAreaWidgetContents)); goto after; } @@ -1037,11 +1037,11 @@ void MainWindow::validateEntries() if(timeAssignment.timespan == QTime(0, 0)) { - if(buchungenIter != m_buchungenModel->constEnd()) + if(bookingsIter != m_bookingsModel->constEnd()) { - errorMessage = tr("There is another Buchung after an unfinished time assignment.\n" - "Buchung ID: %0\nTime assignment ID: %1") - .arg(buchungenIter->id) + errorMessage = tr("There is another booking after an unfinished time assignment.\n" + "Booking ID: %0\nTime assignment ID: %1") + .arg(bookingsIter->id) .arg(timeAssignment.id); goto after; } @@ -1065,11 +1065,11 @@ void MainWindow::validateEntries() } } - if(m_timeAssignmentTime > buchungTimespan) + if(m_timeAssignmentTime > bookingTimespan) { - errorMessage = tr("Time assignment time longer than Buchung time! Time assignment: %0 Buchung: %1") + errorMessage = tr("Time assignment time longer than booking time! Time assignment: %0 Booking: %1") .arg(m_timeAssignmentTime.toString("HH:mm:ss")) - .arg(buchungTimespan.toString("HH:mm:ss")); + .arg(bookingTimespan.toString("HH:mm:ss")); auto label = new QLabel(errorMessage, ui->scrollAreaWidgetContents); ui->verticalLayout2->addWidget(label); @@ -1077,9 +1077,9 @@ void MainWindow::validateEntries() label->setMaximumHeight(20); } - ui->verticalLayout2->addWidget(new BuchungStrip(endBuchung.id, endBuchung.time, endBuchung.type, m_settings, ui->scrollAreaWidgetContents)); + ui->verticalLayout2->addWidget(new BookingStrip(endBooking.id, endBooking.time, endBooking.type, m_settings, ui->scrollAreaWidgetContents)); - if(m_timeAssignmentTime > buchungTimespan) + if(m_timeAssignmentTime > bookingTimespan) goto after; } } @@ -1100,8 +1100,7 @@ void MainWindow::validateEntries() if(!errorMessage.isEmpty()) { - QMessageBox::warning(this, tr("Illegal state!"), tr("Your Buchungen and time assignments for this day are in an invalid state:\n\n%0") - .arg(errorMessage)); + QMessageBox::warning(this, tr("Illegal state!"), tr("Your bookings and time assignments for this day are in an illegal state!") % "\n\n" % errorMessage); return; } diff --git a/mainwindow.h b/mainwindow.h index 68f158a..3396dfb 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -10,7 +10,7 @@ class QLabel; namespace Ui { class MainWindow; } class ZeiterfassungSettings; -class BuchungenModel; +class BookingsModel; class TimeAssignmentsModel; class MainWindow : public QMainWindow @@ -30,9 +30,9 @@ private Q_SLOTS: void refresh(bool forceAuswertung = false); void getProjekctsFinished(bool success, const QString &message, const QVector &projects); void getAuswertungFinished(bool success, const QString &message, const QByteArray &content); - void refreshBuchungenFinished(bool success, const QString &message); + void refreshBookingsFinished(bool success, const QString &message); void refreshTimeAssignmentsFinished(bool success, const QString &message); - void contextMenuBuchung(const QPoint &pos); + void contextMenuBooking(const QPoint &pos); void contextMenuTimeAssignment(const QPoint &pos); void pushButtonStartPressed(); void pushButtonEndPressed(); @@ -55,7 +55,7 @@ private: QLabel *m_balanceLabel; QLabel *m_holidaysLabel; - BuchungenModel *m_buchungenModel; + BookingsModel *m_bookingsModel; TimeAssignmentsModel *m_timeAssignmentsModel; bool m_flag; diff --git a/mainwindow.ui b/mainwindow.ui index 18384e3..9c5f41d 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -213,13 +213,13 @@ Advanced view - + - Buchungen + Bookings - + false diff --git a/models/bookingsmodel.cpp b/models/bookingsmodel.cpp new file mode 100644 index 0000000..4d46796 --- /dev/null +++ b/models/bookingsmodel.cpp @@ -0,0 +1,106 @@ +#include "bookingsmodel.h" + +BookingsModel::BookingsModel(Zeiterfassung &erfassung, QObject *parent) : + QAbstractListModel(parent), + m_erfassung(erfassung) +{ + +} + +int BookingsModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent) + + return m_bookings.count(); +} + +int BookingsModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent) + + return 5; +} + +QVariant BookingsModel::data(const QModelIndex &index, int role) const +{ + Q_ASSERT(index.row() < m_bookings.count()); + const auto &booking = m_bookings.at(index.row()); + + switch(role) + { + case Qt::DisplayRole: + case Qt::EditRole: + switch(index.column()) + { + case 0: return booking.id; + case 1: return booking.time; + case 2: return booking.timespan; + case 3: return booking.type; + case 4: return booking.text; + } + } + + return QVariant(); +} + +QVariant BookingsModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + switch(orientation) + { + case Qt::Horizontal: + switch(role) + { + case Qt::DisplayRole: + case Qt::EditRole: + switch(section) + { + case 0: return tr("ID"); + case 1: return tr("Time"); + case 2: return tr("Timespan"); + case 3: return tr("Type"); + case 4: return tr("Text"); + } + } + } + + return QVariant(); +} + +Zeiterfassung::Booking BookingsModel::getBooking(const QModelIndex &index) const +{ + if(!index.isValid()) + return Zeiterfassung::Booking(); + + Q_ASSERT(index.row() <= m_bookings.count()); + return m_bookings.at(index.row()); +} + +bool BookingsModel::refresh(int userId, const QDate &from, const QDate &to) +{ + if(!m_erfassung.doGetBookings(userId, from, to)) + return false; + + beginResetModel(); + m_bookings.clear(); + endResetModel(); + + connect(&m_erfassung, &Zeiterfassung::getBookingsFinished, + this, &BookingsModel::getBookingsFinished); + + return true; +} + +void BookingsModel::getBookingsFinished(bool success, const QString &message, const QVector &bookings) +{ + disconnect(&m_erfassung, &Zeiterfassung::getBookingsFinished, + this, &BookingsModel::getBookingsFinished); + + if(success) + { + beginResetModel(); + m_bookings = bookings; + endResetModel(); + } + + Q_EMIT refreshFinished(success, message); +} diff --git a/models/buchungenmodel.h b/models/bookingsmodel.h similarity index 53% rename from models/buchungenmodel.h rename to models/bookingsmodel.h index 115b1af..410c519 100644 --- a/models/buchungenmodel.h +++ b/models/bookingsmodel.h @@ -1,17 +1,17 @@ -#ifndef BUCHUNGENMODEL_H -#define BUCHUNGENMODEL_H +#ifndef BOOKINGSMODEL_H +#define BOOKINGSMODEL_H #include #include #include "zeiterfassung.h" -class BuchungenModel : public QAbstractListModel +class BookingsModel : public QAbstractListModel { Q_OBJECT public: - explicit BuchungenModel(Zeiterfassung &erfassung, QObject *parent = nullptr); + explicit BookingsModel(Zeiterfassung &erfassung, QObject *parent = nullptr); // QAbstractItemModel interface int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; @@ -19,50 +19,50 @@ public: QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE; - Zeiterfassung::Buchung getBuchung(const QModelIndex &index) const; + Zeiterfassung::Booking getBooking(const QModelIndex &index) const; bool refresh(int userId, const QDate &from, const QDate &to); - typedef QVector::iterator iterator; - typedef QVector::const_iterator const_iterator; - typedef QVector::reverse_iterator reverse_iterator; - typedef QVector::const_reverse_iterator const_reverse_iterator; + typedef QVector::iterator iterator; + typedef QVector::const_iterator const_iterator; + typedef QVector::reverse_iterator reverse_iterator; + typedef QVector::const_reverse_iterator const_reverse_iterator; #if !defined(QT_STRICT_ITERATORS) || defined(Q_QDOC) - //inline iterator begin() { return m_buchungen.begin(); } - inline const_iterator begin() const Q_DECL_NOTHROW { return m_buchungen.begin(); } - inline const_iterator cbegin() const Q_DECL_NOTHROW { return m_buchungen.cbegin(); } - inline const_iterator constBegin() const Q_DECL_NOTHROW { return m_buchungen.constBegin(); } - //inline iterator end() { return m_buchungen.end(); } - inline const_iterator end() const Q_DECL_NOTHROW { return m_buchungen.end(); } - inline const_iterator cend() const Q_DECL_NOTHROW { return m_buchungen.cend(); } - inline const_iterator constEnd() const Q_DECL_NOTHROW { return m_buchungen.constEnd(); } + //inline iterator begin() { return m_bookings.begin(); } + inline const_iterator begin() const Q_DECL_NOTHROW { return m_bookings.begin(); } + inline const_iterator cbegin() const Q_DECL_NOTHROW { return m_bookings.cbegin(); } + inline const_iterator constBegin() const Q_DECL_NOTHROW { return m_bookings.constBegin(); } + //inline iterator end() { return m_bookings.end(); } + inline const_iterator end() const Q_DECL_NOTHROW { return m_bookings.end(); } + inline const_iterator cend() const Q_DECL_NOTHROW { return m_bookings.cend(); } + inline const_iterator constEnd() const Q_DECL_NOTHROW { return m_bookings.constEnd(); } #else - //inline iterator begin(iterator = iterator()) { return m_buchungen.begin(); } - inline const_iterator begin(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return m_buchungen.begin(); } + //inline iterator begin(iterator = iterator()) { return m_bookings.begin(); } + inline const_iterator begin(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return m_bookings.begin(); } inline const_iterator cbegin(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return d->constBegin(); } - inline const_iterator constBegin(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return m_buchungen.constBegin(); } - //inline iterator end(iterator = iterator()) { return m_buchungen.end(); } - inline const_iterator end(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return m_buchungen.end(); } - inline const_iterator cend(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return m_buchungen.cend(); } - inline const_iterator constEnd(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return m_buchungen.constEnd(); } + inline const_iterator constBegin(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return m_bookings.constBegin(); } + //inline iterator end(iterator = iterator()) { return m_bookings.end(); } + inline const_iterator end(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return m_bookings.end(); } + inline const_iterator cend(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return m_bookings.cend(); } + inline const_iterator constEnd(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return m_bookings.constEnd(); } #endif - //reverse_iterator rbegin() { return m_buchungen.rbegin(); } - //reverse_iterator rend() { return m_buchungen.rbegin(); } - const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return m_buchungen.rbegin(); } - const_reverse_iterator rend() const Q_DECL_NOTHROW { return m_buchungen.rend(); } - const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return m_buchungen.crbegin(); } - const_reverse_iterator crend() const Q_DECL_NOTHROW { return m_buchungen.crend(); } + //reverse_iterator rbegin() { return m_bookings.rbegin(); } + //reverse_iterator rend() { return m_bookings.rbegin(); } + const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return m_bookings.rbegin(); } + const_reverse_iterator rend() const Q_DECL_NOTHROW { return m_bookings.rend(); } + const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return m_bookings.crbegin(); } + const_reverse_iterator crend() const Q_DECL_NOTHROW { return m_bookings.crend(); } Q_SIGNALS: void refreshFinished(bool success, const QString &message); private Q_SLOTS: - void getBuchungenFinished(bool success, const QString &message, const QVector &buchungen); + void getBookingsFinished(bool success, const QString &message, const QVector &bookings); private: Zeiterfassung &m_erfassung; - QVector m_buchungen; + QVector m_bookings; }; -#endif // BUCHUNGENMODEL_H +#endif // BOOKINGSMODEL_H diff --git a/models/buchungenmodel.cpp b/models/buchungenmodel.cpp deleted file mode 100644 index 1abf472..0000000 --- a/models/buchungenmodel.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "buchungenmodel.h" - -BuchungenModel::BuchungenModel(Zeiterfassung &erfassung, QObject *parent) : - QAbstractListModel(parent), - m_erfassung(erfassung) -{ - -} - -int BuchungenModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent) - - return m_buchungen.count(); -} - -int BuchungenModel::columnCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent) - - return 5; -} - -QVariant BuchungenModel::data(const QModelIndex &index, int role) const -{ - Q_ASSERT(index.row() < m_buchungen.count()); - const auto &buchung = m_buchungen.at(index.row()); - - switch(role) - { - case Qt::DisplayRole: - case Qt::EditRole: - switch(index.column()) - { - case 0: return buchung.id; - case 1: return buchung.time; - case 2: return buchung.timespan; - case 3: return buchung.type; - case 4: return buchung.text; - } - } - - return QVariant(); -} - -QVariant BuchungenModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - switch(orientation) - { - case Qt::Horizontal: - switch(role) - { - case Qt::DisplayRole: - case Qt::EditRole: - switch(section) - { - case 0: return tr("ID"); - case 1: return tr("Time"); - case 2: return tr("Timespan"); - case 3: return tr("Type"); - case 4: return tr("Text"); - } - } - } - - return QVariant(); -} - -Zeiterfassung::Buchung BuchungenModel::getBuchung(const QModelIndex &index) const -{ - if(!index.isValid()) - return Zeiterfassung::Buchung(); - - Q_ASSERT(index.row() <= m_buchungen.count()); - return m_buchungen.at(index.row()); -} - -bool BuchungenModel::refresh(int userId, const QDate &from, const QDate &to) -{ - if(!m_erfassung.doGetBuchungen(userId, from, to)) - return false; - - beginResetModel(); - m_buchungen.clear(); - endResetModel(); - - connect(&m_erfassung, &Zeiterfassung::getBuchungenFinished, - this, &BuchungenModel::getBuchungenFinished); - - return true; -} - -void BuchungenModel::getBuchungenFinished(bool success, const QString &message, const QVector &buchungen) -{ - disconnect(&m_erfassung, &Zeiterfassung::getBuchungenFinished, - this, &BuchungenModel::getBuchungenFinished); - - if(success) - { - beginResetModel(); - m_buchungen = buchungen; - endResetModel(); - } - - Q_EMIT refreshFinished(success, message); -} diff --git a/strips/buchungstrip.cpp b/strips/bookingstrip.cpp similarity index 71% rename from strips/buchungstrip.cpp rename to strips/bookingstrip.cpp index 29106b5..6227086 100644 --- a/strips/buchungstrip.cpp +++ b/strips/bookingstrip.cpp @@ -1,14 +1,14 @@ -#include "buchungstrip.h" -#include "ui_buchungstrip.h" +#include "bookingstrip.h" +#include "ui_bookingstrip.h" #include #include #include "zeiterfassungsettings.h" -BuchungStrip::BuchungStrip(int id, const QTime &time, const QString &type, const ZeiterfassungSettings &settings, QWidget *parent) : +BookingStrip::BookingStrip(int id, const QTime &time, const QString &type, const ZeiterfassungSettings &settings, QWidget *parent) : QFrame(parent), - ui(new Ui::BuchungStrip) + ui(new Ui::BookingStrip) { ui->setupUi(this); @@ -18,24 +18,24 @@ BuchungStrip::BuchungStrip(int id, const QTime &time, const QString &type, const ui->labelTime->setText(time.toString(QStringLiteral("HH:mm"))); if(type == QStringLiteral("K")) { - setStyleSheet(QStringLiteral("%0 { background-color: %1; }").arg(staticMetaObject.className()).arg(settings.buchungStartBackgroundColor())); + setStyleSheet(QStringLiteral("%0 { background-color: %1; }").arg(staticMetaObject.className()).arg(settings.bookingStartBackgroundColor())); ui->labelType->setText(tr("START")); } else if(type == QStringLiteral("G")) { - setStyleSheet(QStringLiteral("%0 { background-color: %1; }").arg(staticMetaObject.className()).arg(settings.buchungEndBackgroundColor())); + setStyleSheet(QStringLiteral("%0 { background-color: %1; }").arg(staticMetaObject.className()).arg(settings.bookingEndBackgroundColor())); ui->labelType->setText(tr("END")); } else { - setStyleSheet(QStringLiteral("%0 { background-color: %1; }").arg(staticMetaObject.className()).arg(settings.buchungOtherBackgroundColor())); + setStyleSheet(QStringLiteral("%0 { background-color: %1; }").arg(staticMetaObject.className()).arg(settings.bookingOtherBackgroundColor())); ui->labelType->setText(tr("UNKNOWN")); } ui->labelId->setText(QString::number(id)); } -BuchungStrip::~BuchungStrip() +BookingStrip::~BookingStrip() { delete ui; } diff --git a/strips/bookingstrip.h b/strips/bookingstrip.h new file mode 100644 index 0000000..7500d9c --- /dev/null +++ b/strips/bookingstrip.h @@ -0,0 +1,23 @@ +#ifndef BOOKINGSTRIP_H +#define BOOKINGSTRIP_H + +#include + +class QTime; + +class ZeiterfassungSettings; +namespace Ui { class BookingStrip; } + +class BookingStrip : public QFrame +{ + Q_OBJECT + +public: + explicit BookingStrip(int id, const QTime &time, const QString &type, const ZeiterfassungSettings &settings, QWidget *parent = 0); + ~BookingStrip(); + +private: + Ui::BookingStrip *ui; +}; + +#endif // BOOKINGSTRIP_H diff --git a/strips/buchungstrip.ui b/strips/bookingstrip.ui similarity index 95% rename from strips/buchungstrip.ui rename to strips/bookingstrip.ui index 18cf853..fa3f33b 100644 --- a/strips/buchungstrip.ui +++ b/strips/bookingstrip.ui @@ -1,7 +1,7 @@ - BuchungStrip - + BookingStrip + 0 diff --git a/strips/buchungstrip.h b/strips/buchungstrip.h deleted file mode 100644 index aae7642..0000000 --- a/strips/buchungstrip.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef BUCHUNGSTRIP_H -#define BUCHUNGSTRIP_H - -#include - -class QTime; - -class ZeiterfassungSettings; -namespace Ui { class BuchungStrip; } - -class BuchungStrip : public QFrame -{ - Q_OBJECT - -public: - explicit BuchungStrip(int id, const QTime &time, const QString &type, const ZeiterfassungSettings &settings, QWidget *parent = 0); - ~BuchungStrip(); - -private: - Ui::BuchungStrip *ui; -}; - -#endif // BUCHUNGSTRIP_H diff --git a/translations/zeiterfassung_de.qm b/translations/zeiterfassung_de.qm index e5b60bd..4c8c6cf 100644 Binary files a/translations/zeiterfassung_de.qm and b/translations/zeiterfassung_de.qm differ diff --git a/translations/zeiterfassung_de.ts b/translations/zeiterfassung_de.ts index 76c076c..4393c10 100644 --- a/translations/zeiterfassung_de.ts +++ b/translations/zeiterfassung_de.ts @@ -4,26 +4,33 @@ AboutMeDialog + + About me Über mich + User-ID: Benutzer-ID: + E-Mail: E-Mail: + Long username: Langer Benutzername: + Text: Text: + Username: Benutzername: @@ -31,75 +38,93 @@ AuthenticationDialog + + Authentication Authentifizierung + Username: Benutzername: + Password: Passwort: - BuchungDialog + BookingDialog - Buchung - + + + Booking + Buchung + Time: Zeit: + Timespan: Zeitspanne: + Type: Typ: + Text: Text: - BuchungStrip + BookingStrip + START KOMMEN + END GEHEN + UNKNOWN UNBEKANNT - BuchungenModel + BookingsModel + ID ID + Time Zeit + Timespan Zeitspanne + Type Typ + Text Text @@ -107,22 +132,28 @@ LanguageSelectionDialog + + Language selection Sprachauswahl + Please select a language: - Bitte wählen sie eine Sprache: + Bitte wählen Sie eine Sprache: + Language: Sprache: + English Englisch + German Deutsch @@ -130,333 +161,447 @@ MainWindow + + Start Kommen + End Gehen + Optimized view Optimierte Anzeige + Advanced view Erweiterte Anzeige - Buchungen - + + Bookings + Buchungen + Time assignments Kontierungen + &File &Datei + &About &Über + &View &Ansicht + &Tools &Werkzeuge + &Quit &Beenden + About &Me Über &mich + About &zeiterfassung Über &zeiterfassung + About &Qt Über &Qt + &Today &Heute + &Refresh &Aktualisieren + &Auswertung + &Settings &Einstellungen + Zeiterfassung - %0 (%1) Zeiterfassung - %0 (%1) + + Could not open auswertung! + Could not open default PDF viewer! - Konnte das PDF-Anzeigeprogramm nicht öffnen! + Konnte den PDF-Anzeiger nicht öffnen! + + Subproject + Subprojekt + + + Workpackage Arbeitspaket + Text Text + + + + + + + %0: %1 %0: %1 + + + Assigned time + Kontierte Zeit + + + + + + + ??? ??? - Unknown error occured. - - - - An unknown error occured. - - - + + Balance Saldo + + Holidays - Urlaubsanspruch + Urlaubstage - Could not load Buchungen! - + + + Could not load bookings! + Konnte Buchungen nicht laden! + Could not load Auswertung! + + + %0h %0h - Could not refresh Buchungen! + + Missing time assignment! - Could not refresh time assignments! - Konnte Kontierungen nicht aktualisieren! - - - Edit - Bearbeiten - - - Delete - Löschen - - - Could not update Buchung! + + Missing time assignment! Missing: %0h - Could not delete Buchung! - + + + Unknown error occured! + Unbekannter Fehler aufgetreten! - Create - Erstellen + + Could not load time assignments! + Konnte Kontierungen nicht laden! - Could not create Buchung! - + + Could not delete booking! + Konnte Buchung nicht löschen! - Could not update time assignment! + + Edit booking + Buchung bearbeiten + + + + Delete booking + Buchung löschen + + + + Could not edit booking! + Konnte Buchung nicht bearbeiten! + + + + Create booking + Buchung erstellen + + + + + + Could not create booking! + Konnte Buchung nicht erstellen! + + + + Edit time assignment + Kontierung bearbeiten + + + + Delete time assignment + Kontierung löschen + + + + + + Could not edit time assignment! Konnte Kontierung nicht bearbeiten! + Could not delete time assignment! Konnte Kontierung nicht löschen! + + Create time assignment + Kontierung erstellen + + + + Could not create time assignment! Konnte Kontierung nicht erstellen! - Missing Buchung. - - - - Expected start Buchung, instead got type %0 -Buchung ID: %1 + + Missing booking! + Kontierung fehlend! + + + + Expected start booking, instead got type %0 +Booking ID: %1 + Break Pause - Missing time assignment. - Kontierung fehlend. - - + + + Expected %0 but received %1 in time assignment. Time assignment ID: %2 - There is another Buchung after an unfinished time assignment. -Buchung ID: %0 + + + There is another booking after an unfinished time assignment. +Booking ID: %0 Time assignment ID: %1 + + + There is another time assignment after an unfinished time assignment. Time assignment ID: %0 Time assignment ID: %1 + + + Switch Wechseln - The last time assignment is finished without end Buchung + + The last time assignment is finished without end booking Time assignment ID: %0 - Expected end Buchung, instead got type %0 -Buchung ID: %1 + + Expected end booking, instead got type %0 +Booking ID: %1 - Missing time assignment(s)! Missing: %0h - - - - Time assignment time longer than Buchung time! Time assignment: %0 Buchung: %1 + + Time assignment time longer than booking time! Time assignment: %0 Booking: %1 + Strip rendering aborted due error. + Illegal state! Ungültiger Zustand! - Your Buchungen and time assignments for this day are in an invalid state: - -%0 - - - - Assigned time - Kontierte Zeit - - - Subproject - Subprojekt + + Your bookings and time assignments for this day are in an illegal state! + Ihre Buchungen und Kontierungen für diesen Tag sind in einem ungültigen Zustand! SettingsDialog + + Settings Einstellungen - buchungStartBackgroundColor - - - - buchungEndBackgroundColor - - - - buchungOtherBackgroundColor - - - - timeAssignmentBackgroundColor - - - + language + + bookingStartBackgroundColor + + + + + bookingEndBackgroundColor + + + + + bookingOtherBackgroundColor + + + + + timeAssignmentBackgroundColor + + + + English Englisch + German Deutsch + Restart required! Neustart erforderlich! + To apply the new language a restart is required! - Um die neue Sprache anzuwenden ist ein Neustart erforderlich! + Um die neue Sprache anzuwenden, ist ein Neustart erforderlich! TimeAssignmentDialog + + Time assignment Kontierung + Time: Zeit: + Timespan: Zeitspanne: - Workpackage: - Arbeitspaket: - - - Text: - Text: - - + Project: Projekt: + Subproject: Subprojekt: + + + Workpackage: + Arbeitspaket: + + + + Text: + Text: + TimeAssignmentStrip + Open Offen @@ -464,85 +609,134 @@ Buchung ID: %1 TimeAssignmentsModel + ID ID + Time Zeit + Timespan Zeitspanne - Workpackage - Arbeitspaket - - - Text - Text - - + Project Projekt + Subproject Subprojekt + + + Workpackage + Arbeitspaket + + + + Text + Text + Zeiterfassung + + + + + + + + + + + + + + Request error occured: %0 + Could not find necessary keywords in login page! + Request did not contain a Location header. + Authentication failure. Please check username and password. + An unknown authentication failure occured. Redirected to: %0 + + + + + + + + Parsing JSON failed: %0 + + + + + + JSON document is not an object! + JSON does not contain evoAppsUser! + evoAppsUser is not an object! + + JSON document is not an array! + + + + JSON does not contain bookingNr! + JSON does not contain elements! + elements is not an array! @@ -550,48 +744,63 @@ Buchung ID: %1 main + Loading settings... Lade Einstellungen... + + Invalid language selection! Ungültige Sprachauswahl! + + You did not select a valid language! + Sie haben keine gültige Sprachauswahl getroffen! + + + Loading login page... Lade Login-Seite... - Base url - Basis URL - - - Please enter the base url to the Zeiterfassung: - Bitte geben Sie die Basis URL zur Zeiterfassung ein: - - - Authenticating... - Authentifizieren... - - - Getting user information... - Hole Benutzer Information... - - - Could not get user information! - Konnte Benutzer Information nicht holen! - - - You did not select a valid language. - Sie haben keine gültige Sprache ausgewählt. - - + + Could not access Zeiterfassung! Konnte Zeiterfassung nicht erreichen! + + Base url + Basis URL + + + + Please enter the base url to the Zeiterfassung: + Bitte geben Sie die Basis URL zur Zeiterfassung ein: + + + + Authenticating... + Authentifiziere... + + + + Could not authenticate with Zeiterfassung! - Konnte nicht bei Zeiterfassung authentifizieren! + Konnte nicht mit Zeiterfassung authentifizieren! + + + + Getting user information... + Hole Benutzer Information... + + + + + Could not get user information! + Konnte Benutzer Information nicht holen! diff --git a/translations/zeiterfassung_en.ts b/translations/zeiterfassung_en.ts index 4e5fc8c..963f0e9 100644 --- a/translations/zeiterfassung_en.ts +++ b/translations/zeiterfassung_en.ts @@ -4,26 +4,33 @@ AboutMeDialog + + About me + User-ID: + E-Mail: + Long username: + Text: + Username: @@ -31,75 +38,93 @@ AuthenticationDialog + + Authentication + Username: + Password: - BuchungDialog + BookingDialog - Buchung + + + Booking + Time: + Timespan: + Type: + Text: - BuchungStrip + BookingStrip + START + END + UNKNOWN - BuchungenModel + BookingsModel + ID + Time + Timespan + Type + Text @@ -107,22 +132,28 @@ LanguageSelectionDialog + + Language selection + Please select a language: + Language: + English + German @@ -130,295 +161,400 @@ MainWindow + + Start + End + Optimized view + Advanced view - Buchungen + + Bookings + Time assignments + &File + &About + &View + &Tools + &Quit + About &Me + About &zeiterfassung + About &Qt + &Today + &Refresh + &Auswertung + &Settings + Zeiterfassung - %0 (%1) + + Could not open auswertung! + Could not open default PDF viewer! + + Subproject + + + + Workpackage + Text + + + + + + + %0: %1 + + + Assigned time + + + + + + + + ??? - Unknown error occured. - - - - An unknown error occured. - - - + + Balance + + Holidays - Could not load Buchungen! + + + Could not load bookings! + Could not load Auswertung! + + + %0h - Could not refresh Buchungen! + + Missing time assignment! - Could not refresh time assignments! + + Missing time assignment! Missing: %0h - Edit + + + Unknown error occured! - Delete + + Could not load time assignments! - Could not update Buchung! + + Could not delete booking! - Could not delete Buchung! + + Edit booking - Create + + Delete booking - Could not create Buchung! + + Could not edit booking! - Could not update time assignment! + + Create booking + + + + Could not create booking! + + + + + Edit time assignment + + + + + Delete time assignment + + + + + + + Could not edit time assignment! + + + + Could not delete time assignment! + + Create time assignment + + + + + Could not create time assignment! - Missing Buchung. + + Missing booking! - Expected start Buchung, instead got type %0 -Buchung ID: %1 + + Expected start booking, instead got type %0 +Booking ID: %1 + Break - Missing time assignment. - - - + + + Expected %0 but received %1 in time assignment. Time assignment ID: %2 - There is another Buchung after an unfinished time assignment. -Buchung ID: %0 + + + There is another booking after an unfinished time assignment. +Booking ID: %0 Time assignment ID: %1 + + + There is another time assignment after an unfinished time assignment. Time assignment ID: %0 Time assignment ID: %1 + + + Switch - The last time assignment is finished without end Buchung + + The last time assignment is finished without end booking Time assignment ID: %0 - Expected end Buchung, instead got type %0 -Buchung ID: %1 + + Expected end booking, instead got type %0 +Booking ID: %1 - Missing time assignment(s)! Missing: %0h - - - - Time assignment time longer than Buchung time! Time assignment: %0 Buchung: %1 + + Time assignment time longer than booking time! Time assignment: %0 Booking: %1 + Strip rendering aborted due error. + Illegal state! - Your Buchungen and time assignments for this day are in an invalid state: - -%0 - - - - Assigned time - - - - Subproject + + Your bookings and time assignments for this day are in an illegal state! SettingsDialog + + Settings - buchungStartBackgroundColor - - - - buchungEndBackgroundColor - - - - buchungOtherBackgroundColor - - - - timeAssignmentBackgroundColor - - - + language + + bookingStartBackgroundColor + + + + + bookingEndBackgroundColor + + + + + bookingOtherBackgroundColor + + + + + timeAssignmentBackgroundColor + + + + English + German + Restart required! + To apply the new language a restart is required! @@ -426,37 +562,46 @@ Buchung ID: %1 TimeAssignmentDialog + + Time assignment + Time: + Timespan: - Workpackage: - - - - Text: - - - + Project: + Subproject: + + + Workpackage: + + + + + Text: + + TimeAssignmentStrip + Open @@ -464,85 +609,134 @@ Buchung ID: %1 TimeAssignmentsModel + ID + Time + Timespan - Workpackage - - - - Text - - - + Project + Subproject + + + Workpackage + + + + + Text + + Zeiterfassung + + + + + + + + + + + + + + Request error occured: %0 + Could not find necessary keywords in login page! + Request did not contain a Location header. + Authentication failure. Please check username and password. + An unknown authentication failure occured. Redirected to: %0 + + + + + + + + Parsing JSON failed: %0 + + + + + + JSON document is not an object! + JSON does not contain evoAppsUser! + evoAppsUser is not an object! + + JSON document is not an array! + + + + JSON does not contain bookingNr! + JSON does not contain elements! + elements is not an array! @@ -550,48 +744,63 @@ Buchung ID: %1 main + Loading settings... + + Invalid language selection! + + You did not select a valid language! + + + + Loading login page... - Base url - - - - Please enter the base url to the Zeiterfassung: - - - - Authenticating... - - - - Getting user information... - - - - Could not get user information! - - - - You did not select a valid language. - - - + + Could not access Zeiterfassung! + + Base url + + + + + Please enter the base url to the Zeiterfassung: + + + + + Authenticating... + + + + + Could not authenticate with Zeiterfassung! + + + Getting user information... + + + + + + Could not get user information! + + diff --git a/zeiterfassung.cpp b/zeiterfassung.cpp index 85c8e4a..97bd4f3 100644 --- a/zeiterfassung.cpp +++ b/zeiterfassung.cpp @@ -84,11 +84,13 @@ bool Zeiterfassung::doUserInfo() return true; } -bool Zeiterfassung::doGetBuchungen(int userId, const QDate &start, const QDate &end) +#define NAMEOF(x) #x + +bool Zeiterfassung::doGetBookings(int userId, const QDate &start, const QDate &end) { - if(m_replies.getBuchungen) + if(m_replies.getBookings) { - qWarning() << "another getBuchungen already processing!"; + qWarning() << "another getBookings already processing!"; return false; } @@ -99,18 +101,18 @@ bool Zeiterfassung::doGetBuchungen(int userId, const QDate &start, const QDate & .arg(userId))); request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar")); - m_replies.getBuchungen = m_manager->get(request); - connect(m_replies.getBuchungen, &QNetworkReply::finished, - this, &Zeiterfassung::getBuchungenRequestFinished); + m_replies.getBookings = m_manager->get(request); + connect(m_replies.getBookings, &QNetworkReply::finished, + this, &Zeiterfassung::getBookingsRequestFinished); return true; } -bool Zeiterfassung::doCreateBuchung(int userId, const QDate &date, const QTime &time, const QTime ×pan, const QString &type, const QString &text) +bool Zeiterfassung::doCreateBooking(int userId, const QDate &date, const QTime &time, const QTime ×pan, const QString &type, const QString &text) { - if(m_replies.createBuchung) + if(m_replies.createBooking) { - qWarning() << "another createBuchung already processing!"; + qWarning() << "another createBooking already processing!"; return false; } @@ -129,27 +131,27 @@ bool Zeiterfassung::doCreateBuchung(int userId, const QDate &date, const QTime & obj[QStringLiteral("bewEinh")] = QStringLiteral(""); obj[QStringLiteral("text")] = text; - m_replies.createBuchung = m_manager->post(request, QJsonDocument(obj).toJson()); - connect(m_replies.createBuchung, &QNetworkReply::finished, - this, &Zeiterfassung::createBuchungRequestFinished); + m_replies.createBooking = m_manager->post(request, QJsonDocument(obj).toJson()); + connect(m_replies.createBooking, &QNetworkReply::finished, + this, &Zeiterfassung::createBookingRequestFinished); return true; } -bool Zeiterfassung::doUpdateBuchung(int buchungId, int userId, const QDate &date, const QTime &time, const QTime ×pan, const QString &type, const QString &text) +bool Zeiterfassung::doUpdateBooking(int bookingId, int userId, const QDate &date, const QTime &time, const QTime ×pan, const QString &type, const QString &text) { - if(m_replies.updateBuchung) + if(m_replies.updateBooking) { - qWarning() << "another updateBuchung already processing!"; + qWarning() << "another updateBooking already processing!"; return false; } - QNetworkRequest request(QUrl(QStringLiteral("%0json/booking/%1").arg(m_url).arg(buchungId))); + QNetworkRequest request(QUrl(QStringLiteral("%0json/booking/%1").arg(m_url).arg(bookingId))); request.setHeader(QNetworkRequest::ContentTypeHeader, QByteArrayLiteral("application/json")); request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar")); QJsonObject obj; - obj[QStringLiteral("bookingNr")] = buchungId; + obj[QStringLiteral("bookingNr")] = bookingId; obj[QStringLiteral("persNr")] = userId; obj[QStringLiteral("bookingDate")] = date.toString("yyyyMMdd").toInt(); obj[QStringLiteral("bookingTime")] = time.toString("Hmmss").toInt(); @@ -160,29 +162,29 @@ bool Zeiterfassung::doUpdateBuchung(int buchungId, int userId, const QDate &date obj[QStringLiteral("bewEinh")] = QStringLiteral(""); obj[QStringLiteral("text")] = text; - m_replies.updateBuchung = m_manager->put(request, QJsonDocument(obj).toJson()); - connect(m_replies.updateBuchung, &QNetworkReply::finished, - this, &Zeiterfassung::updateBuchungRequestFinished); + m_replies.updateBooking = m_manager->put(request, QJsonDocument(obj).toJson()); + connect(m_replies.updateBooking, &QNetworkReply::finished, + this, &Zeiterfassung::updateBookingRequestFinished); return true; } -bool Zeiterfassung::doDeleteBuchung(int buchungId) +bool Zeiterfassung::doDeleteBooking(int bookingId) { - if(m_replies.deleteBuchung) + if(m_replies.deleteBooking) { - qWarning() << "another deleteBuchung already processing!"; + qWarning() << "another deleteBooking already processing!"; return false; } QNetworkRequest request(QUrl(QStringLiteral("%0json/booking/%1?text=") .arg(m_url) - .arg(buchungId))); + .arg(bookingId))); request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar")); - m_replies.deleteBuchung = m_manager->deleteResource(request); - connect(m_replies.deleteBuchung, &QNetworkReply::finished, - this, &Zeiterfassung::deleteBuchungRequestFinished); + m_replies.deleteBooking = m_manager->deleteResource(request); + connect(m_replies.deleteBooking, &QNetworkReply::finished, + this, &Zeiterfassung::deleteBookingRequestFinished); return true; } @@ -485,37 +487,37 @@ void Zeiterfassung::userInfoRequestFinished() m_replies.userInfo = Q_NULLPTR; } -void Zeiterfassung::getBuchungenRequestFinished() +void Zeiterfassung::getBookingsRequestFinished() { - if(m_replies.getBuchungen->error() != QNetworkReply::NoError) + if(m_replies.getBookings->error() != QNetworkReply::NoError) { - Q_EMIT getBuchungenFinished(false, tr("Request error occured: %0").arg(m_replies.getBuchungen->error()), {}); + Q_EMIT getBookingsFinished(false, tr("Request error occured: %0").arg(m_replies.getBookings->error()), {}); goto end; } { QJsonParseError error; - QJsonDocument document = QJsonDocument::fromJson(m_replies.getBuchungen->readAll(), &error); + QJsonDocument document = QJsonDocument::fromJson(m_replies.getBookings->readAll(), &error); if(error.error != QJsonParseError::NoError) { - Q_EMIT getBuchungenFinished(false, tr("Parsing JSON failed: %0").arg(error.errorString()), {}); + Q_EMIT getBookingsFinished(false, tr("Parsing JSON failed: %0").arg(error.errorString()), {}); goto end; } if(!document.isArray()) { - Q_EMIT getBuchungenFinished(false, tr("JSON document is not an array!"), {}); + Q_EMIT getBookingsFinished(false, tr("JSON document is not an array!"), {}); goto end; } auto arr = document.array(); - QVector buchungen; + QVector bookings; for(const auto &val : arr) { auto obj = val.toObject(); - buchungen.append({ + bookings.append({ obj.value(QStringLiteral("bookingNr")).toInt(), QDate::fromString(QString::number(obj.value(QStringLiteral("bookingDate")).toInt()), QStringLiteral("yyyyMMdd")), QTime::fromString(QString("%0").arg(obj.value(QStringLiteral("bookingTime")).toInt(), 6, 10, QChar('0')), QStringLiteral("HHmmss")), @@ -525,34 +527,34 @@ void Zeiterfassung::getBuchungenRequestFinished() }); } - Q_EMIT getBuchungenFinished(true, QString(), buchungen); + Q_EMIT getBookingsFinished(true, QString(), bookings); } end: - m_replies.getBuchungen->deleteLater(); - m_replies.getBuchungen = Q_NULLPTR; + m_replies.getBookings->deleteLater(); + m_replies.getBookings = Q_NULLPTR; } -void Zeiterfassung::createBuchungRequestFinished() +void Zeiterfassung::createBookingRequestFinished() { - if(m_replies.createBuchung->error() != QNetworkReply::NoError) + if(m_replies.createBooking->error() != QNetworkReply::NoError) { - Q_EMIT createBuchungFinished(false, tr("Request error occured: %0").arg(m_replies.createBuchung->error()), -1); + Q_EMIT createBookingFinished(false, tr("Request error occured: %0").arg(m_replies.createBooking->error()), -1); goto end; } { QJsonParseError error; - QJsonDocument document = QJsonDocument::fromJson(m_replies.createBuchung->readAll(), &error); + QJsonDocument document = QJsonDocument::fromJson(m_replies.createBooking->readAll(), &error); if(error.error != QJsonParseError::NoError) { - Q_EMIT createBuchungFinished(false, tr("Parsing JSON failed: %0").arg(error.errorString()), -1); + Q_EMIT createBookingFinished(false, tr("Parsing JSON failed: %0").arg(error.errorString()), -1); goto end; } if(!document.isObject()) { - Q_EMIT createBuchungFinished(false, tr("JSON document is not an object!"), -1); + Q_EMIT createBookingFinished(false, tr("JSON document is not an object!"), -1); goto end; } @@ -560,40 +562,40 @@ void Zeiterfassung::createBuchungRequestFinished() if(!obj.contains(QStringLiteral("bookingNr"))) { - Q_EMIT createBuchungFinished(false, tr("JSON does not contain bookingNr!"), -1); + Q_EMIT createBookingFinished(false, tr("JSON does not contain bookingNr!"), -1); goto end; } - auto buchungId = obj.value(QStringLiteral("bookingNr")).toInt(); + auto bookingId = obj.value(QStringLiteral("bookingNr")).toInt(); - Q_EMIT createBuchungFinished(true, QString(), buchungId); + Q_EMIT createBookingFinished(true, QString(), bookingId); } end: - m_replies.createBuchung->deleteLater(); - m_replies.createBuchung = Q_NULLPTR; + m_replies.createBooking->deleteLater(); + m_replies.createBooking = Q_NULLPTR; } -void Zeiterfassung::updateBuchungRequestFinished() +void Zeiterfassung::updateBookingRequestFinished() { - if(m_replies.updateBuchung->error() != QNetworkReply::NoError) + if(m_replies.updateBooking->error() != QNetworkReply::NoError) { - Q_EMIT updateBuchungFinished(false, tr("Request error occured: %0").arg(m_replies.updateBuchung->error()), -1); + Q_EMIT updateBookingFinished(false, tr("Request error occured: %0").arg(m_replies.updateBooking->error()), -1); goto end; } { QJsonParseError error; - QJsonDocument document = QJsonDocument::fromJson(m_replies.updateBuchung->readAll(), &error); + QJsonDocument document = QJsonDocument::fromJson(m_replies.updateBooking->readAll(), &error); if(error.error != QJsonParseError::NoError) { - Q_EMIT updateBuchungFinished(false, tr("Parsing JSON failed: %0").arg(error.errorString()), -1); + Q_EMIT updateBookingFinished(false, tr("Parsing JSON failed: %0").arg(error.errorString()), -1); goto end; } if(!document.isObject()) { - Q_EMIT updateBuchungFinished(false, tr("JSON document is not an object!"), -1); + Q_EMIT updateBookingFinished(false, tr("JSON document is not an object!"), -1); goto end; } @@ -601,34 +603,34 @@ void Zeiterfassung::updateBuchungRequestFinished() if(!obj.contains(QStringLiteral("bookingNr"))) { - Q_EMIT updateBuchungFinished(false, tr("JSON does not contain bookingNr!"), -1); + Q_EMIT updateBookingFinished(false, tr("JSON does not contain bookingNr!"), -1); goto end; } - auto buchungId = obj.value(QStringLiteral("bookingNr")).toInt(); + auto bookingId = obj.value(QStringLiteral("bookingNr")).toInt(); - Q_EMIT updateBuchungFinished(true, QString(), buchungId); + Q_EMIT updateBookingFinished(true, QString(), bookingId); } end: - m_replies.updateBuchung->deleteLater(); - m_replies.updateBuchung = Q_NULLPTR; + m_replies.updateBooking->deleteLater(); + m_replies.updateBooking = Q_NULLPTR; } -void Zeiterfassung::deleteBuchungRequestFinished() +void Zeiterfassung::deleteBookingRequestFinished() { - if(m_replies.deleteBuchung->error() != QNetworkReply::NoError) + if(m_replies.deleteBooking->error() != QNetworkReply::NoError) { - Q_EMIT deleteBuchungFinished(false, tr("Request error occured: %0").arg(m_replies.deleteBuchung->error())); + Q_EMIT deleteBookingFinished(false, tr("Request error occured: %0").arg(m_replies.deleteBooking->error())); goto end; } //should be empty, so nothing to check... - Q_EMIT deleteBuchungFinished(true, QString()); + Q_EMIT deleteBookingFinished(true, QString()); end: - m_replies.deleteBuchung->deleteLater(); - m_replies.deleteBuchung = Q_NULLPTR; + m_replies.deleteBooking->deleteLater(); + m_replies.deleteBooking = Q_NULLPTR; } void Zeiterfassung::getTimeAssignmentsRequestFinished() diff --git a/zeiterfassung.h b/zeiterfassung.h index dc722e5..18a23e0 100644 --- a/zeiterfassung.h +++ b/zeiterfassung.h @@ -30,7 +30,7 @@ public: QString username; }; - struct Buchung + struct Booking { int id; QDate date; @@ -63,12 +63,12 @@ public Q_SLOTS: bool doLogin(const QString &username, const QString &password); bool doUserInfo(); - bool doGetBuchungen(int userId, const QDate &start, const QDate &end); - bool doCreateBuchung(int userId, const QDate &date, const QTime &time, const QTime ×pan, + bool doGetBookings(int userId, const QDate &start, const QDate &end); + bool doCreateBooking(int userId, const QDate &date, const QTime &time, const QTime ×pan, const QString &type, const QString &text); - bool doUpdateBuchung(int buchungId, int userId, const QDate &date, const QTime &time, + bool doUpdateBooking(int bookingId, int userId, const QDate &date, const QTime &time, const QTime ×pan, const QString &type, const QString &text); - bool doDeleteBuchung(int buchungId); + bool doDeleteBooking(int bookingId); bool doGetTimeAssignments(int userId, const QDate &start, const QDate &end); bool doCreateTimeAssignment(int userId, const QDate &date, const QTime &time, const QTime ×pan, @@ -89,10 +89,10 @@ Q_SIGNALS: void loginFinished(bool success, const QString &message); void userInfoFinished(bool success, const QString &message, const UserInfo &userInfo); - void getBuchungenFinished(bool success, const QString &message, const QVector &buchungen); - void createBuchungFinished(bool success, const QString &message, int buchungId); - void updateBuchungFinished(bool success, const QString &message, int buchungId); - void deleteBuchungFinished(bool success, const QString &message); + void getBookingsFinished(bool success, const QString &message, const QVector &bookings); + void createBookingFinished(bool success, const QString &message, int bookingId); + void updateBookingFinished(bool success, const QString &message, int bookingId); + void deleteBookingFinished(bool success, const QString &message); void getTimeAssignmentsFinished(bool success, const QString &message, const QVector &timeAssignments); void createTimeAssignmentFinished(bool success, const QString &message, int timeAssignmentId); @@ -107,10 +107,10 @@ private Q_SLOTS: void loginRequestFinished(); void userInfoRequestFinished(); - void getBuchungenRequestFinished(); - void createBuchungRequestFinished(); - void updateBuchungRequestFinished(); - void deleteBuchungRequestFinished(); + void getBookingsRequestFinished(); + void createBookingRequestFinished(); + void updateBookingRequestFinished(); + void deleteBookingRequestFinished(); void getTimeAssignmentsRequestFinished(); void createTimeAssignmentRequestFinished(); @@ -130,10 +130,10 @@ private: QNetworkReply *login; QNetworkReply *userInfo; - QNetworkReply *getBuchungen; - QNetworkReply *createBuchung; - QNetworkReply *updateBuchung; - QNetworkReply *deleteBuchung; + QNetworkReply *getBookings; + QNetworkReply *createBooking; + QNetworkReply *updateBooking; + QNetworkReply *deleteBooking; QNetworkReply *getTimeAssignments; QNetworkReply *createTimeAssignment; diff --git a/zeiterfassung.pro b/zeiterfassung.pro index d6eadc2..8225a79 100755 --- a/zeiterfassung.pro +++ b/zeiterfassung.pro @@ -21,43 +21,43 @@ SOURCES += main.cpp \ mainwindow.cpp \ dialogs/aboutmedialog.cpp \ dialogs/authenticationdialog.cpp \ - dialogs/buchungdialog.cpp \ - models/buchungenmodel.cpp \ eventloopwithstatus.cpp \ - strips/buchungstrip.cpp \ zeiterfassungsettings.cpp \ dialogs/settingsdialog.cpp \ dialogs/languageselectiondialog.cpp \ dialogs/timeassignmentdialog.cpp \ models/timeassignmentsmodel.cpp \ - strips/timeassignmentstrip.cpp + strips/timeassignmentstrip.cpp \ + dialogs/bookingdialog.cpp \ + models/bookingsmodel.cpp \ + strips/bookingstrip.cpp HEADERS += \ zeiterfassung.h \ mainwindow.h \ dialogs/aboutmedialog.h \ dialogs/authenticationdialog.h \ - dialogs/buchungdialog.h \ - models/buchungenmodel.h \ eventloopwithstatus.h \ - strips/buchungstrip.h \ zeiterfassungsettings.h \ dialogs/settingsdialog.h \ dialogs/languageselectiondialog.h \ dialogs/timeassignmentdialog.h \ models/timeassignmentsmodel.h \ - strips/timeassignmentstrip.h + strips/timeassignmentstrip.h \ + dialogs/bookingdialog.h \ + models/bookingsmodel.h \ + strips/bookingstrip.h FORMS += \ mainwindow.ui \ dialogs/aboutmedialog.ui \ dialogs/authenticationdialog.ui \ - dialogs/buchungdialog.ui \ - strips/buchungstrip.ui \ dialogs/settingsdialog.ui \ dialogs/languageselectiondialog.ui \ dialogs/timeassignmentdialog.ui \ - strips/timeassignmentstrip.ui + strips/timeassignmentstrip.ui \ + dialogs/bookingdialog.ui \ + strips/bookingstrip.ui RESOURCES += \ resources.qrc diff --git a/zeiterfassungsettings.cpp b/zeiterfassungsettings.cpp index 76dd4ab..ae71a73 100644 --- a/zeiterfassungsettings.cpp +++ b/zeiterfassungsettings.cpp @@ -132,34 +132,34 @@ void ZeiterfassungSettings::prependText(const QString &text) prepentItem("texte", text); } -QString ZeiterfassungSettings::buchungStartBackgroundColor() const +QString ZeiterfassungSettings::bookingStartBackgroundColor() const { - return value("buchungStartBackgroundColor", QStringLiteral("qlineargradient( x1:0 y1:0, x2:0 y2:1, stop:0 #7FFF7F, stop:1 #6FBF6F)")).toString(); + return value("bookingStartBackgroundColor", QStringLiteral("qlineargradient( x1:0 y1:0, x2:0 y2:1, stop:0 #7FFF7F, stop:1 #6FBF6F)")).toString(); } -void ZeiterfassungSettings::setBuchungStartBackgroundColor(const QString &buchungStartBackgroundColor) +void ZeiterfassungSettings::setBookingStartBackgroundColor(const QString &bookingStartBackgroundColor) { - setValue("buchungStartBackgroundColor", buchungStartBackgroundColor); + setValue("bookingStartBackgroundColor", bookingStartBackgroundColor); } -QString ZeiterfassungSettings::buchungEndBackgroundColor() const +QString ZeiterfassungSettings::bookingEndBackgroundColor() const { - return value("buchungEndBackgroundColor", QStringLiteral("qlineargradient( x1:0 y1:0, x2:0 y2:1, stop:0 #FF7F7F, stop:1 #BF6F6F)")).toString(); + return value("bookingEndBackgroundColor", QStringLiteral("qlineargradient( x1:0 y1:0, x2:0 y2:1, stop:0 #FF7F7F, stop:1 #BF6F6F)")).toString(); } -void ZeiterfassungSettings::setBuchungEndBackgroundColor(const QString &buchungEndBackgroundColor) +void ZeiterfassungSettings::setBookingEndBackgroundColor(const QString &bookingEndBackgroundColor) { - setValue("buchungEndBackgroundColor", buchungEndBackgroundColor); + setValue("bookingEndBackgroundColor", bookingEndBackgroundColor); } -QString ZeiterfassungSettings::buchungOtherBackgroundColor() const +QString ZeiterfassungSettings::bookingOtherBackgroundColor() const { - return value("buchungOtherBackgroundColor", QStringLiteral("qlineargradient( x1:0 y1:0, x2:0 y2:1, stop:0 #FFFF7F, stop:1 #BFBF6F)")).toString(); + return value("bookingOtherBackgroundColor", QStringLiteral("qlineargradient( x1:0 y1:0, x2:0 y2:1, stop:0 #FFFF7F, stop:1 #BFBF6F)")).toString(); } -void ZeiterfassungSettings::setBuchungOtherBackgroundColor(const QString &buchungOtherBackgroundColor) +void ZeiterfassungSettings::setBookingOtherBackgroundColor(const QString &bookingOtherBackgroundColor) { - setValue("buchungOtherBackgroundColor", buchungOtherBackgroundColor); + setValue("bookingOtherBackgroundColor", bookingOtherBackgroundColor); } QString ZeiterfassungSettings::timeAssignmentBackgroundColor() const diff --git a/zeiterfassungsettings.h b/zeiterfassungsettings.h index 7511424..80793d0 100644 --- a/zeiterfassungsettings.h +++ b/zeiterfassungsettings.h @@ -46,14 +46,14 @@ public: void setTexte(const QStringList &texte); void prependText(const QString &text); - QString buchungStartBackgroundColor() const; - void setBuchungStartBackgroundColor(const QString &buchungStartBackgroundColor); + QString bookingStartBackgroundColor() const; + void setBookingStartBackgroundColor(const QString &bookingStartBackgroundColor); - QString buchungEndBackgroundColor() const; - void setBuchungEndBackgroundColor(const QString &buchungEndBackgroundColor); + QString bookingEndBackgroundColor() const; + void setBookingEndBackgroundColor(const QString &bookingEndBackgroundColor); - QString buchungOtherBackgroundColor() const; - void setBuchungOtherBackgroundColor(const QString &buchungOtherBackgroundColor); + QString bookingOtherBackgroundColor() const; + void setBookingOtherBackgroundColor(const QString &bookingOtherBackgroundColor); QString timeAssignmentBackgroundColor() const; void setTimeAssignmentBackgroundColor(const QString timeAssignmentBackgroundColor);