Browse Source

Use same casting method and fix code style.

adaptive-webui-19844
sledgehammer999 8 years ago
parent
commit
83009adbc0
No known key found for this signature in database
GPG Key ID: 6E4A2D025B7CC9A2
  1. 13
      src/gui/transferlistsortmodel.cpp

13
src/gui/transferlistsortmodel.cpp

@ -176,12 +176,13 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex @@ -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<TorrentModel*>(sourceModel());
const TorrentModel *model = qobject_cast<TorrentModel *>(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 @@ -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<TorrentModel*>(sourceModel());
const TorrentModel *model = qobject_cast<TorrentModel *>(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());

Loading…
Cancel
Save