qskinny/src/layouts/QskStackBox.h

96 lines
2.5 KiB
C
Raw Normal View History

2017-07-21 18:21:34 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#ifndef QSK_STACK_BOX_H
#define QSK_STACK_BOX_H
#include "QskIndexedLayoutBox.h"
class QskStackBoxAnimator;
class QSK_EXPORT QskStackBox : public QskIndexedLayoutBox
{
Q_OBJECT
Q_PROPERTY( int currentIndex READ currentIndex
WRITE setCurrentIndex NOTIFY currentIndexChanged )
Q_PROPERTY( QQuickItem* currentItem READ currentItem
WRITE setCurrentItem NOTIFY currentItemChanged )
using Inherited = QskBox;
2017-07-21 18:21:34 +02:00
2018-08-03 08:15:28 +02:00
public:
2017-07-21 18:21:34 +02:00
explicit QskStackBox( QQuickItem* parent = nullptr );
QskStackBox( bool autoAddChildren, QQuickItem* parent = nullptr );
2018-07-31 17:32:25 +02:00
~QskStackBox() override;
2017-07-21 18:21:34 +02:00
bool isEmpty() const;
int itemCount() const;
QQuickItem* itemAtIndex( int index ) const;
int indexOf( const QQuickItem* ) const;
void addItem( QQuickItem* );
void addItem( QQuickItem*, Qt::Alignment );
void insertItem( int index, QQuickItem* );
void insertItem( int index, QQuickItem*, Qt::Alignment );
void removeItem( const QQuickItem* );
void removeAt( int index );
2017-07-21 18:21:34 +02:00
QQuickItem* currentItem() const;
int currentIndex() const;
void setDefaultAlignment( Qt::Alignment );
Qt::Alignment defaultAlignment() const;
2017-07-21 18:21:34 +02:00
void setAnimator( QskStackBoxAnimator* );
const QskStackBoxAnimator* animator() const;
QskStackBoxAnimator* animator();
QRectF geometryForItemAt( int index ) const;
2019-09-23 13:20:56 +02:00
void dump();
Q_SIGNALS:
void defaultAlignmentChanged( Qt::Alignment );
2018-08-03 08:15:28 +02:00
public Q_SLOTS:
2017-07-21 18:21:34 +02:00
void setCurrentIndex( int index );
void setCurrentItem( const QQuickItem* );
void clear( bool autoDelete = false );
2017-07-21 18:21:34 +02:00
2018-08-03 08:15:28 +02:00
Q_SIGNALS:
2017-07-21 18:21:34 +02:00
void currentIndexChanged( int index );
void currentItemChanged( QQuickItem* );
2018-08-03 08:15:28 +02:00
protected:
bool event( QEvent* ) override;
void updateLayout() override;
QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override;
2019-09-05 15:16:33 +02:00
2017-07-21 18:21:34 +02:00
QskStackBoxAnimator* effectiveAnimator();
2018-08-03 08:15:28 +02:00
private:
2019-11-29 17:33:26 +01:00
void autoAddItem( QQuickItem* ) override final;
void autoRemoveItem( QQuickItem* ) override final;
2019-12-03 17:21:56 +01:00
void removeItemInternal( int index, bool unparent );
2017-07-21 18:21:34 +02:00
class PrivateData;
std::unique_ptr< PrivateData > m_data;
};
inline bool QskStackBox::isEmpty() const
{
return itemCount() <= 0;
}
2017-07-21 18:21:34 +02:00
#endif