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 )
|
|
|
|
|
2019-06-19 14:08:45 +02:00
|
|
|
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
|
|
|
|
2019-06-19 14:08:45 +02:00
|
|
|
bool isEmpty() const;
|
|
|
|
|
|
|
|
int itemCount() const;
|
|
|
|
QQuickItem* itemAtIndex( int index ) const;
|
|
|
|
int indexOf( const QQuickItem* ) const;
|
|
|
|
|
2019-09-05 11:45:25 +02:00
|
|
|
void addItem( QQuickItem* );
|
2019-09-14 15:28:49 +02:00
|
|
|
void addItem( QQuickItem*, Qt::Alignment );
|
2019-06-19 14:08:45 +02:00
|
|
|
|
2019-09-05 11:45:25 +02:00
|
|
|
void insertItem( int index, QQuickItem* );
|
2019-09-14 15:28:49 +02:00
|
|
|
void insertItem( int index, QQuickItem*, Qt::Alignment );
|
2019-06-19 14:08:45 +02:00
|
|
|
|
|
|
|
void removeItem( const QQuickItem* );
|
|
|
|
void removeAt( int index );
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
QQuickItem* currentItem() const;
|
|
|
|
int currentIndex() const;
|
|
|
|
|
2019-06-19 14:08:45 +02:00
|
|
|
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();
|
|
|
|
|
2019-06-19 14:08:45 +02:00
|
|
|
QRectF geometryForItemAt( int index ) const;
|
|
|
|
|
2019-09-23 13:20:56 +02:00
|
|
|
void dump();
|
|
|
|
|
2019-06-19 14:08:45 +02:00
|
|
|
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* );
|
2019-06-19 14:08:45 +02:00
|
|
|
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:
|
2019-06-19 14:08:45 +02:00
|
|
|
bool event( QEvent* ) override;
|
|
|
|
void updateLayout() override;
|
|
|
|
|
2019-09-10 17:01:47 +02:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2019-06-19 14:08:45 +02:00
|
|
|
inline bool QskStackBox::isEmpty() const
|
|
|
|
{
|
|
|
|
return itemCount() <= 0;
|
|
|
|
}
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
#endif
|