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