yearly view
This commit is contained in:
+16
-1
@@ -18,9 +18,17 @@
|
||||
cMainWindow::cMainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::cMainWindow),
|
||||
m_lpYearyView(nullptr),
|
||||
m_lpMonthlyView(nullptr),
|
||||
m_lpBookingList(nullptr)
|
||||
{
|
||||
m_code.insert(" ", tr(""));
|
||||
m_code.insert("G", tr("Gleitzeit"));
|
||||
m_code.insert("U", tr("Urlaub"));
|
||||
m_code.insert("SU", tr("Sonderurlaub"));
|
||||
m_code.insert("K", tr("Krank"));
|
||||
m_code.insert("T", tr("Training"));
|
||||
|
||||
openDB();
|
||||
m_dailyWorkingList.load();
|
||||
m_vacationList.load();
|
||||
@@ -38,6 +46,8 @@ cMainWindow::cMainWindow(QWidget *parent) :
|
||||
// cZeitnachweis zeitnachweis5("C:\\Users\\VET0572\\Downloads\\Zeitnachweis\\2016-05.pdf");
|
||||
|
||||
qDebug() << "count: " << m_lpBookingList->count();
|
||||
|
||||
connect(m_lpMonthlyView, &cMonthlyView::dateChanged, m_lpYearyView, &cYearlyView::onDateChanged);
|
||||
}
|
||||
|
||||
cMainWindow::~cMainWindow()
|
||||
@@ -84,8 +94,13 @@ void cMainWindow::initUI()
|
||||
if(iX != -1 && iY != -1)
|
||||
move(iX, iY);
|
||||
|
||||
m_lpMonthlyView = new cMonthlyView(QDate::currentDate(), &m_monthlyBookingList, &m_publicHoliday, m_lpBookingList, this);
|
||||
m_lpYearyView = new cYearlyView(QDate::currentDate(), m_code, &m_monthlyBookingList, &m_publicHoliday, m_lpBookingList, this);
|
||||
ui->m_lpMainTab->addTab(m_lpYearyView, "Yearly");
|
||||
|
||||
m_lpMonthlyView = new cMonthlyView(QDate::currentDate(), m_code, &m_monthlyBookingList, &m_publicHoliday, m_lpBookingList, this);
|
||||
ui->m_lpMainTab->addTab(m_lpMonthlyView, "Monthly");
|
||||
|
||||
ui->m_lpMainTab->setCurrentWidget(m_lpMonthlyView);
|
||||
}
|
||||
|
||||
void cMainWindow::openDB()
|
||||
|
||||
+16
-11
@@ -2,6 +2,7 @@
|
||||
#define CMAINWINDOW_H
|
||||
|
||||
|
||||
#include "cyearlyview.h"
|
||||
#include "cmonthlyview.h"
|
||||
#include "cdailyworking.h"
|
||||
#include "cvacation.h"
|
||||
@@ -14,6 +15,8 @@
|
||||
|
||||
#include <QSqlDatabase>
|
||||
|
||||
#include <QMap>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cMainWindow;
|
||||
@@ -28,21 +31,23 @@ public:
|
||||
~cMainWindow();
|
||||
|
||||
private:
|
||||
Ui::cMainWindow* ui;
|
||||
cMonthlyView* m_lpMonthlyView;
|
||||
QSqlDatabase m_db;
|
||||
cPublicHoliday m_publicHoliday;
|
||||
cDailyWorkingList m_dailyWorkingList;
|
||||
cVacationList m_vacationList;
|
||||
cMonthlyBookingList m_monthlyBookingList;
|
||||
cBookingList* m_lpBookingList;
|
||||
Ui::cMainWindow* ui;
|
||||
cYearlyView* m_lpYearyView;
|
||||
cMonthlyView* m_lpMonthlyView;
|
||||
QSqlDatabase m_db;
|
||||
cPublicHoliday m_publicHoliday;
|
||||
cDailyWorkingList m_dailyWorkingList;
|
||||
cVacationList m_vacationList;
|
||||
cMonthlyBookingList m_monthlyBookingList;
|
||||
cBookingList* m_lpBookingList;
|
||||
QMap<QString, QString> m_code;
|
||||
|
||||
|
||||
void initUI();
|
||||
void openDB();
|
||||
void initUI();
|
||||
void openDB();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event);
|
||||
void closeEvent(QCloseEvent* event);
|
||||
};
|
||||
|
||||
#endif // CMAINWINDOW_H
|
||||
|
||||
+5
-16
@@ -14,10 +14,11 @@
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
cMonthlyView::cMonthlyView(const QDate& date, cMonthlyBookingList* lpMonthlyBookingList, cPublicHoliday *lpPublicHoliday, cBookingList* lpBookingList, QWidget *parent) :
|
||||
cMonthlyView::cMonthlyView(const QDate& date, const QMap<QString, QString> code, cMonthlyBookingList* lpMonthlyBookingList, cPublicHoliday *lpPublicHoliday, cBookingList* lpBookingList, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::cMonthlyView),
|
||||
m_loading(true),
|
||||
m_code(code),
|
||||
m_lpMonthlyBookingList(lpMonthlyBookingList),
|
||||
m_lpPublicHoliday(lpPublicHoliday),
|
||||
m_lpBookingList(lpBookingList),
|
||||
@@ -25,13 +26,6 @@ cMonthlyView::cMonthlyView(const QDate& date, cMonthlyBookingList* lpMonthlyBook
|
||||
m_lpMonthlyBooking(nullptr),
|
||||
m_lpValidator(nullptr)
|
||||
{
|
||||
m_code.insert(" ", tr(""));
|
||||
m_code.insert("G", tr("Gleitzeit"));
|
||||
m_code.insert("U", tr("Urlaub"));
|
||||
m_code.insert("SU", tr("Sonderurlaub"));
|
||||
m_code.insert("K", tr("Krank"));
|
||||
m_code.insert("T", tr("Training"));
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
QRegExp rx("(?:\\d\\d\\d):(?:[0-5]\\d):(?:[0-5]\\d)");
|
||||
@@ -80,7 +74,6 @@ cMonthlyView::cMonthlyView(const QDate& date, cMonthlyBookingList* lpMonthlyBook
|
||||
void cMonthlyView::setDate(const QDate& date)
|
||||
{
|
||||
m_loading = true;
|
||||
|
||||
m_date = date;
|
||||
|
||||
m_lpPublicHoliday->setYear(static_cast<qint16>(date.year()));
|
||||
@@ -224,13 +217,9 @@ void cMonthlyView::setDate(const QDate& date)
|
||||
ui->m_lpResturlaubLabel->setText(QString(tr("Resturlaub %1:")).arg(date.addMonths(-1).toString("MMMM yyyy")));
|
||||
ui->m_lpUeberstunden->setText(secs2String(m_lpMonthlyBooking->ueberstunden(), 3));
|
||||
|
||||
// if(!m_lpMonthlyBooking->timesheet().isEmpty())
|
||||
// {
|
||||
// cZeitnachweis zeitnachweis(m_lpMonthlyBooking->timesheet());
|
||||
// }
|
||||
|
||||
updatePDF();
|
||||
displaySummary();
|
||||
// emit dateChanged(date);
|
||||
|
||||
m_loading = false;
|
||||
}
|
||||
@@ -577,10 +566,8 @@ void cMonthlyView::recalculate(int day, int /*field*/)
|
||||
void cMonthlyView::displaySummary()
|
||||
{
|
||||
QStandardItem* lpFirstItem = m_lpMonthlyListModel->item(0, COL_DAY1);
|
||||
// QStandardItem* lpLastItem = m_lpMonthlyListModel->item(m_lpMonthlyListModel->rowCount()-1, COL_DAY1);
|
||||
|
||||
cBooking* lpFirstBooking = lpFirstItem->data(DATA_BOOKING).value<cBooking*>();
|
||||
// cBooking* lpLastBooking = lpLastItem->data(DATA_BOOKING).value<cBooking*>();
|
||||
|
||||
ui->m_lpUebertrag->setText(lpFirstBooking->prevDiffString());
|
||||
|
||||
@@ -622,6 +609,8 @@ void cMonthlyView::displaySummary()
|
||||
ui->m_lpUrlaub->setText(QString::number(u));
|
||||
ui->m_lpSonderurlaub->setText(QString::number(su));
|
||||
ui->m_lpTraining->setText(QString::number(t));
|
||||
|
||||
emit dateChanged(ui->m_lpMonth->date());
|
||||
}
|
||||
|
||||
void cMonthlyView::updatePDF()
|
||||
|
||||
+4
-1
@@ -25,7 +25,7 @@ class cMonthlyView : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit cMonthlyView(const QDate& date, cMonthlyBookingList* lpMonthlyBookingList, cPublicHoliday* lpPublicHoliday, cBookingList* lpBookingList, QWidget *parent = nullptr);
|
||||
explicit cMonthlyView(const QDate& date, const QMap<QString, QString> code, cMonthlyBookingList* lpMonthlyBookingList, cPublicHoliday* lpPublicHoliday, cBookingList* lpBookingList, QWidget *parent = nullptr);
|
||||
~cMonthlyView();
|
||||
|
||||
void setDate(const QDate& date);
|
||||
@@ -64,6 +64,9 @@ private slots:
|
||||
void onSaleryDownload();
|
||||
void onSaleryReplace();
|
||||
void onSaleryDelete();
|
||||
|
||||
signals:
|
||||
void dateChanged(const QDate& date);
|
||||
};
|
||||
|
||||
#endif // CMONTHLYVIEW_H
|
||||
|
||||
+369
@@ -0,0 +1,369 @@
|
||||
#include "common.h"
|
||||
|
||||
#include "cyearlyview.h"
|
||||
#include "ui_cyearlyview.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
cYearlyView::cYearlyView(const QDate& date, const QMap<QString, QString> code, cMonthlyBookingList* lpMonthlyBookingList, cPublicHoliday *lpPublicHoliday, cBookingList* lpBookingList, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::cYearlyView),
|
||||
m_loading(true),
|
||||
m_code(code),
|
||||
m_lpMonthlyBookingList(lpMonthlyBookingList),
|
||||
m_lpPublicHoliday(lpPublicHoliday),
|
||||
m_lpBookingList(lpBookingList),
|
||||
m_date(date),
|
||||
m_lpMonthlyBooking(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_lpYearlyListModel = new QStandardItemModel(0, 1);
|
||||
ui->m_lpYearlyList->setModel(m_lpYearlyListModel);
|
||||
|
||||
setDate(date);
|
||||
|
||||
m_loading = false;
|
||||
}
|
||||
|
||||
cYearlyView::~cYearlyView()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QStandardItem* newItem(const QString& string, const QFont& font, const Qt::Alignment& alignment)
|
||||
{
|
||||
QStandardItem* lpItem = new QStandardItem(string);
|
||||
lpItem->setFont(font);
|
||||
lpItem->setTextAlignment(alignment);
|
||||
return(lpItem);
|
||||
}
|
||||
|
||||
void cYearlyView::setDate(const QDate& date)
|
||||
{
|
||||
m_loading = true;
|
||||
m_date = date;
|
||||
|
||||
m_lpPublicHoliday->setYear(static_cast<qint16>(date.year()));
|
||||
|
||||
m_lpYearlyListModel->clear();
|
||||
|
||||
ui->m_lpYear->setDate(date);
|
||||
|
||||
QStringList strings;
|
||||
QFont font;
|
||||
QFont fontBold;
|
||||
QBrush weekend = QBrush(COLOR_WEEKEND);
|
||||
QBrush gleitzeit = QBrush(COLOR_GLEITZEIT);
|
||||
QBrush urlaub = QBrush(COLOR_URLAUB);
|
||||
QBrush sonderurlaub = QBrush(COLOR_SONDERURLAUB);
|
||||
QBrush krank = QBrush(COLOR_KRANK);
|
||||
QBrush training = QBrush(COLOR_TRAINING);
|
||||
QList<int> spanList;
|
||||
|
||||
fontBold.setBold(true);
|
||||
|
||||
for(int x = 0;x < 31;x++)
|
||||
strings.append(QString::number(x+1));
|
||||
|
||||
strings.append("SOLL Arbeitszeit");
|
||||
strings.append("IST Arbeitszeit");
|
||||
strings.append("+/-");
|
||||
strings.append("Gleitzeit");
|
||||
strings.append("Krank");
|
||||
strings.append("Urlaub");
|
||||
strings.append("Resturlaub");
|
||||
strings.append("Sonderurlaub");
|
||||
strings.append("Sonderurlaub Rest");
|
||||
|
||||
ui->m_lpYearlyList->horizontalHeader()->setMinimumSectionSize(1);
|
||||
ui->m_lpYearlyList->setMinimumWidth(1);
|
||||
ui->m_lpYearlyList->verticalHeader()->setMinimumSectionSize(1);
|
||||
ui->m_lpYearlyList->setMinimumHeight(1);
|
||||
|
||||
QList<QStandardItem*> itemList;
|
||||
|
||||
itemList.append(newItem("Day", fontBold, Qt::AlignHCenter));
|
||||
itemList.append(newItem("January", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter));
|
||||
itemList.append(newItem("February", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter));
|
||||
itemList.append(newItem("March", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter));
|
||||
itemList.append(newItem("April", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter));
|
||||
itemList.append(newItem("May", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter));
|
||||
itemList.append(newItem("June", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter));
|
||||
itemList.append(newItem("July", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter));
|
||||
itemList.append(newItem("August", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter));
|
||||
itemList.append(newItem("September", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter));
|
||||
itemList.append(newItem("October", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter));
|
||||
itemList.append(newItem("November", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter));
|
||||
itemList.append(newItem("December", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter)); itemList.append(newItem("", font, Qt::AlignHCenter));
|
||||
itemList.append(newItem("Day", fontBold, Qt::AlignHCenter));
|
||||
|
||||
for(int x = 0;x < itemList.count();x++)
|
||||
itemList[x]->setData(QBrush(Qt::gray), Qt::BackgroundRole);
|
||||
|
||||
m_lpYearlyListModel->appendRow(itemList);
|
||||
|
||||
for(int x = 0;x < 12;x++)
|
||||
{
|
||||
ui->m_lpYearlyList->setSpan(0, x*3+1, 1, 3);
|
||||
|
||||
ui->m_lpYearlyList->setColumnWidth(x*3+1, 25);
|
||||
ui->m_lpYearlyList->setColumnWidth(x*3+2, 70);
|
||||
ui->m_lpYearlyList->setColumnWidth(x*3+3, 20);
|
||||
}
|
||||
|
||||
for(int x = 0;x < strings.count();x++)
|
||||
{
|
||||
spanList.clear();
|
||||
|
||||
QList<QStandardItem*> itemList;
|
||||
|
||||
itemList.append(newItem(strings[x], fontBold, Qt::AlignHCenter));
|
||||
itemList[itemList.count()-1]->setData(QBrush(Qt::gray), Qt::BackgroundRole);
|
||||
|
||||
if(x < 31)
|
||||
{
|
||||
for(int y = 0;y < 12;y++)
|
||||
{
|
||||
QDate d(m_date.year(), y+1, x+1);
|
||||
|
||||
if(d.isValid())
|
||||
{
|
||||
cBooking* lpBooking = m_lpBookingList->find(d);
|
||||
|
||||
itemList.append(newItem(d.toString("ddd").left(2), font, Qt::AlignRight));
|
||||
itemList.append(newItem("", font, Qt::AlignRight));
|
||||
itemList.append(newItem("", font, Qt::AlignLeft));
|
||||
|
||||
if(m_lpPublicHoliday->isPublicHoliday(d))
|
||||
{
|
||||
itemList[itemList.count()-3]->setData(weekend, Qt::BackgroundRole);
|
||||
itemList[itemList.count()-2]->setData(weekend, Qt::BackgroundRole);
|
||||
itemList[itemList.count()-1]->setData(weekend, Qt::BackgroundRole);
|
||||
|
||||
itemList[itemList.count()-2]->setText(m_lpPublicHoliday->name(d));
|
||||
|
||||
spanList.append(itemList.count()-2);
|
||||
}
|
||||
else if(d.dayOfWeek() >= 6)
|
||||
{
|
||||
itemList[itemList.count()-3]->setData(weekend, Qt::BackgroundRole);
|
||||
itemList[itemList.count()-2]->setData(weekend, Qt::BackgroundRole);
|
||||
itemList[itemList.count()-1]->setData(weekend, Qt::BackgroundRole);
|
||||
}
|
||||
else if(lpBooking)
|
||||
{
|
||||
itemList[itemList.count()-2]->setData(QVariant::fromValue(lpBooking), Qt::UserRole);
|
||||
|
||||
if(lpBooking->code() == "G")
|
||||
{
|
||||
itemList[itemList.count()-3]->setData(gleitzeit, Qt::BackgroundRole);
|
||||
itemList[itemList.count()-2]->setData(gleitzeit, Qt::BackgroundRole);
|
||||
itemList[itemList.count()-1]->setData(gleitzeit, Qt::BackgroundRole);
|
||||
|
||||
itemList[itemList.count()-1]->setText(lpBooking->code());
|
||||
}
|
||||
else if(lpBooking->code() == "U")
|
||||
{
|
||||
itemList[itemList.count()-3]->setData(urlaub, Qt::BackgroundRole);
|
||||
itemList[itemList.count()-2]->setData(urlaub, Qt::BackgroundRole);
|
||||
itemList[itemList.count()-1]->setData(urlaub, Qt::BackgroundRole);
|
||||
|
||||
itemList[itemList.count()-1]->setText(lpBooking->code());
|
||||
}
|
||||
else if(lpBooking->code() == "SU")
|
||||
{
|
||||
itemList[itemList.count()-3]->setData(sonderurlaub, Qt::BackgroundRole);
|
||||
itemList[itemList.count()-2]->setData(sonderurlaub, Qt::BackgroundRole);
|
||||
itemList[itemList.count()-1]->setData(sonderurlaub, Qt::BackgroundRole);
|
||||
|
||||
itemList[itemList.count()-1]->setText(lpBooking->code());
|
||||
}
|
||||
else if(lpBooking->code() == "K")
|
||||
{
|
||||
itemList[itemList.count()-3]->setData(krank, Qt::BackgroundRole);
|
||||
itemList[itemList.count()-2]->setData(krank, Qt::BackgroundRole);
|
||||
itemList[itemList.count()-1]->setData(krank, Qt::BackgroundRole);
|
||||
|
||||
itemList[itemList.count()-1]->setText(lpBooking->code());
|
||||
}
|
||||
else if(lpBooking->code() == "T")
|
||||
{
|
||||
itemList[itemList.count()-3]->setData(training, Qt::BackgroundRole);
|
||||
itemList[itemList.count()-2]->setData(training, Qt::BackgroundRole);
|
||||
itemList[itemList.count()-1]->setData(training, Qt::BackgroundRole);
|
||||
|
||||
itemList[itemList.count()-1]->setText(lpBooking->code());
|
||||
}
|
||||
else
|
||||
{
|
||||
itemList[itemList.count()-2]->setText(lpBooking->ist().toString("hh:mm:ss"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itemList.append(newItem("", font, Qt::AlignRight));
|
||||
itemList[itemList.count()-1]->setData(QBrush(Qt::gray), Qt::BackgroundRole);
|
||||
itemList.append(newItem("", font, Qt::AlignHCenter));
|
||||
itemList[itemList.count()-1]->setData(QBrush(Qt::gray), Qt::BackgroundRole);
|
||||
itemList.append(newItem("", font, Qt::AlignLeft));
|
||||
itemList[itemList.count()-1]->setData(QBrush(Qt::gray), Qt::BackgroundRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int y = 0;y < 12;y++)
|
||||
{
|
||||
itemList.append(newItem("", font, Qt::AlignRight));
|
||||
itemList[itemList.count()-1]->setData(QBrush(Qt::gray), Qt::BackgroundRole);
|
||||
itemList.append(newItem("", font, Qt::AlignRight));
|
||||
itemList[itemList.count()-1]->setData(QBrush(Qt::gray), Qt::BackgroundRole);
|
||||
itemList.append(newItem("", font, Qt::AlignLeft));
|
||||
itemList[itemList.count()-1]->setData(QBrush(Qt::gray), Qt::BackgroundRole);
|
||||
}
|
||||
}
|
||||
|
||||
itemList.append(newItem(strings[x], fontBold, Qt::AlignHCenter));
|
||||
itemList[itemList.count()-1]->setData(QBrush(Qt::gray), Qt::BackgroundRole);
|
||||
|
||||
m_lpYearlyListModel->appendRow(itemList);
|
||||
|
||||
for(int y = 0;y < spanList.count();y++)
|
||||
ui->m_lpYearlyList->setSpan(m_lpYearlyListModel->rowCount()-1, spanList[y], 1, 2);
|
||||
}
|
||||
|
||||
for(int x = 0;x < m_lpYearlyListModel->rowCount();x++)
|
||||
ui->m_lpYearlyList->setRowHeight(x, 18);
|
||||
|
||||
ui->m_lpYearlyList->resizeColumnToContents(0);
|
||||
ui->m_lpYearlyList->resizeColumnToContents(m_lpYearlyListModel->columnCount()-1);
|
||||
|
||||
qint32 sollT = 0;
|
||||
qint32 istT = 0;
|
||||
qint16 gT = 0;
|
||||
qint16 kT = 0;
|
||||
qint16 uT = 0;
|
||||
qint16 suT = 0;
|
||||
qint16 tT = 0;
|
||||
qint16 restUrlaub = 0;
|
||||
|
||||
for(int col = 0;col < 12;col++)
|
||||
{
|
||||
qint32 soll = 0;
|
||||
qint32 ist = 0;
|
||||
qint16 g = 0;
|
||||
qint16 k = 0;
|
||||
qint16 u = 0;
|
||||
qint16 su = 0;
|
||||
qint16 t = 0;
|
||||
|
||||
cBooking* lpFirstBooking = nullptr;
|
||||
|
||||
for(int row = 0;row < 31;row++)
|
||||
{
|
||||
QStandardItem* lpItem = m_lpYearlyListModel->item(row+1, col*3+2);
|
||||
|
||||
if(lpItem)
|
||||
{
|
||||
cBooking* lpBooking = lpItem->data(Qt::UserRole).value<cBooking*>();
|
||||
if(lpBooking)
|
||||
{
|
||||
if(!lpFirstBooking)
|
||||
lpFirstBooking = lpBooking;
|
||||
|
||||
soll += lpBooking->sollSecs();
|
||||
ist += lpBooking->istSecs();
|
||||
|
||||
if(lpBooking->code() == "G")
|
||||
g++;
|
||||
else if(lpBooking->code() == "K")
|
||||
k++;
|
||||
else if(lpBooking->code() == "U")
|
||||
u++;
|
||||
else if(lpBooking->code() == "SU")
|
||||
su++;
|
||||
else if(lpBooking->code() == "T")
|
||||
t++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_lpYearlyListModel->item(32, col*3+2)->setText(secs2String(soll));
|
||||
m_lpYearlyListModel->item(33, col*3+2)->setText(secs2String(ist));
|
||||
m_lpYearlyListModel->item(34, col*3+2)->setText(secs2String(ist-soll));
|
||||
if(ist-soll < 0)
|
||||
m_lpYearlyListModel->item(34, col*3+2)->setData(QBrush(Qt::red), Qt::ForegroundRole);
|
||||
|
||||
m_lpYearlyListModel->item(35, col*3+2)->setText(QString::number(g));
|
||||
m_lpYearlyListModel->item(36, col*3+2)->setText(QString::number(k));
|
||||
m_lpYearlyListModel->item(37, col*3+2)->setText(QString::number(u));
|
||||
|
||||
if(lpFirstBooking)
|
||||
{
|
||||
restUrlaub = lpFirstBooking->vacation()-u;
|
||||
m_lpYearlyListModel->item(38, col*3+2)->setText(QString::number(restUrlaub));
|
||||
if(restUrlaub < 0)
|
||||
m_lpYearlyListModel->item(38, col*3+2)->setData(QBrush(Qt::red), Qt::ForegroundRole);
|
||||
}
|
||||
else
|
||||
m_lpYearlyListModel->item(38, col*3+2)->setText("0");
|
||||
|
||||
m_lpYearlyListModel->item(39, col*3+2)->setText(QString::number(su));
|
||||
|
||||
sollT += soll;
|
||||
istT += ist;
|
||||
gT += g;
|
||||
kT += k;
|
||||
uT += u;
|
||||
suT += su;
|
||||
tT += t;
|
||||
}
|
||||
|
||||
m_lpYearlyListModel->item(32, 37)->setText(secs2String(sollT));
|
||||
m_lpYearlyListModel->item(33, 37)->setText(secs2String(istT));
|
||||
m_lpYearlyListModel->item(34, 37)->setText(secs2String(istT-sollT));
|
||||
if(istT-sollT < 0)
|
||||
m_lpYearlyListModel->item(34, 37)->setData(QBrush(Qt::red), Qt::ForegroundRole);
|
||||
|
||||
m_lpYearlyListModel->item(35, 37)->setText(QString::number(gT));
|
||||
m_lpYearlyListModel->item(36, 37)->setText(QString::number(kT));
|
||||
m_lpYearlyListModel->item(37, 37)->setText(QString::number(uT));
|
||||
m_lpYearlyListModel->item(38, 37)->setText(QString::number(restUrlaub));
|
||||
if(restUrlaub < 0)
|
||||
m_lpYearlyListModel->item(38, 37)->setData(QBrush(Qt::red), Qt::ForegroundRole);
|
||||
|
||||
m_lpYearlyListModel->item(39, 37)->setText(QString::number(suT));
|
||||
|
||||
m_loading = false;
|
||||
}
|
||||
|
||||
void cYearlyView::onPrevYear()
|
||||
{
|
||||
if(m_loading)
|
||||
return;
|
||||
|
||||
setDate(ui->m_lpYear->date().addMonths(-12));
|
||||
}
|
||||
|
||||
void cYearlyView::onNextYear()
|
||||
{
|
||||
if(m_loading)
|
||||
return;
|
||||
|
||||
setDate(ui->m_lpYear->date().addMonths(12));
|
||||
}
|
||||
|
||||
void cYearlyView::onDateChanged(const QDate& date)
|
||||
{
|
||||
if(m_loading)
|
||||
return;
|
||||
|
||||
m_loading = true;
|
||||
|
||||
setDate(date);
|
||||
|
||||
m_loading = false;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef CYEARLYVIEW_H
|
||||
#define CYEARLYVIEW_H
|
||||
|
||||
|
||||
#include "cmonthlybooking.h"
|
||||
#include "cmonthlyitemdelegate.h"
|
||||
#include "cpublicholiday.h"
|
||||
|
||||
#include "cbooking.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStandardItemModel>
|
||||
#include <QMap>
|
||||
#include <QTime>
|
||||
|
||||
#include <QRegExpValidator>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cYearlyView;
|
||||
}
|
||||
|
||||
class cYearlyView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit cYearlyView(const QDate& date, const QMap<QString, QString> code, cMonthlyBookingList* lpMonthlyBookingList, cPublicHoliday* lpPublicHoliday, cBookingList* lpBookingList, QWidget *parent = nullptr);
|
||||
~cYearlyView();
|
||||
|
||||
void setDate(const QDate& date);
|
||||
|
||||
private:
|
||||
Ui::cYearlyView* ui;
|
||||
bool m_loading;
|
||||
QStandardItemModel* m_lpYearlyListModel;
|
||||
QMap<QString, QString> m_code;
|
||||
cMonthlyBookingList* m_lpMonthlyBookingList;
|
||||
cPublicHoliday* m_lpPublicHoliday;
|
||||
cBookingList* m_lpBookingList;
|
||||
QDate m_date;
|
||||
cMonthlyBooking* m_lpMonthlyBooking;
|
||||
// QRegExpValidator* m_lpValidator;
|
||||
// QStringList m_temporaryFileList;
|
||||
|
||||
public slots:
|
||||
void onPrevYear();
|
||||
void onNextYear();
|
||||
void onDateChanged(const QDate& date);
|
||||
|
||||
};
|
||||
|
||||
#endif // CYEARLYVIEW_H
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cYearlyView</class>
|
||||
<widget class="QWidget" name="cYearlyView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>760</width>
|
||||
<height>456</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="m_lpPrevYear">
|
||||
<property name="text">
|
||||
<string><</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDateEdit" name="m_lpYear">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimumDateTime">
|
||||
<datetime>
|
||||
<hour>0</hour>
|
||||
<minute>0</minute>
|
||||
<second>0</second>
|
||||
<year>2016</year>
|
||||
<month>5</month>
|
||||
<day>1</day>
|
||||
</datetime>
|
||||
</property>
|
||||
<property name="currentSection">
|
||||
<enum>QDateTimeEdit::YearSection</enum>
|
||||
</property>
|
||||
<property name="displayFormat">
|
||||
<string>yyyy</string>
|
||||
</property>
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="m_lpNextYear">
|
||||
<property name="text">
|
||||
<string>></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>738</width>
|
||||
<height>404</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QTableView" name="m_lpYearlyList">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="cornerButtonEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+4
-1
@@ -52,6 +52,7 @@ SOURCES += \
|
||||
common.cpp \
|
||||
cpublicholiday.cpp \
|
||||
cvacation.cpp \
|
||||
cyearlyview.cpp \
|
||||
czeitnachweis.cpp \
|
||||
main.cpp \
|
||||
cmainwindow.cpp
|
||||
@@ -65,12 +66,14 @@ HEADERS += \
|
||||
cmonthlyview.h \
|
||||
common.h \
|
||||
cpublicholiday.h \
|
||||
cyearlyview.h \
|
||||
czeitnachweis.h \
|
||||
cvacation.h
|
||||
|
||||
FORMS += \
|
||||
cmainwindow.ui \
|
||||
cmonthlyview.ui
|
||||
cmonthlyview.ui \
|
||||
cyearlyview.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
|
||||
Reference in New Issue
Block a user