Absence plugin #54
@@ -3,7 +3,9 @@
|
||||
|
||||
#include <QDate>
|
||||
|
||||
AbsenceDialog::AbsenceDialog(const QDate &date, QWidget *parent) :
|
||||
#include "absencesmodel.h"
|
||||
|
||||
AbsenceDialog::AbsenceDialog(int userId, const QDate &date, ZeiterfassungApi &erfassung, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::AbsenceDialog)
|
||||
{
|
||||
@@ -16,6 +18,8 @@ AbsenceDialog::AbsenceDialog(const QDate &date, QWidget *parent) :
|
||||
#endif
|
||||
|
||||
ui->labelTitle->setText(tr("Absences for %0").arg(date.toString(tr("dd.MM.yyyy"))));
|
||||
|
||||
ui->treeView->setModel(new AbsencesModel(userId, date, erfassung, this));
|
||||
}
|
||||
|
||||
AbsenceDialog::~AbsenceDialog()
|
||||
|
@@ -4,6 +4,8 @@
|
||||
|
||||
class QDate;
|
||||
|
||||
class ZeiterfassungApi;
|
||||
|
||||
namespace Ui { class AbsenceDialog; }
|
||||
|
||||
class AbsenceDialog : public QDialog
|
||||
@@ -11,7 +13,7 @@ class AbsenceDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AbsenceDialog(const QDate &date, QWidget *parent = 0);
|
||||
explicit AbsenceDialog(int userId, const QDate &date, ZeiterfassungApi &erfassung, QWidget *parent = 0);
|
||||
~AbsenceDialog();
|
||||
|
||||
private:
|
||||
|
@@ -17,10 +17,12 @@ DEPENDPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}
|
||||
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
|
||||
|
||||
|
49
plugins/absenceplugin/absencesmodel.cpp
Normal file
49
plugins/absenceplugin/absencesmodel.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#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
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int AbsencesModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QVariant AbsencesModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QVariant AbsencesModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AbsencesModel::setDate(const QDate &date)
|
||||
{
|
||||
m_date = date;
|
||||
|
||||
m_reply = m_erfassung.doGetAbsences(m_userId, m_date, m_date);
|
||||
connect(m_reply.get(), &ZeiterfassungReply::finished, this, &AbsencesModel::finished);
|
||||
}
|
||||
|
||||
void AbsencesModel::finished()
|
||||
{
|
||||
|
||||
}
|
42
plugins/absenceplugin/absencesmodel.h
Normal file
42
plugins/absenceplugin/absencesmodel.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#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);
|
||||
|
||||
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;
|
||||
};
|
@@ -1,6 +1,7 @@
|
||||
#include "absencewidget.h"
|
||||
|
||||
#include "stripswidget.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "absencedialog.h"
|
||||
|
||||
@@ -16,6 +17,7 @@ AbsenceWidget::AbsenceWidget(StripsWidget &stripsWidget) :
|
||||
|
||||
void AbsenceWidget::pressedSlot()
|
||||
{
|
||||
AbsenceDialog dialog(m_stripsWidget.date(), this);
|
||||
AbsenceDialog dialog(m_stripsWidget.mainWindow().userInfo().userId, m_stripsWidget.date(),
|
||||
m_stripsWidget.mainWindow().erfassung(), this);
|
||||
dialog.exec();
|
||||
}
|
||||
|
Reference in New Issue
Block a user