Absence plugin #54
40
plugins/absenceplugin/absencedialog.cpp
Normal file
40
plugins/absenceplugin/absencedialog.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#include "absencedialog.h"
|
||||||
|
#include "ui_absencedialog.h"
|
||||||
|
|
||||||
|
#include <QDate>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QStringBuilder>
|
||||||
|
|
||||||
|
#include "absencesmodel.h"
|
||||||
|
|
||||||
|
AbsenceDialog::AbsenceDialog(int userId, const QDate &date, ZeiterfassungApi &erfassung, QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::AbsenceDialog)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
|
||||||
|
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||||
|
#else
|
||||||
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ui->labelTitle->setText(tr("Absences for %0").arg(date.toString(tr("dd.MM.yyyy"))));
|
||||||
|
|
||||||
|
m_model = new AbsencesModel(userId, date, erfassung, this);
|
||||||
|
connect(m_model, &AbsencesModel::errorOccured, this, &AbsenceDialog::errorOccured);
|
||||||
|
|
||||||
|
ui->treeView->setModel(m_model);
|
||||||
|
ui->treeView->setEnabled(m_model->enabled());
|
||||||
|
connect(m_model, &AbsencesModel::enabledChanged, ui->treeView, &QWidget::setEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
AbsenceDialog::~AbsenceDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbsenceDialog::errorOccured(const QString &message)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, tr("Could not load absences!"), tr("Could not load absences!") % "\n\n" % message);
|
||||||
|
}
|
27
plugins/absenceplugin/absencedialog.h
Normal file
27
plugins/absenceplugin/absencedialog.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
class QDate;
|
||||||
|
|
||||||
|
class ZeiterfassungApi;
|
||||||
|
|
||||||
|
class AbsencesModel;
|
||||||
|
namespace Ui { class AbsenceDialog; }
|
||||||
|
|
||||||
|
class AbsenceDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit AbsenceDialog(int userId, const QDate &date, ZeiterfassungApi &erfassung, QWidget *parent = 0);
|
||||||
|
~AbsenceDialog();
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void errorOccured(const QString &message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::AbsenceDialog *ui;
|
||||||
|
|
||||||
|
AbsencesModel *m_model;
|
||||||
|
};
|
79
plugins/absenceplugin/absencedialog.ui
Normal file
79
plugins/absenceplugin/absencedialog.ui
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>AbsenceDialog</class>
|
||||||
|
<widget class="QDialog" name="AbsenceDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>947</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Absences</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelTitle">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>16</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">Absences for</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTreeView" name="treeView"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Close</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>AbsenceDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>AbsenceDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
38
plugins/absenceplugin/absenceplugin.cpp
Normal file
38
plugins/absenceplugin/absenceplugin.cpp
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#include "absenceplugin.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QLocale>
|
||||||
|
#include <QBoxLayout>
|
||||||
|
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "stripswidget.h"
|
||||||
|
|
||||||
|
#include "absencewidget.h"
|
||||||
|
|
||||||
|
AbsencePlugin::AbsencePlugin(QObject *parent) :
|
||||||
|
ZeiterfassungPlugin(parent)
|
||||||
|
{
|
||||||
|
qDebug() << "called";
|
||||||
|
|
||||||
|
static auto dir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("translations"));
|
||||||
|
|
||||||
|
if(m_translator.load(QLocale(), QStringLiteral("absenceplugin"), QStringLiteral("_"), dir))
|
||||||
|
{
|
||||||
|
if(!QCoreApplication::installTranslator(&m_translator))
|
||||||
|
{
|
||||||
|
qWarning() << "could not install translation absenceplugin";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning() << "could not load translation absenceplugin";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbsencePlugin::attachTo(MainWindow &mainWindow)
|
||||||
|
{
|
||||||
|
for(auto stripsWidget : mainWindow.stripsWidgets())
|
||||||
|
stripsWidget->headerLayout()->addWidget(new AbsenceWidget(*stripsWidget));
|
||||||
|
}
|
24
plugins/absenceplugin/absenceplugin.h
Normal file
24
plugins/absenceplugin/absenceplugin.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
|
#include "zeiterfassungplugin.h"
|
||||||
|
|
||||||
|
class MainWindow;
|
||||||
|
|
||||||
|
class Q_DECL_EXPORT AbsencePlugin : public ZeiterfassungPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "dbsoftware.zeiterfassung.plugin/1.0" FILE "absenceplugin.json")
|
||||||
|
Q_INTERFACES(ZeiterfassungPlugin)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit AbsencePlugin(QObject *parent = Q_NULLPTR);
|
||||||
|
|
||||||
|
// ZeiterfassungPlugin interface
|
||||||
|
void attachTo(MainWindow &mainWindow) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTranslator m_translator;
|
||||||
|
};
|
0
plugins/absenceplugin/absenceplugin.json
Normal file
0
plugins/absenceplugin/absenceplugin.json
Normal file
38
plugins/absenceplugin/absenceplugin.pro
Normal file
38
plugins/absenceplugin/absenceplugin.pro
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
QT += core network gui widgets
|
||||||
|
|
||||||
|
TARGET = absenceplugin
|
||||||
|
TEMPLATE = lib
|
||||||
|
|
||||||
|
CONFIG += shared c++14
|
||||||
|
|
||||||
|
PROJECT_ROOT = ../..
|
||||||
|
|
||||||
|
DESTDIR = $${OUT_PWD}/$${PROJECT_ROOT}/bin/plugins/zeiterfassung
|
||||||
|
|
||||||
|
LIBS += -L$${OUT_PWD}/$${PROJECT_ROOT}/bin -lzeiterfassungcorelib -lzeiterfassungguilib
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib
|
||||||
|
DEPENDPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib
|
||||||
|
|
||||||
|
DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT
|
||||||
|
|
||||||
|
HEADERS += absencedialog.h \
|
||||||
|
absencesmodel.h \
|
||||||
|
absenceplugin.h \
|
||||||
|
absencewidget.h
|
||||||
|
|
||||||
|
SOURCES += absencedialog.cpp \
|
||||||
|
absencesmodel.cpp \
|
||||||
|
absenceplugin.cpp \
|
||||||
|
absencewidget.cpp
|
||||||
|
|
||||||
|
FORMS += absencedialog.ui
|
||||||
|
|
||||||
|
RESOURCES += absenceplugin_resources.qrc
|
||||||
|
|
||||||
|
TRANSLATIONS += translations/absenceplugin_en.ts \
|
||||||
|
translations/absenceplugin_de.ts
|
||||||
|
|
||||||
|
OTHER_FILES += absenceplugin.json
|
||||||
|
|
||||||
|
include(../../lrelease.pri)
|
5
plugins/absenceplugin/absenceplugin_resources.qrc
Normal file
5
plugins/absenceplugin/absenceplugin_resources.qrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/zeiterfassung/plugins/absenceplugin">
|
||||||
|
<file>images/absence.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
115
plugins/absenceplugin/absencesmodel.cpp
Normal file
115
plugins/absenceplugin/absencesmodel.cpp
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
#include "absencesmodel.h"
|
||||||
|
|
||||||
|
#include "zeiterfassungapi.h"
|
||||||
|
|
||||||
|
AbsencesModel::AbsencesModel(int userId, const QDate &date, ZeiterfassungApi &erfassung, QObject *parent) :
|
||||||
|
QAbstractListModel(parent),
|
||||||
|
m_userId(userId),
|
||||||
|
m_erfassung(erfassung)
|
||||||
|
{
|
||||||
|
setDate(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AbsencesModel::enabled() const
|
||||||
|
{
|
||||||
|
return m_reply == Q_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int AbsencesModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent)
|
||||||
|
|
||||||
|
return m_absences.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
int AbsencesModel::columnCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent)
|
||||||
|
|
||||||
|
return 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant AbsencesModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
Q_ASSERT(index.row() < m_absences.count());
|
||||||
|
const auto &absence = m_absences.at(index.row());
|
||||||
|
|
||||||
|
switch(role)
|
||||||
|
{
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
case Qt::EditRole:
|
||||||
|
switch(index.column())
|
||||||
|
{
|
||||||
|
case 0: return absence.altRepresentative;
|
||||||
|
case 1: return absence.compositeId;
|
||||||
|
case 2: return absence.end;
|
||||||
|
case 3: return absence.hourCategory;
|
||||||
|
case 4: return absence.openMarking;
|
||||||
|
case 5: return absence.persNr;
|
||||||
|
case 6: return absence.representative;
|
||||||
|
case 7: return absence.start;
|
||||||
|
case 8: return absence.text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant AbsencesModel::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("altRepresentative");
|
||||||
|
case 1: return tr("compositeId");
|
||||||
|
case 2: return tr("end");
|
||||||
|
case 3: return tr("hourCategory");
|
||||||
|
case 4: return tr("openMarking");
|
||||||
|
case 5: return tr("persNr");
|
||||||
|
case 6: return tr("representative");
|
||||||
|
case 7: return tr("start");
|
||||||
|
case 8: return tr("text");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
qt_noop();
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbsencesModel::setDate(const QDate &date)
|
||||||
|
{
|
||||||
|
m_date = date;
|
||||||
|
|
||||||
|
auto oldEnabled = enabled();
|
||||||
|
|
||||||
|
m_reply = m_erfassung.doGetAbsences(m_userId, m_date, m_date);
|
||||||
|
connect(m_reply.get(), &ZeiterfassungReply::finished, this, &AbsencesModel::finished);
|
||||||
|
|
||||||
|
if(oldEnabled != enabled())
|
||||||
|
Q_EMIT enabledChanged(enabled());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbsencesModel::finished()
|
||||||
|
{
|
||||||
|
if(!m_reply->success())
|
||||||
|
Q_EMIT errorOccured(m_reply->message());
|
||||||
|
|
||||||
|
beginResetModel();
|
||||||
|
m_absences = m_reply->absences();
|
||||||
|
endResetModel();
|
||||||
|
|
||||||
|
auto oldEnabled = enabled();
|
||||||
|
|
||||||
|
m_reply = Q_NULLPTR;
|
||||||
|
|
||||||
|
if(oldEnabled != enabled())
|
||||||
|
Q_EMIT enabledChanged(enabled());
|
||||||
|
}
|
44
plugins/absenceplugin/absencesmodel.h
Normal file
44
plugins/absenceplugin/absencesmodel.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <QAbstractListModel>
|
||||||
|
#include <QDate>
|
||||||
|
|
||||||
|
#include "replies/getabsencesreply.h"
|
||||||
|
|
||||||
|
class ZeiterfassungApi;
|
||||||
|
|
||||||
|
class AbsencesModel : public QAbstractListModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool enabled READ enabled NOTIFY enabledChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit AbsencesModel(int userId, const QDate &date, ZeiterfassungApi &erfassung, QObject *parent = Q_NULLPTR);
|
||||||
|
|
||||||
|
bool enabled() const;
|
||||||
|
|
||||||
|
// QAbstractItemModel interface
|
||||||
|
int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE;
|
||||||
|
int columnCount(const QModelIndex &parent) const Q_DECL_OVERRIDE;
|
||||||
|
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
|
||||||
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void enabledChanged(bool enabled);
|
||||||
|
void errorOccured(const QString &message);
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void setDate(const QDate &date);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void finished();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_userId;
|
||||||
|
QDate m_date;
|
||||||
|
ZeiterfassungApi &m_erfassung;
|
||||||
|
std::unique_ptr<GetAbsencesReply> m_reply;
|
||||||
|
QVector<GetAbsencesReply::Absence> m_absences;
|
||||||
|
};
|
23
plugins/absenceplugin/absencewidget.cpp
Normal file
23
plugins/absenceplugin/absencewidget.cpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#include "absencewidget.h"
|
||||||
|
|
||||||
|
#include "stripswidget.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include "absencedialog.h"
|
||||||
|
|
||||||
|
AbsenceWidget::AbsenceWidget(StripsWidget &stripsWidget) :
|
||||||
|
QToolButton(&stripsWidget),
|
||||||
|
m_stripsWidget(stripsWidget)
|
||||||
|
{
|
||||||
|
setIcon(QIcon(QStringLiteral(":/zeiterfassung/plugins/absenceplugin/images/absence.png")));
|
||||||
|
setText(tr("Absence"));
|
||||||
|
|
||||||
|
connect(this, &QAbstractButton::pressed, this, &AbsenceWidget::pressedSlot);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbsenceWidget::pressedSlot()
|
||||||
|
{
|
||||||
|
AbsenceDialog dialog(m_stripsWidget.mainWindow().userInfo().userId, m_stripsWidget.date(),
|
||||||
|
m_stripsWidget.mainWindow().erfassung(), this);
|
||||||
|
dialog.exec();
|
||||||
|
}
|
19
plugins/absenceplugin/absencewidget.h
Normal file
19
plugins/absenceplugin/absencewidget.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
|
class StripsWidget;
|
||||||
|
|
||||||
|
class AbsenceWidget : public QToolButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit AbsenceWidget(StripsWidget &stripsWidget);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void pressedSlot();
|
||||||
|
|
||||||
|
private:
|
||||||
|
StripsWidget &m_stripsWidget;
|
||||||
|
};
|
BIN
plugins/absenceplugin/images/absence.png
Normal file
BIN
plugins/absenceplugin/images/absence.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
83
plugins/absenceplugin/translations/absenceplugin_de.ts
Normal file
83
plugins/absenceplugin/translations/absenceplugin_de.ts
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="de_DE">
|
||||||
|
<context>
|
||||||
|
<name>AbsenceDialog</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencedialog.ui" line="14"/>
|
||||||
|
<source>Absences</source>
|
||||||
|
<translation>Abwesenheiten</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencedialog.cpp" line="22"/>
|
||||||
|
<source>Absences for %0</source>
|
||||||
|
<translation>Abwesenheiten für %0</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencedialog.cpp" line="22"/>
|
||||||
|
<source>dd.MM.yyyy</source>
|
||||||
|
<translation>dd.MM.yyyy</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencedialog.cpp" line="39"/>
|
||||||
|
<source>Could not load absences!</source>
|
||||||
|
<translation>Konnte Abwesenheiten nicht laden!</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>AbsenceWidget</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencewidget.cpp" line="13"/>
|
||||||
|
<source>Absence</source>
|
||||||
|
<translation>Abwesenheit</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>AbsencesModel</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="69"/>
|
||||||
|
<source>altRepresentative</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="70"/>
|
||||||
|
<source>compositeId</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="71"/>
|
||||||
|
<source>end</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="72"/>
|
||||||
|
<source>hourCategory</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="73"/>
|
||||||
|
<source>openMarking</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="74"/>
|
||||||
|
<source>persNr</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="75"/>
|
||||||
|
<source>representative</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="76"/>
|
||||||
|
<source>start</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="77"/>
|
||||||
|
<source>text</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
83
plugins/absenceplugin/translations/absenceplugin_en.ts
Normal file
83
plugins/absenceplugin/translations/absenceplugin_en.ts
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="en_US">
|
||||||
|
<context>
|
||||||
|
<name>AbsenceDialog</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencedialog.ui" line="14"/>
|
||||||
|
<source>Absences</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencedialog.cpp" line="22"/>
|
||||||
|
<source>Absences for %0</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencedialog.cpp" line="22"/>
|
||||||
|
<source>dd.MM.yyyy</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencedialog.cpp" line="39"/>
|
||||||
|
<source>Could not load absences!</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>AbsenceWidget</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencewidget.cpp" line="13"/>
|
||||||
|
<source>Absence</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>AbsencesModel</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="69"/>
|
||||||
|
<source>altRepresentative</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="70"/>
|
||||||
|
<source>compositeId</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="71"/>
|
||||||
|
<source>end</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="72"/>
|
||||||
|
<source>hourCategory</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="73"/>
|
||||||
|
<source>openMarking</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="74"/>
|
||||||
|
<source>persNr</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="75"/>
|
||||||
|
<source>representative</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="76"/>
|
||||||
|
<source>start</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../absencesmodel.cpp" line="77"/>
|
||||||
|
<source>text</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
@@ -35,8 +35,6 @@ void LunchMealWidget::pressedSlot()
|
|||||||
|
|
||||||
void LunchMealWidget::dateChanged(const QDate &date)
|
void LunchMealWidget::dateChanged(const QDate &date)
|
||||||
{
|
{
|
||||||
qDebug() << "called";
|
|
||||||
|
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
SUBDIRS += advancedviewplugin \
|
SUBDIRS += absenceplugin \
|
||||||
|
advancedviewplugin \
|
||||||
devtoolsplugin \
|
devtoolsplugin \
|
||||||
lunchmealplugin \
|
lunchmealplugin \
|
||||||
profileplugin \
|
profileplugin \
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ void PresenceWidget::finished()
|
|||||||
icon = QIcon(QStringLiteral(":zeiterfassung/plugins/presenceplugin/images/not-present.png"));
|
icon = QIcon(QStringLiteral(":zeiterfassung/plugins/presenceplugin/images/not-present.png"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
qWarning() << "unknown presence" << status.firstName << status.lastName << status.presence;
|
qCritical() << "unknown presence" << status.firstName << status.lastName << status.presence;
|
||||||
|
|
||||||
m_menu->addAction(icon, tr("%0 %1").arg(status.firstName).arg(status.lastName));
|
m_menu->addAction(icon, tr("%0 %1").arg(status.firstName).arg(status.lastName));
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QDebug>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
|
@@ -3,8 +3,7 @@
|
|||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QMessageBox>
|
#include <QDebug>
|
||||||
#include <QStringBuilder>
|
|
||||||
#include <QJsonParseError>
|
#include <QJsonParseError>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
77
zeiterfassungcorelib/replies/getabsencesreply.cpp
Normal file
77
zeiterfassungcorelib/replies/getabsencesreply.cpp
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#include "getabsencesreply.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QJsonParseError>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonValue>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
#include "zeiterfassungapi.h"
|
||||||
|
|
||||||
|
GetAbsencesReply::GetAbsencesReply(std::unique_ptr<QNetworkReply> &&reply, ZeiterfassungApi *zeiterfassung) :
|
||||||
|
ZeiterfassungReply(zeiterfassung),
|
||||||
|
m_reply(std::move(reply))
|
||||||
|
{
|
||||||
|
connect(m_reply.get(), &QNetworkReply::finished, this, &GetAbsencesReply::requestFinished);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVector<GetAbsencesReply::Absence> &GetAbsencesReply::absences() const
|
||||||
|
{
|
||||||
|
return m_absences;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetAbsencesReply::requestFinished()
|
||||||
|
{
|
||||||
|
if(m_reply->error() != QNetworkReply::NoError)
|
||||||
|
{
|
||||||
|
setSuccess(false);
|
||||||
|
setMessage(tr("Request error occured: %0").arg(m_reply->errorString()));
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll(), &error);
|
||||||
|
if(error.error != QJsonParseError::NoError)
|
||||||
|
{
|
||||||
|
setSuccess(false);
|
||||||
|
setMessage(tr("Parsing JSON failed: %0").arg(error.errorString()));
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!document.isArray())
|
||||||
|
{
|
||||||
|
setSuccess(false);
|
||||||
|
setMessage(tr("JSON document is not an array!"));
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto arr = document.array();
|
||||||
|
|
||||||
|
setSuccess(true);
|
||||||
|
m_absences.clear();
|
||||||
|
m_absences.reserve(arr.count());
|
||||||
|
for(const auto &val : arr)
|
||||||
|
{
|
||||||
|
auto obj = val.toObject();
|
||||||
|
|
||||||
|
m_absences.append({
|
||||||
|
obj.value(QStringLiteral("altRepresentative")).toInt(),
|
||||||
|
obj.value(QStringLiteral("compositeId")).toString(),
|
||||||
|
QDate::fromString(QString::number(obj.value(QStringLiteral("end")).toInt()), QStringLiteral("yyyyMMdd")),
|
||||||
|
obj.value(QStringLiteral("hourCategory")).toString(),
|
||||||
|
obj.value(QStringLiteral("openMarking")).toString(),
|
||||||
|
obj.value(QStringLiteral("persNr")).toInt(),
|
||||||
|
obj.value(QStringLiteral("representative")).toInt(),
|
||||||
|
QDate::fromString(QString::number(obj.value(QStringLiteral("start")).toInt()), QStringLiteral("yyyyMMdd")),
|
||||||
|
obj.value(QStringLiteral("text")).toString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
|
m_reply = Q_NULLPTR;
|
||||||
|
|
||||||
|
Q_EMIT finished();
|
||||||
|
}
|
43
zeiterfassungcorelib/replies/getabsencesreply.h
Normal file
43
zeiterfassungcorelib/replies/getabsencesreply.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QDate>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "zeiterfassungcorelib_global.h"
|
||||||
|
#include "zeiterfassungreply.h"
|
||||||
|
|
||||||
|
class ZeiterfassungApi;
|
||||||
|
|
||||||
|
class ZEITERFASSUNGCORELIBSHARED_EXPORT GetAbsencesReply : public ZeiterfassungReply
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit GetAbsencesReply(std::unique_ptr<QNetworkReply> &&reply, ZeiterfassungApi *zeiterfassung);
|
||||||
|
|
||||||
|
struct Absence
|
||||||
|
{
|
||||||
|
int altRepresentative;
|
||||||
|
QString compositeId;
|
||||||
|
QDate end;
|
||||||
|
QString hourCategory;
|
||||||
|
QString openMarking;
|
||||||
|
int persNr;
|
||||||
|
int representative;
|
||||||
|
QDate start;
|
||||||
|
QString text;
|
||||||
|
};
|
||||||
|
|
||||||
|
const QVector<Absence> &absences() const;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void requestFinished();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<QNetworkReply> m_reply;
|
||||||
|
QVector<Absence> m_absences;
|
||||||
|
};
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include <QDate>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
|
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include <QDate>
|
||||||
|
#include <QTime>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
|
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QDate>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
#include "zeiterfassungcorelib_global.h"
|
#include "zeiterfassungcorelib_global.h"
|
||||||
|
@@ -9,20 +9,21 @@
|
|||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
|
||||||
#include "replies/createbookingreply.h"
|
|
||||||
#include "replies/createtimeassignmentreply.h"
|
|
||||||
#include "replies/deletebookingreply.h"
|
|
||||||
#include "replies/deletetimeassignmentreply.h"
|
|
||||||
#include "replies/getreportreply.h"
|
|
||||||
#include "replies/getbookingsreply.h"
|
|
||||||
#include "replies/getpresencestatusreply.h"
|
|
||||||
#include "replies/getprojectsreply.h"
|
|
||||||
#include "replies/gettimeassignmentsreply.h"
|
|
||||||
#include "replies/loginpagereply.h"
|
#include "replies/loginpagereply.h"
|
||||||
#include "replies/loginreply.h"
|
#include "replies/loginreply.h"
|
||||||
#include "replies/updatebookingreply.h"
|
|
||||||
#include "replies/updatetimeassignmentreply.h"
|
|
||||||
#include "replies/getuserinforeply.h"
|
#include "replies/getuserinforeply.h"
|
||||||
|
#include "replies/getbookingsreply.h"
|
||||||
|
#include "replies/createbookingreply.h"
|
||||||
|
#include "replies/updatebookingreply.h"
|
||||||
|
#include "replies/deletebookingreply.h"
|
||||||
|
#include "replies/gettimeassignmentsreply.h"
|
||||||
|
#include "replies/createtimeassignmentreply.h"
|
||||||
|
#include "replies/updatetimeassignmentreply.h"
|
||||||
|
#include "replies/deletetimeassignmentreply.h"
|
||||||
|
#include "replies/getprojectsreply.h"
|
||||||
|
#include "replies/getreportreply.h"
|
||||||
|
#include "replies/getpresencestatusreply.h"
|
||||||
|
#include "replies/getabsencesreply.h"
|
||||||
|
|
||||||
//add support for pre cpp14 compilers
|
//add support for pre cpp14 compilers
|
||||||
#include "cpp14polyfills.h"
|
#include "cpp14polyfills.h"
|
||||||
@@ -286,3 +287,15 @@ std::unique_ptr<GetPresenceStatusReply> ZeiterfassungApi::doGetPresenceStatus()
|
|||||||
|
|
||||||
return std::make_unique<GetPresenceStatusReply>(std::unique_ptr<QNetworkReply>(m_manager->get(request)), this);
|
return std::make_unique<GetPresenceStatusReply>(std::unique_ptr<QNetworkReply>(m_manager->get(request)), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<GetAbsencesReply> ZeiterfassungApi::doGetAbsences(int userId, const QDate &start, const QDate &end)
|
||||||
|
{
|
||||||
|
QNetworkRequest request(QUrl(QStringLiteral("%0json/fulldayAbsences?start=%1&end=%2&pnrLst=%3")
|
||||||
|
.arg(m_url)
|
||||||
|
.arg(start.toString(QStringLiteral("yyyyMMdd")))
|
||||||
|
.arg(end.toString(QStringLiteral("yyyyMMdd")))
|
||||||
|
.arg(userId)));
|
||||||
|
request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar"));
|
||||||
|
|
||||||
|
return std::make_unique<GetAbsencesReply>(std::unique_ptr<QNetworkReply>(m_manager->get(request)), this);
|
||||||
|
}
|
||||||
|
@@ -25,6 +25,7 @@ class DeleteTimeAssignmentReply;
|
|||||||
class GetProjectsReply;
|
class GetProjectsReply;
|
||||||
class GetReportReply;
|
class GetReportReply;
|
||||||
class GetPresenceStatusReply;
|
class GetPresenceStatusReply;
|
||||||
|
class GetAbsencesReply;
|
||||||
|
|
||||||
class ZEITERFASSUNGCORELIBSHARED_EXPORT ZeiterfassungApi : public QObject
|
class ZEITERFASSUNGCORELIBSHARED_EXPORT ZeiterfassungApi : public QObject
|
||||||
{
|
{
|
||||||
@@ -63,6 +64,7 @@ public:
|
|||||||
std::unique_ptr<GetProjectsReply> doGetProjects(int userId, const QDate &date);
|
std::unique_ptr<GetProjectsReply> doGetProjects(int userId, const QDate &date);
|
||||||
std::unique_ptr<GetReportReply> doGetReport(int userId, const QDate &date);
|
std::unique_ptr<GetReportReply> doGetReport(int userId, const QDate &date);
|
||||||
std::unique_ptr<GetPresenceStatusReply> doGetPresenceStatus();
|
std::unique_ptr<GetPresenceStatusReply> doGetPresenceStatus();
|
||||||
|
std::unique_ptr<GetAbsencesReply> doGetAbsences(int userId, const QDate &start, const QDate &end);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_url;
|
QString m_url;
|
||||||
|
@@ -20,6 +20,7 @@ SOURCES += timeutils.cpp \
|
|||||||
replies/createtimeassignmentreply.cpp \
|
replies/createtimeassignmentreply.cpp \
|
||||||
replies/deletebookingreply.cpp \
|
replies/deletebookingreply.cpp \
|
||||||
replies/deletetimeassignmentreply.cpp \
|
replies/deletetimeassignmentreply.cpp \
|
||||||
|
replies/getabsencesreply.cpp \
|
||||||
replies/getbookingsreply.cpp \
|
replies/getbookingsreply.cpp \
|
||||||
replies/getpresencestatusreply.cpp \
|
replies/getpresencestatusreply.cpp \
|
||||||
replies/getprojectsreply.cpp \
|
replies/getprojectsreply.cpp \
|
||||||
@@ -41,6 +42,7 @@ HEADERS += cpp14polyfills.h \
|
|||||||
replies/createtimeassignmentreply.h \
|
replies/createtimeassignmentreply.h \
|
||||||
replies/deletebookingreply.h \
|
replies/deletebookingreply.h \
|
||||||
replies/deletetimeassignmentreply.h \
|
replies/deletetimeassignmentreply.h \
|
||||||
|
replies/getabsencesreply.h \
|
||||||
replies/getbookingsreply.h \
|
replies/getbookingsreply.h \
|
||||||
replies/getpresencestatusreply.h \
|
replies/getpresencestatusreply.h \
|
||||||
replies/getprojectsreply.h \
|
replies/getprojectsreply.h \
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="pixmap">
|
<property name="pixmap">
|
||||||
<pixmap resource="../resources.qrc">:/zeiterfassungguilib/images/authentication.png</pixmap>
|
<pixmap resource="../zeiterfassungguilib_resources.qrc">:/zeiterfassungguilib/images/authentication.png</pixmap>
|
||||||
</property>
|
</property>
|
||||||
<property name="scaledContents">
|
<property name="scaledContents">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@@ -105,7 +105,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../resources.qrc"/>
|
<include location="../zeiterfassungguilib_resources.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
Reference in New Issue
Block a user