QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskStackBox.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_STACK_BOX_H
7#define QSK_STACK_BOX_H
8
9#include "QskIndexedLayoutBox.h"
10
12
13class QSK_EXPORT QskStackBox : public QskIndexedLayoutBox
14{
15 Q_OBJECT
16
17 Q_PROPERTY( int currentIndex READ currentIndex
18 WRITE setCurrentIndex NOTIFY currentIndexChanged )
19
20 Q_PROPERTY( qreal transientIndex READ transientIndex
21 NOTIFY transientIndexChanged )
22
23 Q_PROPERTY( QQuickItem* currentItem READ currentItem
24 WRITE setCurrentItem NOTIFY currentItemChanged )
25
26 using Inherited = QskBox;
27
28 public:
29 explicit QskStackBox( QQuickItem* parent = nullptr );
30 QskStackBox( bool autoAddChildren, QQuickItem* parent = nullptr );
31
32 ~QskStackBox() override;
33
34 bool isEmpty() const;
35
36 int itemCount() const;
37 QQuickItem* itemAtIndex( int index ) const;
38 int indexOf( const QQuickItem* ) const;
39
40 void addItem( QQuickItem* );
41 void addItem( QQuickItem*, Qt::Alignment );
42
43 void insertItem( int index, QQuickItem* );
44 void insertItem( int index, QQuickItem*, Qt::Alignment );
45
46 void removeItem( const QQuickItem* );
47 void removeAt( int index );
48
49 QQuickItem* currentItem() const;
50 int currentIndex() const;
51
52 qreal transientIndex() const;
53
54 void setDefaultAlignment( Qt::Alignment );
55 Qt::Alignment defaultAlignment() const;
56
57 void setAnimator( QskStackBoxAnimator* );
58 const QskStackBoxAnimator* animator() const;
59 QskStackBoxAnimator* animator();
60
61 QRectF geometryForItemAt( int index ) const;
62
63 void dump() const;
64
65 Q_SIGNALS:
66 void defaultAlignmentChanged( Qt::Alignment );
67
68 public Q_SLOTS:
69 void setCurrentIndex( int index );
70 void setCurrentItem( const QQuickItem* );
71 void clear( bool autoDelete = false );
72
73 Q_SIGNALS:
74 void currentIndexChanged( int index );
75 void transientIndexChanged( qreal index );
76 void currentItemChanged( QQuickItem* );
77
78 protected:
79 bool event( QEvent* ) override;
80 void updateLayout() override;
81
82 QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override;
83
84 QskStackBoxAnimator* effectiveAnimator();
85
86 private:
87 void autoAddItem( QQuickItem* ) override final;
88 void autoRemoveItem( QQuickItem* ) override final;
89
90 void removeItemInternal( int index, bool unparent );
91
92 class PrivateData;
93 std::unique_ptr< PrivateData > m_data;
94};
95
96inline bool QskStackBox::isEmpty() const
97{
98 return itemCount() <= 0;
99}
100
101#endif
Base class of layouts with index ordered elements.