From 7c8846fc53803d104e1d6fdd3efeb77b06307545 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 16 May 2020 21:05:15 +0800 Subject: [PATCH 1/3] Don't use deprecated QRegularExpression option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The following is the warning from compiler: rss_item.cpp:70:79: warning: ‘QRegularExpression::OptimizeOnFirstUsageOption’ is deprecated: This option does not have any effect since Qt 5.12 [-Wdeprecated-declarations] --- src/base/rss/rss_item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/rss/rss_item.cpp b/src/base/rss/rss_item.cpp index 1d655efa8..37d55102e 100644 --- a/src/base/rss/rss_item.cpp +++ b/src/base/rss/rss_item.cpp @@ -67,7 +67,7 @@ bool Item::isValidPath(const QString &path) { static const QRegularExpression re( QString(R"(\A[^\%1]+(\%1[^\%1]+)*\z)").arg(Item::PathSeparator) - , QRegularExpression::DontCaptureOption | QRegularExpression::OptimizeOnFirstUsageOption); + , QRegularExpression::DontCaptureOption); if (path.isEmpty() || !re.match(path).hasMatch()) { qDebug() << "Incorrect RSS Item path:" << path; From 21e1c33d158cfbb6132cb59adc52794460776ea2 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 16 May 2020 21:09:06 +0800 Subject: [PATCH 2/3] Don't use deprecated QPainter option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Warning from compiler: speedplotview.cpp:342:63: warning: ‘QPainter::HighQualityAntialiasing’ is deprecated: Use Antialiasing instead [-Wdeprecated-declarations] --- src/gui/properties/speedplotview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/properties/speedplotview.cpp b/src/gui/properties/speedplotview.cpp index 9f7ee5d53..b924ae370 100644 --- a/src/gui/properties/speedplotview.cpp +++ b/src/gui/properties/speedplotview.cpp @@ -339,7 +339,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *) } // Set antialiasing for graphs - painter.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing); + painter.setRenderHints(QPainter::Antialiasing); // draw graphs rect.adjust(3, 0, 0, 0); // Need, else graphs cross left gridline From 328eb5b5cc85e502765d8cc0742ad4a66b33f66b Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 16 May 2020 21:40:46 +0800 Subject: [PATCH 3/3] Provide a proper default return statement for the function --- src/gui/transferlistsortmodel.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/gui/transferlistsortmodel.cpp b/src/gui/transferlistsortmodel.cpp index 1bc1e70bd..c253d9b1b 100644 --- a/src/gui/transferlistsortmodel.cpp +++ b/src/gui/transferlistsortmodel.cpp @@ -100,6 +100,14 @@ bool TransferListSortModel::lessThan_impl(const QModelIndex &left, const QModelI return lessThan_impl(left.sibling(left.row(), column), right.sibling(right.row(), column)); }; + const auto hashLessThan = [this, &left, &right]() -> bool + { + const TransferListModel *model = qobject_cast(sourceModel()); + const QString hashL = model->torrentHandle(left)->hash(); + const QString hashR = model->torrentHandle(right)->hash(); + return hashL < hashR; + }; + const int sortColumn = left.column(); const QVariant leftValue = left.data(TransferListModel::UnderlyingDataRole); const QVariant rightValue = right.data(TransferListModel::UnderlyingDataRole); @@ -138,8 +146,9 @@ bool TransferListSortModel::lessThan_impl(const QModelIndex &left, const QModelI else if (dateR.isValid()) { return false; } + + return hashLessThan(); } - break; case TransferListModel::TR_QUEUE_POSITION: { // QVariant has comparators for all basic types @@ -166,8 +175,9 @@ bool TransferListSortModel::lessThan_impl(const QModelIndex &left, const QModelI else if (dateR.isValid()) { return true; } + + return hashLessThan(); } - break; case TransferListModel::TR_SEEDS: case TransferListModel::TR_PEERS: { @@ -237,19 +247,11 @@ bool TransferListSortModel::lessThan_impl(const QModelIndex &left, const QModelI if (rightValue < 0) return true; return (leftValue < rightValue); - - default: - if (leftValue != rightValue) - return QSortFilterProxyModel::lessThan(left, right); - - return invokeLessThanForColumn(TransferListModel::TR_QUEUE_POSITION); } - // Finally, sort by hash - const TransferListModel *model = qobject_cast(sourceModel()); - const QString hashL = model->torrentHandle(left)->hash(); - const QString hashR = model->torrentHandle(right)->hash(); - return hashL < hashR; + return (leftValue != rightValue) + ? QSortFilterProxyModel::lessThan(left, right) + : invokeLessThanForColumn(TransferListModel::TR_QUEUE_POSITION); } bool TransferListSortModel::filterAcceptsRow(const int sourceRow, const QModelIndex &sourceParent) const