-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmysortfilterproxymodel.h
More file actions
62 lines (47 loc) · 1.61 KB
/
Copy pathmysortfilterproxymodel.h
File metadata and controls
62 lines (47 loc) · 1.61 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef MYSORTFILTERPROXYMODEL_H
#define MYSORTFILTERPROXYMODEL_H
#include <QVariant>
#include <QtSql/QtSql>
#include <QtSql/QSqlQuery>
#include <QSortFilterProxyModel>
#include <QtConcurrent/QtConcurrent>
#include "sortings.h"
enum MySortingMethods { QtMap, QuickSort, HeapSort, StableSort, SimpleSort, TimSort };
class MySortFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
MySortFilterProxyModel(QObject *parent = 0);
~MySortFilterProxyModel();
void sortByQMap(int column, Qt::SortOrder order);
void sort(int column, Qt::SortOrder order);
void sortWithFunc(int column, Qt::SortOrder order);
void setPrevColumn(int value);
void setSorted(bool value);
protected:
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
private:
QList<int> *sortedList;
MySortingMethods choice;
int prevColumn;
bool sorted;
public slots:
void revertList();
void giveSortChoice(MySortingMethods ch);
};
class StProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
mutable int m_time = 0;
StProxyModel(QObject *parent = 0);
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
};
void worker(QVector<Container> *arr,
void (*sortFunc)(QVector<Container>::Iterator, QVector<Container>::Iterator),
int threadCount = QThread::idealThreadCount());
void myMerge(QVector<Container> *arr,
int count = (QThread::idealThreadCount() / 2));
#endif // MYSORTFILTERPROXYMODEL_H