Moved report functionality into plugin
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "mainwindow.h"
|
|
||||||
#include "presencewidget.h"
|
#include "presencewidget.h"
|
||||||
|
|
||||||
PresencePlugin::PresencePlugin(QObject *parent) :
|
PresencePlugin::PresencePlugin(QObject *parent) :
|
||||||
|
@@ -13,6 +13,7 @@ class MainWindow;
|
|||||||
class PresenceWidget : public QWidget
|
class PresenceWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PresenceWidget(MainWindow &mainWindow);
|
explicit PresenceWidget(MainWindow &mainWindow);
|
||||||
|
|
||||||
|
BIN
plugins/reportsplugin/images/refresh.png
Normal file
BIN
plugins/reportsplugin/images/refresh.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "reportswidget.h"
|
||||||
|
|
||||||
ReportsPlugin::ReportsPlugin(QObject *parent) :
|
ReportsPlugin::ReportsPlugin(QObject *parent) :
|
||||||
ZeiterfassungPlugin(parent)
|
ZeiterfassungPlugin(parent)
|
||||||
{
|
{
|
||||||
@@ -10,4 +12,5 @@ ReportsPlugin::ReportsPlugin(QObject *parent) :
|
|||||||
|
|
||||||
void ReportsPlugin::attachTo(MainWindow &mainWindow)
|
void ReportsPlugin::attachTo(MainWindow &mainWindow)
|
||||||
{
|
{
|
||||||
|
new ReportsWidget(mainWindow);
|
||||||
}
|
}
|
||||||
|
@@ -14,13 +14,15 @@ DEPENDPATH += $$PWD/../../zeiterfassunglib
|
|||||||
|
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT
|
DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT
|
||||||
|
|
||||||
HEADERS += reportsplugin.h
|
HEADERS += reportsplugin.h \
|
||||||
|
reportswidget.h
|
||||||
|
|
||||||
SOURCES += reportsplugin.cpp
|
SOURCES += reportsplugin.cpp \
|
||||||
|
reportswidget.cpp
|
||||||
|
|
||||||
FORMS +=
|
FORMS +=
|
||||||
|
|
||||||
RESOURCES +=
|
RESOURCES += reportsplugin_resources.qrc
|
||||||
|
|
||||||
TRANSLATIONS +=
|
TRANSLATIONS +=
|
||||||
|
|
||||||
|
6
plugins/reportsplugin/reportsplugin_resources.qrc
Normal file
6
plugins/reportsplugin/reportsplugin_resources.qrc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/zeiterfassung/plugins/reportsplugin">
|
||||||
|
<file>images/refresh.png</file>
|
||||||
|
<file>images/report.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
145
plugins/reportsplugin/reportswidget.cpp
Normal file
145
plugins/reportsplugin/reportswidget.cpp
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
#include "reportswidget.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QStatusBar>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QToolBar>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QStringBuilder>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QTemporaryFile>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "zeiterfassungapi.h"
|
||||||
|
|
||||||
|
ReportsWidget::ReportsWidget(MainWindow &mainWindow) :
|
||||||
|
QWidget(&mainWindow),
|
||||||
|
m_mainWindow(mainWindow)
|
||||||
|
{
|
||||||
|
m_labelBalance = new QLabel(this);
|
||||||
|
m_labelBalance->setFrameShape(QFrame::Panel);
|
||||||
|
m_labelBalance->setFrameShadow(QFrame::Sunken);
|
||||||
|
m_mainWindow.statusBar()->addPermanentWidget(m_labelBalance);
|
||||||
|
|
||||||
|
m_labelHolidays = new QLabel(this);
|
||||||
|
m_labelHolidays->setFrameShape(QFrame::Panel);
|
||||||
|
m_labelHolidays->setFrameShadow(QFrame::Sunken);
|
||||||
|
m_mainWindow.statusBar()->addPermanentWidget(m_labelHolidays);
|
||||||
|
|
||||||
|
m_actionRefreshReport = m_mainWindow.menuView()->addAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/reportsplugin/images/refresh.png")),
|
||||||
|
tr("Refresh report"), this, &ReportsWidget::refresh);
|
||||||
|
|
||||||
|
m_actionOpenReport = m_mainWindow.menuTools()->addAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/reportsplugin/images/report.png")),
|
||||||
|
tr("Open report"), this, &ReportsWidget::openReport);
|
||||||
|
m_mainWindow.toolBar()->addAction(m_actionOpenReport);
|
||||||
|
|
||||||
|
dateChanged(m_mainWindow.date());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReportsWidget::dateChanged(const QDate &date)
|
||||||
|
{
|
||||||
|
if(!date.isValid())
|
||||||
|
{
|
||||||
|
qWarning() << "invalid date" << date;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto monthBegin = QDate(date.year(), date.month(), 1);
|
||||||
|
if(monthBegin != m_date)
|
||||||
|
{
|
||||||
|
m_date = monthBegin;
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReportsWidget::refresh()
|
||||||
|
{
|
||||||
|
if(!m_date.isValid())
|
||||||
|
{
|
||||||
|
qWarning() << "invalid date" << m_date;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_actionRefreshReport->setEnabled(false);
|
||||||
|
m_actionOpenReport->setEnabled(false);
|
||||||
|
|
||||||
|
m_labelBalance->setText(tr("%0: %1").arg(tr("Balance")).arg(tr("???")));
|
||||||
|
m_labelHolidays->setText(tr("%0: %1").arg(tr("Holidays")).arg(tr("???")));
|
||||||
|
|
||||||
|
m_reply = m_mainWindow.erfassung().doGetAuswertung(m_mainWindow.userInfo().userId, m_date);
|
||||||
|
connect(m_reply.get(), &ZeiterfassungReply::finished, this, &ReportsWidget::finished);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReportsWidget::finished()
|
||||||
|
{
|
||||||
|
if(!m_reply->success())
|
||||||
|
{
|
||||||
|
m_date = QDate();
|
||||||
|
QMessageBox::warning(this, tr("Could not load report!"), tr("Could not load report!") % "\n\n" % m_reply->message());
|
||||||
|
goto after;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto content = m_reply->auswertung();
|
||||||
|
|
||||||
|
{
|
||||||
|
static QRegularExpression regex(QStringLiteral("Gleitzeit +([0-9]+\\:[0-9]+\\-?) +([0-9]+\\:[0-9]+\\-?)"));
|
||||||
|
auto match = regex.match(content);
|
||||||
|
if(match.hasMatch())
|
||||||
|
{
|
||||||
|
auto balance = match.captured(2);
|
||||||
|
if(balance.endsWith(QChar('-')))
|
||||||
|
{
|
||||||
|
balance.chop(1);
|
||||||
|
balance = QChar('-') % balance;
|
||||||
|
}
|
||||||
|
m_labelBalance->setText(tr("%0: %1").arg(tr("Balance")).arg(tr("%0h").arg(balance)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_labelBalance->setText(tr("%0: %1").arg(tr("Balance")).arg(tr("n/a")));
|
||||||
|
qWarning() << "balance not found in PDF";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
static QRegularExpression regex(QStringLiteral("Urlaubsanspruch +([0-9]+\\.[0-9]+\\-?) +([0-9]+\\.[0-9]+\\-?)"));
|
||||||
|
auto match = regex.match(content);
|
||||||
|
if(match.hasMatch())
|
||||||
|
m_labelHolidays->setText(tr("%0: %1").arg(tr("Holidays")).arg(match.captured(2)));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_labelHolidays->setText(tr("%0: %1").arg(tr("Holidays")).arg(tr("n/a")));
|
||||||
|
qWarning() << "holidays not found in PDF";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
QTemporaryFile file(QDir::temp().absoluteFilePath(QStringLiteral("auswertungXXXXXX.pdf")));
|
||||||
|
file.setAutoRemove(false);
|
||||||
|
if(!file.open())
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, tr("Could not write report!"), tr("Could not write report!") % "\n\n" % file.errorString());
|
||||||
|
goto after;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.write(content);
|
||||||
|
|
||||||
|
m_url = QUrl::fromLocalFile(file.fileName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_actionOpenReport->setEnabled(true);
|
||||||
|
|
||||||
|
after:
|
||||||
|
m_actionRefreshReport->setEnabled(true);
|
||||||
|
m_reply = Q_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReportsWidget::openReport()
|
||||||
|
{
|
||||||
|
if(!QDesktopServices::openUrl(m_url))
|
||||||
|
QMessageBox::warning(this, tr("Could not launch your default PDF viewer!"), tr("Could not launch your default PDF viewer!"));
|
||||||
|
}
|
43
plugins/reportsplugin/reportswidget.h
Normal file
43
plugins/reportsplugin/reportswidget.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#ifndef REPORTSWIDGET_H
|
||||||
|
#define REPORTSWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QDate>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include "replies/getauswertungreply.h"
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
class QAction;
|
||||||
|
|
||||||
|
class MainWindow;
|
||||||
|
|
||||||
|
class ReportsWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ReportsWidget(MainWindow &mainWindow);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void dateChanged(const QDate &date);
|
||||||
|
void refresh();
|
||||||
|
void finished();
|
||||||
|
void openReport();
|
||||||
|
|
||||||
|
private:
|
||||||
|
MainWindow &m_mainWindow;
|
||||||
|
|
||||||
|
QLabel *m_labelBalance;
|
||||||
|
QLabel *m_labelHolidays;
|
||||||
|
|
||||||
|
QAction *m_actionOpenReport;
|
||||||
|
QAction *m_actionRefreshReport;
|
||||||
|
|
||||||
|
QDate m_date;
|
||||||
|
QUrl m_url;
|
||||||
|
|
||||||
|
std::unique_ptr<GetAuswertungReply> m_reply;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // REPORTSWIDGET_H
|
@@ -22,7 +22,6 @@
|
|||||||
#include "dialogs/aboutmedialog.h"
|
#include "dialogs/aboutmedialog.h"
|
||||||
#include "dialogs/settingsdialog.h"
|
#include "dialogs/settingsdialog.h"
|
||||||
#include "replies/getprojectsreply.h"
|
#include "replies/getprojectsreply.h"
|
||||||
#include "replies/getauswertungreply.h"
|
|
||||||
#include "replies/createbookingreply.h"
|
#include "replies/createbookingreply.h"
|
||||||
#include "replies/createtimeassignmentreply.h"
|
#include "replies/createtimeassignmentreply.h"
|
||||||
#include "replies/updatetimeassignmentreply.h"
|
#include "replies/updatetimeassignmentreply.h"
|
||||||
@@ -35,8 +34,6 @@ MainWindow::MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfass
|
|||||||
m_erfassung(erfassung),
|
m_erfassung(erfassung),
|
||||||
m_userInfo(userInfo),
|
m_userInfo(userInfo),
|
||||||
m_stripFactory(stripFactory),
|
m_stripFactory(stripFactory),
|
||||||
m_getProjectsReply(Q_NULLPTR),
|
|
||||||
m_getAuswertungReply(Q_NULLPTR),
|
|
||||||
m_currentStripWidget(Q_NULLPTR)
|
m_currentStripWidget(Q_NULLPTR)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@@ -57,8 +54,6 @@ MainWindow::MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfass
|
|||||||
ui->actionRefresh->setShortcut(QKeySequence::Refresh);
|
ui->actionRefresh->setShortcut(QKeySequence::Refresh);
|
||||||
connect(ui->actionRefresh, &QAction::triggered, this, [=](){ dateChanged(true); });
|
connect(ui->actionRefresh, &QAction::triggered, this, [=](){ dateChanged(true); });
|
||||||
|
|
||||||
connect(ui->actionAuswertung, &QAction::triggered, this, &MainWindow::openAuswertung);
|
|
||||||
|
|
||||||
connect(ui->actionAboutMe, &QAction::triggered, [=](){ AboutMeDialog(userInfo, this).exec(); });
|
connect(ui->actionAboutMe, &QAction::triggered, [=](){ AboutMeDialog(userInfo, this).exec(); });
|
||||||
connect(ui->actionSettings, &QAction::triggered, [=](){ SettingsDialog(m_settings, this).exec(); });
|
connect(ui->actionSettings, &QAction::triggered, [=](){ SettingsDialog(m_settings, this).exec(); });
|
||||||
|
|
||||||
@@ -88,13 +83,6 @@ MainWindow::MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfass
|
|||||||
connect(ui->pushButtonStart, &QAbstractButton::pressed, this, &MainWindow::pushButtonStartPressed);
|
connect(ui->pushButtonStart, &QAbstractButton::pressed, this, &MainWindow::pushButtonStartPressed);
|
||||||
connect(ui->pushButtonEnd, &QAbstractButton::pressed, this, &MainWindow::pushButtonEndPressed);
|
connect(ui->pushButtonEnd, &QAbstractButton::pressed, this, &MainWindow::pushButtonEndPressed);
|
||||||
|
|
||||||
ui->statusbar->addPermanentWidget(m_balanceLabel = new QLabel(ui->statusbar));
|
|
||||||
m_balanceLabel->setFrameShape(QFrame::Panel);
|
|
||||||
m_balanceLabel->setFrameShadow(QFrame::Sunken);
|
|
||||||
ui->statusbar->addPermanentWidget(m_holidaysLabel = new QLabel(ui->statusbar));
|
|
||||||
m_holidaysLabel->setFrameShape(QFrame::Panel);
|
|
||||||
m_holidaysLabel->setFrameShadow(QFrame::Sunken);
|
|
||||||
|
|
||||||
dateChanged();
|
dateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,6 +111,11 @@ QMenu *MainWindow::menuAbout() const
|
|||||||
return ui->menuAbout;
|
return ui->menuAbout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QToolBar *MainWindow::toolBar() const
|
||||||
|
{
|
||||||
|
return ui->mainToolBar;
|
||||||
|
}
|
||||||
|
|
||||||
ZeiterfassungSettings &MainWindow::settings() const
|
ZeiterfassungSettings &MainWindow::settings() const
|
||||||
{
|
{
|
||||||
return m_settings;
|
return m_settings;
|
||||||
@@ -143,6 +136,11 @@ StripFactory &MainWindow::stripFactory() const
|
|||||||
return m_stripFactory;
|
return m_stripFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDate MainWindow::date() const
|
||||||
|
{
|
||||||
|
return ui->dateEditDate->date();
|
||||||
|
}
|
||||||
|
|
||||||
const QMap<QString, QString> &MainWindow::projects() const
|
const QMap<QString, QString> &MainWindow::projects() const
|
||||||
{
|
{
|
||||||
return m_projects;
|
return m_projects;
|
||||||
@@ -171,66 +169,6 @@ void MainWindow::getProjectsFinished()
|
|||||||
m_getProjectsReply = Q_NULLPTR;
|
m_getProjectsReply = Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::getAuswertungFinished()
|
|
||||||
{
|
|
||||||
if(std::none_of(std::begin(m_stripsWidgets), std::end(m_stripsWidgets), [](StripsWidget *stripsWidget){
|
|
||||||
return stripsWidget->refreshing();
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
ui->actionToday->setEnabled(true);
|
|
||||||
ui->actionRefresh->setEnabled(true);
|
|
||||||
ui->dateEditDate->setReadOnly(false);
|
|
||||||
ui->pushButtonPrev->setEnabled(true);
|
|
||||||
ui->pushButtonNext->setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!m_getAuswertungReply->success())
|
|
||||||
{
|
|
||||||
m_auswertungDate = QDate();
|
|
||||||
QMessageBox::warning(this, tr("Could not load Auswertung!"), tr("Could not load Auswertung!") % "\n\n" % m_getAuswertungReply->message());
|
|
||||||
m_getAuswertungReply = Q_NULLPTR;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->actionAuswertung->setEnabled(true);
|
|
||||||
m_auswertung = m_getAuswertungReply->auswertung();
|
|
||||||
|
|
||||||
auto urlaubsAnspruch = tr("n/a");
|
|
||||||
|
|
||||||
{
|
|
||||||
static QRegularExpression regex(QStringLiteral("Urlaubsanspruch +([0-9]+\\.[0-9]+\\-?) +([0-9]+\\.[0-9]+\\-?)"));
|
|
||||||
auto match = regex.match(m_auswertung);
|
|
||||||
if(match.hasMatch())
|
|
||||||
urlaubsAnspruch = match.captured(2);
|
|
||||||
else
|
|
||||||
qWarning() << "Urlaubsanspruch not found";
|
|
||||||
}
|
|
||||||
|
|
||||||
auto gleitzeit = tr("n/a");
|
|
||||||
|
|
||||||
{
|
|
||||||
static QRegularExpression regex(QStringLiteral("Gleitzeit +([0-9]+\\:[0-9]+\\-?) +([0-9]+\\:[0-9]+\\-?)"));
|
|
||||||
auto match = regex.match(m_auswertung);
|
|
||||||
if(match.hasMatch())
|
|
||||||
{
|
|
||||||
gleitzeit = match.captured(2);
|
|
||||||
if(gleitzeit.endsWith(QChar('-')))
|
|
||||||
{
|
|
||||||
gleitzeit.chop(1);
|
|
||||||
gleitzeit = QChar('-') % gleitzeit;
|
|
||||||
}
|
|
||||||
gleitzeit = tr("%0h").arg(gleitzeit);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
qWarning() << "Gleitzeit not found";
|
|
||||||
}
|
|
||||||
|
|
||||||
m_balanceLabel->setText(tr("%0: %1").arg(tr("Balance")).arg(gleitzeit));
|
|
||||||
m_holidaysLabel->setText(tr("%0: %1").arg(tr("Holidays")).arg(urlaubsAnspruch));
|
|
||||||
|
|
||||||
m_getAuswertungReply = Q_NULLPTR;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::pushButtonStartPressed()
|
void MainWindow::pushButtonStartPressed()
|
||||||
{
|
{
|
||||||
auto bookingsChanged = false;
|
auto bookingsChanged = false;
|
||||||
@@ -307,8 +245,7 @@ void MainWindow::pushButtonStartPressed()
|
|||||||
if(bookingsChanged)
|
if(bookingsChanged)
|
||||||
{
|
{
|
||||||
m_currentStripWidget->refresh();
|
m_currentStripWidget->refresh();
|
||||||
|
//refreshAuswertung();
|
||||||
refreshAuswertung();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_currentStripWidget->refreshTimeAssignments();
|
m_currentStripWidget->refreshTimeAssignments();
|
||||||
@@ -359,7 +296,7 @@ void MainWindow::pushButtonEndPressed()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_currentStripWidget->refresh();
|
m_currentStripWidget->refresh();
|
||||||
refreshAuswertung();
|
//refreshAuswertung();
|
||||||
|
|
||||||
ui->actionToday->setEnabled(false);
|
ui->actionToday->setEnabled(false);
|
||||||
ui->actionRefresh->setEnabled(false);
|
ui->actionRefresh->setEnabled(false);
|
||||||
@@ -400,12 +337,9 @@ void MainWindow::dateChanged(bool force)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(force || m_auswertungDate != QDate(ui->dateEditDate->date().year(), ui->dateEditDate->date().month(), 1))
|
|
||||||
refreshAuswertung();
|
|
||||||
|
|
||||||
if(std::any_of(std::begin(m_stripsWidgets), std::end(m_stripsWidgets), [](StripsWidget *stripsWidget) {
|
if(std::any_of(std::begin(m_stripsWidgets), std::end(m_stripsWidgets), [](StripsWidget *stripsWidget) {
|
||||||
return stripsWidget->refreshing();
|
return stripsWidget->refreshing();
|
||||||
}) || m_getAuswertungReply)
|
}))
|
||||||
{
|
{
|
||||||
ui->actionToday->setEnabled(false);
|
ui->actionToday->setEnabled(false);
|
||||||
ui->actionRefresh->setEnabled(false);
|
ui->actionRefresh->setEnabled(false);
|
||||||
@@ -415,26 +349,6 @@ void MainWindow::dateChanged(bool force)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::openAuswertung()
|
|
||||||
{
|
|
||||||
QTemporaryFile file(QDir::temp().absoluteFilePath(QStringLiteral("auswertungXXXXXX.pdf")));
|
|
||||||
file.setAutoRemove(false);
|
|
||||||
if(!file.open())
|
|
||||||
{
|
|
||||||
QMessageBox::warning(this, tr("Could not open auswertung!"), tr("Could not open auswertung!") % "\n\n" % file.errorString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
file.write(m_auswertung);
|
|
||||||
file.close();
|
|
||||||
|
|
||||||
if(!QDesktopServices::openUrl(QUrl::fromLocalFile(file.fileName())))
|
|
||||||
{
|
|
||||||
QMessageBox::warning(this, tr("Could not open auswertung!"), tr("Could not open default PDF viewer!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::minimumTimeChanged()
|
void MainWindow::minimumTimeChanged()
|
||||||
{
|
{
|
||||||
ui->timeEditTime->setMinimumTime(m_currentStripWidget->minimumTime());
|
ui->timeEditTime->setMinimumTime(m_currentStripWidget->minimumTime());
|
||||||
@@ -442,9 +356,6 @@ void MainWindow::minimumTimeChanged()
|
|||||||
|
|
||||||
void MainWindow::refreshingChanged()
|
void MainWindow::refreshingChanged()
|
||||||
{
|
{
|
||||||
if(m_getAuswertungReply)
|
|
||||||
return;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto allFinished = std::none_of(std::begin(m_stripsWidgets), std::end(m_stripsWidgets), [](StripsWidget *stripsWidget){
|
auto allFinished = std::none_of(std::begin(m_stripsWidgets), std::end(m_stripsWidgets), [](StripsWidget *stripsWidget){
|
||||||
return stripsWidget->refreshing();
|
return stripsWidget->refreshing();
|
||||||
@@ -487,19 +398,6 @@ void MainWindow::endEnabledChanged()
|
|||||||
ui->pushButtonEnd->setEnabled(endEnabled);
|
ui->pushButtonEnd->setEnabled(endEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::refreshAuswertung()
|
|
||||||
{
|
|
||||||
m_balanceLabel->setText(tr("%0: %1").arg(tr("Balance")).arg(tr("???")));
|
|
||||||
m_holidaysLabel->setText(tr("%0: %1").arg(tr("Holidays")).arg(tr("???")));
|
|
||||||
|
|
||||||
ui->actionAuswertung->setEnabled(false);
|
|
||||||
m_auswertung.clear();
|
|
||||||
|
|
||||||
m_auswertungDate = QDate(ui->dateEditDate->date().year(), ui->dateEditDate->date().month(), 1);
|
|
||||||
m_getAuswertungReply = m_erfassung.doGetAuswertung(m_userInfo.userId, m_auswertungDate);
|
|
||||||
connect(m_getAuswertungReply.get(), &ZeiterfassungReply::finished, this, &MainWindow::getAuswertungFinished);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::updateComboboxes()
|
void MainWindow::updateComboboxes()
|
||||||
{
|
{
|
||||||
ui->comboBoxProject->clear();
|
ui->comboBoxProject->clear();
|
||||||
|
@@ -9,9 +9,10 @@
|
|||||||
#include "zeiterfassunglib_global.h"
|
#include "zeiterfassunglib_global.h"
|
||||||
#include "replies/getuserinforeply.h"
|
#include "replies/getuserinforeply.h"
|
||||||
#include "replies/getprojectsreply.h"
|
#include "replies/getprojectsreply.h"
|
||||||
#include "replies/getauswertungreply.h"
|
|
||||||
#include "replies/getpresencestatusreply.h"
|
#include "replies/getpresencestatusreply.h"
|
||||||
|
|
||||||
|
class QMenu;
|
||||||
|
class QToolBar;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QBoxLayout;
|
class QBoxLayout;
|
||||||
|
|
||||||
@@ -33,22 +34,23 @@ public:
|
|||||||
QMenu *menuView() const;
|
QMenu *menuView() const;
|
||||||
QMenu *menuTools() const;
|
QMenu *menuTools() const;
|
||||||
QMenu *menuAbout() const;
|
QMenu *menuAbout() const;
|
||||||
|
QToolBar *toolBar() const;
|
||||||
|
|
||||||
ZeiterfassungSettings &settings() const;
|
ZeiterfassungSettings &settings() const;
|
||||||
ZeiterfassungApi &erfassung() const;
|
ZeiterfassungApi &erfassung() const;
|
||||||
const GetUserInfoReply::UserInfo &userInfo() const;
|
const GetUserInfoReply::UserInfo &userInfo() const;
|
||||||
StripFactory &stripFactory() const;
|
StripFactory &stripFactory() const;
|
||||||
|
|
||||||
|
QDate date() const;
|
||||||
|
|
||||||
const QMap<QString, QString> &projects() const;
|
const QMap<QString, QString> &projects() const;
|
||||||
const std::array<StripsWidget*, 7> &stripsWidgets() const;
|
const std::array<StripsWidget*, 7> &stripsWidgets() const;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void getProjectsFinished();
|
void getProjectsFinished();
|
||||||
void getAuswertungFinished();
|
|
||||||
void pushButtonStartPressed();
|
void pushButtonStartPressed();
|
||||||
void pushButtonEndPressed();
|
void pushButtonEndPressed();
|
||||||
void dateChanged(bool force = false);
|
void dateChanged(bool force = false);
|
||||||
void openAuswertung();
|
|
||||||
|
|
||||||
void minimumTimeChanged();
|
void minimumTimeChanged();
|
||||||
void refreshingChanged();
|
void refreshingChanged();
|
||||||
@@ -56,7 +58,6 @@ private Q_SLOTS:
|
|||||||
void endEnabledChanged();
|
void endEnabledChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void refreshAuswertung();
|
|
||||||
void updateComboboxes();
|
void updateComboboxes();
|
||||||
|
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
@@ -66,16 +67,9 @@ private:
|
|||||||
StripFactory &m_stripFactory;
|
StripFactory &m_stripFactory;
|
||||||
|
|
||||||
std::unique_ptr<GetProjectsReply> m_getProjectsReply;
|
std::unique_ptr<GetProjectsReply> m_getProjectsReply;
|
||||||
std::unique_ptr<GetAuswertungReply> m_getAuswertungReply;
|
|
||||||
|
|
||||||
QMap<QString, QString> m_projects;
|
QMap<QString, QString> m_projects;
|
||||||
|
|
||||||
QDate m_auswertungDate;
|
|
||||||
QByteArray m_auswertung;
|
|
||||||
|
|
||||||
QLabel *m_balanceLabel;
|
|
||||||
QLabel *m_holidaysLabel;
|
|
||||||
|
|
||||||
std::array<StripsWidget*, 7> m_stripsWidgets;
|
std::array<StripsWidget*, 7> m_stripsWidgets;
|
||||||
StripsWidget *m_currentStripWidget;
|
StripsWidget *m_currentStripWidget;
|
||||||
};
|
};
|
||||||
|
@@ -229,7 +229,6 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Tools</string>
|
<string>&Tools</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionAuswertung"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
<addaction name="menuView"/>
|
<addaction name="menuView"/>
|
||||||
@@ -245,8 +244,6 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<addaction name="actionToday"/>
|
<addaction name="actionToday"/>
|
||||||
<addaction name="actionRefresh"/>
|
<addaction name="actionRefresh"/>
|
||||||
<addaction name="actionAuswertung"/>
|
|
||||||
<addaction name="actionSettings"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
<action name="actionQuit">
|
<action name="actionQuit">
|
||||||
@@ -299,15 +296,6 @@
|
|||||||
<string>&Refresh everything</string>
|
<string>&Refresh everything</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionAuswertung">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="resources.qrc">
|
|
||||||
<normaloff>:/zeiterfassunglib/images/auswertung.png</normaloff>:/zeiterfassunglib/images/auswertung.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>&Auswertung</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionSettings">
|
<action name="actionSettings">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="resources.qrc">
|
<iconset resource="resources.qrc">
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/zeiterfassunglib">
|
<qresource prefix="/zeiterfassunglib">
|
||||||
<file>images/about.png</file>
|
<file>images/about.png</file>
|
||||||
<file>images/auswertung.png</file>
|
|
||||||
<file>images/authentication.png</file>
|
<file>images/authentication.png</file>
|
||||||
<file>images/help.png</file>
|
<file>images/help.png</file>
|
||||||
<file>images/icon.png</file>
|
<file>images/icon.png</file>
|
||||||
|
Reference in New Issue
Block a user