QmlMaterial 0.1.0
Loading...
Searching...
No Matches
header_view.hpp
1#pragma once
2
3#include <QtQuick/private/qquicktableview_p.h>
4#include "qml_material/model/header_model.hpp"
5
6namespace qml_material
7{
8class HeaderDragHandler;
9class QML_MATERIAL_API HeaderView : public QQuickTableView {
10 Q_OBJECT
11 QML_NAMED_ELEMENT(HeaderViewBase)
12 QML_UNCREATABLE("Use HorizontalHeaderViewBase or VerticalHeaderViewBase")
13 Q_PROPERTY(QVariant model READ headerModel WRITE setHeaderModel RESET resetHeaderModel NOTIFY
14 modelChanged FINAL)
15 Q_PROPERTY(QString textRole READ textRole WRITE setTextRole NOTIFY textRoleChanged FINAL)
16 Q_PROPERTY(HeaderModel::SourceMode sourceMode READ sourceMode WRITE setSourceMode NOTIFY
17 sourceModeChanged FINAL)
18 Q_PROPERTY(QStringList headerTexts READ headerTexts NOTIFY headerContentChanged FINAL)
19 Q_PROPERTY(int sectionCount READ sectionCount NOTIFY headerContentChanged FINAL)
20 Q_PROPERTY(QList<int> visualSections READ visualSections NOTIFY sectionOrderChanged FINAL)
21public:
22 ~HeaderView() override;
23 bool movableSections() const { return m_movable; }
24 void setMovableSections(bool);
25 QVariant headerModel() const { return m_model.model(); }
26 void setHeaderModel(const QVariant& value) { m_model.setModel(value); }
27 void resetHeaderModel() { m_model.resetModel(); }
28 QString textRole() const { return m_model.textRole(); }
29 void setTextRole(const QString& value) { m_model.setTextRole(value); }
30 HeaderModel::SourceMode sourceMode() const { return m_model.sourceMode(); }
31 void setSourceMode(HeaderModel::SourceMode value) { m_model.setSourceMode(value); }
32 QStringList headerTexts() const { return m_model.texts(); }
33 int sectionCount() const { return m_model.sectionCount(); }
34 QList<int> visualSections() const;
35 Q_SIGNAL void textRoleChanged();
36 Q_SIGNAL void sourceModeChanged();
37 Q_SIGNAL void headerContentChanged();
38 Q_SIGNAL void movableSectionsChanged();
39 Q_SIGNAL void sectionOrderChanged();
40
41protected:
42 HeaderView(Qt::Orientation orientation, QQuickItem* parent);
43
44private:
45 void syncSource();
46 HeaderModel m_model;
47 QMetaObject::Connection m_syncChanged, m_syncDestroyed;
48 HeaderDragHandler* m_drag = nullptr;
49 bool m_movable = false;
50};
51
52class QML_MATERIAL_API HorizontalHeaderView : public HeaderView {
53 Q_OBJECT
54 QML_NAMED_ELEMENT(HorizontalHeaderViewBase)
55 Q_PROPERTY(bool movableColumns READ movableSections WRITE setMovableSections NOTIFY
56 movableSectionsChanged FINAL)
57public:
58 explicit HorizontalHeaderView(QQuickItem* parent = nullptr);
59};
60
61class QML_MATERIAL_API VerticalHeaderView : public HeaderView {
62 Q_OBJECT
63 QML_NAMED_ELEMENT(VerticalHeaderViewBase)
64 Q_PROPERTY(bool movableRows READ movableSections WRITE setMovableSections NOTIFY
65 movableSectionsChanged FINAL)
66public:
67 explicit VerticalHeaderView(QQuickItem* parent = nullptr);
68};
69} // namespace qml_material