Skip to content

Commit

Permalink
Fixed time AM/PM are not translated
Browse files Browse the repository at this point in the history
  • Loading branch information
foldynl committed Feb 22, 2025
1 parent df7db5f commit 1665a12
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 28 deletions.
2 changes: 1 addition & 1 deletion models/AlertTableModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ QVariant AlertTableModel::data(const QModelIndex& index, int role) const
case COLUMN_FREQ: return QSTRING_FREQ(selectedRecord.alert.spot.freq);
case COLUMN_MODE: return selectedRecord.alert.spot.modeGroupString;
case COLUMN_UPDATED: return selectedRecord.counter;
case COLUMN_LAST_UPDATE: return selectedRecord.alert.spot.dateTime.toString(locale.formatTimeLongWithoutTZ());
case COLUMN_LAST_UPDATE: return locale.toString(selectedRecord.alert.spot.dateTime,locale.formatTimeLongWithoutTZ());
case COLUMN_LAST_COMMENT: return selectedRecord.alert.spot.comment;
case COLUMN_MEMBER: return selectedRecord.alert.spot.memberList2StringList().join(",");
default: return QVariant();
Expand Down
2 changes: 1 addition & 1 deletion ui/BandmapWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void BandmapWidget::updateStations()
QPen(QColor(192,192,192))));

const QString &callsignTmp = lower.value().callsign;
const QString &timeTmp = lower.value().dateTime.toString(locale.formatTimeShort());
const QString &timeTmp = locale.toString(lower.value().dateTime, locale.formatTimeShort());

QGraphicsTextItem* text = bandmapScene->addText(callsignTmp + " @ " + timeTmp);
text->document()->setDocumentMargin(0);
Expand Down
6 changes: 3 additions & 3 deletions ui/ClockWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void ClockWidget::updateClock()
QDateTime now = QDateTime::currentDateTime().toTimeZone(QTimeZone::utc());
QColor textColor = qApp->palette().color(QPalette::Text);
clockItem->setDefaultTextColor(textColor);
clockItem->setPlainText(now.toString(locale.formatTimeLongWithoutTZ()));
clockItem->setPlainText(locale.toString(now, locale.formatTimeLongWithoutTZ()));

if (now.time().second() == 0)
{
Expand Down Expand Up @@ -95,8 +95,8 @@ void ClockWidget::updateSun()
sunrise = QTime::fromMSecsSinceStartOfDay(static_cast<int>(fmod(Jrise, 1.0) * MSECS_PER_DAY));
sunset = QTime::fromMSecsSinceStartOfDay(static_cast<int>(fmod(Jset, 1.0) * MSECS_PER_DAY));

ui->sunRiseLabel->setText(sunrise.toString(locale.formatTimeShort()));
ui->sunSetLabel->setText(sunset.toString(locale.formatTimeShort()));
ui->sunRiseLabel->setText(locale.toString(sunrise, locale.formatTimeShort()));
ui->sunSetLabel->setText(locale.toString(sunset, locale.formatTimeShort()));
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions ui/DxWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ QVariant DxTableModel::data(const QModelIndex& index, int role) const
switch ( index.column() )
{
case 0:
return spot.dateTime.toString(locale.formatTimeLongWithoutTZ());
return locale.toString(spot.dateTime, locale.formatTimeLongWithoutTZ());
case 1:
return spot.callsign;
case 2:
Expand Down Expand Up @@ -174,7 +174,7 @@ QVariant WCYTableModel::data(const QModelIndex& index, int role) const
switch ( index.column() )
{
case 0:
return spot.time.toString(locale.formatTimeLongWithoutTZ());
return locale.toString(spot.time, locale.formatTimeLongWithoutTZ());
case 1:
return spot.KIndex;
case 2:
Expand Down Expand Up @@ -252,7 +252,7 @@ QVariant WWVTableModel::data(const QModelIndex& index, int role) const
switch ( index.column() )
{
case 0:
return spot.time.toString(locale.formatTimeLongWithoutTZ());
return locale.toString(spot.time, locale.formatTimeLongWithoutTZ());
case 1:
return spot.SFI;
case 2:
Expand Down Expand Up @@ -317,7 +317,7 @@ QVariant ToAllTableModel::data(const QModelIndex& index, int role) const

switch (index.column()) {
case 0:
return spot.time.toString(locale.formatTimeLongWithoutTZ());
return locale.toString(spot.time, locale.formatTimeLongWithoutTZ());
case 1:
return spot.spotter;
case 2:
Expand Down
2 changes: 1 addition & 1 deletion ui/ImportDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void ImportDialog::saveImportDetails(const QString &importDetail, const QString
QTextStream out(&file);
out << tr("QLog Import Summary") << "\n"
<< "\n"
<< tr("Import date") << ": " << currTime.toString(locale.formatDateShortWithYYYY()) << " " << currTime.toString(locale.formatTimeLongWithoutTZ()) << " UTC\n"
<< tr("Import date") << ": " << currTime.toString(locale.formatDateShortWithYYYY()) << " " << locale.toString(currTime, locale.formatTimeLongWithoutTZ()) << " UTC\n"
<< tr("Imported file") << ": " << filename
<< "\n\n"
<< tr("Imported: %n contact(s)", "", count) << "\n"
Expand Down
2 changes: 1 addition & 1 deletion ui/NewContactWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2199,7 +2199,7 @@ void NewContactWidget::updatePartnerLocTime()

if ( partnerTimeZone.isValid() )
{
ui->partnerLocTimeInfo->setText(QDateTime::currentDateTime().toTimeZone(partnerTimeZone).toString(locale.formatTimeLong())
ui->partnerLocTimeInfo->setText(locale.toString(QDateTime::currentDateTime().toTimeZone(partnerTimeZone), locale.formatTimeLong())
+ " (" + getGreeting() +")");
}
}
Expand Down
20 changes: 3 additions & 17 deletions ui/StyleItemDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,6 @@ class DateFormatDelegate : public QStyledItemDelegate {
}
};

class TimeFormatDelegate : public QStyledItemDelegate {
private:
LogLocale locale;
public:
TimeFormatDelegate(QObject* parent = 0) :
QStyledItemDelegate(parent) { }

QString displayText(const QVariant& value, const QLocale&) const
{
// own Locale

return value.toTime().toString(locale.formatTimeLongWithoutTZ());
}
};

class TimestampFormatDelegate : public QStyledItemDelegate {
private:
LogLocale locale;
Expand All @@ -112,8 +97,9 @@ class TimestampFormatDelegate : public QStyledItemDelegate {

QString displayText(const QVariant& value, const QLocale&) const
{
// own Locale
return value.toDateTime().toTimeZone(QTimeZone::utc()).toString(locale.formatDateShortWithYYYY() + " " + locale.formatTimeLongWithoutTZ());
return locale.toString(value.toDateTime().toTimeZone(QTimeZone::utc()), locale.formatDateShortWithYYYY()
+ " "
+ locale.formatTimeLongWithoutTZ());
}

QWidget* createEditor(QWidget* parent,
Expand Down

0 comments on commit 1665a12

Please sign in to comment.