QskLayout -> QskLayoutBox

This commit is contained in:
Uwe Rathmann 2019-04-08 13:08:58 +02:00
parent d6cd4858cc
commit 44368f97a8
7 changed files with 52 additions and 53 deletions

View File

@ -21,7 +21,7 @@ class QskGridBox::PrivateData
}; };
QskGridBox::QskGridBox( QQuickItem* parent ) QskGridBox::QskGridBox( QQuickItem* parent )
: QskLayout( parent ) : QskLayoutBox( parent )
, m_data( new PrivateData() ) , m_data( new PrivateData() )
{ {
} }

View File

@ -6,9 +6,9 @@
#ifndef QSK_GRID_BOX_H #ifndef QSK_GRID_BOX_H
#define QSK_GRID_BOX_H #define QSK_GRID_BOX_H
#include "QskLayout.h" #include "QskLayoutBox.h"
class QSK_EXPORT QskGridBox : public QskLayout class QSK_EXPORT QskGridBox : public QskLayoutBox
{ {
Q_OBJECT Q_OBJECT
@ -20,7 +20,7 @@ class QSK_EXPORT QskGridBox : public QskLayout
WRITE setVerticalSpacing RESET resetVerticalSpacing WRITE setVerticalSpacing RESET resetVerticalSpacing
NOTIFY verticalSpacingChanged ) NOTIFY verticalSpacingChanged )
using Inherited = QskLayout; using Inherited = QskLayoutBox;
public: public:
explicit QskGridBox( QQuickItem* parent = nullptr ); explicit QskGridBox( QQuickItem* parent = nullptr );

View File

@ -37,7 +37,7 @@ class QskIndexedLayoutBox::PrivateData
}; };
QskIndexedLayoutBox::QskIndexedLayoutBox( QQuickItem* parent ) QskIndexedLayoutBox::QskIndexedLayoutBox( QQuickItem* parent )
: QskLayout( parent ) : QskLayoutBox( parent )
, m_data( new PrivateData() ) , m_data( new PrivateData() )
{ {
// classBegin/componentComplete -> setActive( false/true ) ? // classBegin/componentComplete -> setActive( false/true ) ?

View File

@ -6,9 +6,9 @@
#ifndef QSK_INDEXED_LAYOUT_BOX_H #ifndef QSK_INDEXED_LAYOUT_BOX_H
#define QSK_INDEXED_LAYOUT_BOX_H #define QSK_INDEXED_LAYOUT_BOX_H
#include "QskLayout.h" #include "QskLayoutBox.h"
class QSK_EXPORT QskIndexedLayoutBox : public QskLayout class QSK_EXPORT QskIndexedLayoutBox : public QskLayoutBox
{ {
Q_OBJECT Q_OBJECT
@ -18,7 +18,7 @@ class QSK_EXPORT QskIndexedLayoutBox : public QskLayout
Q_PROPERTY( Qt::Alignment defaultAlignment READ defaultAlignment Q_PROPERTY( Qt::Alignment defaultAlignment READ defaultAlignment
WRITE setDefaultAlignment NOTIFY defaultAlignmentChanged ) WRITE setDefaultAlignment NOTIFY defaultAlignmentChanged )
using Inherited = QskLayout; using Inherited = QskLayoutBox;
public: public:
explicit QskIndexedLayoutBox( QQuickItem* parent = nullptr ); explicit QskIndexedLayoutBox( QQuickItem* parent = nullptr );

View File

@ -3,12 +3,12 @@
* This file may be used under the terms of the QSkinny License, Version 1.0 * This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/ *****************************************************************************/
#include "QskLayout.h" #include "QskLayoutBox.h"
#include "QskEvent.h" #include "QskEvent.h"
#include "QskLayoutEngine.h" #include "QskLayoutEngine.h"
#include "QskLayoutItem.h" #include "QskLayoutItem.h"
class QskLayout::PrivateData class QskLayoutBox::PrivateData
{ {
public: public:
PrivateData() PrivateData()
@ -21,19 +21,19 @@ class QskLayout::PrivateData
QskLayoutEngine engine; QskLayoutEngine engine;
}; };
QskLayout::QskLayout( QQuickItem* parent ) QskLayoutBox::QskLayoutBox( QQuickItem* parent )
: QskControl( parent ) : QskControl( parent )
, m_data( new PrivateData() ) , m_data( new PrivateData() )
{ {
} }
QskLayout::~QskLayout() QskLayoutBox::~QskLayoutBox()
{ {
disconnect( this, 0, this, 0 ); // destructor runs on invalidate else disconnect( this, 0, this, 0 ); // destructor runs on invalidate else
setActive( false ); setActive( false );
} }
void QskLayout::setActive( bool on ) void QskLayoutBox::setActive( bool on )
{ {
if ( on == m_data->isActive ) if ( on == m_data->isActive )
return; return;
@ -54,17 +54,17 @@ void QskLayout::setActive( bool on )
} }
} }
bool QskLayout::isActive() const bool QskLayoutBox::isActive() const
{ {
return m_data->isActive; return m_data->isActive;
} }
int QskLayout::itemCount() const int QskLayoutBox::itemCount() const
{ {
return m_data->engine.itemCount(); return m_data->engine.itemCount();
} }
QQuickItem* QskLayout::itemAtIndex( int index ) const QQuickItem* QskLayoutBox::itemAtIndex( int index ) const
{ {
QskLayoutItem* layoutItem = m_data->engine.layoutItemAt( index ); QskLayoutItem* layoutItem = m_data->engine.layoutItemAt( index );
if ( layoutItem ) if ( layoutItem )
@ -73,7 +73,7 @@ QQuickItem* QskLayout::itemAtIndex( int index ) const
return nullptr; return nullptr;
} }
int QskLayout::indexOf( const QQuickItem* item ) const int QskLayoutBox::indexOf( const QQuickItem* item ) const
{ {
if ( item != nullptr ) if ( item != nullptr )
return m_data->engine.indexOf( item ); return m_data->engine.indexOf( item );
@ -81,7 +81,7 @@ int QskLayout::indexOf( const QQuickItem* item ) const
return -1; return -1;
} }
void QskLayout::insertItemInternal( QskLayoutItem* layoutItem, int index ) void QskLayoutBox::insertItemInternal( QskLayoutItem* layoutItem, int index )
{ {
// check if item is already inserted ??? // check if item is already inserted ???
@ -140,7 +140,7 @@ void QskLayout::insertItemInternal( QskLayoutItem* layoutItem, int index )
} }
} }
void QskLayout::removeAt( int index ) void QskLayoutBox::removeAt( int index )
{ {
QskLayoutEngine& engine = this->engine(); QskLayoutEngine& engine = this->engine();
@ -162,12 +162,12 @@ void QskLayout::removeAt( int index )
} }
} }
void QskLayout::removeItem( QQuickItem* item ) void QskLayoutBox::removeItem( QQuickItem* item )
{ {
removeAt( indexOf( item ) ); removeAt( indexOf( item ) );
} }
void QskLayout::clear( bool autoDelete ) void QskLayoutBox::clear( bool autoDelete )
{ {
const bool isActive = m_data->isActive; const bool isActive = m_data->isActive;
setActive( false ); setActive( false );
@ -190,31 +190,31 @@ void QskLayout::clear( bool autoDelete )
setActive( isActive ); setActive( isActive );
} }
void QskLayout::setupLayoutItem( QskLayoutItem* layoutItem, int index ) void QskLayoutBox::setupLayoutItem( QskLayoutItem* layoutItem, int index )
{ {
Q_UNUSED( layoutItem ) Q_UNUSED( layoutItem )
Q_UNUSED( index ) Q_UNUSED( index )
} }
void QskLayout::layoutItemInserted( QskLayoutItem* layoutItem, int index ) void QskLayoutBox::layoutItemInserted( QskLayoutItem* layoutItem, int index )
{ {
Q_UNUSED( layoutItem ) Q_UNUSED( layoutItem )
Q_UNUSED( index ) Q_UNUSED( index )
} }
void QskLayout::layoutItemRemoved( QskLayoutItem* layoutItem, int index ) void QskLayoutBox::layoutItemRemoved( QskLayoutItem* layoutItem, int index )
{ {
Q_UNUSED( layoutItem ) Q_UNUSED( layoutItem )
Q_UNUSED( index ) Q_UNUSED( index )
} }
void QskLayout::activate() void QskLayoutBox::activate()
{ {
if ( m_data->isActive ) if ( m_data->isActive )
polish(); polish();
} }
void QskLayout::invalidate() void QskLayoutBox::invalidate()
{ {
engine().invalidate(); engine().invalidate();
activate(); activate();
@ -222,12 +222,12 @@ void QskLayout::invalidate()
resetImplicitSize(); resetImplicitSize();
} }
void QskLayout::adjustItem( const QQuickItem* item ) void QskLayoutBox::adjustItem( const QQuickItem* item )
{ {
adjustItemAt( indexOf( item ) ); adjustItemAt( indexOf( item ) );
} }
void QskLayout::adjustItemAt( int index ) void QskLayoutBox::adjustItemAt( int index )
{ {
QskLayoutItem* layoutItem = engine().layoutItemAt( index ); QskLayoutItem* layoutItem = engine().layoutItemAt( index );
if ( layoutItem == nullptr ) if ( layoutItem == nullptr )
@ -239,18 +239,18 @@ void QskLayout::adjustItemAt( int index )
layoutItem->setUpdateMode( QskLayoutItem::UpdateWhenVisible ); layoutItem->setUpdateMode( QskLayoutItem::UpdateWhenVisible );
} }
void QskLayout::updateLayout() void QskLayoutBox::updateLayout()
{ {
if ( m_data->isActive ) if ( m_data->isActive )
engine().setGeometries( alignedLayoutRect( layoutRect() ) ); engine().setGeometries( alignedLayoutRect( layoutRect() ) );
} }
QRectF QskLayout::alignedLayoutRect( const QRectF& rect ) const QRectF QskLayoutBox::alignedLayoutRect( const QRectF& rect ) const
{ {
return rect; return rect;
} }
void QskLayout::geometryChangeEvent( QskGeometryChangeEvent* event ) void QskLayoutBox::geometryChangeEvent( QskGeometryChangeEvent* event )
{ {
Inherited::geometryChangeEvent( event ); Inherited::geometryChangeEvent( event );
@ -258,7 +258,7 @@ void QskLayout::geometryChangeEvent( QskGeometryChangeEvent* event )
activate(); activate();
} }
void QskLayout::setItemActive( const QQuickItem* item, bool on ) void QskLayoutBox::setItemActive( const QQuickItem* item, bool on )
{ {
if ( item == nullptr ) if ( item == nullptr )
return; return;
@ -271,38 +271,38 @@ void QskLayout::setItemActive( const QQuickItem* item, bool on )
if ( on ) if ( on )
{ {
connect( item, &QQuickItem::implicitWidthChanged, connect( item, &QQuickItem::implicitWidthChanged,
this, &QskLayout::invalidate ); this, &QskLayoutBox::invalidate );
connect( item, &QQuickItem::implicitHeightChanged, connect( item, &QQuickItem::implicitHeightChanged,
this, &QskLayout::invalidate ); this, &QskLayoutBox::invalidate );
} }
else else
{ {
disconnect( item, &QQuickItem::implicitWidthChanged, disconnect( item, &QQuickItem::implicitWidthChanged,
this, &QskLayout::invalidate ); this, &QskLayoutBox::invalidate );
disconnect( item, &QQuickItem::implicitHeightChanged, disconnect( item, &QQuickItem::implicitHeightChanged,
this, &QskLayout::invalidate ); this, &QskLayoutBox::invalidate );
} }
} }
if ( on ) if ( on )
connect( item, &QQuickItem::visibleChanged, this, &QskLayout::activate ); connect( item, &QQuickItem::visibleChanged, this, &QskLayoutBox::activate );
else else
disconnect( item, &QQuickItem::visibleChanged, this, &QskLayout::activate ); disconnect( item, &QQuickItem::visibleChanged, this, &QskLayoutBox::activate );
} }
QskLayoutEngine& QskLayout::engine() QskLayoutEngine& QskLayoutBox::engine()
{ {
return m_data->engine; return m_data->engine;
} }
const QskLayoutEngine& QskLayout::engine() const const QskLayoutEngine& QskLayoutBox::engine() const
{ {
return m_data->engine; return m_data->engine;
} }
void QskLayout::itemChange( ItemChange change, const ItemChangeData& value ) void QskLayoutBox::itemChange( ItemChange change, const ItemChangeData& value )
{ {
Inherited::itemChange( change, value ); Inherited::itemChange( change, value );
@ -330,7 +330,7 @@ void QskLayout::itemChange( ItemChange change, const ItemChangeData& value )
} }
} }
bool QskLayout::event( QEvent* event ) bool QskLayoutBox::event( QEvent* event )
{ {
switch ( event->type() ) switch ( event->type() )
{ {
@ -359,4 +359,4 @@ bool QskLayout::event( QEvent* event )
return Inherited::event( event ); return Inherited::event( event );
} }
#include "moc_QskLayout.cpp" #include "moc_QskLayoutBox.cpp"

View File

@ -3,24 +3,23 @@
* This file may be used under the terms of the QSkinny License, Version 1.0 * This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/ *****************************************************************************/
#ifndef QSK_LAYOUT_H #ifndef QSK_LAYOUT_BOX_H
#define QSK_LAYOUT_H #define QSK_LAYOUT_BOX_H
#include "QskControl.h" #include "QskControl.h"
class QskLayoutEngine; class QskLayoutEngine;
class QskLayoutItem; class QskLayoutItem;
// might be derived from QskFrame class QSK_EXPORT QskLayoutBox : public QskControl
class QSK_EXPORT QskLayout : public QskControl
{ {
Q_OBJECT Q_OBJECT
using Inherited = QskControl; using Inherited = QskControl;
public: public:
explicit QskLayout( QQuickItem* parent = 0 ); explicit QskLayoutBox( QQuickItem* parent = 0 );
~QskLayout() override; ~QskLayoutBox() override;
Q_INVOKABLE bool isEmpty() const; Q_INVOKABLE bool isEmpty() const;
@ -69,12 +68,12 @@ class QSK_EXPORT QskLayout : public QskControl
std::unique_ptr< PrivateData > m_data; std::unique_ptr< PrivateData > m_data;
}; };
inline bool QskLayout::isEmpty() const inline bool QskLayoutBox::isEmpty() const
{ {
return itemCount() <= 0; return itemCount() <= 0;
} }
inline void QskLayout::removeItem( const QQuickItem* item ) inline void QskLayoutBox::removeItem( const QQuickItem* item )
{ {
removeItem( const_cast< QQuickItem* >( item ) ); removeItem( const_cast< QQuickItem* >( item ) );
} }

View File

@ -235,7 +235,7 @@ HEADERS += \
layouts/QskGridBox.h \ layouts/QskGridBox.h \
layouts/QskIndexedLayoutBox.h \ layouts/QskIndexedLayoutBox.h \
layouts/QskLayoutEngine.h \ layouts/QskLayoutEngine.h \
layouts/QskLayout.h \ layouts/QskLayoutBox.h \
layouts/QskLayoutConstraint.h \ layouts/QskLayoutConstraint.h \
layouts/QskLayoutItem.h \ layouts/QskLayoutItem.h \
layouts/QskLinearBox.h \ layouts/QskLinearBox.h \
@ -245,7 +245,7 @@ HEADERS += \
SOURCES += \ SOURCES += \
layouts/QskGridBox.cpp \ layouts/QskGridBox.cpp \
layouts/QskIndexedLayoutBox.cpp \ layouts/QskIndexedLayoutBox.cpp \
layouts/QskLayout.cpp \ layouts/QskLayoutBox.cpp \
layouts/QskLayoutConstraint.cpp \ layouts/QskLayoutConstraint.cpp \
layouts/QskLayoutEngine.cpp \ layouts/QskLayoutEngine.cpp \
layouts/QskLayoutItem.cpp \ layouts/QskLayoutItem.cpp \