Date and time formatting now uses QLocale
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "ui_absencedialog.h"
|
||||
|
||||
#include <QDate>
|
||||
#include <QLocale>
|
||||
#include <QMessageBox>
|
||||
#include <QStringBuilder>
|
||||
#include <QMenu>
|
||||
@@ -15,7 +16,7 @@ AbsenceDialog::AbsenceDialog(int userId, const QDate &date, ZeiterfassungApi &er
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->labelTitle->setText(tr("Absences for %0").arg(date.toString(tr("dd.MM.yyyy"))));
|
||||
ui->labelTitle->setText(tr("Absences for %0").arg(QLocale().toString(date)));
|
||||
|
||||
m_model = new AbsencesModel(userId, date, erfassung, this);
|
||||
connect(m_model, &AbsencesModel::errorOccured, this, &AbsenceDialog::errorOccured);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#include "ui_lunchmealdialog.h"
|
||||
|
||||
#include <QDate>
|
||||
#include <QLocale>
|
||||
|
||||
LunchMealDialog::LunchMealDialog(const QDate &date, const QString &content, QWidget *parent) :
|
||||
ZeiterfassungDialog(parent),
|
||||
@@ -9,7 +10,7 @@ LunchMealDialog::LunchMealDialog(const QDate &date, const QString &content, QWid
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->labelTitle->setText(tr("Lunch meal for %0").arg(date.toString(tr("dd.MM.yyyy"))));
|
||||
ui->labelTitle->setText(tr("Lunch meal for %0").arg(QLocale().toString(date)));
|
||||
ui->labelLunchMeal->setText(content);
|
||||
}
|
||||
|
||||
|
@@ -14,8 +14,8 @@ ProfileDialog::ProfileDialog(const GetUserInfoReply::UserInfo &userInfo, QWidget
|
||||
ui->lineEditUsername->setText(userInfo.username);
|
||||
ui->lineEditStreet->setText(userInfo.street);
|
||||
ui->lineEditCity->setText(userInfo.city);
|
||||
ui->lineEditEmployedSince->setText(userInfo.employedSince.toString(tr("dd.MM.yyyy")));
|
||||
ui->lineEditEmployedTill->setText(userInfo.employedTill.toString(tr("dd.MM.yyyy")));
|
||||
ui->dateEditEmployedSince->setDate(userInfo.employedSince);
|
||||
ui->dateEditEmployedTill->setDate(userInfo.employedTill);
|
||||
ui->lineEditPlaceOfBirth->setText(userInfo.placeOfBirth);
|
||||
ui->lineEditZipcode->setText(userInfo.zipcode);
|
||||
ui->lineEditReligion->setText(userInfo.religion);
|
||||
|
@@ -13,7 +13,7 @@
|
||||
<property name="windowTitle">
|
||||
<string>Profile</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
@@ -25,7 +25,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>540</height>
|
||||
<height>610</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
@@ -122,6 +122,9 @@
|
||||
<property name="text">
|
||||
<string>Street:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditStreet</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
@@ -129,6 +132,9 @@
|
||||
<property name="text">
|
||||
<string>City:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditCity</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
@@ -136,6 +142,9 @@
|
||||
<property name="text">
|
||||
<string>Employed since:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>dateEditEmployedSince</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
@@ -143,6 +152,9 @@
|
||||
<property name="text">
|
||||
<string>Employed till:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>dateEditEmployedTill</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
@@ -150,6 +162,9 @@
|
||||
<property name="text">
|
||||
<string>Place of birth:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditPlaceOfBirth</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
@@ -157,6 +172,9 @@
|
||||
<property name="text">
|
||||
<string>Zipcode:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditZipcode</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
@@ -164,6 +182,9 @@
|
||||
<property name="text">
|
||||
<string>Religion:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditReligion</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
@@ -171,6 +192,9 @@
|
||||
<property name="text">
|
||||
<string>Department:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditDepartment</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
@@ -178,6 +202,9 @@
|
||||
<property name="text">
|
||||
<string>Verwendgr:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditVerwendgr</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="0">
|
||||
@@ -185,6 +212,9 @@
|
||||
<property name="text">
|
||||
<string>Taetig:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditTaetig</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="0">
|
||||
@@ -192,6 +222,9 @@
|
||||
<property name="text">
|
||||
<string>Arbverh:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditArbverh</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="16" column="0">
|
||||
@@ -199,6 +232,9 @@
|
||||
<property name="text">
|
||||
<string>Betriebsnr:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditBetriebsnr</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
@@ -215,20 +251,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLineEdit" name="lineEditEmployedSince">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QLineEdit" name="lineEditEmployedTill">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QLineEdit" name="lineEditPlaceOfBirth">
|
||||
<property name="readOnly">
|
||||
@@ -285,6 +307,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QDateEdit" name="dateEditEmployedSince">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QDateEdit" name="dateEditEmployedTill">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "stripswidget.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QLocale>
|
||||
#include <QVector>
|
||||
#include <QLabel>
|
||||
#include <QMap>
|
||||
@@ -12,9 +13,6 @@
|
||||
#include "timeutils.h"
|
||||
#include "stripfactory.h"
|
||||
|
||||
const QStringList StripsWidget::m_weekDays { tr("Monday"), tr("Tuesday"),
|
||||
tr("Wednesday"), tr("Thursday"), tr("Friday"), tr("Saturday"), tr("Sunday") };
|
||||
|
||||
StripsWidget::StripsWidget(MainWindow &mainWindow, QWidget *parent) :
|
||||
QFrame(parent),
|
||||
m_mainWindow(mainWindow),
|
||||
@@ -87,9 +85,7 @@ void StripsWidget::setDate(const QDate &date)
|
||||
Q_EMIT dateChanged(m_date = date);
|
||||
|
||||
if(m_date.isValid())
|
||||
m_label[0]->setText(tr("%0 (%1)")
|
||||
.arg(m_weekDays.at(m_date.dayOfWeek() - 1))
|
||||
.arg(m_date.toString(tr("dd.MM.yyyy"))));
|
||||
m_label[0]->setText(QLocale().toString(m_date, QLocale::LongFormat));
|
||||
else
|
||||
m_label[0]->setText(tr("Invalid"));
|
||||
|
||||
@@ -313,7 +309,7 @@ bool StripsWidget::createStrips()
|
||||
if(lastBooking)
|
||||
{
|
||||
auto breakTime = timeBetween(lastBooking->time, startBooking.time);
|
||||
auto label = new QLabel(tr("%0: %1").arg(tr("Break")).arg(tr("%0h").arg(breakTime.toString(tr("HH:mm")))), this);
|
||||
auto label = new QLabel(tr("%0: %1").arg(tr("Break")).arg(tr("%0h").arg(QLocale().toString(breakTime, QLocale::ShortFormat))), this);
|
||||
m_stripsLayout->addWidget(label);
|
||||
}
|
||||
|
||||
@@ -420,7 +416,7 @@ bool StripsWidget::createStrips()
|
||||
if(timeAssignmentsIter == m_timeAssignments.constEnd())
|
||||
{
|
||||
errorMessage = tr("Missing time assignment! Missing: %0")
|
||||
.arg(tr("%0h").arg(timeBetween(timeAssignmentTime, bookingTimespan).toString(tr("HH:mm:ss"))));
|
||||
.arg(tr("%0h").arg(QLocale().toString(timeBetween(timeAssignmentTime, bookingTimespan), QLocale::ShortFormat)));
|
||||
|
||||
appendBookingEndStrip(endBooking.id, endBooking.time, currBookingDuration);
|
||||
|
||||
@@ -464,8 +460,8 @@ bool StripsWidget::createStrips()
|
||||
if(timeAssignmentTime > bookingTimespan)
|
||||
{
|
||||
errorMessage = tr("Time assignment time longer than booking time!\nTime assignment: %0\nBooking: %1")
|
||||
.arg(timeAssignmentTime.toString(tr("HH:mm:ss")))
|
||||
.arg(bookingTimespan.toString(tr("HH:mm:ss")));
|
||||
.arg(QLocale().toString(timeAssignmentTime, QLocale::ShortFormat))
|
||||
.arg(QLocale().toString(bookingTimespan, QLocale::ShortFormat));
|
||||
}
|
||||
|
||||
appendBookingEndStrip(endBooking.id, endBooking.time, currBookingDuration);
|
||||
@@ -483,7 +479,7 @@ bool StripsWidget::createStrips()
|
||||
{
|
||||
auto label = new QLabel(tr("%0: %1")
|
||||
.arg(tr("Assigned time"))
|
||||
.arg(tr("%0h").arg(timeAssignmentTime.toString(tr("HH:mm")))), this);
|
||||
.arg(tr("%0h").arg(QLocale().toString(timeAssignmentTime, QLocale::ShortFormat))), this);
|
||||
m_stripsLayout->addWidget(label);
|
||||
}
|
||||
else
|
||||
@@ -532,7 +528,8 @@ void StripsWidget::getDayinfoFinished()
|
||||
{
|
||||
Q_EMIT dayinfoChanged(m_dayinfo = m_getDayinfoReply->dayinfos().first());
|
||||
|
||||
m_label[1]->setText(QString("%0 - %1").arg(m_dayinfo.soll.toString("HH:mm")).arg(m_dayinfo.ist.toString("HH:mm")));
|
||||
m_label[1]->setText(QString("%0 - %1").arg(QLocale().toString(m_dayinfo.soll, QLocale::ShortFormat),
|
||||
QLocale().toString(m_dayinfo.ist, QLocale::ShortFormat)));
|
||||
}
|
||||
|
||||
void StripsWidget::getBookingsFinished()
|
||||
@@ -601,7 +598,7 @@ QWidget *StripsWidget::appendBookingStartStrip(int id, const QTime &time)
|
||||
auto widget = m_mainWindow.stripFactory().createBookingStartStrip(this).release();
|
||||
|
||||
if(auto labelTime = widget->findChild<QWidget*>(QStringLiteral("labelTime")))
|
||||
labelTime->setProperty("text", time.toString(tr("HH:mm")));
|
||||
labelTime->setProperty("text", QLocale().toString(time, QLocale::ShortFormat));
|
||||
else
|
||||
qWarning() << "no labelTime found!";
|
||||
|
||||
@@ -620,12 +617,12 @@ QWidget *StripsWidget::appendBookingEndStrip(int id, const QTime &time, const QT
|
||||
auto widget = m_mainWindow.stripFactory().createBookingEndStrip(this).release();
|
||||
|
||||
if(auto labelTime = widget->findChild<QWidget*>(QStringLiteral("labelTime")))
|
||||
labelTime->setProperty("text", time.toString(tr("HH:mm")));
|
||||
labelTime->setProperty("text", QLocale().toString(time, QLocale::ShortFormat));
|
||||
else
|
||||
qWarning() << "no labelTime found!";
|
||||
|
||||
if(auto labelDuration = widget->findChild<QWidget*>(QStringLiteral("labelDuration")))
|
||||
labelDuration->setProperty("text", tr("%0h").arg(duration.toString(tr("HH:mm"))));
|
||||
labelDuration->setProperty("text", tr("%0h").arg(QLocale().toString(duration, QLocale::ShortFormat)));
|
||||
else
|
||||
qWarning() << "no labelDuration found!";
|
||||
|
||||
@@ -644,7 +641,7 @@ QWidget *StripsWidget::appendTimeAssignmentStrip(int id, const QTime &duration,
|
||||
auto widget = m_mainWindow.stripFactory().createTimeAssignmentStrip(this).release();
|
||||
|
||||
if(auto labelTime = widget->findChild<QWidget*>(QStringLiteral("labelTime")))
|
||||
labelTime->setProperty("text", duration == QTime(0, 0) ? tr("Open") : duration.toString(tr("HH:mm")));
|
||||
labelTime->setProperty("text", duration == QTime(0, 0) ? tr("Open") : QLocale().toString(duration, QLocale::ShortFormat));
|
||||
else
|
||||
qWarning() << "no labelTime found!";
|
||||
|
||||
|
@@ -117,6 +117,4 @@ private:
|
||||
std::unique_ptr<GetDayinfoReply> m_getDayinfoReply;
|
||||
std::unique_ptr<GetBookingsReply> m_getBookingsReply;
|
||||
std::unique_ptr<GetTimeAssignmentsReply> m_getTimeAssignmentsReply;
|
||||
|
||||
static const QStringList m_weekDays;
|
||||
};
|
||||
|
Reference in New Issue
Block a user