From cede5ac9d203d484b643165941be3c532e9f9d99 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 6 Jan 2021 12:47:18 +0800 Subject: [PATCH] Migrate away from deprecated Qt functions `QString QDateTime::toString(Qt::DateFormat format = Qt::TextDate)` will be removed in Qt6. --- src/gui/addnewtorrentdialog.cpp | 2 +- src/gui/log/logmodel.cpp | 4 ++-- src/gui/properties/propertieswidget.cpp | 8 ++++---- src/gui/rss/rsswidget.cpp | 2 +- src/gui/transferlistmodel.cpp | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index f05cd94c5..0a2fee182 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -655,7 +655,7 @@ void AddNewTorrentDialog::setupTreeview() // Set torrent information m_ui->labelCommentData->setText(Utils::Misc::parseHtmlLinks(m_torrentInfo.comment().toHtmlEscaped())); - m_ui->labelDateData->setText(!m_torrentInfo.creationDate().isNull() ? m_torrentInfo.creationDate().toString(Qt::DefaultLocaleShortDate) : tr("Not available")); + m_ui->labelDateData->setText(!m_torrentInfo.creationDate().isNull() ? QLocale().toString(m_torrentInfo.creationDate(), QLocale::ShortFormat) : tr("Not available")); // Prepare content tree m_contentModel = new TorrentContentFilterModel(this); diff --git a/src/gui/log/logmodel.cpp b/src/gui/log/logmodel.cpp index d15b66504..50386e323 100644 --- a/src/gui/log/logmodel.cpp +++ b/src/gui/log/logmodel.cpp @@ -155,7 +155,7 @@ LogMessageModel::LogMessageModel(QObject *parent) void LogMessageModel::handleNewMessage(const Log::Msg &message) { - const QString time = QDateTime::fromMSecsSinceEpoch(message.timestamp).toString(Qt::SystemLocaleShortDate); + const QString time = QLocale::system().toString(QDateTime::fromMSecsSinceEpoch(message.timestamp), QLocale::ShortFormat); const QString messageText = message.message; const QColor foreground = m_foregroundForMessageTypes[message.type]; @@ -173,7 +173,7 @@ LogPeerModel::LogPeerModel(QObject *parent) void LogPeerModel::handleNewMessage(const Log::Peer &peer) { - const QString time = QDateTime::fromMSecsSinceEpoch(peer.timestamp).toString(Qt::SystemLocaleShortDate); + const QString time = QLocale::system().toString(QDateTime::fromMSecsSinceEpoch(peer.timestamp), QLocale::ShortFormat); const QString message = peer.blocked ? tr("%1 was blocked. Reason: %2.", "0.0.0.0 was blocked. Reason: reason for blocking.").arg(peer.ip, peer.reason) : tr("%1 was banned", "0.0.0.0 was banned").arg(peer.ip); diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index ea050b175..960987149 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -319,7 +319,7 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::TorrentHandle *const torrent if (m_torrent->hasMetadata()) { // Creation date - m_ui->labelCreatedOnVal->setText(m_torrent->creationDate().toString(Qt::DefaultLocaleShortDate)); + m_ui->labelCreatedOnVal->setText(QLocale().toString(m_torrent->creationDate(), QLocale::ShortFormat)); m_ui->labelTotalSizeVal->setText(Utils::Misc::friendlyUnit(m_torrent->totalSize())); @@ -457,11 +457,11 @@ void PropertiesWidget::loadDynamicData() m_ui->labelUpSpeedVal->setText(tr("%1 (%2 avg.)", "%1 and %2 are speed rates, e.g. 200KiB/s (100KiB/s avg.)") .arg(Utils::Misc::friendlyUnit(m_torrent->uploadPayloadRate(), true), ulAvg)); - m_ui->labelLastSeenCompleteVal->setText(m_torrent->lastSeenComplete().isValid() ? m_torrent->lastSeenComplete().toString(Qt::DefaultLocaleShortDate) : tr("Never")); + m_ui->labelLastSeenCompleteVal->setText(m_torrent->lastSeenComplete().isValid() ? QLocale().toString(m_torrent->lastSeenComplete(), QLocale::ShortFormat) : tr("Never")); - m_ui->labelCompletedOnVal->setText(m_torrent->completedTime().isValid() ? m_torrent->completedTime().toString(Qt::DefaultLocaleShortDate) : ""); + m_ui->labelCompletedOnVal->setText(m_torrent->completedTime().isValid() ? QLocale().toString(m_torrent->completedTime(), QLocale::ShortFormat) : QString {}); - m_ui->labelAddedOnVal->setText(m_torrent->addedTime().toString(Qt::DefaultLocaleShortDate)); + m_ui->labelAddedOnVal->setText(QLocale().toString(m_torrent->addedTime(), QLocale::ShortFormat)); if (m_torrent->hasMetadata()) { diff --git a/src/gui/rss/rsswidget.cpp b/src/gui/rss/rsswidget.cpp index ff085c38f..4a11a7635 100644 --- a/src/gui/rss/rsswidget.cpp +++ b/src/gui/rss/rsswidget.cpp @@ -486,7 +486,7 @@ void RSSWidget::handleCurrentArticleItemChanged(QListWidgetItem *currentItem, QL QString::fromLatin1("
") + QString::fromLatin1("
%3
").arg(highlightedBaseColor, highlightedBaseTextColor, article->title()); if (article->date().isValid()) - html += QString::fromLatin1("
%2%3
").arg(alternateBaseColor, tr("Date: "), article->date().toLocalTime().toString(Qt::SystemLocaleLongDate)); + html += QString::fromLatin1("
%2%3
").arg(alternateBaseColor, tr("Date: "), QLocale::system().toString(article->date().toLocalTime())); if (!article->author().isEmpty()) html += QString::fromLatin1("
%2%3
").arg(alternateBaseColor, tr("Author: "), article->author()); html += "
" diff --git a/src/gui/transferlistmodel.cpp b/src/gui/transferlistmodel.cpp index 479ec0d3c..26d25dabf 100644 --- a/src/gui/transferlistmodel.cpp +++ b/src/gui/transferlistmodel.cpp @@ -361,9 +361,9 @@ QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent case TR_TAGS: return tagsString(torrent->tags()); case TR_ADD_DATE: - return torrent->addedTime().toLocalTime().toString(Qt::DefaultLocaleShortDate); + return QLocale().toString(torrent->addedTime().toLocalTime(), QLocale::ShortFormat); case TR_SEED_DATE: - return torrent->completedTime().toLocalTime().toString(Qt::DefaultLocaleShortDate); + return QLocale().toString(torrent->completedTime().toLocalTime(), QLocale::ShortFormat); case TR_TRACKER: return torrent->currentTracker(); case TR_DLLIMIT: @@ -387,7 +387,7 @@ QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent case TR_COMPLETED: return unitString(torrent->completedSize()); case TR_SEEN_COMPLETE_DATE: - return torrent->lastSeenComplete().toLocalTime().toString(Qt::DefaultLocaleShortDate); + return QLocale().toString(torrent->lastSeenComplete().toLocalTime(), QLocale::ShortFormat); case TR_LAST_ACTIVITY: return lastActivityString((torrent->isPaused() || torrent->isChecking()) ? -1 : torrent->timeSinceActivity()); case TR_AVAILABILITY: