blob: 02f02779e5bfa7977b5f5ca40b6d5b68ab4dd27d (
plain)
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
|
// Copyright (C) 2016 Jochen Becher
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <QSortFilterProxyModel>
#include "qmt/infrastructure/qmt_global.h"
#include <QTimer>
namespace qmt {
class TreeModel;
class QMT_EXPORT SortedTreeModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
explicit SortedTreeModel(QObject *parent = nullptr);
~SortedTreeModel() override;
TreeModel *treeModel() const { return m_treeModel; }
void setTreeModel(TreeModel *treeModel);
protected:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
private:
void onTreeModelRowsInserted(const QModelIndex &parent, int start, int end);
void onDataChanged(const QModelIndex &, const QModelIndex &, const QVector<int> &);
void onDelayedSortTimeout();
void startDelayedSortTimer();
TreeModel *m_treeModel = nullptr;
QTimer m_delayedSortTimer;
};
} // namespace qmt
|