shifting code to qmlexport
This commit is contained in:
parent
6113667976
commit
20a9b3bc76
@ -12,6 +12,11 @@
|
||||
#include <QskLinearBox.h>
|
||||
#include <QskGridBox.h>
|
||||
|
||||
/*
|
||||
QML need methods being Q_INVOKABLE and QQuickItem parameters
|
||||
need to be non const.
|
||||
*/
|
||||
|
||||
template< typename LayoutBox >
|
||||
class QskLayoutBoxQml : public LayoutBox
|
||||
{
|
||||
@ -42,10 +47,85 @@ class QskLayoutBoxQml : public LayoutBox
|
||||
// QML does not like a const version
|
||||
LayoutBox::removeItem( item );
|
||||
}
|
||||
|
||||
Q_INVOKABLE void setAlignment( QQuickItem* item, Qt::Alignment alignment )
|
||||
{
|
||||
LayoutBox::setAlignment( item, alignment );
|
||||
}
|
||||
|
||||
Q_INVOKABLE Qt::Alignment alignment( QQuickItem* item ) const
|
||||
{
|
||||
return LayoutBox::alignment( item );
|
||||
}
|
||||
};
|
||||
|
||||
class QskStackBoxQml : public QskLayoutBoxQml< QskLinearBox > { Q_OBJECT };
|
||||
class QskLinearBoxQml : public QskLayoutBoxQml< QskLinearBox > { Q_OBJECT };
|
||||
class QskGridBoxQml : public QskLayoutBoxQml< QskGridBox > { Q_OBJECT };
|
||||
class QskStackBoxQml : public QskLayoutBoxQml< QskStackBox >
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_INVOKABLE void setAlignment( int index, Qt::Alignment alignment )
|
||||
{
|
||||
QskStackBox::setAlignment( index, alignment );
|
||||
}
|
||||
|
||||
Q_INVOKABLE Qt::Alignment alignment( int index ) const
|
||||
{
|
||||
return QskStackBox::alignment( index );
|
||||
}
|
||||
};
|
||||
|
||||
class QskLinearBoxQml : public QskLayoutBoxQml< QskLinearBox >
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
Q_INVOKABLE void setAlignment( int index, Qt::Alignment alignment )
|
||||
{
|
||||
QskLinearBox::setAlignment( index, alignment );
|
||||
}
|
||||
|
||||
Q_INVOKABLE Qt::Alignment alignment( int index ) const
|
||||
{
|
||||
return QskLinearBox::alignment( index );
|
||||
}
|
||||
|
||||
Q_INVOKABLE void setStretchFactor( QQuickItem* item, int stretchFactor )
|
||||
{
|
||||
QskLinearBox::setStretchFactor( item, stretchFactor );
|
||||
}
|
||||
|
||||
Q_INVOKABLE int stretchFactor( QQuickItem* item ) const
|
||||
{
|
||||
return QskLinearBox::stretchFactor( item );
|
||||
}
|
||||
|
||||
Q_INVOKABLE void setRetainSizeWhenHidden( QQuickItem* item, bool on )
|
||||
{
|
||||
QskLinearBox::setRetainSizeWhenHidden( item, on );
|
||||
}
|
||||
|
||||
Q_INVOKABLE bool retainSizeWhenHidden( QQuickItem* item ) const
|
||||
{
|
||||
return QskLinearBox::retainSizeWhenHidden( item );
|
||||
}
|
||||
};
|
||||
|
||||
class QskGridBoxQml : public QskLayoutBoxQml< QskGridBox >
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
Q_INVOKABLE bool retainSizeWhenHidden( QQuickItem* item ) const
|
||||
{
|
||||
return QskGridBox::retainSizeWhenHidden( item );
|
||||
}
|
||||
|
||||
Q_INVOKABLE void setRetainSizeWhenHidden( QQuickItem* item, bool on )
|
||||
{
|
||||
QskGridBox::setRetainSizeWhenHidden( item, on );
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -382,7 +382,7 @@ Qt::Alignment QskGridBox::columnAlignment( int column ) const
|
||||
return engine().rowAlignment( column, Qt::Horizontal );
|
||||
}
|
||||
|
||||
void QskGridBox::setAlignment( QQuickItem* item, Qt::Alignment alignment )
|
||||
void QskGridBox::setAlignment( const QQuickItem* item, Qt::Alignment alignment )
|
||||
{
|
||||
QskLayoutItem* layoutItem = engine().layoutItemOf( item );
|
||||
if ( layoutItem && layoutItem->alignment() != alignment )
|
||||
@ -392,7 +392,7 @@ void QskGridBox::setAlignment( QQuickItem* item, Qt::Alignment alignment )
|
||||
}
|
||||
}
|
||||
|
||||
Qt::Alignment QskGridBox::alignment( QQuickItem* item ) const
|
||||
Qt::Alignment QskGridBox::alignment( const QQuickItem* item ) const
|
||||
{
|
||||
QskLayoutItem* layoutItem = engine().layoutItemOf( item );
|
||||
if ( layoutItem )
|
||||
@ -401,7 +401,7 @@ Qt::Alignment QskGridBox::alignment( QQuickItem* item ) const
|
||||
return Qt::Alignment();
|
||||
}
|
||||
|
||||
void QskGridBox::setRetainSizeWhenHidden( QQuickItem* item, bool on )
|
||||
void QskGridBox::setRetainSizeWhenHidden( const QQuickItem* item, bool on )
|
||||
{
|
||||
QskLayoutItem* layoutItem = engine().layoutItemOf( item );
|
||||
if ( layoutItem && on != layoutItem->retainSizeWhenHidden() )
|
||||
@ -411,7 +411,7 @@ void QskGridBox::setRetainSizeWhenHidden( QQuickItem* item, bool on )
|
||||
}
|
||||
}
|
||||
|
||||
bool QskGridBox::retainSizeWhenHidden( QQuickItem* item ) const
|
||||
bool QskGridBox::retainSizeWhenHidden( const QQuickItem* item ) const
|
||||
{
|
||||
QskLayoutItem* layoutItem = engine().layoutItemOf( item );
|
||||
if ( layoutItem )
|
||||
|
@ -104,15 +104,9 @@ class QSK_EXPORT QskGridBox : public QskLayoutBox
|
||||
void setAlignment( const QQuickItem* item, Qt::Alignment alignment );
|
||||
Qt::Alignment alignment( const QQuickItem* item ) const;
|
||||
|
||||
Q_INVOKABLE void setAlignment( QQuickItem* item, Qt::Alignment alignment );
|
||||
Q_INVOKABLE Qt::Alignment alignment( QQuickItem* item ) const;
|
||||
|
||||
bool retainSizeWhenHidden( const QQuickItem* ) const;
|
||||
void setRetainSizeWhenHidden( const QQuickItem*, bool on );
|
||||
|
||||
Q_INVOKABLE bool retainSizeWhenHidden( QQuickItem* ) const;
|
||||
Q_INVOKABLE void setRetainSizeWhenHidden( QQuickItem*, bool on );
|
||||
|
||||
Q_SIGNALS:
|
||||
void verticalSpacingChanged();
|
||||
void horizontalSpacingChanged();
|
||||
@ -137,26 +131,4 @@ inline void QskGridBox::addItem(
|
||||
addItem( item, row, column, 1, 1, alignment );
|
||||
}
|
||||
|
||||
// Qml does not like the const versions
|
||||
|
||||
inline void QskGridBox::setAlignment( const QQuickItem* item, Qt::Alignment alignment )
|
||||
{
|
||||
setAlignment( const_cast< QQuickItem* >( item ), alignment );
|
||||
}
|
||||
|
||||
inline Qt::Alignment QskGridBox::alignment( const QQuickItem* item ) const
|
||||
{
|
||||
return alignment( const_cast< QQuickItem* >( item ) );
|
||||
}
|
||||
|
||||
inline bool QskGridBox::retainSizeWhenHidden( const QQuickItem* item ) const
|
||||
{
|
||||
return retainSizeWhenHidden( const_cast< QQuickItem* >( item ) );
|
||||
}
|
||||
|
||||
inline void QskGridBox::setRetainSizeWhenHidden( const QQuickItem* item, bool on )
|
||||
{
|
||||
setRetainSizeWhenHidden( const_cast< QQuickItem* >( item ), on );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -127,7 +127,7 @@ void QskIndexedLayoutBox::insertItem(
|
||||
}
|
||||
}
|
||||
|
||||
QskLayoutItem* layoutItem = new QskLayoutItem( item, 0, 0 );
|
||||
auto layoutItem = new QskLayoutItem( item, 0, 0 );
|
||||
layoutItem->setAlignment( alignment );
|
||||
|
||||
insertLayoutItem( layoutItem, index );
|
||||
@ -135,8 +135,8 @@ void QskIndexedLayoutBox::insertItem(
|
||||
|
||||
void QskIndexedLayoutBox::setAlignment( int index, Qt::Alignment alignment )
|
||||
{
|
||||
QskLayoutItem* layoutItem = engine().layoutItemAt( index );
|
||||
if ( layoutItem && alignment != layoutItem->alignment() )
|
||||
auto layoutItem = engine().layoutItemAt( index );
|
||||
if ( layoutItem && ( alignment != layoutItem->alignment() ) )
|
||||
{
|
||||
layoutItem->setAlignment( alignment );
|
||||
activate(); // invalidate() ???
|
||||
@ -145,19 +145,20 @@ void QskIndexedLayoutBox::setAlignment( int index, Qt::Alignment alignment )
|
||||
|
||||
Qt::Alignment QskIndexedLayoutBox::alignment( int index ) const
|
||||
{
|
||||
QskLayoutItem* layoutItem = engine().layoutItemAt( index );
|
||||
const auto layoutItem = engine().layoutItemAt( index );
|
||||
if ( layoutItem )
|
||||
return layoutItem->alignment();
|
||||
|
||||
return Qt::Alignment();
|
||||
}
|
||||
|
||||
void QskIndexedLayoutBox::setAlignment( QQuickItem* item, Qt::Alignment alignment )
|
||||
void QskIndexedLayoutBox::setAlignment(
|
||||
const QQuickItem* item, Qt::Alignment alignment )
|
||||
{
|
||||
setAlignment( engine().indexOf( item ), alignment );
|
||||
}
|
||||
|
||||
Qt::Alignment QskIndexedLayoutBox::alignment( QQuickItem* item ) const
|
||||
Qt::Alignment QskIndexedLayoutBox::alignment( const QQuickItem* item ) const
|
||||
{
|
||||
return alignment( engine().indexOf( item ) );
|
||||
}
|
||||
|
@ -36,15 +36,12 @@ class QSK_EXPORT QskIndexedLayoutBox : public QskLayoutBox
|
||||
Q_INVOKABLE void insertItem(
|
||||
int index, QQuickItem*, Qt::Alignment alignment = Qt::Alignment() );
|
||||
|
||||
Q_INVOKABLE void setAlignment( int index, Qt::Alignment );
|
||||
Q_INVOKABLE Qt::Alignment alignment( int index ) const;
|
||||
void setAlignment( int index, Qt::Alignment );
|
||||
Qt::Alignment alignment( int index ) const;
|
||||
|
||||
void setAlignment( const QQuickItem*, Qt::Alignment );
|
||||
Qt::Alignment alignment( const QQuickItem* ) const;
|
||||
|
||||
Q_INVOKABLE void setAlignment( QQuickItem*, Qt::Alignment );
|
||||
Q_INVOKABLE Qt::Alignment alignment( QQuickItem* ) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void autoAddChildrenChanged();
|
||||
void defaultAlignmentChanged();
|
||||
@ -58,16 +55,4 @@ class QSK_EXPORT QskIndexedLayoutBox : public QskLayoutBox
|
||||
std::unique_ptr< PrivateData > m_data;
|
||||
};
|
||||
|
||||
// Qml does not like the const version
|
||||
|
||||
inline void QskIndexedLayoutBox::setAlignment( const QQuickItem* item, Qt::Alignment alignment )
|
||||
{
|
||||
setAlignment( const_cast< QQuickItem* >( item ), alignment );
|
||||
}
|
||||
|
||||
inline Qt::Alignment QskIndexedLayoutBox::alignment( const QQuickItem* item ) const
|
||||
{
|
||||
return alignment( const_cast< QQuickItem* >( item ) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -225,19 +225,19 @@ int QskLinearBox::stretchFactor( int index ) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QskLinearBox::setStretchFactor( QQuickItem* item, int stretch )
|
||||
void QskLinearBox::setStretchFactor( const QQuickItem* item, int stretch )
|
||||
{
|
||||
setStretchFactor( engine().indexOf( item ), stretch );
|
||||
}
|
||||
|
||||
int QskLinearBox::stretchFactor( QQuickItem* item ) const
|
||||
int QskLinearBox::stretchFactor( const QQuickItem* item ) const
|
||||
{
|
||||
return stretchFactor( engine().indexOf( item ) );
|
||||
}
|
||||
|
||||
void QskLinearBox::setRetainSizeWhenHidden( int index, bool on )
|
||||
{
|
||||
QskLayoutItem* layoutItem = engine().layoutItemAt( index );
|
||||
auto layoutItem = engine().layoutItemAt( index );
|
||||
if ( layoutItem && on != layoutItem->retainSizeWhenHidden() )
|
||||
{
|
||||
layoutItem->setRetainSizeWhenHidden( on );
|
||||
@ -247,19 +247,18 @@ void QskLinearBox::setRetainSizeWhenHidden( int index, bool on )
|
||||
|
||||
bool QskLinearBox::retainSizeWhenHidden( int index ) const
|
||||
{
|
||||
QskLayoutItem* layoutItem = engine().layoutItemAt( index );
|
||||
if ( layoutItem )
|
||||
if ( const auto layoutItem = engine().layoutItemAt( index ) )
|
||||
return layoutItem->retainSizeWhenHidden();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void QskLinearBox::setRetainSizeWhenHidden( QQuickItem* item, bool on )
|
||||
void QskLinearBox::setRetainSizeWhenHidden( const QQuickItem* item, bool on )
|
||||
{
|
||||
setRetainSizeWhenHidden( engine().indexOf( item ), on );
|
||||
}
|
||||
|
||||
bool QskLinearBox::retainSizeWhenHidden( QQuickItem* item ) const
|
||||
bool QskLinearBox::retainSizeWhenHidden( const QQuickItem* item ) const
|
||||
{
|
||||
return retainSizeWhenHidden( engine().indexOf( item ) );
|
||||
}
|
||||
|
@ -60,18 +60,12 @@ class QSK_EXPORT QskLinearBox : public QskIndexedLayoutBox
|
||||
void setStretchFactor( const QQuickItem*, int stretchFactor );
|
||||
int stretchFactor( const QQuickItem* ) const;
|
||||
|
||||
Q_INVOKABLE void setStretchFactor( QQuickItem*, int stretchFactor );
|
||||
Q_INVOKABLE int stretchFactor( QQuickItem* ) const;
|
||||
|
||||
Q_INVOKABLE bool retainSizeWhenHidden( int index ) const;
|
||||
Q_INVOKABLE void setRetainSizeWhenHidden( int index, bool on );
|
||||
|
||||
bool retainSizeWhenHidden( const QQuickItem* ) const;
|
||||
void setRetainSizeWhenHidden( const QQuickItem*, bool on );
|
||||
|
||||
Q_INVOKABLE bool retainSizeWhenHidden( QQuickItem* ) const;
|
||||
Q_INVOKABLE void setRetainSizeWhenHidden( QQuickItem*, bool on );
|
||||
|
||||
#if 1
|
||||
Q_INVOKABLE void setRowSpacing( int row, qreal spacing );
|
||||
Q_INVOKABLE qreal rowSpacing( int row ) const;
|
||||
@ -109,26 +103,4 @@ class QSK_EXPORT QskLinearBox : public QskIndexedLayoutBox
|
||||
std::unique_ptr< PrivateData > m_data;
|
||||
};
|
||||
|
||||
// using const is the right thing, unfortunately Qml does not like it.
|
||||
|
||||
inline void QskLinearBox::setStretchFactor( const QQuickItem* item, int stretchFactor )
|
||||
{
|
||||
setStretchFactor( const_cast< QQuickItem* >( item ), stretchFactor );
|
||||
}
|
||||
|
||||
inline int QskLinearBox::stretchFactor( const QQuickItem* item ) const
|
||||
{
|
||||
return stretchFactor( const_cast< QQuickItem* >( item ) );
|
||||
}
|
||||
|
||||
inline void QskLinearBox::setRetainSizeWhenHidden( const QQuickItem* item, bool on )
|
||||
{
|
||||
setRetainSizeWhenHidden( const_cast< QQuickItem* >( item ), on );
|
||||
}
|
||||
|
||||
inline bool QskLinearBox::retainSizeWhenHidden( const QQuickItem* item ) const
|
||||
{
|
||||
return retainSizeWhenHidden( const_cast< QQuickItem* >( item ) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user