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() ||
|
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(),
|
auto reply = m_erfassung.doCreateBooking(m_userInfo.userId, ui->dateEditDate->date(),
|
||||||
timeNormalise(ui->timeEditTime->time()), QTime(0, 0),
|
timeNormalise(ui->timeEditTime->time()), QTime(0, 0),
|
||||||
|
@@ -298,7 +298,9 @@ bool StripsWidget::createStrips()
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto startBooking = *bookingsIter++;
|
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")
|
errorMessage = tr("Expected start booking, instead got type %0\nBooking ID: %1")
|
||||||
.arg(startBooking.type)
|
.arg(startBooking.type)
|
||||||
@@ -316,7 +318,7 @@ bool StripsWidget::createStrips()
|
|||||||
lastBooking = &startBooking;
|
lastBooking = &startBooking;
|
||||||
|
|
||||||
lastTimeAssignmentStart = startBooking.time;
|
lastTimeAssignmentStart = startBooking.time;
|
||||||
appendBookingStartStrip(startBooking.id, startBooking.time);
|
appendBookingStartStrip(startBooking.id, startBooking.time, startBooking.type);
|
||||||
|
|
||||||
if(timeAssignmentsIter == m_timeAssignments.constEnd())
|
if(timeAssignmentsIter == m_timeAssignments.constEnd())
|
||||||
{
|
{
|
||||||
@@ -397,7 +399,9 @@ bool StripsWidget::createStrips()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto endBooking = *bookingsIter++;
|
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")
|
errorMessage = tr("Expected end booking, instead got type %0\nBooking ID: %1")
|
||||||
.arg(endBooking.type)
|
.arg(endBooking.type)
|
||||||
@@ -418,7 +422,7 @@ bool StripsWidget::createStrips()
|
|||||||
errorMessage = tr("Missing time assignment! Missing: %0")
|
errorMessage = tr("Missing time assignment! Missing: %0")
|
||||||
.arg(tr("%0h").arg(QLocale().toString(timeBetween(timeAssignmentTime, bookingTimespan), QLocale::ShortFormat)));
|
.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;
|
goto after;
|
||||||
}
|
}
|
||||||
@@ -464,7 +468,7 @@ bool StripsWidget::createStrips()
|
|||||||
.arg(QLocale().toString(bookingTimespan, QLocale::ShortFormat));
|
.arg(QLocale().toString(bookingTimespan, QLocale::ShortFormat));
|
||||||
}
|
}
|
||||||
|
|
||||||
appendBookingEndStrip(endBooking.id, endBooking.time, currBookingDuration);
|
appendBookingEndStrip(endBooking.id, endBooking.time, currBookingDuration, endBooking.type);
|
||||||
|
|
||||||
if(timeAssignmentTime > bookingTimespan)
|
if(timeAssignmentTime > bookingTimespan)
|
||||||
goto after;
|
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();
|
auto widget = m_mainWindow.stripFactory().createBookingStartStrip(this).release();
|
||||||
|
|
||||||
@@ -602,6 +606,22 @@ QWidget *StripsWidget::appendBookingStartStrip(int id, const QTime &time)
|
|||||||
else
|
else
|
||||||
qWarning() << "no labelTime found!";
|
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")))
|
if(auto labelId = widget->findChild<QWidget*>(QStringLiteral("labelId")))
|
||||||
labelId->setProperty("text", QString::number(id));
|
labelId->setProperty("text", QString::number(id));
|
||||||
else
|
else
|
||||||
@@ -612,7 +632,7 @@ QWidget *StripsWidget::appendBookingStartStrip(int id, const QTime &time)
|
|||||||
return widget;
|
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();
|
auto widget = m_mainWindow.stripFactory().createBookingEndStrip(this).release();
|
||||||
|
|
||||||
@@ -621,6 +641,22 @@ QWidget *StripsWidget::appendBookingEndStrip(int id, const QTime &time, const QT
|
|||||||
else
|
else
|
||||||
qWarning() << "no labelTime found!";
|
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")))
|
if(auto labelDuration = widget->findChild<QWidget*>(QStringLiteral("labelDuration")))
|
||||||
labelDuration->setProperty("text", tr("%0h").arg(QLocale().toString(duration, QLocale::ShortFormat)));
|
labelDuration->setProperty("text", tr("%0h").arg(QLocale().toString(duration, QLocale::ShortFormat)));
|
||||||
else
|
else
|
||||||
|
@@ -85,8 +85,8 @@ private:
|
|||||||
void invalidateValues();
|
void invalidateValues();
|
||||||
QString buildProjectString(const QString &project) const;
|
QString buildProjectString(const QString &project) const;
|
||||||
|
|
||||||
QWidget *appendBookingStartStrip(int id, const QTime &time);
|
QWidget *appendBookingStartStrip(int id, const QTime &time, const QString &type);
|
||||||
QWidget *appendBookingEndStrip(int id, const QTime &time, const QTime &duration);
|
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,
|
QWidget *appendTimeAssignmentStrip(int id, const QTime &duration, const QString &project, const QString &subproject,
|
||||||
const QString &workpackage, const QString &text);
|
const QString &workpackage, const QString &text);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user