Implemented strip rendering with other booking types
This commit is contained in:
@@ -213,7 +213,9 @@ void MainWindow::pushButtonStartPressed()
|
||||
}
|
||||
|
||||
if(m_currentStripWidget->bookings().rbegin() == m_currentStripWidget->bookings().rend() ||
|
||||
m_currentStripWidget->bookings().rbegin()->type == QStringLiteral("G"))
|
||||
m_currentStripWidget->bookings().rbegin()->type == QStringLiteral("G") ||
|
||||
m_currentStripWidget->bookings().rbegin()->type == QStringLiteral("GA") ||
|
||||
m_currentStripWidget->bookings().rbegin()->type == QStringLiteral("GM"))
|
||||
{
|
||||
auto reply = m_erfassung.doCreateBooking(m_userInfo.userId, ui->dateEditDate->date(),
|
||||
timeNormalise(ui->timeEditTime->time()), QTime(0, 0),
|
||||
|
@@ -298,7 +298,9 @@ bool StripsWidget::createStrips()
|
||||
}
|
||||
|
||||
auto startBooking = *bookingsIter++;
|
||||
if(startBooking.type != QStringLiteral("K"))
|
||||
if(startBooking.type != QStringLiteral("K") &&
|
||||
startBooking.type != QStringLiteral("KA") &&
|
||||
startBooking.type != QStringLiteral("KM"))
|
||||
{
|
||||
errorMessage = tr("Expected start booking, instead got type %0\nBooking ID: %1")
|
||||
.arg(startBooking.type)
|
||||
@@ -316,7 +318,7 @@ bool StripsWidget::createStrips()
|
||||
lastBooking = &startBooking;
|
||||
|
||||
lastTimeAssignmentStart = startBooking.time;
|
||||
appendBookingStartStrip(startBooking.id, startBooking.time);
|
||||
appendBookingStartStrip(startBooking.id, startBooking.time, startBooking.type);
|
||||
|
||||
if(timeAssignmentsIter == m_timeAssignments.constEnd())
|
||||
{
|
||||
@@ -397,7 +399,9 @@ bool StripsWidget::createStrips()
|
||||
else
|
||||
{
|
||||
auto endBooking = *bookingsIter++;
|
||||
if(endBooking.type != QStringLiteral("G"))
|
||||
if(endBooking.type != QStringLiteral("G") &&
|
||||
endBooking.type != QStringLiteral("GA") &&
|
||||
endBooking.type != QStringLiteral("GM"))
|
||||
{
|
||||
errorMessage = tr("Expected end booking, instead got type %0\nBooking ID: %1")
|
||||
.arg(endBooking.type)
|
||||
@@ -418,7 +422,7 @@ bool StripsWidget::createStrips()
|
||||
errorMessage = tr("Missing time assignment! Missing: %0")
|
||||
.arg(tr("%0h").arg(QLocale().toString(timeBetween(timeAssignmentTime, bookingTimespan), QLocale::ShortFormat)));
|
||||
|
||||
appendBookingEndStrip(endBooking.id, endBooking.time, currBookingDuration);
|
||||
appendBookingEndStrip(endBooking.id, endBooking.time, currBookingDuration, endBooking.type);
|
||||
|
||||
goto after;
|
||||
}
|
||||
@@ -464,7 +468,7 @@ bool StripsWidget::createStrips()
|
||||
.arg(QLocale().toString(bookingTimespan, QLocale::ShortFormat));
|
||||
}
|
||||
|
||||
appendBookingEndStrip(endBooking.id, endBooking.time, currBookingDuration);
|
||||
appendBookingEndStrip(endBooking.id, endBooking.time, currBookingDuration, endBooking.type);
|
||||
|
||||
if(timeAssignmentTime > bookingTimespan)
|
||||
goto after;
|
||||
@@ -593,7 +597,7 @@ QString StripsWidget::buildProjectString(const QString &project) const
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *StripsWidget::appendBookingStartStrip(int id, const QTime &time)
|
||||
QWidget *StripsWidget::appendBookingStartStrip(int id, const QTime &time, const QString &type)
|
||||
{
|
||||
auto widget = m_mainWindow.stripFactory().createBookingStartStrip(this).release();
|
||||
|
||||
@@ -602,6 +606,22 @@ QWidget *StripsWidget::appendBookingStartStrip(int id, const QTime &time)
|
||||
else
|
||||
qWarning() << "no labelTime found!";
|
||||
|
||||
if(type != QStringLiteral("K"))
|
||||
{
|
||||
QString textToAppend;
|
||||
if(type == QStringLiteral("KA"))
|
||||
textToAppend = tr("Doctor");
|
||||
else if(type == QStringLiteral("KM"))
|
||||
textToAppend = tr("Government");
|
||||
else
|
||||
textToAppend = tr("Unknown");
|
||||
|
||||
if(auto labelType = widget->findChild<QWidget*>(QStringLiteral("labelType")))
|
||||
labelType->setProperty("text", QString(labelType->property("text").toString() % " (" % textToAppend % ')'));
|
||||
else
|
||||
qWarning() << "no labelType found!";
|
||||
}
|
||||
|
||||
if(auto labelId = widget->findChild<QWidget*>(QStringLiteral("labelId")))
|
||||
labelId->setProperty("text", QString::number(id));
|
||||
else
|
||||
@@ -612,7 +632,7 @@ QWidget *StripsWidget::appendBookingStartStrip(int id, const QTime &time)
|
||||
return widget;
|
||||
}
|
||||
|
||||
QWidget *StripsWidget::appendBookingEndStrip(int id, const QTime &time, const QTime &duration)
|
||||
QWidget *StripsWidget::appendBookingEndStrip(int id, const QTime &time, const QTime &duration, const QString &type)
|
||||
{
|
||||
auto widget = m_mainWindow.stripFactory().createBookingEndStrip(this).release();
|
||||
|
||||
@@ -621,6 +641,22 @@ QWidget *StripsWidget::appendBookingEndStrip(int id, const QTime &time, const QT
|
||||
else
|
||||
qWarning() << "no labelTime found!";
|
||||
|
||||
if(type != QStringLiteral("G"))
|
||||
{
|
||||
QString textToAppend;
|
||||
if(type == QStringLiteral("GA"))
|
||||
textToAppend = tr("Doctor");
|
||||
else if(type == QStringLiteral("GM"))
|
||||
textToAppend = tr("Government");
|
||||
else
|
||||
textToAppend = tr("Unknown");
|
||||
|
||||
if(auto labelType = widget->findChild<QWidget*>(QStringLiteral("labelType")))
|
||||
labelType->setProperty("text", QString(labelType->property("text").toString() % " (" % textToAppend % ')'));
|
||||
else
|
||||
qWarning() << "no labelType found!";
|
||||
}
|
||||
|
||||
if(auto labelDuration = widget->findChild<QWidget*>(QStringLiteral("labelDuration")))
|
||||
labelDuration->setProperty("text", tr("%0h").arg(QLocale().toString(duration, QLocale::ShortFormat)));
|
||||
else
|
||||
|
@@ -85,8 +85,8 @@ private:
|
||||
void invalidateValues();
|
||||
QString buildProjectString(const QString &project) const;
|
||||
|
||||
QWidget *appendBookingStartStrip(int id, const QTime &time);
|
||||
QWidget *appendBookingEndStrip(int id, const QTime &time, const QTime &duration);
|
||||
QWidget *appendBookingStartStrip(int id, const QTime &time, const QString &type);
|
||||
QWidget *appendBookingEndStrip(int id, const QTime &time, const QTime &duration, const QString &type);
|
||||
QWidget *appendTimeAssignmentStrip(int id, const QTime &duration, const QString &project, const QString &subproject,
|
||||
const QString &workpackage, const QString &text);
|
||||
|
||||
|
Reference in New Issue
Block a user