qskinny/src/layouts/QskLayoutBox.h

88 lines
2.3 KiB
C
Raw Normal View History

2017-07-21 16:21:34 +00:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
2019-04-08 11:08:58 +00:00
#ifndef QSK_LAYOUT_BOX_H
#define QSK_LAYOUT_BOX_H
2017-07-21 16:21:34 +00:00
2019-05-10 05:45:10 +00:00
#include "QskBox.h"
2017-07-21 16:21:34 +00:00
class QskLayoutEngine;
class QskLayoutItem;
2019-05-10 05:45:10 +00:00
class QSK_EXPORT QskLayoutBox : public QskBox
2017-07-21 16:21:34 +00:00
{
Q_OBJECT
using Inherited = QskControl;
2018-08-03 06:15:28 +00:00
public:
2019-04-08 11:08:58 +00:00
explicit QskLayoutBox( QQuickItem* parent = 0 );
~QskLayoutBox() override;
2017-07-21 16:21:34 +00:00
Q_INVOKABLE bool isEmpty() const;
Q_INVOKABLE int itemCount() const;
Q_INVOKABLE QQuickItem* itemAtIndex( int index ) const;
Q_INVOKABLE int indexOf( const QQuickItem* ) const;
void removeItem( const QQuickItem* );
Q_INVOKABLE void removeItem( QQuickItem* );
Q_INVOKABLE void removeAt( int index );
Q_INVOKABLE void clear( bool autoDelete = false );
2017-07-21 16:21:34 +00:00
Q_INVOKABLE void setActive( bool );
Q_INVOKABLE bool isActive() const;
void adjustItem( const QQuickItem* );
void adjustItemAt( int index );
2019-04-08 11:25:06 +00:00
QSizeF contentsSizeHint() const override;
qreal heightForWidth( qreal width ) const override;
qreal widthForHeight( qreal height ) const override;
2018-08-03 06:15:28 +00:00
public Q_SLOTS:
2017-07-21 16:21:34 +00:00
void activate();
void invalidate();
2018-08-03 06:15:28 +00:00
protected:
2018-07-31 15:32:25 +00:00
bool event( QEvent* ) override;
void geometryChangeEvent( QskGeometryChangeEvent* ) override;
2017-07-21 16:21:34 +00:00
2018-07-31 15:32:25 +00:00
void itemChange( ItemChange, const ItemChangeData& ) override;
void updateLayout() override;
2017-07-21 16:21:34 +00:00
QskLayoutEngine& engine();
const QskLayoutEngine& engine() const;
void setItemActive( const QQuickItem*, bool on );
void insertItemInternal( QskLayoutItem*, int index );
virtual void setupLayoutItem( QskLayoutItem*, int index );
virtual void layoutItemInserted( QskLayoutItem*, int index );
virtual void layoutItemRemoved( QskLayoutItem*, int index );
virtual QRectF alignedLayoutRect( const QRectF& ) const;
2019-04-08 11:25:06 +00:00
virtual QSizeF layoutItemsSizeHint() const;
2017-07-21 16:21:34 +00:00
2018-08-03 06:15:28 +00:00
private:
2017-07-21 16:21:34 +00:00
class PrivateData;
std::unique_ptr< PrivateData > m_data;
};
2019-04-08 11:08:58 +00:00
inline bool QskLayoutBox::isEmpty() const
2017-07-21 16:21:34 +00:00
{
2019-02-05 14:08:21 +00:00
return itemCount() <= 0;
2017-07-21 16:21:34 +00:00
}
2019-04-08 11:08:58 +00:00
inline void QskLayoutBox::removeItem( const QQuickItem* item )
2017-07-21 16:21:34 +00:00
{
removeItem( const_cast< QQuickItem* >( item ) );
}
#endif