Überstunden Berechnung
This commit is contained in:
+9
-6
@@ -518,6 +518,8 @@ void cBookingList::recalculate(const QDate& date)
|
||||
if(i == begin())
|
||||
bFirst = true;
|
||||
|
||||
qint32 ueberstunden = 0;
|
||||
|
||||
for(;i != end(); i++)
|
||||
{
|
||||
cVacation* lpVacation = m_lpVacationList->find((*i)->date());
|
||||
@@ -526,12 +528,6 @@ void cBookingList::recalculate(const QDate& date)
|
||||
else
|
||||
(*i)->setVacation(oldVacation);
|
||||
|
||||
cMonthlyBooking* lpMonthlyBooking = m_lpMonthlyBookingList->find((*i)->date());
|
||||
qint32 ueberstunden = 0;
|
||||
|
||||
if(lpMonthlyBooking)
|
||||
ueberstunden = time2Secs(lpMonthlyBooking->ueberstunden());
|
||||
|
||||
if(bFirst)
|
||||
{
|
||||
bFirst = false;
|
||||
@@ -540,6 +536,13 @@ void cBookingList::recalculate(const QDate& date)
|
||||
else
|
||||
(*i)->setPrevDiff((*(i-1))->currentDiff()-ueberstunden);
|
||||
|
||||
cMonthlyBooking* lpMonthlyBooking = m_lpMonthlyBookingList->find((*i)->date());
|
||||
|
||||
if(lpMonthlyBooking)
|
||||
ueberstunden = lpMonthlyBooking->ueberstunden();
|
||||
else
|
||||
ueberstunden = 0;
|
||||
|
||||
oldVacation = (*i)->vacation();
|
||||
|
||||
if((*i)->code() == "U")
|
||||
|
||||
+1
-1
@@ -157,7 +157,7 @@ void cMainWindow::openDB()
|
||||
query.prepare("CREATE TABLE monthlyBooking "
|
||||
"( "
|
||||
" datum DATE PRIMARY KEY UNIQUE, "
|
||||
" ueberstunden TIME "
|
||||
" ueberstunden INTEGER "
|
||||
");");
|
||||
|
||||
if(!query.exec())
|
||||
|
||||
+5
-5
@@ -8,7 +8,7 @@
|
||||
cMonthlyBooking::cMonthlyBooking(const QDate& date, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_date(date),
|
||||
m_ueberstunden(QTime(0, 0, 0))
|
||||
m_ueberstunden(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ QDate cMonthlyBooking::date()
|
||||
return(m_date);
|
||||
}
|
||||
|
||||
void cMonthlyBooking::setUeberstunden(const QTime &time)
|
||||
void cMonthlyBooking::setUeberstunden(qint32 ueberstunden)
|
||||
{
|
||||
m_ueberstunden = time;
|
||||
m_ueberstunden = ueberstunden;
|
||||
}
|
||||
|
||||
QTime cMonthlyBooking::ueberstunden()
|
||||
qint32 cMonthlyBooking::ueberstunden()
|
||||
{
|
||||
return(m_ueberstunden);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ bool cMonthlyBookingList::load()
|
||||
|
||||
if(lpBooking)
|
||||
{
|
||||
lpBooking->setUeberstunden(query.value("ueberstunden").toTime());
|
||||
lpBooking->setUeberstunden(query.value("ueberstunden").toInt());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -18,14 +18,14 @@ public:
|
||||
|
||||
QDate date();
|
||||
|
||||
void setUeberstunden(const QTime& time);
|
||||
QTime ueberstunden();
|
||||
void setUeberstunden(qint32 ueberstunden);
|
||||
qint32 ueberstunden();
|
||||
|
||||
bool save();
|
||||
|
||||
private:
|
||||
QDate m_date;
|
||||
QTime m_ueberstunden;
|
||||
qint32 m_ueberstunden;
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
+12
-6
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
@@ -14,7 +15,8 @@ cMonthlyView::cMonthlyView(const QDate& date, cMonthlyBookingList* lpMonthlyBook
|
||||
m_lpPublicHoliday(lpPublicHoliday),
|
||||
m_lpBookingList(lpBookingList),
|
||||
m_date(date),
|
||||
m_lpMonthlyBooking(nullptr)
|
||||
m_lpMonthlyBooking(nullptr),
|
||||
m_lpValidator(nullptr)
|
||||
{
|
||||
m_code.insert(" ", tr(""));
|
||||
m_code.insert("G", tr("Gleitzeit"));
|
||||
@@ -25,6 +27,10 @@ cMonthlyView::cMonthlyView(const QDate& date, cMonthlyBookingList* lpMonthlyBook
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
QRegExp rx("(?:\\d\\d\\d):(?:[0-5]\\d):(?:[0-5]\\d)");
|
||||
m_lpValidator = new QRegExpValidator(rx, this);
|
||||
ui->m_lpUeberstunden->setValidator(m_lpValidator);
|
||||
|
||||
m_lpMonthlyListModel = new QStandardItemModel(0, 1);
|
||||
ui->m_lpMonthlyList->setModel(m_lpMonthlyListModel);
|
||||
|
||||
@@ -48,7 +54,7 @@ cMonthlyView::cMonthlyView(const QDate& date, cMonthlyBookingList* lpMonthlyBook
|
||||
connect(static_cast<cMonthlyItemDelegate*>(ui->m_lpMonthlyList->itemDelegate()), &cMonthlyItemDelegate::textChanged, this, &cMonthlyView::onTextChanged);
|
||||
|
||||
connect(ui->m_lpMonth, &QDateEdit::dateChanged, this, &cMonthlyView::onDateChanged);
|
||||
connect(ui->m_lpUeberstunden, &QTimeEdit::timeChanged, this, &cMonthlyView::onUeberstundenChanged);
|
||||
connect(ui->m_lpUeberstunden, &QLineEdit::textChanged, this, &cMonthlyView::onUeberstundenChanged);
|
||||
}
|
||||
|
||||
void cMonthlyView::setDate(const QDate& date)
|
||||
@@ -196,7 +202,7 @@ 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_lpUeberstunden->setTime(m_lpMonthlyBooking->ueberstunden());
|
||||
ui->m_lpUeberstunden->setText(secs2String(m_lpMonthlyBooking->ueberstunden(), 3));
|
||||
|
||||
displaySummary();
|
||||
|
||||
@@ -307,9 +313,9 @@ void cMonthlyView::onDateChanged(const QDate& date)
|
||||
setDate(date);
|
||||
}
|
||||
|
||||
void cMonthlyView::onUeberstundenChanged(const QTime& time)
|
||||
void cMonthlyView::onUeberstundenChanged(const QString& string)
|
||||
{
|
||||
m_lpMonthlyBooking->setUeberstunden(time);
|
||||
m_lpMonthlyBooking->setUeberstunden(string2Secs(string));
|
||||
m_lpMonthlyBooking->save();
|
||||
|
||||
displaySummary();
|
||||
@@ -412,7 +418,7 @@ void cMonthlyView::displaySummary()
|
||||
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-time2Secs(m_lpMonthlyBooking->ueberstunden())));
|
||||
ui->m_lpUebertragNaechsterMonat->setText(secs2String(lpFirstBooking->prevDiff()+ist-soll-m_lpMonthlyBooking->ueberstunden()));
|
||||
ui->m_lpResturlaub->setText(QString::number(lpFirstBooking->vacation()));
|
||||
ui->m_lpUebertragUrlaub->setText(QString::number(lpFirstBooking->vacation()-u));
|
||||
|
||||
|
||||
+4
-1
@@ -13,6 +13,8 @@
|
||||
#include <QMap>
|
||||
#include <QTime>
|
||||
|
||||
#include <QRegExpValidator>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cMonthlyView;
|
||||
@@ -37,6 +39,7 @@ private:
|
||||
cBookingList* m_lpBookingList;
|
||||
QDate m_date;
|
||||
cMonthlyBooking* m_lpMonthlyBooking;
|
||||
QRegExpValidator* m_lpValidator;
|
||||
|
||||
void setBackground(const int day, const QString& code);
|
||||
void setText(QStandardItem* lpItem, const QTime& time);
|
||||
@@ -48,7 +51,7 @@ private slots:
|
||||
void onTimeChanged(const int day, const int field, const QTime& time);
|
||||
void onTextChanged(const int day, const int field, const QString& text);
|
||||
void onDateChanged(const QDate& date);
|
||||
void onUeberstundenChanged(const QTime& time);
|
||||
void onUeberstundenChanged(const QString& string);
|
||||
};
|
||||
|
||||
#endif // CMONTHLYVIEW_H
|
||||
|
||||
+6
-13
@@ -110,19 +110,6 @@
|
||||
</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">
|
||||
@@ -378,6 +365,12 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QLineEdit" name="m_lpUeberstunden"/>
|
||||
</item>
|
||||
<item row="6" column="4">
|
||||
<widget class="QLineEdit" name="m_lpRegExpTest"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
+12
-2
@@ -5,9 +5,10 @@
|
||||
#include "common.h"
|
||||
|
||||
#include <QTime>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
QString secs2String(const qint32& secs)
|
||||
QString secs2String(const qint32& secs, qint8 leading)
|
||||
{
|
||||
QTime t;
|
||||
qint32 h = secs/3600;
|
||||
@@ -22,7 +23,16 @@ QString secs2String(const qint32& secs)
|
||||
else
|
||||
t = QTime(0, 0, 0).addSecs(secs);
|
||||
|
||||
return((neg ? "-" : "") + QString::number(h) + t.toString(":mm:ss"));
|
||||
return((neg ? "-" : "") + QString::number(h).rightJustified(leading, '0') + t.toString(":mm:ss"));
|
||||
}
|
||||
|
||||
qint32 string2Secs(const QString& string)
|
||||
{
|
||||
QStringList list = string.split(":");
|
||||
qint32 h = list[0].toInt();
|
||||
qint32 m = list[1].toInt();
|
||||
qint32 s = list[2].toInt();
|
||||
return(h*3600+m*60+s);
|
||||
}
|
||||
|
||||
qint32 time2Secs(const QTime& time)
|
||||
|
||||
Reference in New Issue
Block a user