initial commit

This commit is contained in:
2019-10-09 14:00:35 +02:00
parent cee60c1a25
commit 3b18cfe7fa
6 changed files with 431 additions and 28 deletions
+5 -1
View File
@@ -30,6 +30,9 @@ QWidget* cMonthlyItemDelegate::createEditor( QWidget *parent, const QStyleOption
}
case COL_CODE:
{
if(index.data(Qt::UserRole+1).toBool())
return(nullptr);
QComboBox* lpComboBox = new QComboBox(parent);
for(QMap<QString, QString>::const_iterator i = m_code.constBegin();i != m_code.constEnd();i++)
@@ -93,7 +96,8 @@ void cMonthlyItemDelegate::setModelData ( QWidget *editor, QAbstractItemModel *m
QTimeEdit* lpTimeEdit = qobject_cast<QTimeEdit*>(editor);
if(!lpTimeEdit->time().hour() &&
!lpTimeEdit->time().minute() &&
!lpTimeEdit->time().second())
!lpTimeEdit->time().second() &&
index.column() != COL_BREAK)
model->setData(index, "", Qt::EditRole);
else
model->setData(index, lpTimeEdit->time().toString(), Qt::EditRole);
+50 -2
View File
@@ -23,6 +23,15 @@ cMonthlyView::cMonthlyView(const QDate& date, QWidget *parent) :
ui->m_lpMonthlyList->setItemDelegate(new cMonthlyItemDelegate(m_code));
ui->m_lpGleitzeitLabel->setAutoFillBackground(true);
ui->m_lpGleitzeitLabel->setStyleSheet(QString("QLabel { background-color: rgba(%1, %2, %3, 255); }").arg(COLOR_GLEITZEIT.red()).arg(COLOR_GLEITZEIT.green()).arg(COLOR_GLEITZEIT.blue()));
ui->m_lpKrankLabel->setAutoFillBackground(true);
ui->m_lpKrankLabel->setStyleSheet(QString("QLabel { background-color: rgba(%1, %2, %3, 255); }").arg(COLOR_KRANK.red()).arg(COLOR_KRANK.green()).arg(COLOR_KRANK.blue()));
ui->m_lpUrlaubLabel->setAutoFillBackground(true);
ui->m_lpUrlaubLabel->setStyleSheet(QString("QLabel { background-color: rgba(%1, %2, %3, 255); }").arg(COLOR_URLAUB.red()).arg(COLOR_URLAUB.green()).arg(COLOR_URLAUB.blue()));
ui->m_lpSonderurlaubLabel->setAutoFillBackground(true);
ui->m_lpSonderurlaubLabel->setStyleSheet(QString("QLabel { background-color: rgba(%1, %2, %3, 255); }").arg(COLOR_SONDERURLAUB.red()).arg(COLOR_SONDERURLAUB.green()).arg(COLOR_SONDERURLAUB.blue()));
setDate(date);
connect(static_cast<cMonthlyItemDelegate*>(ui->m_lpMonthlyList->itemDelegate()), &cMonthlyItemDelegate::timeChanged, this, &cMonthlyView::onTimeChanged);
@@ -53,9 +62,9 @@ void cMonthlyView::setDate(const QDate& date)
items[COL_CODE]->setText("");
items[COL_IS]->setText("00:00:00");
items[COL_SHOULD]->setText("00:00:00");
items[COL_DIFF]->setText("00:00:00");
items[COL_DIFF]->setText("+00:00:00");
items[COL_INFORMATION]->setText("");
items[COL_CURRENT]->setText("00:00:00");
items[COL_CURRENT]->setText("+00:00:00");
items[COL_HOURS_DEC]->setText("0.0");
items[COL_DAY2]->setText("99");
@@ -66,6 +75,7 @@ void cMonthlyView::setDate(const QDate& date)
m_lpMonthlyListModel->removeRows(0, 1);
QBrush weekend = QBrush(COLOR_WEEKEND);
QDate date1 = date;
date1.setDate(date.year(), date.month(), 1);
@@ -112,10 +122,27 @@ void cMonthlyView::setDate(const QDate& date)
items[COL_HOURS_DEC]->setTextAlignment(Qt::AlignRight);
items[COL_DAY2]->setTextAlignment(Qt::AlignLeft);
for(int z = 0;z < items.count();z++)
{
if(date1.dayOfWeek() >= 6)
{
items[z]->setData(QVariant::fromValue(true), Qt::UserRole+1);
items[z]->setBackground(weekend);
}
else
items[z]->setData(QVariant::fromValue(false), Qt::UserRole+1);
}
m_lpMonthlyListModel->appendRow(items);
}
ui->m_lpMonthlyList->resizeColumnToContents(COL_DAY1);
ui->m_lpMonthlyList->resizeColumnToContents(COL_DAY2);
ui->m_lpUebertragLabel->setText(QString(tr("Übertrag %1:")).arg(date.addMonths(-1).toString("MMMM yyyy")));
ui->m_lpShouldLabel->setText(QString(tr("SOLL Arbeitszeit (%1):")).arg(date.toString("MMMM yyyy")));
ui->m_lpIsLabel->setText(QString(tr("IST Arbeitszeit (%1):")).arg(date.toString("MMMM yyyy")));
ui->m_lpResturlaubLabel->setText(QString(tr("Resturlaub %1:")).arg(date.addMonths(-1).toString("MMMM yyyy")));
ui->m_lpRestSonderurlaubLabel->setText(QString(tr("Sonderurlaub %1:")).arg(date.addMonths(-1).toString("MMMM yyyy")));
}
cMonthlyView::~cMonthlyView()
@@ -135,4 +162,25 @@ void cMonthlyView::onTextChanged(const int day, const int field, const QString&
qDebug() << "Day: " << day;
qDebug() << "field: " << field;
qDebug() << "time: " << text;
if(field == COL_CODE)
{
QBrush brush;
QString code = m_code.key(text);
if(code == "G")
brush = QBrush(COLOR_GLEITZEIT);
else if(code == "U")
brush = QBrush(COLOR_URLAUB);
else if(code == "K")
brush = QBrush(COLOR_KRANK);
else if(code == "SU")
brush = QBrush(COLOR_SONDERURLAUB);
for(int x = 0;x < m_lpMonthlyListModel->columnCount();x++)
{
QStandardItem* lpItem = m_lpMonthlyListModel->item(day-1, x);
lpItem->setBackground(brush);
}
}
}
+283 -22
View File
@@ -6,42 +6,303 @@
<rect>
<x>0</x>
<y>0</y>
<width>996</width>
<width>883</width>
<height>525</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<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>976</width>
<height>505</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QVBoxLayout" name="verticalLayout">
<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>861</width>
<height>241</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTreeView" name="m_lpMonthlyList">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout" columnstretch="10,1,1,5,1,1,100">
<item row="6" column="1">
<widget class="QLabel" name="m_lpResturlaubLabel">
<property name="text">
<string>Resturlaub:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QTreeView" name="m_lpMonthlyList">
<property name="alternatingRowColors">
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QLineEdit" name="m_lpSonderurlaub">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="m_lpSaldo">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLineEdit" name="m_lpGleitzeit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="m_lpUeberstundenLabel">
<property name="text">
<string>ausbezahlte Überstunden:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="6">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1">
<widget class="QLabel" name="m_lpUebertragNaechsterMonatLabel">
<property name="text">
<string>Übertrag nächster Monat:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLineEdit" name="m_lpKrank">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="m_lpIsLabel">
<property name="text">
<string>IST:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="m_lpRestSonderurlaubLabel">
<property name="text">
<string>Sonderurlaub:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="m_lpUebertragUrlaubLabel">
<property name="text">
<string>Übertrag Urlaub:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="m_lpSaldoLabel">
<property name="text">
<string>Saldo:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="m_lpUebertrag">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLabel" name="m_lpGleitzeitLabel">
<property name="text">
<string>Gleitzeit</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QLabel" name="m_lpKrankLabel">
<property name="text">
<string>Krank</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="m_lpShouldLabel">
<property name="text">
<string>SOLL:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="5">
<widget class="QLabel" name="m_lpUrlaubLabel">
<property name="text">
<string>Urlaub</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QLineEdit" name="m_lpUrlaub">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="m_lpUebertragLabel">
<property name="text">
<string>Übertrag:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="m_lpShould">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="m_lpIs">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="5">
<widget class="QLabel" name="m_lpSonderurlaubLabel">
<property name="text">
<string>Sonderurlaub</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLabel" name="m_lpSonderurlaubUebertragLabel">
<property name="text">
<string>Übertrag Sonderurlaub:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLineEdit" name="m_lpUebertragNaechsterMonat">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLineEdit" name="m_lpResturlaub">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLineEdit" name="m_lpUebertragUrlaub">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLineEdit" name="m_lpRestSonderurlaub">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QLineEdit" name="m_lpSonderurlaubUebertrag">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QTimeEdit" name="m_lpUeberstunden">
<property name="displayFormat">
<string>HH:mm:ss</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_3">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
+8
View File
@@ -2,6 +2,9 @@
#define COMMON_H
#include <QColor>
#define COL_DAY1 0
#define COL_PUBLIC_HOLIDAY 1
#define COL_COME1 2
@@ -20,5 +23,10 @@
#define COL_HOURS_DEC 15
#define COL_DAY2 16
#define COLOR_GLEITZEIT QColor(191, 191, 255)
#define COLOR_URLAUB QColor(127, 127, 255)
#define COLOR_SONDERURLAUB QColor(127, 127, 255)
#define COLOR_KRANK QColor(Qt::yellow)
#define COLOR_WEEKEND QColor(255, 165, 0)
#endif // COMMON_H
+33 -2
View File
@@ -1,7 +1,38 @@
#include "cpublicholiday.h"
#include <QObject>
cPublicHoliday::cPublicHoliday()
cPublicHoliday::cPublicHoliday(qint16 year) :
m_year(year)
{
m_holidays.insert(ostersonntag(), QObject::tr("Ostersonntag"));
}
bool cPublicHoliday::isPublicHoliday(const QDate& date)
{
return(m_holidays.contains(date));
}
QString cPublicHoliday::name(const QDate& date)
{
return(m_holidays.value(date, ""));
}
QDate cPublicHoliday::ostersonntag()
{
int a = m_year % 19;
int b = m_year / 100;
int c = m_year % 100;
int e = b % 4;
int f = (b + 8) / 25;
int g = (b - f + 1) / 3;
int h = (19 * a + b - (b/4) - g + 15) % 30;
int k = c % 4;
int l = (32 + 2 * e + 2 * (c / 4) - h - k) % 7;
int m = (a + 11 * h + 22 * l) / 451;
int nMonth = (h + l - 7 * m + 114) / 31;
int nDay = (h + l - 7 * m + 114) % 31 + 1;
return(QDate(m_year, nMonth, nDay));
}
+52 -1
View File
@@ -2,10 +2,61 @@
#define CPUBLICHOLIDAY_H
#include <QString>
#include <QDate>
#include <QMap>
class cPublicHoliday
{
public:
cPublicHoliday();
cPublicHoliday(qint16 year);
bool isPublicHoliday(const QDate& date);
QString name(const QDate& date);
private:
qint16 m_year;
QMap<QDate, QString> m_holidays;
QDate neujahr();
QDate heilige3Koenige();
QDate karfreitag();
QDate ostersonntag();
QDate ostermontag();
QDate staatsfeiertag1();
QDate christiHimmelfahrt();
QDate pfingstsonntag();
QDate pfingstMontag();
QDate fronleichnam();
QDate mariaHimmelfahrt();
QDate staatsfeiertag();
QDate allerheiligen();
QDate silvester();
};
/*
1,1,jahr, "Neujahr (18 Uhr)"
6,1,jahr, "Hl. Drei Könige"
14,7,jahr, "Sel. Bernhard"
15,8,jahr, "Mariä Himmelfahrt"
1,11,jahr, "Allerheiligen"
8,12,jahr, "Maria Empfängnis"
24,12,jahr, "Heilig Abend"
25,12,jahr, "1.Weihnachtsfeiertag"
26,12,jahr, "2.Weihnachtsfeiertag"
// von Ostern abhängige Feiertage
Ostern-46, "Aschermittwoch"
Ostern-7, "Palmsonntag"
Ostern-3, "Gründonnerstag"
Ostern-2, "Karfreitag"
Ostern-1, "Karsamstag"
Ostern, "Ostersonntag"
Ostern+1, "Ostermontag"
Ostern+39, "Christi Himmelfahrt"
Ostern+49, "Pfingstsonntag"
Ostern+50, "Pfingstmontag"
Ostern+60, "Fronleichnam"
*/
#endif // CPUBLICHOLIDAY_H