From a1138041f06e1941ebbf28bef6014c700c921e3b Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Sun, 17 Dec 2017 16:26:16 +0100 Subject: [PATCH] Moved structs into their correct reply classes --- zeiterfassung/main.cpp | 6 +- .../translations/zeiterfassung_de.ts | 70 ++--- .../translations/zeiterfassung_en.ts | 70 ++--- zeiterfassunglib/dialogs/aboutmedialog.cpp | 5 +- zeiterfassunglib/dialogs/aboutmedialog.h | 5 +- zeiterfassunglib/mainwindow.cpp | 5 +- zeiterfassunglib/mainwindow.h | 8 +- zeiterfassunglib/replies/getbookingsreply.cpp | 4 +- zeiterfassunglib/replies/getbookingsreply.h | 17 +- .../replies/getpresencestatusreply.cpp | 4 +- .../replies/getpresencestatusreply.h | 15 +- zeiterfassunglib/replies/getprojectsreply.cpp | 4 +- zeiterfassunglib/replies/getprojectsreply.h | 13 +- .../replies/gettimeassignmentsreply.cpp | 4 +- .../replies/gettimeassignmentsreply.h | 19 +- ...userinforeply.cpp => getuserinforeply.cpp} | 12 +- zeiterfassunglib/replies/getuserinforeply.h | 39 +++ zeiterfassunglib/replies/userinforeply.h | 29 -- zeiterfassunglib/stripswidget.cpp | 7 +- zeiterfassunglib/stripswidget.h | 14 +- .../translations/zeiterfassunglib_de.ts | 264 +++++++++--------- .../translations/zeiterfassunglib_en.ts | 264 +++++++++--------- zeiterfassunglib/zeiterfassungapi.cpp | 8 +- zeiterfassunglib/zeiterfassungapi.h | 49 +--- zeiterfassunglib/zeiterfassunglib.pro | 8 +- 25 files changed, 478 insertions(+), 465 deletions(-) rename zeiterfassunglib/replies/{userinforeply.cpp => getuserinforeply.cpp} (83%) create mode 100644 zeiterfassunglib/replies/getuserinforeply.h delete mode 100644 zeiterfassunglib/replies/userinforeply.h diff --git a/zeiterfassung/main.cpp b/zeiterfassung/main.cpp index 4075122..c4580fa 100755 --- a/zeiterfassung/main.cpp +++ b/zeiterfassung/main.cpp @@ -24,7 +24,7 @@ #include "mainwindow.h" #include "replies/loginpagereply.h" #include "replies/loginreply.h" -#include "replies/userinforeply.h" +#include "replies/getuserinforeply.h" #include "stripfactory.h" struct { @@ -250,7 +250,7 @@ bool doAuthentication(QSplashScreen &splashScreen, ZeiterfassungSettings &settin return true; } -bool loadUserInfo(QSplashScreen &splashScreen, ZeiterfassungApi &erfassung, ZeiterfassungApi::UserInfo &userInfo) +bool loadUserInfo(QSplashScreen &splashScreen, ZeiterfassungApi &erfassung, GetUserInfoReply::UserInfo &userInfo) { splashScreen.showMessage(QCoreApplication::translate("main", "Getting user information...")); @@ -370,7 +370,7 @@ int main(int argc, char *argv[]) if(!doAuthentication(splashScreen, settings, erfassung)) return -5; - ZeiterfassungApi::UserInfo userInfo; + GetUserInfoReply::UserInfo userInfo; if(!loadUserInfo(splashScreen, erfassung, userInfo)) return -6; diff --git a/zeiterfassung/translations/zeiterfassung_de.ts b/zeiterfassung/translations/zeiterfassung_de.ts index 40cbf92..9206edb 100644 --- a/zeiterfassung/translations/zeiterfassung_de.ts +++ b/zeiterfassung/translations/zeiterfassung_de.ts @@ -20,113 +20,113 @@ main - + Loading settings... Lade Einstellungen... - + Loading translations... Lade Übersetzungen... - - + + Invalid language selection! Ungültige Sprachauswahl! - + You did not select a valid language! Sie haben keine gültige Sprachauswahl getroffen! - + Loading theme... Lade Aussehen... - - - - + + + + Could not load theme! Konnte Aussehen nicht laden! - + Theme file does not exist! Aussehen-Datei existiert nicht! - + Loading login page... Lade Login-Seite... - - + + 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 mit Zeiterfassung authentifizieren! - + Getting user information... Hole Benutzer Information... - - + + Could not get user information! Konnte Benutzer Information nicht holen! - - + + Could not load plugin %0! Konnte Plugin %0 nicht laden! - - + + Plugin not valid %0! Plugin %0 nicht gültig! - + Loading strip layouts... Lade Streifenlayouts... - - - - - - - - + + + + + + + + Could not load strips! Konnte Streifenlayouts nicht laden! diff --git a/zeiterfassung/translations/zeiterfassung_en.ts b/zeiterfassung/translations/zeiterfassung_en.ts index 332fdf7..81507c1 100644 --- a/zeiterfassung/translations/zeiterfassung_en.ts +++ b/zeiterfassung/translations/zeiterfassung_en.ts @@ -20,113 +20,113 @@ main - + Loading settings... - + Loading translations... - - + + Invalid language selection! - + You did not select a valid language! - + Loading theme... - - - - + + + + Could not load theme! - + Theme file does not exist! - + Loading login page... - - + + 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! - - + + Could not load plugin %0! - - + + Plugin not valid %0! - + Loading strip layouts... - - - - - - - - + + + + + + + + Could not load strips! diff --git a/zeiterfassunglib/dialogs/aboutmedialog.cpp b/zeiterfassunglib/dialogs/aboutmedialog.cpp index 9747cb6..338a67b 100644 --- a/zeiterfassunglib/dialogs/aboutmedialog.cpp +++ b/zeiterfassunglib/dialogs/aboutmedialog.cpp @@ -1,10 +1,9 @@ #include "aboutmedialog.h" #include "ui_aboutmedialog.h" -AboutMeDialog::AboutMeDialog(const ZeiterfassungApi::UserInfo &userInfo, QWidget *parent) : +AboutMeDialog::AboutMeDialog(const GetUserInfoReply::UserInfo &userInfo, QWidget *parent) : QDialog(parent), - ui(new Ui::AboutMeDialog), - m_userInfo(userInfo) + ui(new Ui::AboutMeDialog) { ui->setupUi(this); diff --git a/zeiterfassunglib/dialogs/aboutmedialog.h b/zeiterfassunglib/dialogs/aboutmedialog.h index 2297c13..d33fbd4 100644 --- a/zeiterfassunglib/dialogs/aboutmedialog.h +++ b/zeiterfassunglib/dialogs/aboutmedialog.h @@ -4,7 +4,7 @@ #include #include "zeiterfassunglib_global.h" -#include "zeiterfassungapi.h" +#include "replies/getuserinforeply.h" namespace Ui { class AboutMeDialog; } @@ -13,12 +13,11 @@ class ZEITERFASSUNGLIBSHARED_EXPORT AboutMeDialog : public QDialog Q_OBJECT public: - explicit AboutMeDialog(const ZeiterfassungApi::UserInfo &userInfo, QWidget *parent = Q_NULLPTR); + explicit AboutMeDialog(const GetUserInfoReply::UserInfo &userInfo, QWidget *parent = Q_NULLPTR); ~AboutMeDialog(); private: Ui::AboutMeDialog *ui; - const ZeiterfassungApi::UserInfo &m_userInfo; }; #endif // ABOUTMEDIALOG_H diff --git a/zeiterfassunglib/mainwindow.cpp b/zeiterfassunglib/mainwindow.cpp index 723cd98..da35f4b 100644 --- a/zeiterfassunglib/mainwindow.cpp +++ b/zeiterfassunglib/mainwindow.cpp @@ -15,6 +15,7 @@ #include #include +#include "zeiterfassungapi.h" #include "timeutils.h" #include "zeiterfassungsettings.h" #include "stripfactory.h" @@ -36,7 +37,7 @@ #include "replies/createtimeassignmentreply.h" #include "replies/createbookingreply.h" -MainWindow::MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfassung, const ZeiterfassungApi::UserInfo &userInfo, +MainWindow::MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfassung, const GetUserInfoReply::UserInfo &userInfo, StripFactory &stripFactory, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), @@ -155,7 +156,7 @@ ZeiterfassungApi &MainWindow::erfassung() const return m_erfassung; } -const ZeiterfassungApi::UserInfo &MainWindow::userInfo() const +const GetUserInfoReply::UserInfo &MainWindow::userInfo() const { return m_userInfo; } diff --git a/zeiterfassunglib/mainwindow.h b/zeiterfassunglib/mainwindow.h index 8de3dcd..a41e9cc 100644 --- a/zeiterfassunglib/mainwindow.h +++ b/zeiterfassunglib/mainwindow.h @@ -7,7 +7,7 @@ #include #include "zeiterfassunglib_global.h" -#include "zeiterfassungapi.h" +#include "replies/getuserinforeply.h" #include "replies/getprojectsreply.h" #include "replies/getauswertungreply.h" #include "replies/getpresencestatusreply.h" @@ -27,7 +27,7 @@ class ZEITERFASSUNGLIBSHARED_EXPORT MainWindow : public QMainWindow Q_OBJECT public: - explicit MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfassung, const ZeiterfassungApi::UserInfo &userInfo, + explicit MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfassung, const GetUserInfoReply::UserInfo &userInfo, StripFactory &stripFactory, QWidget *parent = Q_NULLPTR); ~MainWindow(); @@ -38,7 +38,7 @@ public: ZeiterfassungSettings &settings() const; ZeiterfassungApi &erfassung() const; - const ZeiterfassungApi::UserInfo &userInfo() const; + const GetUserInfoReply::UserInfo &userInfo() const; StripFactory &stripFactory() const; private Q_SLOTS: @@ -63,7 +63,7 @@ private: Ui::MainWindow *ui; ZeiterfassungSettings &m_settings; ZeiterfassungApi &m_erfassung; - const ZeiterfassungApi::UserInfo &m_userInfo; + const GetUserInfoReply::UserInfo &m_userInfo; StripFactory &m_stripFactory; std::unique_ptr m_getProjectsReply; diff --git a/zeiterfassunglib/replies/getbookingsreply.cpp b/zeiterfassunglib/replies/getbookingsreply.cpp index d08704a..b7941fa 100644 --- a/zeiterfassunglib/replies/getbookingsreply.cpp +++ b/zeiterfassunglib/replies/getbookingsreply.cpp @@ -6,6 +6,8 @@ #include #include +#include "zeiterfassungapi.h" + GetBookingsReply::GetBookingsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : ZeiterfassungReply(zeiterfassung), m_reply(std::move(reply)) @@ -13,7 +15,7 @@ GetBookingsReply::GetBookingsReply(std::unique_ptr &&reply, Zeite connect(m_reply.get(), &QNetworkReply::finished, this, &GetBookingsReply::requestFinished); } -const QVector &GetBookingsReply::bookings() const +const QVector &GetBookingsReply::bookings() const { return m_bookings; } diff --git a/zeiterfassunglib/replies/getbookingsreply.h b/zeiterfassunglib/replies/getbookingsreply.h index e60c8d7..59344b9 100644 --- a/zeiterfassunglib/replies/getbookingsreply.h +++ b/zeiterfassunglib/replies/getbookingsreply.h @@ -8,7 +8,8 @@ #include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -#include "zeiterfassungapi.h" + +class ZeiterfassungApi; class ZEITERFASSUNGLIBSHARED_EXPORT GetBookingsReply : public ZeiterfassungReply { @@ -17,14 +18,24 @@ class ZEITERFASSUNGLIBSHARED_EXPORT GetBookingsReply : public ZeiterfassungReply public: GetBookingsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - const QVector &bookings() const; + struct Booking + { + int id; + QDate date; + QTime time; + QTime timespan; + QString type; + QString text; + }; + + const QVector &bookings() const; private Q_SLOTS: void requestFinished(); private: std::unique_ptr m_reply; - QVector m_bookings; + QVector m_bookings; }; #endif // GETBOOKINGSREPLY_H diff --git a/zeiterfassunglib/replies/getpresencestatusreply.cpp b/zeiterfassunglib/replies/getpresencestatusreply.cpp index de95aa3..5ee41db 100644 --- a/zeiterfassunglib/replies/getpresencestatusreply.cpp +++ b/zeiterfassunglib/replies/getpresencestatusreply.cpp @@ -6,6 +6,8 @@ #include #include +#include "zeiterfassungapi.h" + GetPresenceStatusReply::GetPresenceStatusReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : ZeiterfassungReply(zeiterfassung), m_reply(std::move(reply)) @@ -13,7 +15,7 @@ GetPresenceStatusReply::GetPresenceStatusReply(std::unique_ptr && connect(m_reply.get(), &QNetworkReply::finished, this, &GetPresenceStatusReply::requestFinished); } -const QVector &GetPresenceStatusReply::presenceStatuses() const +const QVector &GetPresenceStatusReply::presenceStatuses() const { return m_presenceStatuses; } diff --git a/zeiterfassunglib/replies/getpresencestatusreply.h b/zeiterfassunglib/replies/getpresencestatusreply.h index 730b2fb..e220379 100644 --- a/zeiterfassunglib/replies/getpresencestatusreply.h +++ b/zeiterfassunglib/replies/getpresencestatusreply.h @@ -7,7 +7,8 @@ #include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -#include "zeiterfassungapi.h" + +class ZeiterfassungApi; class ZEITERFASSUNGLIBSHARED_EXPORT GetPresenceStatusReply : public ZeiterfassungReply { @@ -16,14 +17,22 @@ class ZEITERFASSUNGLIBSHARED_EXPORT GetPresenceStatusReply : public Zeiterfassun public: explicit GetPresenceStatusReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - const QVector &presenceStatuses() const; + struct PresenceStatus + { + int userId; + QString firstName; + QString lastName; + QString presence; + }; + + const QVector &presenceStatuses() const; private Q_SLOTS: void requestFinished(); private: std::unique_ptr m_reply; - QVector m_presenceStatuses; + QVector m_presenceStatuses; }; #endif // GETPRESENCESTATUSREPLY_H diff --git a/zeiterfassunglib/replies/getprojectsreply.cpp b/zeiterfassunglib/replies/getprojectsreply.cpp index 9c18ebb..1800d10 100644 --- a/zeiterfassunglib/replies/getprojectsreply.cpp +++ b/zeiterfassunglib/replies/getprojectsreply.cpp @@ -6,6 +6,8 @@ #include #include +#include "zeiterfassungapi.h" + GetProjectsReply::GetProjectsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : ZeiterfassungReply(zeiterfassung), m_reply(std::move(reply)) @@ -13,7 +15,7 @@ GetProjectsReply::GetProjectsReply(std::unique_ptr &&reply, Zeite connect(m_reply.get(), &QNetworkReply::finished, this, &GetProjectsReply::requestFinished); } -const QVector &GetProjectsReply::projects() const +const QVector &GetProjectsReply::projects() const { return m_projects; } diff --git a/zeiterfassunglib/replies/getprojectsreply.h b/zeiterfassunglib/replies/getprojectsreply.h index 5aa5c23..576728a 100644 --- a/zeiterfassunglib/replies/getprojectsreply.h +++ b/zeiterfassunglib/replies/getprojectsreply.h @@ -8,7 +8,8 @@ #include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -#include "zeiterfassungapi.h" + +class ZeiterfassungApi; class ZEITERFASSUNGLIBSHARED_EXPORT GetProjectsReply : public ZeiterfassungReply { @@ -17,14 +18,20 @@ class ZEITERFASSUNGLIBSHARED_EXPORT GetProjectsReply : public ZeiterfassungReply public: GetProjectsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - const QVector &projects() const; + struct Project + { + QString label; + QString value; + }; + + const QVector &projects() const; private Q_SLOTS: void requestFinished(); private: std::unique_ptr m_reply; - QVector m_projects; + QVector m_projects; }; #endif // GETPROJECTSREPLY_H diff --git a/zeiterfassunglib/replies/gettimeassignmentsreply.cpp b/zeiterfassunglib/replies/gettimeassignmentsreply.cpp index 9d04093..a4b62ef 100644 --- a/zeiterfassunglib/replies/gettimeassignmentsreply.cpp +++ b/zeiterfassunglib/replies/gettimeassignmentsreply.cpp @@ -7,6 +7,8 @@ #include #include +#include "zeiterfassungapi.h" + GetTimeAssignmentsReply::GetTimeAssignmentsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : ZeiterfassungReply(zeiterfassung), m_reply(std::move(reply)) @@ -14,7 +16,7 @@ GetTimeAssignmentsReply::GetTimeAssignmentsReply(std::unique_ptr connect(m_reply.get(), &QNetworkReply::finished, this, &GetTimeAssignmentsReply::requestFinished); } -const QVector &GetTimeAssignmentsReply::timeAssignments() const +const QVector &GetTimeAssignmentsReply::timeAssignments() const { return m_timeAssignments; } diff --git a/zeiterfassunglib/replies/gettimeassignmentsreply.h b/zeiterfassunglib/replies/gettimeassignmentsreply.h index aa5355c..a335a70 100644 --- a/zeiterfassunglib/replies/gettimeassignmentsreply.h +++ b/zeiterfassunglib/replies/gettimeassignmentsreply.h @@ -8,7 +8,8 @@ #include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -#include "zeiterfassungapi.h" + +class ZeiterfassungApi; class ZEITERFASSUNGLIBSHARED_EXPORT GetTimeAssignmentsReply : public ZeiterfassungReply { @@ -17,14 +18,26 @@ class ZEITERFASSUNGLIBSHARED_EXPORT GetTimeAssignmentsReply : public Zeiterfassu public: GetTimeAssignmentsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - const QVector &timeAssignments() const; + struct TimeAssignment + { + int id; + QDate date; + QTime time; + QTime timespan; + QString text; + QString project; + QString subproject; + QString workpackage; + }; + + const QVector &timeAssignments() const; private Q_SLOTS: void requestFinished(); private: std::unique_ptr m_reply; - QVector m_timeAssignments; + QVector m_timeAssignments; }; #endif // GETTIMEASSIGNMENTSREPLY_H diff --git a/zeiterfassunglib/replies/userinforeply.cpp b/zeiterfassunglib/replies/getuserinforeply.cpp similarity index 83% rename from zeiterfassunglib/replies/userinforeply.cpp rename to zeiterfassunglib/replies/getuserinforeply.cpp index 4e45625..73d751b 100644 --- a/zeiterfassunglib/replies/userinforeply.cpp +++ b/zeiterfassunglib/replies/getuserinforeply.cpp @@ -1,23 +1,25 @@ -#include "userinforeply.h" +#include "getuserinforeply.h" #include #include #include #include -UserInfoReply::UserInfoReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : +#include "zeiterfassungapi.h" + +GetUserInfoReply::GetUserInfoReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : ZeiterfassungReply(zeiterfassung), m_reply(std::move(reply)) { - connect(m_reply.get(), &QNetworkReply::finished, this, &UserInfoReply::requestFinished); + connect(m_reply.get(), &QNetworkReply::finished, this, &GetUserInfoReply::requestFinished); } -const ZeiterfassungApi::UserInfo &UserInfoReply::userInfo() const +const GetUserInfoReply::UserInfo &GetUserInfoReply::userInfo() const { return m_userInfo; } -void UserInfoReply::requestFinished() +void GetUserInfoReply::requestFinished() { if(m_reply->error() != QNetworkReply::NoError) { diff --git a/zeiterfassunglib/replies/getuserinforeply.h b/zeiterfassunglib/replies/getuserinforeply.h new file mode 100644 index 0000000..30e2579 --- /dev/null +++ b/zeiterfassunglib/replies/getuserinforeply.h @@ -0,0 +1,39 @@ +#ifndef GETUSERINFOREPLY_H +#define GETUSERINFOREPLY_H + +#include + +#include + +#include "zeiterfassunglib_global.h" +#include "zeiterfassungreply.h" + +class ZeiterfassungApi; + +class ZEITERFASSUNGLIBSHARED_EXPORT GetUserInfoReply : public ZeiterfassungReply +{ + Q_OBJECT + +public: + GetUserInfoReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + + struct UserInfo + { + int userId; + QString email; + QString longUsername; + QString text; + QString username; + }; + + const UserInfo &userInfo() const; + +private Q_SLOTS: + void requestFinished(); + +private: + std::unique_ptr m_reply; + UserInfo m_userInfo; +}; + +#endif // GETUSERINFOREPLY_H diff --git a/zeiterfassunglib/replies/userinforeply.h b/zeiterfassunglib/replies/userinforeply.h deleted file mode 100644 index 3b7fc09..0000000 --- a/zeiterfassunglib/replies/userinforeply.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef USERINFOREPLY_H -#define USERINFOREPLY_H - -#include - -#include - -#include "zeiterfassunglib_global.h" -#include "zeiterfassungreply.h" -#include "zeiterfassungapi.h" - -class ZEITERFASSUNGLIBSHARED_EXPORT UserInfoReply : public ZeiterfassungReply -{ - Q_OBJECT - -public: - UserInfoReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - - const ZeiterfassungApi::UserInfo &userInfo() const; - -private Q_SLOTS: - void requestFinished(); - -private: - std::unique_ptr m_reply; - ZeiterfassungApi::UserInfo m_userInfo; -}; - -#endif // USERINFOREPLY_H diff --git a/zeiterfassunglib/stripswidget.cpp b/zeiterfassunglib/stripswidget.cpp index 150a711..6b00f52 100644 --- a/zeiterfassunglib/stripswidget.cpp +++ b/zeiterfassunglib/stripswidget.cpp @@ -7,6 +7,7 @@ #include #include +#include "zeiterfassungapi.h" #include "timeutils.h" #include "stripfactory.h" @@ -40,12 +41,12 @@ void StripsWidget::setDate(const QDate &date) refresh(); } -const QVector &StripsWidget::bookings() const +const QVector &StripsWidget::bookings() const { return m_bookings; } -const QVector &StripsWidget::timeAssignments() const +const QVector &StripsWidget::timeAssignments() const { return m_timeAssignments; } @@ -167,7 +168,7 @@ bool StripsWidget::createStrips() auto bookingTimespan = QTime(0, 0); - const ZeiterfassungApi::Booking *lastBooking = Q_NULLPTR; + const GetBookingsReply::Booking *lastBooking = Q_NULLPTR; QString errorMessage; diff --git a/zeiterfassunglib/stripswidget.h b/zeiterfassunglib/stripswidget.h index 90614d2..8995538 100644 --- a/zeiterfassunglib/stripswidget.h +++ b/zeiterfassunglib/stripswidget.h @@ -7,7 +7,6 @@ #include #include "zeiterfassunglib_global.h" -#include "zeiterfassungapi.h" #include "replies/getbookingsreply.h" #include "replies/gettimeassignmentsreply.h" @@ -15,6 +14,7 @@ class QBoxLayout; template class QMap; template class QVector; +class ZeiterfassungApi; class StripFactory; class ZEITERFASSUNGLIBSHARED_EXPORT StripsWidget : public QWidget @@ -28,8 +28,8 @@ public: const QDate &date() const; void setDate(const QDate &date); - const QVector &bookings() const; - const QVector &timeAssignments() const; + const QVector &bookings() const; + const QVector &timeAssignments() const; const QTime &timeAssignmentTime() const; const QTime &lastTimeAssignmentStart() const; @@ -47,8 +47,8 @@ public: void clearStrips(); Q_SIGNALS: - void bookingsChanged(const QVector &bookings); - void timeAssignmentsChanged(const QVector &timeAssignments); + void bookingsChanged(const QVector &bookings); + void timeAssignmentsChanged(const QVector &timeAssignments); void timeAssignmentTimeChanged(const QTime &timeAssignmentTime); void lastTimeAssignmentStartChanged(const QTime &lastTimeAssignmentStart); @@ -82,8 +82,8 @@ private: QDate m_date; - QVector m_bookings; - QVector m_timeAssignments; + QVector m_bookings; + QVector m_timeAssignments; QTime m_timeAssignmentTime; QTime m_lastTimeAssignmentStart; diff --git a/zeiterfassunglib/translations/zeiterfassunglib_de.ts b/zeiterfassunglib/translations/zeiterfassunglib_de.ts index 7beaec5..db4389c 100644 --- a/zeiterfassunglib/translations/zeiterfassunglib_de.ts +++ b/zeiterfassunglib/translations/zeiterfassunglib_de.ts @@ -185,17 +185,17 @@ GetBookingsReply - + Request error occured: %0 - + Parsing JSON failed: %0 - + JSON document is not an array! @@ -203,17 +203,17 @@ GetPresenceStatusReply - + Request error occured: %0 - + Parsing JSON failed: %0 - + JSON document is not an array! @@ -221,27 +221,27 @@ GetProjectsReply - + Request error occured: %0 - + Parsing JSON failed: %0 - + JSON document is not an object! - + JSON does not contain elements! - + elements is not an array! @@ -249,21 +249,49 @@ GetTimeAssignmentsReply - + Request error occured: %0 - + Parsing JSON failed: %0 - + JSON document is not an array! + + GetUserInfoReply + + + Request error occured: %0 + + + + + Parsing JSON failed: %0 + + + + + JSON document is not an object! + + + + + JSON does not contain evoAppsUser! + + + + + evoAppsUser is not an object! + + + LanguageSelectionDialog @@ -348,8 +376,8 @@ - - + + Start Kommen @@ -449,13 +477,13 @@ Zeiterfassung - %0 (%1) - - + + Could not open auswertung! - + Could not open default PDF viewer! Konnte den PDF-Anzeiger nicht öffnen! @@ -475,149 +503,147 @@ Text - - + + + - %0: %1 %0: %1 - - + - ??? ??? - - + + Balance Saldo - - + + Holidays Urlaubstage - - + + Could not load bookings! Konnte Buchungen nicht laden! - + Could not load Auswertung! - + %0h %0h - + Could not delete booking! Konnte Buchung nicht löschen! - + Edit booking Buchung bearbeiten - + Delete booking Buchung löschen - + Could not edit booking! Konnte Buchung nicht bearbeiten! - + Create booking Buchung erstellen - - + + n/a n/v - + Refresh bookings Buchungen aktualisieren - - - + + + Could not create booking! Konnte Buchung nicht erstellen! - + Do you really want to delete the booking? Möchten Sie die Buchung wirklich löschen? - + Refresh time assignments Kontierungen aktualisieren - + Edit time assignment Kontierung bearbeiten - + Delete time assignment Kontierung löschen - - - + + + Could not edit time assignment! Konnte Kontierung nicht bearbeiten! - + Do you really want to delete the time assignment? Möchten Sie die Kontierung wirklich löschen? - + Could not delete time assignment! Konnte Kontierung nicht löschen! - - + + %0 (%1) %0 (%1) - + Create time assignment Kontierung erstellen - - + + Could not create time assignment! Konnte Kontierung nicht erstellen! - - + + Switch Wechseln @@ -702,178 +728,178 @@ StripsWidget - + Loading... Lade... - + Missing booking! Kontierung fehlend! - + Expected start booking, instead got type %0 Booking ID: %1 - - + + %0: %1 %0: %1 - + Break Pause - - - + + + %0h %0h - - - - - + + + + + HH:mm HH:mm - + Missing time assignment! Kontierung fehlend! - - - + + + Expected %0 but received %1 in time assignment. Time assignment ID: %2 - - + - - + + - + + HH:mm:ss HH:mm:ss - - + + 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 - + The last time assignment is finished without end booking Time assignment ID: %0 - + Expected end booking, instead got type %0 Booking ID: %1 - + Missing time assignment! Missing: %0 Kontierung fehlend! %0 nicht kontiert - + Assigned time Kontierte Zeit - + dd.MM.yyyy dd.MM.yyyy - + %0 (%1) %0 (%1) - + Time assignment time longer than booking time! Time assignment: %0 Booking: %1 - + Strip rendering aborted due error. Your bookings and time assignments for this day are in an illegal state! - + Monday Montag - + Tuesday Dienstag - + Wednesday Mittwoch - + Thursday Donnerstag - + Friday Freitag - + Saturday Samstag - + Sunday Sonntag - + Invalid Ungültig - + Open Offen @@ -1031,32 +1057,4 @@ Your bookings and time assignments for this day are in an illegal state! - - UserInfoReply - - - Request error occured: %0 - - - - - Parsing JSON failed: %0 - - - - - JSON document is not an object! - - - - - JSON does not contain evoAppsUser! - - - - - evoAppsUser is not an object! - - - diff --git a/zeiterfassunglib/translations/zeiterfassunglib_en.ts b/zeiterfassunglib/translations/zeiterfassunglib_en.ts index b8bbd95..7fb33eb 100644 --- a/zeiterfassunglib/translations/zeiterfassunglib_en.ts +++ b/zeiterfassunglib/translations/zeiterfassunglib_en.ts @@ -185,17 +185,17 @@ GetBookingsReply - + Request error occured: %0 - + Parsing JSON failed: %0 - + JSON document is not an array! @@ -203,17 +203,17 @@ GetPresenceStatusReply - + Request error occured: %0 - + Parsing JSON failed: %0 - + JSON document is not an array! @@ -221,27 +221,27 @@ GetProjectsReply - + Request error occured: %0 - + Parsing JSON failed: %0 - + JSON document is not an object! - + JSON does not contain elements! - + elements is not an array! @@ -249,21 +249,49 @@ GetTimeAssignmentsReply - + Request error occured: %0 - + Parsing JSON failed: %0 - + JSON document is not an array! + + GetUserInfoReply + + + Request error occured: %0 + + + + + Parsing JSON failed: %0 + + + + + JSON document is not an object! + + + + + JSON does not contain evoAppsUser! + + + + + evoAppsUser is not an object! + + + LanguageSelectionDialog @@ -348,8 +376,8 @@ - - + + Start @@ -464,160 +492,158 @@ - - + - ??? - - + + Could not load bookings! - + Could not load Auswertung! - - + + n/a - + %0h - - + + + - %0: %1 - - + + Balance - - + + Holidays - + Create booking - + Refresh bookings - - - + + + Could not create booking! - + Edit booking - + Delete booking - + Could not edit booking! - + Do you really want to delete the booking? - + Could not delete booking! - + Create time assignment - + Refresh time assignments - - + + Could not create time assignment! - + Edit time assignment - + Delete time assignment - - - + + + Could not edit time assignment! - + Do you really want to delete the time assignment? - + Could not delete time assignment! - - + + Could not open auswertung! - + Could not open default PDF viewer! - - + + Switch - - + + %0 (%1) @@ -702,178 +728,178 @@ StripsWidget - + Loading... - + Missing booking! - + Expected start booking, instead got type %0 Booking ID: %1 - - + + %0: %1 - + Break - - - + + + %0h - - - - - + + + + + HH:mm - + Missing time assignment! - - - + + + Expected %0 but received %1 in time assignment. Time assignment ID: %2 - - + - - + + - + + HH:mm:ss - - + + 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 - + The last time assignment is finished without end booking Time assignment ID: %0 - + Expected end booking, instead got type %0 Booking ID: %1 - + Missing time assignment! Missing: %0 - + Time assignment time longer than booking time! Time assignment: %0 Booking: %1 - + Assigned time - + Strip rendering aborted due error. Your bookings and time assignments for this day are in an illegal state! - + %0 (%1) - + Monday - + Tuesday - + Wednesday - + Thursday - + Friday - + Saturday - + Sunday - + dd.MM.yyyy - + Invalid - + Open @@ -1031,32 +1057,4 @@ Your bookings and time assignments for this day are in an illegal state! - - UserInfoReply - - - Request error occured: %0 - - - - - Parsing JSON failed: %0 - - - - - JSON document is not an object! - - - - - JSON does not contain evoAppsUser! - - - - - evoAppsUser is not an object! - - - diff --git a/zeiterfassunglib/zeiterfassungapi.cpp b/zeiterfassunglib/zeiterfassungapi.cpp index d723091..84bebfa 100644 --- a/zeiterfassunglib/zeiterfassungapi.cpp +++ b/zeiterfassunglib/zeiterfassungapi.cpp @@ -22,7 +22,7 @@ #include "replies/loginreply.h" #include "replies/updatebookingreply.h" #include "replies/updatetimeassignmentreply.h" -#include "replies/userinforeply.h" +#include "replies/getuserinforeply.h" //add support for pre cpp14 compilers #include "cpp14polyfills.h" @@ -55,6 +55,8 @@ std::unique_ptr ZeiterfassungApi::doLoginPage() auto reply = std::unique_ptr(m_manager->get(request)); + qDebug() << reply->parent(); + return std::make_unique(std::move(reply), this); } @@ -71,14 +73,14 @@ std::unique_ptr ZeiterfassungApi::doLogin(const QString &username, c return std::make_unique(std::move(reply), this); } -std::unique_ptr ZeiterfassungApi::doUserInfo() +std::unique_ptr ZeiterfassungApi::doUserInfo() { QNetworkRequest request(QUrl(m_url % "json/evoAppsUserInfoDialogController/load-EvoAppsUserInfoTO")); request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("home")); auto reply = std::unique_ptr(m_manager->get(request)); - return std::make_unique(std::move(reply), this); + return std::make_unique(std::move(reply), this); } std::unique_ptr ZeiterfassungApi::doGetBookings(int userId, const QDate &start, const QDate &end) diff --git a/zeiterfassunglib/zeiterfassungapi.h b/zeiterfassunglib/zeiterfassungapi.h index 19e04e2..ff1f3b7 100644 --- a/zeiterfassunglib/zeiterfassungapi.h +++ b/zeiterfassunglib/zeiterfassungapi.h @@ -14,7 +14,7 @@ class QNetworkAccessManager; class LoginPageReply; class LoginReply; -class UserInfoReply; +class GetUserInfoReply; class GetBookingsReply; class CreateBookingReply; class UpdateBookingReply; @@ -39,54 +39,9 @@ public: QNetworkAccessManager *manager() const; - struct UserInfo - { - int userId; - QString email; - QString longUsername; - QString text; - QString username; - }; - - struct Booking - { - int id; - QDate date; - QTime time; - QTime timespan; - QString type; - QString text; - }; - - struct TimeAssignment - { - int id; - QDate date; - QTime time; - QTime timespan; - QString text; - QString project; - QString subproject; - QString workpackage; - }; - - struct Project - { - QString label; - QString value; - }; - - struct PresenceStatus - { - int userId; - QString firstName; - QString lastName; - QString presence; - }; - std::unique_ptr doLoginPage(); std::unique_ptr doLogin(const QString &username, const QString &password); - std::unique_ptr doUserInfo(); + std::unique_ptr doUserInfo(); std::unique_ptr doGetBookings(int userId, const QDate &start, const QDate &end); std::unique_ptr doCreateBooking(int userId, const QDate &date, const QTime &time, const QTime ×pan, diff --git a/zeiterfassunglib/zeiterfassunglib.pro b/zeiterfassunglib/zeiterfassunglib.pro index 4e5ce59..4b10025 100644 --- a/zeiterfassunglib/zeiterfassunglib.pro +++ b/zeiterfassunglib/zeiterfassunglib.pro @@ -39,8 +39,8 @@ SOURCES += mainwindow.cpp \ replies/loginreply.cpp \ replies/updatebookingreply.cpp \ replies/updatetimeassignmentreply.cpp \ - replies/userinforeply.cpp \ - replies/zeiterfassungreply.cpp + replies/zeiterfassungreply.cpp \ + replies/getuserinforeply.cpp HEADERS += cpp14polyfills.h \ mainwindow.h \ @@ -73,8 +73,8 @@ HEADERS += cpp14polyfills.h \ replies/loginreply.h \ replies/updatebookingreply.h \ replies/updatetimeassignmentreply.h \ - replies/userinforeply.h \ - replies/zeiterfassungreply.h + replies/zeiterfassungreply.h \ + replies/getuserinforeply.h FORMS += mainwindow.ui \ dialogs/updatedialog.ui \