Browse Source

Merge pull request #12847 from Chocobo1/deprecated

Don't use deprecated Qt function options
adaptive-webui-19844
Mike Tzou 5 years ago committed by GitHub
parent
commit
774c0276f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/base/rss/rss_item.cpp
  2. 2
      src/gui/properties/speedplotview.cpp
  3. 28
      src/gui/transferlistsortmodel.cpp

2
src/base/rss/rss_item.cpp

@ -67,7 +67,7 @@ bool Item::isValidPath(const QString &path)
{ {
static const QRegularExpression re( static const QRegularExpression re(
QString(R"(\A[^\%1]+(\%1[^\%1]+)*\z)").arg(Item::PathSeparator) QString(R"(\A[^\%1]+(\%1[^\%1]+)*\z)").arg(Item::PathSeparator)
, QRegularExpression::DontCaptureOption | QRegularExpression::OptimizeOnFirstUsageOption); , QRegularExpression::DontCaptureOption);
if (path.isEmpty() || !re.match(path).hasMatch()) { if (path.isEmpty() || !re.match(path).hasMatch()) {
qDebug() << "Incorrect RSS Item path:" << path; qDebug() << "Incorrect RSS Item path:" << path;

2
src/gui/properties/speedplotview.cpp

@ -339,7 +339,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
} }
// Set antialiasing for graphs // Set antialiasing for graphs
painter.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing); painter.setRenderHints(QPainter::Antialiasing);
// draw graphs // draw graphs
rect.adjust(3, 0, 0, 0); // Need, else graphs cross left gridline rect.adjust(3, 0, 0, 0); // Need, else graphs cross left gridline

28
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)); 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<TransferListModel *>(sourceModel());
const QString hashL = model->torrentHandle(left)->hash();
const QString hashR = model->torrentHandle(right)->hash();
return hashL < hashR;
};
const int sortColumn = left.column(); const int sortColumn = left.column();
const QVariant leftValue = left.data(TransferListModel::UnderlyingDataRole); const QVariant leftValue = left.data(TransferListModel::UnderlyingDataRole);
const QVariant rightValue = right.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()) { else if (dateR.isValid()) {
return false; return false;
} }
return hashLessThan();
} }
break;
case TransferListModel::TR_QUEUE_POSITION: { case TransferListModel::TR_QUEUE_POSITION: {
// QVariant has comparators for all basic types // QVariant has comparators for all basic types
@ -166,8 +175,9 @@ bool TransferListSortModel::lessThan_impl(const QModelIndex &left, const QModelI
else if (dateR.isValid()) { else if (dateR.isValid()) {
return true; return true;
} }
return hashLessThan();
} }
break;
case TransferListModel::TR_SEEDS: case TransferListModel::TR_SEEDS:
case TransferListModel::TR_PEERS: { case TransferListModel::TR_PEERS: {
@ -237,19 +247,11 @@ bool TransferListSortModel::lessThan_impl(const QModelIndex &left, const QModelI
if (rightValue < 0) return true; if (rightValue < 0) return true;
return (leftValue < rightValue); return (leftValue < rightValue);
default:
if (leftValue != rightValue)
return QSortFilterProxyModel::lessThan(left, right);
return invokeLessThanForColumn(TransferListModel::TR_QUEUE_POSITION);
} }
// Finally, sort by hash return (leftValue != rightValue)
const TransferListModel *model = qobject_cast<TransferListModel *>(sourceModel()); ? QSortFilterProxyModel::lessThan(left, right)
const QString hashL = model->torrentHandle(left)->hash(); : invokeLessThanForColumn(TransferListModel::TR_QUEUE_POSITION);
const QString hashR = model->torrentHandle(right)->hash();
return hashL < hashR;
} }
bool TransferListSortModel::filterAcceptsRow(const int sourceRow, const QModelIndex &sourceParent) const bool TransferListSortModel::filterAcceptsRow(const int sourceRow, const QModelIndex &sourceParent) const

Loading…
Cancel
Save