initial release
This commit is contained in:
+387
@@ -0,0 +1,387 @@
|
|||||||
|
#include "cbooking.h"
|
||||||
|
|
||||||
|
#include <QSqlQuery>
|
||||||
|
#include <QSqlError>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
|
cBooking::cBooking(const QDate& date, QObject* parent) :
|
||||||
|
QObject(parent),
|
||||||
|
m_date(date),
|
||||||
|
m_kommt1(QTime()),
|
||||||
|
m_geht1(QTime()),
|
||||||
|
m_kommt2(QTime()),
|
||||||
|
m_geht2(QTime()),
|
||||||
|
m_kommt3(QTime()),
|
||||||
|
m_geht3(QTime()),
|
||||||
|
m_kommt4(QTime()),
|
||||||
|
m_geht4(QTime()),
|
||||||
|
m_kommt5(QTime()),
|
||||||
|
m_geht5(QTime()),
|
||||||
|
m_code(""),
|
||||||
|
m_information(""),
|
||||||
|
m_soll(QTime()),
|
||||||
|
m_prevDiff(0)
|
||||||
|
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cBooking::date()
|
||||||
|
{
|
||||||
|
return(m_date);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cBooking::setKommt1(const QTime& time)
|
||||||
|
{
|
||||||
|
m_kommt1 = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime cBooking::kommt1()
|
||||||
|
{
|
||||||
|
return(m_kommt1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cBooking::setGeht1(const QTime& time)
|
||||||
|
{
|
||||||
|
m_geht1 = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime cBooking::geht1()
|
||||||
|
{
|
||||||
|
return(m_geht1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cBooking::setKommt2(const QTime& time)
|
||||||
|
{
|
||||||
|
m_kommt2 = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime cBooking::kommt2()
|
||||||
|
{
|
||||||
|
return(m_kommt2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cBooking::setGeht2(const QTime& time)
|
||||||
|
{
|
||||||
|
m_geht2 = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime cBooking::geht2()
|
||||||
|
{
|
||||||
|
return(m_geht2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cBooking::setKommt3(const QTime& time)
|
||||||
|
{
|
||||||
|
m_kommt3 = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime cBooking::kommt3()
|
||||||
|
{
|
||||||
|
return(m_kommt3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cBooking::setGeht3(const QTime& time)
|
||||||
|
{
|
||||||
|
m_geht3 = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime cBooking::geht3()
|
||||||
|
{
|
||||||
|
return(m_geht3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cBooking::setKommt4(const QTime& time)
|
||||||
|
{
|
||||||
|
m_kommt4 = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime cBooking::kommt4()
|
||||||
|
{
|
||||||
|
return(m_kommt4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cBooking::setGeht4(const QTime& time)
|
||||||
|
{
|
||||||
|
m_geht4 = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime cBooking::geht4()
|
||||||
|
{
|
||||||
|
return(m_geht4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cBooking::setKommt5(const QTime& time)
|
||||||
|
{
|
||||||
|
m_kommt5 = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime cBooking::kommt5()
|
||||||
|
{
|
||||||
|
return(m_kommt5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cBooking::setGeht5(const QTime& time)
|
||||||
|
{
|
||||||
|
m_geht5 = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime cBooking::geht5()
|
||||||
|
{
|
||||||
|
return(m_geht5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cBooking::setCode(const QString& code)
|
||||||
|
{
|
||||||
|
m_code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cBooking::code()
|
||||||
|
{
|
||||||
|
return(m_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cBooking::setInformation(const QString& information)
|
||||||
|
{
|
||||||
|
m_information = information;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cBooking::information()
|
||||||
|
{
|
||||||
|
return(m_information);
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime cBooking::pause()
|
||||||
|
{
|
||||||
|
return(QTime(0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime cBooking::ist()
|
||||||
|
{
|
||||||
|
return(QTime(0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void cBooking::setSoll()
|
||||||
|
{
|
||||||
|
m_soll = QTime(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime cBooking::soll()
|
||||||
|
{
|
||||||
|
return(m_soll);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint32 cBooking::diff()
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cBooking::diffString()
|
||||||
|
{
|
||||||
|
QTime t;
|
||||||
|
qint32 d = diff();
|
||||||
|
bool bNeg = false;
|
||||||
|
|
||||||
|
if(d < 0)
|
||||||
|
{
|
||||||
|
t = QTime(0, 0, 0, d*1000);
|
||||||
|
bNeg = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
t = QTime(0, 0, 0, d*1000);
|
||||||
|
|
||||||
|
return(bNeg ? "-" : "" + t.toString("hh:mm:ss"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void cBooking::setPrevDiff(qint32 diff)
|
||||||
|
{
|
||||||
|
m_prevDiff = diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
qint32 cBooking::prevDiff()
|
||||||
|
{
|
||||||
|
return(m_prevDiff);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint32 cBooking::currentDiff()
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cBooking::currentDiffString()
|
||||||
|
{
|
||||||
|
QTime t;
|
||||||
|
qint32 d = currentDiff();
|
||||||
|
bool bNeg = false;
|
||||||
|
|
||||||
|
if(d < 0)
|
||||||
|
{
|
||||||
|
t = QTime(0, 0, 0, d*1000);
|
||||||
|
bNeg = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
t = QTime(0, 0, 0, d*1000);
|
||||||
|
|
||||||
|
return(bNeg ? "-" : "" + t.toString("hh:mm:ss"));
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal cBooking::hoursDecimal()
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cBooking::save()
|
||||||
|
{
|
||||||
|
QSqlQuery query;
|
||||||
|
|
||||||
|
query.prepare("SELECT datum FROM booking WHERE datum=:datum;");
|
||||||
|
query.bindValue(":datum", m_date);
|
||||||
|
|
||||||
|
if(!query.exec())
|
||||||
|
{
|
||||||
|
qDebug() << "Save: " << query.lastError().text();
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(query.next())
|
||||||
|
query.prepare("UPDATE booking "
|
||||||
|
"SET kommt1=:kommt1, "
|
||||||
|
" geht1=:geht1, "
|
||||||
|
" kommt2=:kommt2, "
|
||||||
|
" geht2=:geht2, "
|
||||||
|
" kommt3=:kommt3, "
|
||||||
|
" geht3=:geht3, "
|
||||||
|
" kommt4=:kommt4, "
|
||||||
|
" geht4=:geht4, "
|
||||||
|
" kommt5=:kommt5, "
|
||||||
|
" geht5=:geht5, "
|
||||||
|
" code=:code, "
|
||||||
|
" information=:information "
|
||||||
|
"WHERE datum=:datum;");
|
||||||
|
else
|
||||||
|
query.prepare("INSERT INTO booking ( "
|
||||||
|
" datum, "
|
||||||
|
" kommt1, "
|
||||||
|
" geht1, "
|
||||||
|
" kommt2, "
|
||||||
|
" geht2, "
|
||||||
|
" kommt3, "
|
||||||
|
" geht3, "
|
||||||
|
" kommt4, "
|
||||||
|
" geht4, "
|
||||||
|
" kommt5, "
|
||||||
|
" geht5, "
|
||||||
|
" code, "
|
||||||
|
" information"
|
||||||
|
" ) "
|
||||||
|
"VALUES "
|
||||||
|
" ( "
|
||||||
|
" :datum, "
|
||||||
|
" :kommt1, "
|
||||||
|
" :geht1, "
|
||||||
|
" :kommt2, "
|
||||||
|
" :geht2, "
|
||||||
|
" :kommt3, "
|
||||||
|
" :geht3, "
|
||||||
|
" :kommt4, "
|
||||||
|
" :geht4, "
|
||||||
|
" :kommt5, "
|
||||||
|
" :geht5, "
|
||||||
|
" :code, "
|
||||||
|
" :information"
|
||||||
|
" );");
|
||||||
|
|
||||||
|
query.bindValue(":datum", date());
|
||||||
|
query.bindValue(":kommt1", kommt1());
|
||||||
|
query.bindValue(":geht1", geht1());
|
||||||
|
query.bindValue(":kommt2", kommt2());
|
||||||
|
query.bindValue(":geht2", geht2());
|
||||||
|
query.bindValue(":kommt3", kommt3());
|
||||||
|
query.bindValue(":geht3", geht3());
|
||||||
|
query.bindValue(":kommt4", kommt4());
|
||||||
|
query.bindValue(":geht4", geht4());
|
||||||
|
query.bindValue(":kommt5", kommt5());
|
||||||
|
query.bindValue(":geht5", geht5());
|
||||||
|
query.bindValue(":code", code());
|
||||||
|
query.bindValue(":information", information());
|
||||||
|
|
||||||
|
if(!query.exec())
|
||||||
|
{
|
||||||
|
qDebug() << "Save: " << query.lastError().text();
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "saved.";
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cBookingList::load()
|
||||||
|
{
|
||||||
|
QSqlQuery query;
|
||||||
|
|
||||||
|
query.prepare("SELECT datum, "
|
||||||
|
" kommt1, "
|
||||||
|
" geht1, "
|
||||||
|
" kommt2, "
|
||||||
|
" geht2, "
|
||||||
|
" kommt3, "
|
||||||
|
" geht3, "
|
||||||
|
" kommt4, "
|
||||||
|
" geht4, "
|
||||||
|
" kommt5, "
|
||||||
|
" geht5, "
|
||||||
|
" code, "
|
||||||
|
" information "
|
||||||
|
"FROM booking "
|
||||||
|
"ORDER BY datum;");
|
||||||
|
|
||||||
|
if(!query.exec())
|
||||||
|
{
|
||||||
|
qDebug() << "SELECT FROM booking: " << query.lastError().text();
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
while(query.next())
|
||||||
|
{
|
||||||
|
cBooking* lpBooking = add(query.value("datum").toDate());
|
||||||
|
|
||||||
|
if(lpBooking)
|
||||||
|
{
|
||||||
|
lpBooking->setKommt1(query.value("kommt1").toTime());
|
||||||
|
lpBooking->setGeht1(query.value("geht1").toTime());
|
||||||
|
lpBooking->setKommt2(query.value("kommt2").toTime());
|
||||||
|
lpBooking->setGeht2(query.value("geht2").toTime());
|
||||||
|
lpBooking->setKommt3(query.value("kommt3").toTime());
|
||||||
|
lpBooking->setGeht3(query.value("geht3").toTime());
|
||||||
|
lpBooking->setKommt4(query.value("kommt4").toTime());
|
||||||
|
lpBooking->setGeht4(query.value("geht4").toTime());
|
||||||
|
lpBooking->setKommt5(query.value("kommt5").toTime());
|
||||||
|
lpBooking->setGeht5(query.value("geht5").toTime());
|
||||||
|
lpBooking->setCode(query.value("code").toString());
|
||||||
|
lpBooking->setInformation(query.value("information").toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
cBooking* cBookingList::add(const QDate& date)
|
||||||
|
{
|
||||||
|
if(find(date))
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
|
cBooking* lpBooking = new cBooking(date);
|
||||||
|
append(lpBooking);
|
||||||
|
return(lpBooking);
|
||||||
|
}
|
||||||
|
|
||||||
|
cBooking* cBookingList::find(const QDate& date)
|
||||||
|
{
|
||||||
|
for(cBookingList::iterator i = begin();i != end(); i++)
|
||||||
|
{
|
||||||
|
if((*i)->date() == date)
|
||||||
|
return(*i);
|
||||||
|
}
|
||||||
|
return(nullptr);
|
||||||
|
}
|
||||||
+104
@@ -0,0 +1,104 @@
|
|||||||
|
#ifndef CBOOKING_H
|
||||||
|
#define CBOOKING_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
#include <QList>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDate>
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
|
|
||||||
|
class cBooking : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit cBooking(const QDate& date, QObject* parent = nullptr);
|
||||||
|
|
||||||
|
QDate date();
|
||||||
|
|
||||||
|
void setKommt1(const QTime& time);
|
||||||
|
QTime kommt1();
|
||||||
|
|
||||||
|
void setGeht1(const QTime& time);
|
||||||
|
QTime geht1();
|
||||||
|
|
||||||
|
void setKommt2(const QTime& time);
|
||||||
|
QTime kommt2();
|
||||||
|
|
||||||
|
void setGeht2(const QTime& time);
|
||||||
|
QTime geht2();
|
||||||
|
|
||||||
|
void setKommt3(const QTime& time);
|
||||||
|
QTime kommt3();
|
||||||
|
|
||||||
|
void setGeht3(const QTime& time);
|
||||||
|
QTime geht3();
|
||||||
|
|
||||||
|
void setKommt4(const QTime& time);
|
||||||
|
QTime kommt4();
|
||||||
|
|
||||||
|
void setGeht4(const QTime& time);
|
||||||
|
QTime geht4();
|
||||||
|
|
||||||
|
void setKommt5(const QTime& time);
|
||||||
|
QTime kommt5();
|
||||||
|
|
||||||
|
void setGeht5(const QTime& time);
|
||||||
|
QTime geht5();
|
||||||
|
|
||||||
|
void setCode(const QString& code);
|
||||||
|
QString code();
|
||||||
|
|
||||||
|
void setInformation(const QString& information);
|
||||||
|
QString information();
|
||||||
|
|
||||||
|
QTime pause();
|
||||||
|
|
||||||
|
QTime ist();
|
||||||
|
|
||||||
|
void setSoll();
|
||||||
|
QTime soll();
|
||||||
|
|
||||||
|
qint32 diff();
|
||||||
|
QString diffString();
|
||||||
|
|
||||||
|
void setPrevDiff(qint32 diff);
|
||||||
|
qint32 prevDiff();
|
||||||
|
|
||||||
|
qint32 currentDiff();
|
||||||
|
QString currentDiffString();
|
||||||
|
|
||||||
|
qreal hoursDecimal();
|
||||||
|
|
||||||
|
bool save();
|
||||||
|
private:
|
||||||
|
QDate m_date;
|
||||||
|
QTime m_kommt1;
|
||||||
|
QTime m_geht1;
|
||||||
|
QTime m_kommt2;
|
||||||
|
QTime m_geht2;
|
||||||
|
QTime m_kommt3;
|
||||||
|
QTime m_geht3;
|
||||||
|
QTime m_kommt4;
|
||||||
|
QTime m_geht4;
|
||||||
|
QTime m_kommt5;
|
||||||
|
QTime m_geht5;
|
||||||
|
QString m_code;
|
||||||
|
QString m_information;
|
||||||
|
QTime m_soll;
|
||||||
|
qint32 m_prevDiff;
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(cBooking*)
|
||||||
|
|
||||||
|
class cBookingList : public QList<cBooking*>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool load();
|
||||||
|
cBooking* add(const QDate& date);
|
||||||
|
cBooking* find(const QDate& date);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CBOOKING_H
|
||||||
+94
-13
@@ -2,34 +2,35 @@
|
|||||||
#include "ui_cmainwindow.h"
|
#include "ui_cmainwindow.h"
|
||||||
|
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
#include <QSqlQuery>
|
||||||
|
#include <QSqlError>
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
cMainWindow::cMainWindow(QWidget *parent) :
|
cMainWindow::cMainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::cMainWindow),
|
ui(new Ui::cMainWindow),
|
||||||
m_lpMonthlyView(nullptr)
|
m_lpMonthlyView(nullptr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
openDB();
|
||||||
|
m_bookingList.load();
|
||||||
|
|
||||||
QSettings settings;
|
initUI();
|
||||||
qint32 iX = settings.value("main/x", QVariant::fromValue(-1)).toInt();
|
|
||||||
qint32 iY = settings.value("main/y", QVariant::fromValue(-1)).toInt();
|
|
||||||
qint32 iWidth = settings.value("main/width", QVariant::fromValue(-1)).toInt();
|
|
||||||
qint32 iHeight = settings.value("main/height", QVariant::fromValue(-1)).toInt();
|
|
||||||
|
|
||||||
if(iWidth != -1 && iHeight != -1)
|
qDebug() << "count: " << m_bookingList.count();
|
||||||
resize(iWidth, iHeight);
|
|
||||||
if(iX != -1 && iY != -1)
|
|
||||||
move(iX, iY);
|
|
||||||
|
|
||||||
m_lpMonthlyView = new cMonthlyView(QDate(2019, 10, 8), this);
|
|
||||||
ui->m_lpMainTab->addTab(m_lpMonthlyView, "Monthly");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cMainWindow::~cMainWindow()
|
cMainWindow::~cMainWindow()
|
||||||
{
|
{
|
||||||
|
if(m_db.isOpen())
|
||||||
|
m_db.close();
|
||||||
|
|
||||||
if(m_lpMonthlyView)
|
if(m_lpMonthlyView)
|
||||||
delete m_lpMonthlyView;
|
delete m_lpMonthlyView;
|
||||||
|
|
||||||
@@ -50,3 +51,83 @@ void cMainWindow::closeEvent(QCloseEvent *event)
|
|||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cMainWindow::initUI()
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
QSettings settings;
|
||||||
|
qint32 iX = settings.value("main/x", QVariant::fromValue(-1)).toInt();
|
||||||
|
qint32 iY = settings.value("main/y", QVariant::fromValue(-1)).toInt();
|
||||||
|
qint32 iWidth = settings.value("main/width", QVariant::fromValue(-1)).toInt();
|
||||||
|
qint32 iHeight = settings.value("main/height", QVariant::fromValue(-1)).toInt();
|
||||||
|
|
||||||
|
if(iWidth != -1 && iHeight != -1)
|
||||||
|
resize(iWidth, iHeight);
|
||||||
|
if(iX != -1 && iY != -1)
|
||||||
|
move(iX, iY);
|
||||||
|
|
||||||
|
m_lpMonthlyView = new cMonthlyView(QDate::currentDate(), &m_bookingList, this);
|
||||||
|
ui->m_lpMainTab->addTab(m_lpMonthlyView, "Monthly");
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::openDB()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
if(!settings.contains("db/file"))
|
||||||
|
settings.setValue("db/file", QDir::homePath() + "/workingHours.db");
|
||||||
|
|
||||||
|
QString szDB = settings.value("db/file", QDir::homePath() + "/workingHours.db").toString();
|
||||||
|
qDebug() << "Database: " << szDB;
|
||||||
|
|
||||||
|
m_db = QSqlDatabase::addDatabase("QSQLITE");
|
||||||
|
m_db.setHostName("localhost");
|
||||||
|
m_db.setDatabaseName(szDB);
|
||||||
|
|
||||||
|
if(!m_db.open())
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Database Open"), "Database cannot be opened!\n" + m_db.lastError().text());
|
||||||
|
qDebug() << "Database Open error: " << m_db.lastError().text();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "Database opened";
|
||||||
|
|
||||||
|
// if(!m_db.tables().contains("config"))
|
||||||
|
// {
|
||||||
|
// QSqlQuery query;
|
||||||
|
|
||||||
|
// query.prepare("CREATE TABLE config "
|
||||||
|
// " ")
|
||||||
|
// }
|
||||||
|
|
||||||
|
if(!m_db.tables().contains("booking"))
|
||||||
|
{
|
||||||
|
QSqlQuery query;
|
||||||
|
|
||||||
|
query.prepare("CREATE TABLE booking "
|
||||||
|
"( "
|
||||||
|
" datum DATE PRIMARY KEY UNIQE, "
|
||||||
|
" kommt1 TIME, "
|
||||||
|
" geht1 TIME, "
|
||||||
|
" kommt2 TIME, "
|
||||||
|
" geht2 TIME, "
|
||||||
|
" kommt3 TIME, "
|
||||||
|
" geht3 TIME, "
|
||||||
|
" kommt4 TIME, "
|
||||||
|
" geht4 TIME, "
|
||||||
|
" kommt5 TIME, "
|
||||||
|
" geht5 TIME, "
|
||||||
|
" code INTEGER, "
|
||||||
|
" information STRING "
|
||||||
|
");");
|
||||||
|
|
||||||
|
if(!query.exec())
|
||||||
|
{
|
||||||
|
qDebug() << "CREATE TABLE booking: " << query.lastError().text();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
qDebug() << "CREATE TABLE booking";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,10 +3,13 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "cmonthlyview.h"
|
#include "cmonthlyview.h"
|
||||||
|
#include "cbooking.h"
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
|
|
||||||
|
#include <QSqlDatabase>
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class cMainWindow;
|
class cMainWindow;
|
||||||
@@ -23,6 +26,11 @@ public:
|
|||||||
private:
|
private:
|
||||||
Ui::cMainWindow* ui;
|
Ui::cMainWindow* ui;
|
||||||
cMonthlyView* m_lpMonthlyView;
|
cMonthlyView* m_lpMonthlyView;
|
||||||
|
QSqlDatabase m_db;
|
||||||
|
cBookingList m_bookingList;
|
||||||
|
|
||||||
|
void initUI();
|
||||||
|
void openDB();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent* event);
|
void closeEvent(QCloseEvent* event);
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ QWidget* cMonthlyItemDelegate::createEditor( QWidget *parent, const QStyleOption
|
|||||||
case COL_GO2:
|
case COL_GO2:
|
||||||
case COL_COME3:
|
case COL_COME3:
|
||||||
case COL_GO3:
|
case COL_GO3:
|
||||||
case COL_BREAK:
|
case COL_COME4:
|
||||||
|
case COL_GO4:
|
||||||
|
case COL_COME5:
|
||||||
|
case COL_GO5:
|
||||||
{
|
{
|
||||||
QTimeEdit* lpTimeEdit = new QTimeEdit(parent);
|
QTimeEdit* lpTimeEdit = new QTimeEdit(parent);
|
||||||
lpTimeEdit->setDisplayFormat("HH:mm:ss");
|
lpTimeEdit->setDisplayFormat("HH:mm:ss");
|
||||||
@@ -56,7 +59,10 @@ void cMonthlyItemDelegate::setEditorData ( QWidget *editor, const QModelIndex &i
|
|||||||
case COL_GO2:
|
case COL_GO2:
|
||||||
case COL_COME3:
|
case COL_COME3:
|
||||||
case COL_GO3:
|
case COL_GO3:
|
||||||
case COL_BREAK:
|
case COL_COME4:
|
||||||
|
case COL_GO4:
|
||||||
|
case COL_COME5:
|
||||||
|
case COL_GO5:
|
||||||
{
|
{
|
||||||
QTimeEdit* lpTimeEdit = qobject_cast<QTimeEdit*>(editor);
|
QTimeEdit* lpTimeEdit = qobject_cast<QTimeEdit*>(editor);
|
||||||
lpTimeEdit->setTime(QTime::fromString(index.data(Qt::EditRole).toString()));
|
lpTimeEdit->setTime(QTime::fromString(index.data(Qt::EditRole).toString()));
|
||||||
@@ -91,7 +97,10 @@ void cMonthlyItemDelegate::setModelData ( QWidget *editor, QAbstractItemModel *m
|
|||||||
case COL_GO2:
|
case COL_GO2:
|
||||||
case COL_COME3:
|
case COL_COME3:
|
||||||
case COL_GO3:
|
case COL_GO3:
|
||||||
case COL_BREAK:
|
case COL_COME4:
|
||||||
|
case COL_GO4:
|
||||||
|
case COL_COME5:
|
||||||
|
case COL_GO5:
|
||||||
{
|
{
|
||||||
QTimeEdit* lpTimeEdit = qobject_cast<QTimeEdit*>(editor);
|
QTimeEdit* lpTimeEdit = qobject_cast<QTimeEdit*>(editor);
|
||||||
if(!lpTimeEdit->time().hour() &&
|
if(!lpTimeEdit->time().hour() &&
|
||||||
|
|||||||
+152
-41
@@ -6,9 +6,11 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
cMonthlyView::cMonthlyView(const QDate& date, QWidget *parent) :
|
cMonthlyView::cMonthlyView(const QDate& date, cBookingList* lpBookingList, QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::cMonthlyView)
|
ui(new Ui::cMonthlyView),
|
||||||
|
m_loading(true),
|
||||||
|
m_lpBookingList(lpBookingList)
|
||||||
{
|
{
|
||||||
m_code.insert(" ", tr(""));
|
m_code.insert(" ", tr(""));
|
||||||
m_code.insert("G", tr("Gleitzeit"));
|
m_code.insert("G", tr("Gleitzeit"));
|
||||||
@@ -32,18 +34,25 @@ cMonthlyView::cMonthlyView(const QDate& date, QWidget *parent) :
|
|||||||
ui->m_lpSonderurlaubLabel->setAutoFillBackground(true);
|
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()));
|
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()));
|
||||||
|
|
||||||
|
ui->m_lpMonth->setDate(date);
|
||||||
setDate(date);
|
setDate(date);
|
||||||
|
|
||||||
connect(static_cast<cMonthlyItemDelegate*>(ui->m_lpMonthlyList->itemDelegate()), &cMonthlyItemDelegate::timeChanged, this, &cMonthlyView::onTimeChanged);
|
connect(static_cast<cMonthlyItemDelegate*>(ui->m_lpMonthlyList->itemDelegate()), &cMonthlyItemDelegate::timeChanged, this, &cMonthlyView::onTimeChanged);
|
||||||
connect(static_cast<cMonthlyItemDelegate*>(ui->m_lpMonthlyList->itemDelegate()), &cMonthlyItemDelegate::textChanged, this, &cMonthlyView::onTextChanged);
|
connect(static_cast<cMonthlyItemDelegate*>(ui->m_lpMonthlyList->itemDelegate()), &cMonthlyItemDelegate::textChanged, this, &cMonthlyView::onTextChanged);
|
||||||
|
|
||||||
|
connect(ui->m_lpMonth, &QDateEdit::dateChanged, this, &cMonthlyView::onDateChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cMonthlyView::setDate(const QDate& date)
|
void cMonthlyView::setDate(const QDate& date)
|
||||||
{
|
{
|
||||||
|
m_loading = true;
|
||||||
|
|
||||||
|
m_publicHoliday.setYear(static_cast<qint16>(date.year()));
|
||||||
|
|
||||||
m_lpMonthlyListModel->clear();
|
m_lpMonthlyListModel->clear();
|
||||||
|
|
||||||
QStringList header;
|
QStringList header;
|
||||||
header << tr("day") << tr("public holiday") << tr("come1") << tr("go1") << tr("come2") << tr("go2") << tr("come3") << tr("go3") << tr("break") << tr("code") << tr("is") << tr("should") << tr("+/-") << tr("information") << tr("current +/-") << tr("hours dec") << tr("day");
|
header << tr("Tag") << tr("Feiertag") << tr("kommt 1") << tr("geht 1") << tr("kommt 2") << tr("geht 2") << tr("kommt 3") << tr("geht 3") << tr("kommt 4") << tr("geht 4") << tr("kommt 5") << tr("geht 5") << tr("Pause") << tr("Kode") << tr("ist") << tr("soll") << tr("+/-") << tr("information") << tr("aktuell +/-") << tr("dezimal") << tr("Tag");
|
||||||
m_lpMonthlyListModel->setHorizontalHeaderLabels(header);
|
m_lpMonthlyListModel->setHorizontalHeaderLabels(header);
|
||||||
|
|
||||||
QList<QStandardItem*> items;
|
QList<QStandardItem*> items;
|
||||||
@@ -58,6 +67,10 @@ void cMonthlyView::setDate(const QDate& date)
|
|||||||
items[COL_GO2]->setText("00:00:00");
|
items[COL_GO2]->setText("00:00:00");
|
||||||
items[COL_COME3]->setText("00:00:00");
|
items[COL_COME3]->setText("00:00:00");
|
||||||
items[COL_GO3]->setText("00:00:00");
|
items[COL_GO3]->setText("00:00:00");
|
||||||
|
items[COL_COME4]->setText("00:00:00");
|
||||||
|
items[COL_GO4]->setText("00:00:00");
|
||||||
|
items[COL_COME5]->setText("00:00:00");
|
||||||
|
items[COL_GO5]->setText("00:00:00");
|
||||||
items[COL_BREAK]->setText("00:00:00");
|
items[COL_BREAK]->setText("00:00:00");
|
||||||
items[COL_CODE]->setText("");
|
items[COL_CODE]->setText("");
|
||||||
items[COL_IS]->setText("00:00:00");
|
items[COL_IS]->setText("00:00:00");
|
||||||
@@ -81,29 +94,42 @@ void cMonthlyView::setDate(const QDate& date)
|
|||||||
|
|
||||||
for(;date1.month() == date.month();date1 = date1.addDays(1))
|
for(;date1.month() == date.month();date1 = date1.addDays(1))
|
||||||
{
|
{
|
||||||
|
cBooking* lpBooking = m_lpBookingList->find(date1);
|
||||||
|
|
||||||
|
if(!lpBooking)
|
||||||
|
{
|
||||||
|
lpBooking = m_lpBookingList->add(date1);
|
||||||
|
lpBooking->save();
|
||||||
|
}
|
||||||
|
|
||||||
items.clear();
|
items.clear();
|
||||||
|
|
||||||
for(int y = 0;y < header.count();y++)
|
for(int y = 0;y < header.count();y++)
|
||||||
items.append(new QStandardItem);
|
items.append(new QStandardItem);
|
||||||
|
|
||||||
items[COL_DAY1]->setText(date1.toString("dddd dd"));
|
items[COL_DAY1]->setText(date1.toString("dddd dd"));
|
||||||
items[COL_PUBLIC_HOLIDAY]->setText("");
|
items[COL_PUBLIC_HOLIDAY]->setText(m_publicHoliday.name(date1));
|
||||||
items[COL_COME1]->setText("");
|
|
||||||
items[COL_GO1]->setText("");
|
|
||||||
items[COL_COME2]->setText("");
|
|
||||||
items[COL_GO2]->setText("");
|
|
||||||
items[COL_COME3]->setText("");
|
|
||||||
items[COL_GO3]->setText("");
|
|
||||||
items[COL_BREAK]->setText("00:00:00");
|
|
||||||
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_INFORMATION]->setText("");
|
|
||||||
items[COL_CURRENT]->setText("00:00:00");
|
|
||||||
items[COL_HOURS_DEC]->setText("0.0");
|
|
||||||
items[COL_DAY2]->setText(date1.toString("dd dddd"));
|
items[COL_DAY2]->setText(date1.toString("dd dddd"));
|
||||||
|
|
||||||
|
items[COL_COME1]->setText(lpBooking->kommt1().toString("hh:mm:ss"));
|
||||||
|
items[COL_GO1]->setText(lpBooking->geht1().toString("hh:mm:ss"));
|
||||||
|
items[COL_COME2]->setText(lpBooking->kommt2().toString("hh:mm:ss"));
|
||||||
|
items[COL_GO2]->setText(lpBooking->geht2().toString("hh:mm:ss"));
|
||||||
|
items[COL_COME3]->setText(lpBooking->kommt3().toString("hh:mm:ss"));
|
||||||
|
items[COL_GO3]->setText(lpBooking->geht3().toString("hh:mm:ss"));
|
||||||
|
items[COL_COME4]->setText(lpBooking->kommt4().toString("hh:mm:ss"));
|
||||||
|
items[COL_GO4]->setText(lpBooking->geht4().toString("hh:mm:ss"));
|
||||||
|
items[COL_COME5]->setText(lpBooking->kommt5().toString("hh:mm:ss"));
|
||||||
|
items[COL_GO5]->setText(lpBooking->geht5().toString("hh:mm:ss"));
|
||||||
|
items[COL_BREAK]->setText(lpBooking->pause().toString("hh:mm:ss"));
|
||||||
|
items[COL_CODE]->setText(lpBooking->code());
|
||||||
|
items[COL_IS]->setText(lpBooking->ist().toString("hh:mm:ss"));
|
||||||
|
items[COL_SHOULD]->setText(lpBooking->soll().toString("hh:mm:ss"));
|
||||||
|
items[COL_DIFF]->setText(lpBooking->diffString());
|
||||||
|
items[COL_INFORMATION]->setText(lpBooking->information());
|
||||||
|
items[COL_CURRENT]->setText(lpBooking->currentDiffString());
|
||||||
|
items[COL_HOURS_DEC]->setText(QString::number(lpBooking->hoursDecimal()));
|
||||||
|
|
||||||
items[COL_DAY1]->setTextAlignment(Qt::AlignRight);
|
items[COL_DAY1]->setTextAlignment(Qt::AlignRight);
|
||||||
items[COL_PUBLIC_HOLIDAY]->setTextAlignment(Qt::AlignHCenter);
|
items[COL_PUBLIC_HOLIDAY]->setTextAlignment(Qt::AlignHCenter);
|
||||||
items[COL_COME1]->setTextAlignment(Qt::AlignHCenter);
|
items[COL_COME1]->setTextAlignment(Qt::AlignHCenter);
|
||||||
@@ -112,6 +138,10 @@ void cMonthlyView::setDate(const QDate& date)
|
|||||||
items[COL_GO2]->setTextAlignment(Qt::AlignHCenter);
|
items[COL_GO2]->setTextAlignment(Qt::AlignHCenter);
|
||||||
items[COL_COME3]->setTextAlignment(Qt::AlignHCenter);
|
items[COL_COME3]->setTextAlignment(Qt::AlignHCenter);
|
||||||
items[COL_GO3]->setTextAlignment(Qt::AlignHCenter);
|
items[COL_GO3]->setTextAlignment(Qt::AlignHCenter);
|
||||||
|
items[COL_COME4]->setTextAlignment(Qt::AlignHCenter);
|
||||||
|
items[COL_GO4]->setTextAlignment(Qt::AlignHCenter);
|
||||||
|
items[COL_COME5]->setTextAlignment(Qt::AlignHCenter);
|
||||||
|
items[COL_GO5]->setTextAlignment(Qt::AlignHCenter);
|
||||||
items[COL_BREAK]->setTextAlignment(Qt::AlignHCenter);
|
items[COL_BREAK]->setTextAlignment(Qt::AlignHCenter);
|
||||||
items[COL_CODE]->setTextAlignment(Qt::AlignHCenter);
|
items[COL_CODE]->setTextAlignment(Qt::AlignHCenter);
|
||||||
items[COL_IS]->setTextAlignment(Qt::AlignHCenter);
|
items[COL_IS]->setTextAlignment(Qt::AlignHCenter);
|
||||||
@@ -124,25 +154,33 @@ void cMonthlyView::setDate(const QDate& date)
|
|||||||
|
|
||||||
for(int z = 0;z < items.count();z++)
|
for(int z = 0;z < items.count();z++)
|
||||||
{
|
{
|
||||||
if(date1.dayOfWeek() >= 6)
|
if(date1.dayOfWeek() >= 6 || m_publicHoliday.isPublicHoliday(date1))
|
||||||
{
|
{
|
||||||
items[z]->setData(QVariant::fromValue(true), Qt::UserRole+1);
|
items[z]->setData(QVariant::fromValue(true), Qt::UserRole+1);
|
||||||
items[z]->setBackground(weekend);
|
items[z]->setBackground(weekend);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
items[z]->setData(QVariant::fromValue(false), Qt::UserRole+1);
|
items[z]->setData(QVariant::fromValue(false), Qt::UserRole+1);
|
||||||
|
|
||||||
|
items[z]->setData(QVariant::fromValue(lpBooking), Qt::UserRole+2);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lpMonthlyListModel->appendRow(items);
|
m_lpMonthlyListModel->appendRow(items);
|
||||||
|
|
||||||
|
if(date1.dayOfWeek() < 6 && !m_publicHoliday.isPublicHoliday(date1))
|
||||||
|
setBackground(date1.day(), lpBooking->code());
|
||||||
}
|
}
|
||||||
ui->m_lpMonthlyList->resizeColumnToContents(COL_DAY1);
|
ui->m_lpMonthlyList->resizeColumnToContents(COL_DAY1);
|
||||||
ui->m_lpMonthlyList->resizeColumnToContents(COL_DAY2);
|
ui->m_lpMonthlyList->resizeColumnToContents(COL_DAY2);
|
||||||
|
ui->m_lpMonthlyList->resizeColumnToContents(COL_PUBLIC_HOLIDAY);
|
||||||
|
|
||||||
ui->m_lpUebertragLabel->setText(QString(tr("Übertrag %1:")).arg(date.addMonths(-1).toString("MMMM yyyy")));
|
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_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_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_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")));
|
ui->m_lpRestSonderurlaubLabel->setText(QString(tr("Sonderurlaub %1:")).arg(date.addMonths(-1).toString("MMMM yyyy")));
|
||||||
|
|
||||||
|
m_loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cMonthlyView::~cMonthlyView()
|
cMonthlyView::~cMonthlyView()
|
||||||
@@ -152,35 +190,108 @@ cMonthlyView::~cMonthlyView()
|
|||||||
|
|
||||||
void cMonthlyView::onTimeChanged(const int day, const int field, const QTime& time)
|
void cMonthlyView::onTimeChanged(const int day, const int field, const QTime& time)
|
||||||
{
|
{
|
||||||
qDebug() << "Day: " << day;
|
QStandardItem* lpItem = m_lpMonthlyListModel->item(day-1, field);
|
||||||
qDebug() << "field: " << field;
|
if(!lpItem)
|
||||||
qDebug() << "time: " << time;
|
return;
|
||||||
|
|
||||||
|
cBooking* lpBooking = lpItem->data(Qt::UserRole+2).value<cBooking*>();
|
||||||
|
if(!lpBooking)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch(field)
|
||||||
|
{
|
||||||
|
case COL_COME1:
|
||||||
|
lpBooking->setKommt1(time);
|
||||||
|
lpBooking->save();
|
||||||
|
break;
|
||||||
|
case COL_GO1:
|
||||||
|
lpBooking->setGeht1(time);
|
||||||
|
lpBooking->save();
|
||||||
|
break;
|
||||||
|
case COL_COME2:
|
||||||
|
lpBooking->setKommt2(time);
|
||||||
|
lpBooking->save();
|
||||||
|
break;
|
||||||
|
case COL_GO2:
|
||||||
|
lpBooking->setGeht2(time);
|
||||||
|
lpBooking->save();
|
||||||
|
break;
|
||||||
|
case COL_COME3:
|
||||||
|
lpBooking->setKommt3(time);
|
||||||
|
lpBooking->save();
|
||||||
|
break;
|
||||||
|
case COL_GO3:
|
||||||
|
lpBooking->setGeht3(time);
|
||||||
|
lpBooking->save();
|
||||||
|
break;
|
||||||
|
case COL_COME4:
|
||||||
|
lpBooking->setKommt4(time);
|
||||||
|
lpBooking->save();
|
||||||
|
break;
|
||||||
|
case COL_GO4:
|
||||||
|
lpBooking->setGeht4(time);
|
||||||
|
lpBooking->save();
|
||||||
|
break;
|
||||||
|
case COL_COME5:
|
||||||
|
lpBooking->setKommt5(time);
|
||||||
|
lpBooking->save();
|
||||||
|
break;
|
||||||
|
case COL_GO5:
|
||||||
|
lpBooking->setGeht5(time);
|
||||||
|
lpBooking->save();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cMonthlyView::onTextChanged(const int day, const int field, const QString& text)
|
void cMonthlyView::onTextChanged(const int day, const int field, const QString& text)
|
||||||
{
|
{
|
||||||
qDebug() << "Day: " << day;
|
QStandardItem* lpItem = m_lpMonthlyListModel->item(day-1, field);
|
||||||
qDebug() << "field: " << field;
|
if(!lpItem)
|
||||||
qDebug() << "time: " << text;
|
return;
|
||||||
|
|
||||||
if(field == COL_CODE)
|
cBooking* lpBooking = lpItem->data(Qt::UserRole+2).value<cBooking*>();
|
||||||
|
if(!lpBooking)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch(field)
|
||||||
|
{
|
||||||
|
case COL_CODE:
|
||||||
{
|
{
|
||||||
QBrush brush;
|
|
||||||
QString code = m_code.key(text);
|
QString code = m_code.key(text);
|
||||||
|
|
||||||
if(code == "G")
|
setBackground(day, code);
|
||||||
brush = QBrush(COLOR_GLEITZEIT);
|
lpBooking->setCode(code);
|
||||||
else if(code == "U")
|
lpBooking->save();
|
||||||
brush = QBrush(COLOR_URLAUB);
|
break;
|
||||||
else if(code == "K")
|
}
|
||||||
brush = QBrush(COLOR_KRANK);
|
case COL_INFORMATION:
|
||||||
else if(code == "SU")
|
lpBooking->setInformation(text);
|
||||||
brush = QBrush(COLOR_SONDERURLAUB);
|
lpBooking->save();
|
||||||
|
break;
|
||||||
for(int x = 0;x < m_lpMonthlyListModel->columnCount();x++)
|
}
|
||||||
{
|
}
|
||||||
QStandardItem* lpItem = m_lpMonthlyListModel->item(day-1, x);
|
|
||||||
lpItem->setBackground(brush);
|
void cMonthlyView::onDateChanged(const QDate& date)
|
||||||
}
|
{
|
||||||
|
setDate(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMonthlyView::setBackground(const int day, const QString& code)
|
||||||
|
{
|
||||||
|
QBrush brush;
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-1
@@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "cmonthlyitemdelegate.h"
|
#include "cmonthlyitemdelegate.h"
|
||||||
|
#include "cpublicholiday.h"
|
||||||
|
|
||||||
|
#include "cbooking.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
@@ -19,18 +22,24 @@ class cMonthlyView : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit cMonthlyView(const QDate& date, QWidget *parent = nullptr);
|
explicit cMonthlyView(const QDate& date, cBookingList* lpBookingList, QWidget *parent = nullptr);
|
||||||
~cMonthlyView();
|
~cMonthlyView();
|
||||||
|
|
||||||
void setDate(const QDate& date);
|
void setDate(const QDate& date);
|
||||||
private:
|
private:
|
||||||
Ui::cMonthlyView* ui;
|
Ui::cMonthlyView* ui;
|
||||||
|
bool m_loading;
|
||||||
QStandardItemModel* m_lpMonthlyListModel;
|
QStandardItemModel* m_lpMonthlyListModel;
|
||||||
QMap<QString, QString> m_code;
|
QMap<QString, QString> m_code;
|
||||||
|
cPublicHoliday m_publicHoliday;
|
||||||
|
cBookingList* m_lpBookingList;
|
||||||
|
|
||||||
|
void setBackground(const int day, const QString& code);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onTimeChanged(const int day, const int field, const QTime& time);
|
void onTimeChanged(const int day, const int field, const QTime& time);
|
||||||
void onTextChanged(const int day, const int field, const QString& text);
|
void onTextChanged(const int day, const int field, const QString& text);
|
||||||
|
void onDateChanged(const QDate& date);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CMONTHLYVIEW_H
|
#endif // CMONTHLYVIEW_H
|
||||||
|
|||||||
+12
-2
@@ -16,6 +16,16 @@
|
|||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QDateEdit" name="m_lpMonth">
|
||||||
|
<property name="currentSection">
|
||||||
|
<enum>QDateTimeEdit::MonthSection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="displayFormat">
|
||||||
|
<string>MM.yyyy</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QScrollArea" name="scrollArea">
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
<property name="widgetResizable">
|
<property name="widgetResizable">
|
||||||
@@ -27,11 +37,11 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>861</width>
|
<width>861</width>
|
||||||
<height>241</height>
|
<height>215</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QTreeView" name="m_lpMonthlyList">
|
<widget class="QTreeView" name="m_lpMonthlyList">
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|||||||
@@ -13,15 +13,19 @@
|
|||||||
#define COL_GO2 5
|
#define COL_GO2 5
|
||||||
#define COL_COME3 6
|
#define COL_COME3 6
|
||||||
#define COL_GO3 7
|
#define COL_GO3 7
|
||||||
#define COL_BREAK 8
|
#define COL_COME4 8
|
||||||
#define COL_CODE 9
|
#define COL_GO4 9
|
||||||
#define COL_IS 10
|
#define COL_COME5 10
|
||||||
#define COL_SHOULD 11
|
#define COL_GO5 11
|
||||||
#define COL_DIFF 12
|
#define COL_BREAK 12
|
||||||
#define COL_INFORMATION 13
|
#define COL_CODE 13
|
||||||
#define COL_CURRENT 14
|
#define COL_IS 14
|
||||||
#define COL_HOURS_DEC 15
|
#define COL_SHOULD 15
|
||||||
#define COL_DAY2 16
|
#define COL_DIFF 16
|
||||||
|
#define COL_INFORMATION 17
|
||||||
|
#define COL_CURRENT 18
|
||||||
|
#define COL_HOURS_DEC 19
|
||||||
|
#define COL_DAY2 20
|
||||||
|
|
||||||
#define COLOR_GLEITZEIT QColor(191, 191, 255)
|
#define COLOR_GLEITZEIT QColor(191, 191, 255)
|
||||||
#define COLOR_URLAUB QColor(127, 127, 255)
|
#define COLOR_URLAUB QColor(127, 127, 255)
|
||||||
|
|||||||
+151
-1
@@ -6,9 +6,68 @@
|
|||||||
cPublicHoliday::cPublicHoliday(qint16 year) :
|
cPublicHoliday::cPublicHoliday(qint16 year) :
|
||||||
m_year(year)
|
m_year(year)
|
||||||
{
|
{
|
||||||
m_holidays.insert(ostersonntag(), QObject::tr("Ostersonntag"));
|
calculate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cPublicHoliday::setYear(qint16 year)
|
||||||
|
{
|
||||||
|
m_year = year;
|
||||||
|
calculate();
|
||||||
|
}
|
||||||
|
|
||||||
|
qint16 cPublicHoliday::year()
|
||||||
|
{
|
||||||
|
return(m_year);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cPublicHoliday::calculate()
|
||||||
|
{
|
||||||
|
m_holidays.clear();
|
||||||
|
|
||||||
|
m_holidays.insert(neujahr(), QObject::tr("Neujahr"));
|
||||||
|
m_holidays.insert(heilige3koenige(), QObject::tr("Heilige 3 Könige"));
|
||||||
|
m_holidays.insert(karfreitag(), QObject::tr("Karfreitag"));
|
||||||
|
m_holidays.insert(ostersonntag(), QObject::tr("Ostersonntag"));
|
||||||
|
m_holidays.insert(ostermontag(), QObject::tr("OsterMontag"));
|
||||||
|
m_holidays.insert(staatsfeiertag1(), QObject::tr("Staatsfeiertag"));
|
||||||
|
m_holidays.insert(christihimmelfahrt(), QObject::tr("Christi Himmelfahrt"));
|
||||||
|
m_holidays.insert(pfingstsonntag(), QObject::tr("Pfingstsonntag"));
|
||||||
|
m_holidays.insert(pfingstmontag(), QObject::tr("Pfingstmontag"));
|
||||||
|
m_holidays.insert(fronleichnam(), QObject::tr("Fronleichnam"));
|
||||||
|
m_holidays.insert(mariahimmelfahrt(), QObject::tr("Maria Himmelfahrt"));
|
||||||
|
m_holidays.insert(staatsfeiertag(), QObject::tr("Staatsfeiertag"));
|
||||||
|
m_holidays.insert(allerheiligen(), QObject::tr("Allerheiligen"));
|
||||||
|
m_holidays.insert(ersteradvent(), QObject::tr("1. Advent"));
|
||||||
|
m_holidays.insert(mariaempfaengnis(), QObject::tr("Maria Emphängnis"));
|
||||||
|
m_holidays.insert(ersterweihnachtstag(), QObject::tr("1. Weihnachtstag"));
|
||||||
|
m_holidays.insert(zweiterweihnachtstag(), QObject::tr("2. Weihnachtstag"));
|
||||||
|
m_holidays.insert(silvester(), QObject::tr("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"
|
||||||
|
*/
|
||||||
|
|
||||||
bool cPublicHoliday::isPublicHoliday(const QDate& date)
|
bool cPublicHoliday::isPublicHoliday(const QDate& date)
|
||||||
{
|
{
|
||||||
return(m_holidays.contains(date));
|
return(m_holidays.contains(date));
|
||||||
@@ -19,6 +78,21 @@ QString cPublicHoliday::name(const QDate& date)
|
|||||||
return(m_holidays.value(date, ""));
|
return(m_holidays.value(date, ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::neujahr()
|
||||||
|
{
|
||||||
|
return(QDate(m_year, 1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::heilige3koenige()
|
||||||
|
{
|
||||||
|
return(QDate(m_year, 1, 6));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::karfreitag()
|
||||||
|
{
|
||||||
|
return(ostersonntag().addDays(-2));
|
||||||
|
}
|
||||||
|
|
||||||
QDate cPublicHoliday::ostersonntag()
|
QDate cPublicHoliday::ostersonntag()
|
||||||
{
|
{
|
||||||
int a = m_year % 19;
|
int a = m_year % 19;
|
||||||
@@ -36,3 +110,79 @@ QDate cPublicHoliday::ostersonntag()
|
|||||||
|
|
||||||
return(QDate(m_year, nMonth, nDay));
|
return(QDate(m_year, nMonth, nDay));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::ostermontag()
|
||||||
|
{
|
||||||
|
return(ostersonntag().addDays(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::staatsfeiertag1()
|
||||||
|
{
|
||||||
|
return(QDate(m_year, 5, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::christihimmelfahrt()
|
||||||
|
{
|
||||||
|
return(ostersonntag().addDays(39));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::pfingstsonntag()
|
||||||
|
{
|
||||||
|
return(ostersonntag().addDays(49));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::pfingstmontag()
|
||||||
|
{
|
||||||
|
return(ostersonntag().addDays(50));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::fronleichnam()
|
||||||
|
{
|
||||||
|
return(ostersonntag().addDays(60));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::mariahimmelfahrt()
|
||||||
|
{
|
||||||
|
return(QDate(m_year, 8, 15));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::staatsfeiertag()
|
||||||
|
{
|
||||||
|
return(QDate(m_year, 10, 26));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::allerheiligen()
|
||||||
|
{
|
||||||
|
return(QDate(m_year, 11, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::ersteradvent()
|
||||||
|
{
|
||||||
|
QDate date(m_year, 11, 27);
|
||||||
|
return(date.addDays(7-date.dayOfWeek()));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::mariaempfaengnis()
|
||||||
|
{
|
||||||
|
return(QDate(m_year, 12, 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::ersterweihnachtstag()
|
||||||
|
{
|
||||||
|
return(QDate(m_year, 12, 25));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::zweiterweihnachtstag()
|
||||||
|
{
|
||||||
|
return(QDate(m_year, 12, 26));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate cPublicHoliday::silvester()
|
||||||
|
{
|
||||||
|
return(QDate(m_year, 12, 31));
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QDate, QString> cPublicHoliday::list()
|
||||||
|
{
|
||||||
|
return(m_holidays);
|
||||||
|
}
|
||||||
|
|||||||
+15
-5
@@ -11,28 +11,38 @@
|
|||||||
class cPublicHoliday
|
class cPublicHoliday
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cPublicHoliday(qint16 year);
|
cPublicHoliday(qint16 year = 2000);
|
||||||
|
|
||||||
|
void setYear(qint16 year);
|
||||||
|
qint16 year();
|
||||||
|
|
||||||
bool isPublicHoliday(const QDate& date);
|
bool isPublicHoliday(const QDate& date);
|
||||||
QString name(const QDate& date);
|
QString name(const QDate& date);
|
||||||
|
QMap<QDate, QString> list();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qint16 m_year;
|
qint16 m_year;
|
||||||
QMap<QDate, QString> m_holidays;
|
QMap<QDate, QString> m_holidays;
|
||||||
|
|
||||||
|
void calculate();
|
||||||
|
|
||||||
QDate neujahr();
|
QDate neujahr();
|
||||||
QDate heilige3Koenige();
|
QDate heilige3koenige();
|
||||||
QDate karfreitag();
|
QDate karfreitag();
|
||||||
QDate ostersonntag();
|
QDate ostersonntag();
|
||||||
QDate ostermontag();
|
QDate ostermontag();
|
||||||
QDate staatsfeiertag1();
|
QDate staatsfeiertag1();
|
||||||
QDate christiHimmelfahrt();
|
QDate christihimmelfahrt();
|
||||||
QDate pfingstsonntag();
|
QDate pfingstsonntag();
|
||||||
QDate pfingstMontag();
|
QDate pfingstmontag();
|
||||||
QDate fronleichnam();
|
QDate fronleichnam();
|
||||||
QDate mariaHimmelfahrt();
|
QDate mariahimmelfahrt();
|
||||||
QDate staatsfeiertag();
|
QDate staatsfeiertag();
|
||||||
QDate allerheiligen();
|
QDate allerheiligen();
|
||||||
|
QDate ersteradvent();
|
||||||
|
QDate mariaempfaengnis();
|
||||||
|
QDate ersterweihnachtstag();
|
||||||
|
QDate zweiterweihnachtstag();
|
||||||
QDate silvester();
|
QDate silvester();
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
|
|||||||
+3
-1
@@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
||||||
QT += core gui
|
QT += core gui sql
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
@@ -25,6 +25,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
cbooking.cpp \
|
||||||
cmonthlyitemdelegate.cpp \
|
cmonthlyitemdelegate.cpp \
|
||||||
cmonthlyview.cpp \
|
cmonthlyview.cpp \
|
||||||
cpublicholiday.cpp \
|
cpublicholiday.cpp \
|
||||||
@@ -32,6 +33,7 @@ SOURCES += \
|
|||||||
cmainwindow.cpp
|
cmainwindow.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
cbooking.h \
|
||||||
cmainwindow.h \
|
cmainwindow.h \
|
||||||
cmonthlyitemdelegate.h \
|
cmonthlyitemdelegate.h \
|
||||||
cmonthlyview.h \
|
cmonthlyview.h \
|
||||||
|
|||||||
Reference in New Issue
Block a user