From 683826060633d6f5009eb2366824f359d7718e5c Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Tue, 9 Jul 2019 14:27:50 +0200 Subject: [PATCH] QskLinearBox::spacingAtIndex added --- examples/layouts/FlowLayoutPage.cpp | 2 +- examples/layouts/LinearLayoutPage.cpp | 16 ++++++---------- src/layouts/QskLinearBox.cpp | 5 +++++ src/layouts/QskLinearBox.h | 2 ++ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/examples/layouts/FlowLayoutPage.cpp b/examples/layouts/FlowLayoutPage.cpp index 2cbf81ed..75fbcbe8 100644 --- a/examples/layouts/FlowLayoutPage.cpp +++ b/examples/layouts/FlowLayoutPage.cpp @@ -53,7 +53,7 @@ namespace { const int index = 0; - QQuickItem* item = itemAtIndex( index ); + auto item = itemAtIndex( index ); removeAt( index ); if ( item == nullptr ) diff --git a/examples/layouts/LinearLayoutPage.cpp b/examples/layouts/LinearLayoutPage.cpp index 13bc9d09..29d70f7c 100644 --- a/examples/layouts/LinearLayoutPage.cpp +++ b/examples/layouts/LinearLayoutPage.cpp @@ -35,10 +35,7 @@ namespace addRectangle( "FireBrick" ); addRectangle( "DarkRed" ); - // setRowSpacing( 5, 30 ); insertSpacer( 5, 30 ); - // insertStretch( 5, 2 ); - // setRetainSizeWhenHidden( 2, true ); } void mirror() @@ -50,17 +47,16 @@ namespace { const int index = 0; - QQuickItem* item = itemAtIndex( index ); - removeAt( index ); - - if ( item == nullptr ) + if ( auto item = itemAtIndex( index ) ) { - // how to get the spacer item and its settings ??? - addSpacer( 30 ); + removeAt( index ); + addItem( item ); } else { - addItem( item ); + const auto spacing = spacingAtIndex( index ); + removeAt( index ); + addSpacer( spacing ); } } diff --git a/src/layouts/QskLinearBox.cpp b/src/layouts/QskLinearBox.cpp index 9bd72397..66470c42 100644 --- a/src/layouts/QskLinearBox.cpp +++ b/src/layouts/QskLinearBox.cpp @@ -82,6 +82,11 @@ int QskLinearBox::entryCount() const return m_data->engine.count(); } +int QskLinearBox::spacingAtIndex( int index ) const +{ + return m_data->engine.spacerAt( index ); +} + QQuickItem* QskLinearBox::itemAtIndex( int index ) const { return m_data->engine.itemAt( index ); diff --git a/src/layouts/QskLinearBox.h b/src/layouts/QskLinearBox.h index 2deb0fd6..9f8bcab1 100644 --- a/src/layouts/QskLinearBox.h +++ b/src/layouts/QskLinearBox.h @@ -46,6 +46,8 @@ class QSK_EXPORT QskLinearBox : public QskIndexedLayoutBox int itemCount() const { return entryCount(); } // items and spacers #endif + int spacingAtIndex( int index ) const; + QQuickItem* itemAtIndex( int index ) const; int indexOf( const QQuickItem* ) const;