Browse Source

Migrate away from deprecated Qt functions

`QString QDateTime::toString(Qt::DateFormat format = Qt::TextDate)` will
be removed in Qt6.
adaptive-webui-19844
Chocobo1 4 years ago
parent
commit
cede5ac9d2
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 2
      src/gui/addnewtorrentdialog.cpp
  2. 4
      src/gui/log/logmodel.cpp
  3. 8
      src/gui/properties/propertieswidget.cpp
  4. 2
      src/gui/rss/rsswidget.cpp
  5. 6
      src/gui/transferlistmodel.cpp

2
src/gui/addnewtorrentdialog.cpp

@ -655,7 +655,7 @@ void AddNewTorrentDialog::setupTreeview()
// Set torrent information // Set torrent information
m_ui->labelCommentData->setText(Utils::Misc::parseHtmlLinks(m_torrentInfo.comment().toHtmlEscaped())); 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 // Prepare content tree
m_contentModel = new TorrentContentFilterModel(this); m_contentModel = new TorrentContentFilterModel(this);

4
src/gui/log/logmodel.cpp

@ -155,7 +155,7 @@ LogMessageModel::LogMessageModel(QObject *parent)
void LogMessageModel::handleNewMessage(const Log::Msg &message) 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 QString messageText = message.message;
const QColor foreground = m_foregroundForMessageTypes[message.type]; const QColor foreground = m_foregroundForMessageTypes[message.type];
@ -173,7 +173,7 @@ LogPeerModel::LogPeerModel(QObject *parent)
void LogPeerModel::handleNewMessage(const Log::Peer &peer) 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 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 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); : tr("%1 was banned", "0.0.0.0 was banned").arg(peer.ip);

8
src/gui/properties/propertieswidget.cpp

@ -319,7 +319,7 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::TorrentHandle *const torrent
if (m_torrent->hasMetadata()) if (m_torrent->hasMetadata())
{ {
// Creation date // 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())); 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.)") 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)); .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()) if (m_torrent->hasMetadata())
{ {

2
src/gui/rss/rsswidget.cpp

@ -486,7 +486,7 @@ void RSSWidget::handleCurrentArticleItemChanged(QListWidgetItem *currentItem, QL
QString::fromLatin1("<div style='border: 2px solid red; margin-left: 5px; margin-right: 5px; margin-bottom: 5px;'>") + QString::fromLatin1("<div style='border: 2px solid red; margin-left: 5px; margin-right: 5px; margin-bottom: 5px;'>") +
QString::fromLatin1("<div style='background-color: \"%1\"; font-weight: bold; color: \"%2\";'>%3</div>").arg(highlightedBaseColor, highlightedBaseTextColor, article->title()); QString::fromLatin1("<div style='background-color: \"%1\"; font-weight: bold; color: \"%2\";'>%3</div>").arg(highlightedBaseColor, highlightedBaseTextColor, article->title());
if (article->date().isValid()) if (article->date().isValid())
html += QString::fromLatin1("<div style='background-color: \"%1\";'><b>%2</b>%3</div>").arg(alternateBaseColor, tr("Date: "), article->date().toLocalTime().toString(Qt::SystemLocaleLongDate)); html += QString::fromLatin1("<div style='background-color: \"%1\";'><b>%2</b>%3</div>").arg(alternateBaseColor, tr("Date: "), QLocale::system().toString(article->date().toLocalTime()));
if (!article->author().isEmpty()) if (!article->author().isEmpty())
html += QString::fromLatin1("<div style='background-color: \"%1\";'><b>%2</b>%3</div>").arg(alternateBaseColor, tr("Author: "), article->author()); html += QString::fromLatin1("<div style='background-color: \"%1\";'><b>%2</b>%3</div>").arg(alternateBaseColor, tr("Author: "), article->author());
html += "</div>" html += "</div>"

6
src/gui/transferlistmodel.cpp

@ -361,9 +361,9 @@ QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent
case TR_TAGS: case TR_TAGS:
return tagsString(torrent->tags()); return tagsString(torrent->tags());
case TR_ADD_DATE: case TR_ADD_DATE:
return torrent->addedTime().toLocalTime().toString(Qt::DefaultLocaleShortDate); return QLocale().toString(torrent->addedTime().toLocalTime(), QLocale::ShortFormat);
case TR_SEED_DATE: case TR_SEED_DATE:
return torrent->completedTime().toLocalTime().toString(Qt::DefaultLocaleShortDate); return QLocale().toString(torrent->completedTime().toLocalTime(), QLocale::ShortFormat);
case TR_TRACKER: case TR_TRACKER:
return torrent->currentTracker(); return torrent->currentTracker();
case TR_DLLIMIT: case TR_DLLIMIT:
@ -387,7 +387,7 @@ QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent
case TR_COMPLETED: case TR_COMPLETED:
return unitString(torrent->completedSize()); return unitString(torrent->completedSize());
case TR_SEEN_COMPLETE_DATE: case TR_SEEN_COMPLETE_DATE:
return torrent->lastSeenComplete().toLocalTime().toString(Qt::DefaultLocaleShortDate); return QLocale().toString(torrent->lastSeenComplete().toLocalTime(), QLocale::ShortFormat);
case TR_LAST_ACTIVITY: case TR_LAST_ACTIVITY:
return lastActivityString((torrent->isPaused() || torrent->isChecking()) ? -1 : torrent->timeSinceActivity()); return lastActivityString((torrent->isPaused() || torrent->isChecking()) ? -1 : torrent->timeSinceActivity());
case TR_AVAILABILITY: case TR_AVAILABILITY:

Loading…
Cancel
Save