Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmlsortercompositor_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLSORTERCOMPOSITOR_H
5#define QQMLSORTERCOMPOSITOR_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQmlModels/private/qqmlsorterbase_p.h>
19
20QT_BEGIN_NAMESPACE
21
22class QQmlSortFilterProxyModel;
24
26{
27 Q_OBJECT
28 QML_ANONYMOUS
30
31public:
32 explicit QQmlSorterCompositor(QObject *parent = nullptr);
34
37
38 static void append(QQmlListProperty<QQmlSorterBase> *sorterComp, QQmlSorterBase *sorter);
39 static qsizetype count(QQmlListProperty<QQmlSorterBase> *sorterComp);
40 static QQmlSorterBase* at(QQmlListProperty<QQmlSorterBase> *sorterComp, qsizetype index);
41 static void clear(QQmlListProperty<QQmlSorterBase> *sorterComp);
42
43 QPartialOrdering compare(const QModelIndex &, const QModelIndex &, const QQmlSortFilterProxyModel *) const override { return QPartialOrdering::Unordered; };
44 bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight, const QQmlSortFilterProxyModel *proxyModel) const;
45 void updateSorters();
47
48private:
49 void append(QQmlSorterBase *sorter);
50 qsizetype count();
51 QQmlSorterBase* at(qsizetype index);
52 void clear();
53
54public slots:
55 void updateCache();
56
57private:
59};
60
62{
63 Q_DECLARE_PUBLIC(QQmlSorterCompositor)
64
65public:
66 void init();
67 void setPrimarySorter(QQmlSorterBase *sorter);
68 QPointer<QQmlSorterBase> primarySorter() const { return m_primarySorter; }
69 void resetPrimarySorter();
70
71 // Holds sorters in the same order as declared in the qml
73 // Holds effective sorters that will be evaluated with the
74 // model content
76 QQmlSortFilterProxyModel *m_sfpmModel = nullptr;
78};
79
80QT_END_NAMESPACE
81
82#endif // QQMLSORTERCOMPOSITOR_H
QList< QQmlSorterBase * > m_effectiveSorters
QPointer< QQmlSorterBase > m_primarySorter
void setPrimarySorter(QQmlSorterBase *sorter)
QQmlSortFilterProxyModel * m_sfpmModel
QList< QQmlSorterBase * > m_sorters
QPointer< QQmlSorterBase > primarySorter() const
QPartialOrdering compare(const QModelIndex &, const QModelIndex &, const QQmlSortFilterProxyModel *) const override
static void clear(QQmlListProperty< QQmlSorterBase > *sorterComp)
QQmlListProperty< QQmlSorterBase > sortersListProperty()
static void append(QQmlListProperty< QQmlSorterBase > *sorterComp, QQmlSorterBase *sorter)
QList< QQmlSorterBase * > sorters()
bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight, const QQmlSortFilterProxyModel *proxyModel) const
static qsizetype count(QQmlListProperty< QQmlSorterBase > *sorterComp)
static QQmlSorterBase * at(QQmlListProperty< QQmlSorterBase > *sorterComp, qsizetype index)