calculations
This commit is contained in:
+48
-34
@@ -195,12 +195,19 @@ void cBooking::setSoll(const QTime& time)
|
||||
m_soll = time;
|
||||
}
|
||||
|
||||
qint32 cBooking::sollSecs()
|
||||
{
|
||||
QTime t = soll();
|
||||
int s = t.hour()*3600+t.minute()*60+t.second();
|
||||
|
||||
return(s);
|
||||
}
|
||||
|
||||
QTime cBooking::soll()
|
||||
{
|
||||
if(code() == "G" ||
|
||||
code() == "K" ||
|
||||
code() == "U" ||
|
||||
code() == "SU")
|
||||
if(code() == "K" ||
|
||||
code() == "U" ||
|
||||
code() == "SU")
|
||||
return(QTime(0, 0, 0));
|
||||
|
||||
return(m_soll);
|
||||
@@ -218,19 +225,8 @@ qint32 cBooking::diff()
|
||||
|
||||
QString cBooking::diffString()
|
||||
{
|
||||
QTime t;
|
||||
qint32 d = diff();
|
||||
bool bNeg = false;
|
||||
|
||||
if(d < 0)
|
||||
{
|
||||
t = QTime(0, 0, 0).addSecs(-d);
|
||||
bNeg = true;
|
||||
}
|
||||
else
|
||||
t = QTime(0, 0, 0).addSecs(d);
|
||||
|
||||
return((bNeg ? "-" : "") + t.toString("hh:mm:ss"));
|
||||
return(secs2String(d));
|
||||
}
|
||||
|
||||
void cBooking::setPrevDiff(qint32 diff)
|
||||
@@ -243,6 +239,12 @@ qint32 cBooking::prevDiff()
|
||||
return(m_prevDiff);
|
||||
}
|
||||
|
||||
QString cBooking::prevDiffString()
|
||||
{
|
||||
qint32 d = prevDiff();
|
||||
return(secs2String(d));
|
||||
}
|
||||
|
||||
qint32 cBooking::currentDiff()
|
||||
{
|
||||
return(prevDiff()+diff());
|
||||
@@ -250,21 +252,8 @@ qint32 cBooking::currentDiff()
|
||||
|
||||
QString cBooking::currentDiffString()
|
||||
{
|
||||
QTime t;
|
||||
qint32 d = currentDiff();
|
||||
bool bNeg = false;
|
||||
|
||||
if(d < 0)
|
||||
{
|
||||
t = QTime(0, 0, 0).addSecs(-d);
|
||||
bNeg = true;
|
||||
}
|
||||
else
|
||||
t = QTime(0, 0, 0).addSecs(d);
|
||||
|
||||
qint32 h = d / 3600;
|
||||
|
||||
return(QString::number(h) + t.toString(":mm:ss"));
|
||||
return(secs2String(d));
|
||||
}
|
||||
|
||||
qreal cBooking::hoursDecimal()
|
||||
@@ -274,6 +263,16 @@ qreal cBooking::hoursDecimal()
|
||||
return(static_cast<qreal>(w)/3600);
|
||||
}
|
||||
|
||||
void cBooking::setVacation(qint16 vac)
|
||||
{
|
||||
m_vacation = vac;
|
||||
}
|
||||
|
||||
qint16 cBooking::vacation()
|
||||
{
|
||||
return(m_vacation);
|
||||
}
|
||||
|
||||
bool cBooking::save()
|
||||
{
|
||||
QSqlQuery query;
|
||||
@@ -377,9 +376,10 @@ int cBooking::totalPause()
|
||||
return(geht1().secsTo(kommt2()) + geht2().secsTo(kommt3()) + geht3().secsTo(kommt4()) + geht4().secsTo(kommt5()));
|
||||
}
|
||||
|
||||
cBookingList::cBookingList(cPublicHoliday* lpPublicHoliday, cDailyWorkingList* lpDailyWorkingList) :
|
||||
cBookingList::cBookingList(cPublicHoliday* lpPublicHoliday, cDailyWorkingList* lpDailyWorkingList, cVacationList* lpVacationList) :
|
||||
m_lpPublicHoliday(lpPublicHoliday),
|
||||
m_lpDailyWorkingList(lpDailyWorkingList)
|
||||
m_lpDailyWorkingList(lpDailyWorkingList),
|
||||
m_lpVacationList(lpVacationList)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -487,8 +487,9 @@ void cBookingList::recalculate(const QDate& date)
|
||||
{
|
||||
sort();
|
||||
|
||||
bool bFirst = false;
|
||||
cBookingList::iterator i = begin();
|
||||
bool bFirst = false;
|
||||
cBookingList::iterator i = begin();
|
||||
qint16 oldVacation = 0;
|
||||
|
||||
if(!date.isNull() && date.isValid())
|
||||
{
|
||||
@@ -496,6 +497,8 @@ void cBookingList::recalculate(const QDate& date)
|
||||
{
|
||||
if((*i)->date() >= date)
|
||||
break;
|
||||
|
||||
oldVacation = (*i)->vacation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,6 +510,12 @@ void cBookingList::recalculate(const QDate& date)
|
||||
|
||||
for(;i != end(); i++)
|
||||
{
|
||||
cVacation* lpVacation = m_lpVacationList->find((*i)->date());
|
||||
if(lpVacation)
|
||||
(*i)->setVacation(oldVacation + lpVacation->days());
|
||||
else
|
||||
(*i)->setVacation(oldVacation);
|
||||
|
||||
if(bFirst)
|
||||
{
|
||||
bFirst = false;
|
||||
@@ -514,5 +523,10 @@ void cBookingList::recalculate(const QDate& date)
|
||||
}
|
||||
else
|
||||
(*i)->setPrevDiff((*(i-1))->currentDiff());
|
||||
|
||||
oldVacation = (*i)->vacation();
|
||||
|
||||
if((*i)->code() == "U")
|
||||
oldVacation--;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "cpublicholiday.h"
|
||||
#include "cdailyworking.h"
|
||||
#include "cvacation.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
@@ -66,6 +67,7 @@ public:
|
||||
QTime ist();
|
||||
|
||||
void setSoll(const QTime& time);
|
||||
qint32 sollSecs();
|
||||
QTime soll();
|
||||
|
||||
qint32 diff();
|
||||
@@ -73,12 +75,16 @@ public:
|
||||
|
||||
void setPrevDiff(qint32 diff);
|
||||
qint32 prevDiff();
|
||||
QString prevDiffString();
|
||||
|
||||
qint32 currentDiff();
|
||||
QString currentDiffString();
|
||||
|
||||
qreal hoursDecimal();
|
||||
|
||||
void setVacation(qint16 vac);
|
||||
qint16 vacation();
|
||||
|
||||
bool save();
|
||||
private:
|
||||
QDate m_date;
|
||||
@@ -96,6 +102,7 @@ private:
|
||||
QString m_information;
|
||||
QTime m_soll;
|
||||
qint32 m_prevDiff;
|
||||
qint16 m_vacation;
|
||||
|
||||
void bind(QSqlQuery& query, const QString& variable, const QTime& time);
|
||||
|
||||
@@ -108,7 +115,7 @@ Q_DECLARE_METATYPE(cBooking*)
|
||||
class cBookingList : public QList<cBooking*>
|
||||
{
|
||||
public:
|
||||
explicit cBookingList(cPublicHoliday* lpPublicHoliday, cDailyWorkingList* lpDailyWorkingList);
|
||||
explicit cBookingList(cPublicHoliday* lpPublicHoliday, cDailyWorkingList* lpDailyWorkingList, cVacationList* lpVacationList);
|
||||
bool load();
|
||||
cBooking* add(const QDate& date);
|
||||
cBooking* find(const QDate& date);
|
||||
@@ -118,6 +125,7 @@ public:
|
||||
private:
|
||||
cPublicHoliday* m_lpPublicHoliday;
|
||||
cDailyWorkingList* m_lpDailyWorkingList;
|
||||
cVacationList* m_lpVacationList;
|
||||
};
|
||||
|
||||
#endif // CBOOKING_H
|
||||
|
||||
+18
-1
@@ -21,8 +21,9 @@ cMainWindow::cMainWindow(QWidget *parent) :
|
||||
{
|
||||
openDB();
|
||||
m_dailyWorkingList.load();
|
||||
m_vacationList.load();
|
||||
|
||||
m_lpBookingList = new cBookingList(&m_publicHoliday, &m_dailyWorkingList);
|
||||
m_lpBookingList = new cBookingList(&m_publicHoliday, &m_dailyWorkingList, &m_vacationList);
|
||||
m_lpBookingList->load();
|
||||
|
||||
initUI();
|
||||
@@ -149,4 +150,20 @@ void cMainWindow::openDB()
|
||||
}
|
||||
qDebug() << "CREATE TABLE booking";
|
||||
}
|
||||
|
||||
if(!m_db.tables().contains("vacation"))
|
||||
{
|
||||
query.prepare("CREATE TABLE vacation "
|
||||
"( "
|
||||
" ab DATE PRIMARY KEY UNIQUE, "
|
||||
" days INTEGER "
|
||||
");");
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << "CREATE TABLE vacation: " << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
qDebug() << "CREATE TABLE vacation";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "cmonthlyview.h"
|
||||
#include "cdailyworking.h"
|
||||
#include "cvacation.h"
|
||||
#include "cpublicholiday.h"
|
||||
#include "cbooking.h"
|
||||
|
||||
@@ -31,6 +32,7 @@ private:
|
||||
QSqlDatabase m_db;
|
||||
cPublicHoliday m_publicHoliday;
|
||||
cDailyWorkingList m_dailyWorkingList;
|
||||
cVacationList m_vacationList;
|
||||
cBookingList* m_lpBookingList;
|
||||
|
||||
|
||||
|
||||
+54
-1
@@ -186,7 +186,8 @@ void cMonthlyView::setDate(const QDate& date)
|
||||
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")));
|
||||
|
||||
displaySummary();
|
||||
|
||||
m_loading = false;
|
||||
}
|
||||
@@ -349,4 +350,56 @@ void cMonthlyView::recalculate(int day, int /*field*/)
|
||||
cBooking* lpCurrentBooking = lpCurrentDiffItem->data(DATA_BOOKING).value<cBooking*>();
|
||||
lpCurrentDiffItem->setText(lpCurrentBooking->currentDiffString());
|
||||
}
|
||||
|
||||
displaySummary();
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
qint32 soll = 0;
|
||||
qint32 ist = 0;
|
||||
qint16 g = 0;
|
||||
qint16 k = 0;
|
||||
qint16 u = 0;
|
||||
qint16 su = 0;
|
||||
qint16 t = 0;
|
||||
for(int i = 0;i < m_lpMonthlyListModel->rowCount();i++)
|
||||
{
|
||||
cBooking* lpBooking = m_lpMonthlyListModel->item(i, 0)->data(DATA_BOOKING).value<cBooking*>();
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
ui->m_lpShould->setText(secs2String(soll));
|
||||
ui->m_lpIs->setText(secs2String(ist));
|
||||
ui->m_lpSaldo->setText(secs2String(ist-soll));
|
||||
ui->m_lpUebertragNaechsterMonat->setText(secs2String(lpFirstBooking->prevDiff()+ist-soll));
|
||||
ui->m_lpResturlaub->setText(QString::number(lpFirstBooking->vacation()));
|
||||
ui->m_lpUebertragUrlaub->setText(QString::number(lpFirstBooking->vacation()-u));
|
||||
|
||||
ui->m_lpGleitzeit->setText(QString::number(g));
|
||||
ui->m_lpKrank->setText(QString::number(k));
|
||||
ui->m_lpUrlaub->setText(QString::number(u));
|
||||
ui->m_lpSonderurlaub->setText(QString::number(su));
|
||||
ui->m_lpTraining->setText(QString::number(t));
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ private:
|
||||
void setText(QStandardItem* lpItem, const QTime& time);
|
||||
|
||||
void recalculate(int day, int field);
|
||||
void displaySummary();
|
||||
|
||||
private slots:
|
||||
void onTimeChanged(const int day, const int field, const QTime& time);
|
||||
|
||||
+202
-190
@@ -83,7 +83,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>861</width>
|
||||
<height>211</height>
|
||||
<height>263</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
@@ -103,10 +103,157 @@
|
||||
</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">
|
||||
<item row="3" column="5">
|
||||
<widget class="QLabel" name="m_lpSonderurlaubLabel">
|
||||
<property name="text">
|
||||
<string>Resturlaub:</string>
|
||||
<string>Sonderurlaub</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QTimeEdit" name="m_lpUeberstunden">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="displayFormat">
|
||||
<string>HH:mm:ss</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QLineEdit" name="m_lpGleitzeit">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QLineEdit" name="m_lpResturlaub">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QLineEdit" name="m_lpSonderurlaub">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</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="4" column="4">
|
||||
<widget class="QLineEdit" name="m_lpTraining">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<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="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</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="2" column="2">
|
||||
<widget class="QLineEdit" name="m_lpIs">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QLineEdit" name="m_lpUebertragNaechsterMonat">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<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="2" column="4">
|
||||
<widget class="QLineEdit" name="m_lpUrlaub">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="5">
|
||||
<widget class="QLabel" name="m_lpTrainingLabel">
|
||||
<property name="text">
|
||||
<string>Training</string>
|
||||
</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>
|
||||
@@ -120,31 +267,44 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QLineEdit" name="m_lpSonderurlaub">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</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">
|
||||
<item row="2" column="5">
|
||||
<widget class="QLabel" name="m_lpUrlaubLabel">
|
||||
<property name="text">
|
||||
<string>ausbezahlte Überstunden:</string>
|
||||
<string>Urlaub</string>
|
||||
</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="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="0" column="2">
|
||||
<widget class="QLineEdit" name="m_lpUebertrag">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</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>
|
||||
@@ -164,191 +324,46 @@
|
||||
</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="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<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>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLineEdit" name="m_lpSaldo">
|
||||
<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">
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="m_lpResturlaubLabel">
|
||||
<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>
|
||||
<string>Resturlaub:</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="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<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">
|
||||
@@ -356,13 +371,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<widget class="QLineEdit" name="m_lpTraining"/>
|
||||
</item>
|
||||
<item row="4" column="5">
|
||||
<widget class="QLabel" name="m_lpTrainingLabel">
|
||||
<item row="1" column="5">
|
||||
<widget class="QLabel" name="m_lpKrankLabel">
|
||||
<property name="text">
|
||||
<string>Training</string>
|
||||
<string>Krank</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QTime>
|
||||
|
||||
|
||||
QString secs2String(const qint32& secs)
|
||||
{
|
||||
QTime t;
|
||||
qint32 h = secs/3600;
|
||||
|
||||
if(secs < 0)
|
||||
t = QTime(0, 0, 0).addSecs(-secs);
|
||||
else
|
||||
t = QTime(0, 0, 0).addSecs(secs);
|
||||
|
||||
return(QString::number(h) + t.toString(":mm:ss"));
|
||||
}
|
||||
|
||||
#endif //COMMON_H
|
||||
@@ -2,6 +2,7 @@
|
||||
#define COMMON_H
|
||||
|
||||
|
||||
#include <QString>
|
||||
#include <QColor>
|
||||
|
||||
|
||||
@@ -37,4 +38,8 @@
|
||||
#define COLOR_TRAINING QColor(Qt::red)
|
||||
#define COLOR_WEEKEND QColor(255, 165, 0)
|
||||
|
||||
|
||||
QString secs2String(const qint32& secs);
|
||||
|
||||
|
||||
#endif // COMMON_H
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
#include "cvacation.h"
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
cVacation::cVacation(const QDate& date, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_date(date),
|
||||
m_days(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QDate cVacation::date()
|
||||
{
|
||||
return(m_date);
|
||||
}
|
||||
|
||||
void cVacation::setDays(qint16 days)
|
||||
{
|
||||
m_days = days;
|
||||
}
|
||||
|
||||
qint16 cVacation::days()
|
||||
{
|
||||
return(m_days);
|
||||
}
|
||||
|
||||
bool cVacationList::load()
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT ab, "
|
||||
" days "
|
||||
"FROM vacation "
|
||||
"ORDER BY ab;");
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << "SELECT FROM vacation: " << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
cVacation* lpVacation = add(query.value("ab").toDate());
|
||||
|
||||
if(lpVacation)
|
||||
{
|
||||
lpVacation->setDays(static_cast<qint16>(query.value("days").toInt()));
|
||||
}
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
cVacation* cVacationList::add(const QDate& date)
|
||||
{
|
||||
if(find(date))
|
||||
return(nullptr);
|
||||
|
||||
cVacation* lpVacation = new cVacation(date);
|
||||
append(lpVacation);
|
||||
return(lpVacation);
|
||||
}
|
||||
|
||||
cVacation* cVacationList::find(const QDate& date)
|
||||
{
|
||||
for(cVacationList::iterator i = begin();i != end(); i++)
|
||||
{
|
||||
if((*i)->date() == date)
|
||||
return(*i);
|
||||
}
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
cVacation* cVacationList::get(const QDate& date)
|
||||
{
|
||||
for(cVacationList::iterator i = begin();i != end(); i++)
|
||||
{
|
||||
if((*i)->date() <= date)
|
||||
return(*i);
|
||||
}
|
||||
return(nullptr);
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#ifndef CVACATION_H
|
||||
#define CVACATION_H
|
||||
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QDate>
|
||||
|
||||
|
||||
class cVacation : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit cVacation(const QDate& date, QObject *parent = nullptr);
|
||||
|
||||
QDate date();
|
||||
|
||||
void setDays(qint16 days);
|
||||
qint16 days();
|
||||
|
||||
private:
|
||||
QDate m_date;
|
||||
qint16 m_days;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cVacation*)
|
||||
|
||||
class cVacationList : public QList<cVacation*>
|
||||
{
|
||||
public:
|
||||
bool load();
|
||||
cVacation* add(const QDate& date);
|
||||
cVacation* find(const QDate& date);
|
||||
cVacation* get(const QDate& date);
|
||||
};
|
||||
|
||||
#endif // CVACATION_H
|
||||
+4
-1
@@ -29,7 +29,9 @@ SOURCES += \
|
||||
cdailyworking.cpp \
|
||||
cmonthlyitemdelegate.cpp \
|
||||
cmonthlyview.cpp \
|
||||
common.cpp \
|
||||
cpublicholiday.cpp \
|
||||
cvacation.cpp \
|
||||
main.cpp \
|
||||
cmainwindow.cpp
|
||||
|
||||
@@ -40,7 +42,8 @@ HEADERS += \
|
||||
cmonthlyitemdelegate.h \
|
||||
cmonthlyview.h \
|
||||
common.h \
|
||||
cpublicholiday.h
|
||||
cpublicholiday.h \
|
||||
cvacation.h
|
||||
|
||||
FORMS += \
|
||||
cmainwindow.ui \
|
||||
|
||||
Reference in New Issue
Block a user