From 83009adbc04f12bd16da40beebf0ca74b53157f2 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Mon, 6 Feb 2017 18:38:51 +0200 Subject: [PATCH] Use same casting method and fix code style. --- src/gui/transferlistsortmodel.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/gui/transferlistsortmodel.cpp b/src/gui/transferlistsortmodel.cpp index 0396de12e..5f16fa604 100644 --- a/src/gui/transferlistsortmodel.cpp +++ b/src/gui/transferlistsortmodel.cpp @@ -138,7 +138,7 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex } if (invalidL && invalidR) { - if (seedingL) //Both seeding + if (seedingL) // Both seeding return dateLessThan(TorrentModel::TR_SEED_DATE, left, right, true); else return prioL < prioR; @@ -176,12 +176,13 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex return lowerPositionThan(left, right); return QSortFilterProxyModel::lessThan(left, right); } - }; + } + ; } bool TransferListSortModel::lowerPositionThan(const QModelIndex &left, const QModelIndex &right) const { - const TorrentModel *model = static_cast(sourceModel()); + const TorrentModel *model = qobject_cast(sourceModel()); // Sort according to TR_PRIORITY const int queueL = model->data(model->index(left.row(), TorrentModel::TR_PRIORITY)).toInt(); @@ -202,17 +203,19 @@ bool TransferListSortModel::lowerPositionThan(const QModelIndex &left, const QMo // (detailed discussion in #2526 and #2158). bool TransferListSortModel::dateLessThan(const int dateColumn, const QModelIndex &left, const QModelIndex &right, bool sortInvalidInBottom) const { - const TorrentModel *model = dynamic_cast(sourceModel()); + const TorrentModel *model = qobject_cast(sourceModel()); const QDateTime dateL = model->data(model->index(left.row(), dateColumn)).toDateTime(); const QDateTime dateR = model->data(model->index(right.row(), dateColumn)).toDateTime(); if (dateL.isValid() && dateR.isValid()) { if (dateL != dateR) return dateL < dateR; } - else if (dateL.isValid()) + else if (dateL.isValid()) { return sortInvalidInBottom; - else if (dateR.isValid()) + } + else if (dateR.isValid()) { return !sortInvalidInBottom; + } // Finally, sort by hash const QString hashL(model->torrentHandle(model->index(left.row()))->hash()); @@ -223,7 +226,7 @@ bool TransferListSortModel::dateLessThan(const int dateColumn, const QModelIndex bool TransferListSortModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { return matchFilter(sourceRow, sourceParent) - && QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); + && QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); } bool TransferListSortModel::matchFilter(int sourceRow, const QModelIndex &sourceParent) const