3#include <QQmlComponent>
5#include "qml_material/control/control.hpp"
11class QML_MATERIAL_API PageIndicator :
public Control {
13 QML_NAMED_ELEMENT(PageIndicatorBase)
14 Q_PROPERTY(
int count READ count WRITE setCount NOTIFY countChanged FINAL)
16 int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL)
18 bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged FINAL)
19 Q_PROPERTY(QQmlComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
21 explicit PageIndicator(QQuickItem* parent =
nullptr);
22 ~PageIndicator()
override;
23 int count()
const {
return m_count; }
24 int currentIndex()
const {
return m_current_index; }
25 bool interactive()
const {
return m_interactive; }
26 QQmlComponent* delegate()
const {
return m_delegate; }
28 void setCurrentIndex(
int);
29 void setInteractive(
bool);
30 void setDelegate(QQmlComponent*);
31 Q_INVOKABLE QQuickItem* itemAt(
int index)
const;
32 Q_SIGNAL
void countChanged();
33 Q_SIGNAL
void currentIndexChanged();
34 Q_SIGNAL
void interactiveChanged();
35 Q_SIGNAL
void delegateChanged();
38 void componentComplete()
override;
39 void updatePolish()
override;
40 void mousePressEvent(QMouseEvent*)
override;
41 void mouseMoveEvent(QMouseEvent*)
override;
42 void mouseReleaseEvent(QMouseEvent*)
override;
43 void mouseUngrabEvent()
override;
44 void touchEvent(QTouchEvent*)
override;
45 void touchUngrabEvent()
override;
46 void itemChange(ItemChange,
const ItemChangeData&)
override;
50 QPointer<QQuickItem> item;
51 QPointer<QQmlContext> context;
52 bool pressedProperty =
false;
54 void scheduleDelegates();
55 void clearDelegates();
58 int hitIndex(
const QPointF&)
const;
59 void releasePress(
const QPointF&);
62 QPointer<QQmlComponent> m_delegate;
63 QList<QMetaObject::Connection> m_delegate_connections;
65 int m_current_index = 0;
66 int m_pressed_index = -1;
68 bool m_interactive =
false;
69 bool m_mouse_pressed =
false;
70 bool m_rebuild =
false;
71 bool m_syncing =
false;