-
Notifications
You must be signed in to change notification settings - Fork 0
/
torrenttablesortmodel.h
44 lines (35 loc) · 1.4 KB
/
torrenttablesortmodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once
#ifndef TORRENTTABLESORTMODEL_H
#define TORRENTTABLESORTMODEL_H
#include <QSortFilterProxyModel>
#include "torrentsqltablemodel.h"
class TorrentTableSortModel final : public QSortFilterProxyModel
{
Q_OBJECT
Q_DISABLE_COPY(TorrentTableSortModel)
public:
/*! Inherit constructors. */
using QSortFilterProxyModel::QSortFilterProxyModel;
private:
/*! Main comparison method. */
bool lessThan(const QModelIndex &left, const QModelIndex &right) const final;
bool sortETA(
const QModelIndex &left, const QModelIndex &right,
const QVariant &leftRawValue, const QVariant &rightRawValue) const;
bool sortSeedsAndLeechers(
const QModelIndex &left, const QModelIndex &right,
const QVariant &leftRawValue, const QVariant &rightRawValue) const;
/*! Invoke lessThan() for a passed column, used in the second sort (recursion). */
inline bool
invokeLessThanForColumn(
TorrentSqlTableModel::Column column,
const QModelIndex &left, const QModelIndex &right) const;
};
bool TorrentTableSortModel::invokeLessThanForColumn( // NOLINT(misc-no-recursion)
const TorrentSqlTableModel::Column column,
const QModelIndex &left, const QModelIndex &right) const
{
return lessThan(left.sibling(left.row(), column),
right.sibling(right.row(), column));
}
#endif // TORRENTTABLESORTMODEL_H