initial release
This commit is contained in:
+152
-41
@@ -6,9 +6,11 @@
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
cMonthlyView::cMonthlyView(const QDate& date, QWidget *parent) :
|
||||
cMonthlyView::cMonthlyView(const QDate& date, cBookingList* lpBookingList, 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("G", tr("Gleitzeit"));
|
||||
@@ -32,18 +34,25 @@ cMonthlyView::cMonthlyView(const QDate& date, QWidget *parent) :
|
||||
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_lpMonth->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::textChanged, this, &cMonthlyView::onTextChanged);
|
||||
|
||||
connect(ui->m_lpMonth, &QDateEdit::dateChanged, this, &cMonthlyView::onDateChanged);
|
||||
}
|
||||
|
||||
void cMonthlyView::setDate(const QDate& date)
|
||||
{
|
||||
m_loading = true;
|
||||
|
||||
m_publicHoliday.setYear(static_cast<qint16>(date.year()));
|
||||
|
||||
m_lpMonthlyListModel->clear();
|
||||
|
||||
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);
|
||||
|
||||
QList<QStandardItem*> items;
|
||||
@@ -58,6 +67,10 @@ void cMonthlyView::setDate(const QDate& date)
|
||||
items[COL_GO2]->setText("00:00:00");
|
||||
items[COL_COME3]->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_CODE]->setText("");
|
||||
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))
|
||||
{
|
||||
cBooking* lpBooking = m_lpBookingList->find(date1);
|
||||
|
||||
if(!lpBooking)
|
||||
{
|
||||
lpBooking = m_lpBookingList->add(date1);
|
||||
lpBooking->save();
|
||||
}
|
||||
|
||||
items.clear();
|
||||
|
||||
for(int y = 0;y < header.count();y++)
|
||||
items.append(new QStandardItem);
|
||||
|
||||
items[COL_DAY1]->setText(date1.toString("dddd dd"));
|
||||
items[COL_PUBLIC_HOLIDAY]->setText("");
|
||||
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_PUBLIC_HOLIDAY]->setText(m_publicHoliday.name(date1));
|
||||
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_PUBLIC_HOLIDAY]->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_COME3]->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_CODE]->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++)
|
||||
{
|
||||
if(date1.dayOfWeek() >= 6)
|
||||
if(date1.dayOfWeek() >= 6 || m_publicHoliday.isPublicHoliday(date1))
|
||||
{
|
||||
items[z]->setData(QVariant::fromValue(true), Qt::UserRole+1);
|
||||
items[z]->setBackground(weekend);
|
||||
}
|
||||
else
|
||||
items[z]->setData(QVariant::fromValue(false), Qt::UserRole+1);
|
||||
|
||||
items[z]->setData(QVariant::fromValue(lpBooking), Qt::UserRole+2);
|
||||
}
|
||||
|
||||
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_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_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")));
|
||||
|
||||
m_loading = false;
|
||||
}
|
||||
|
||||
cMonthlyView::~cMonthlyView()
|
||||
@@ -152,35 +190,108 @@ cMonthlyView::~cMonthlyView()
|
||||
|
||||
void cMonthlyView::onTimeChanged(const int day, const int field, const QTime& time)
|
||||
{
|
||||
qDebug() << "Day: " << day;
|
||||
qDebug() << "field: " << field;
|
||||
qDebug() << "time: " << time;
|
||||
QStandardItem* lpItem = m_lpMonthlyListModel->item(day-1, field);
|
||||
if(!lpItem)
|
||||
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)
|
||||
{
|
||||
qDebug() << "Day: " << day;
|
||||
qDebug() << "field: " << field;
|
||||
qDebug() << "time: " << text;
|
||||
QStandardItem* lpItem = m_lpMonthlyListModel->item(day-1, field);
|
||||
if(!lpItem)
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
setBackground(day, code);
|
||||
lpBooking->setCode(code);
|
||||
lpBooking->save();
|
||||
break;
|
||||
}
|
||||
case COL_INFORMATION:
|
||||
lpBooking->setInformation(text);
|
||||
lpBooking->save();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user