6#include "QskSizePolicy.h"
14static void qskRegisterSizePolicy()
16 qRegisterMetaType< QskSizePolicy >();
18#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
19 QMetaType::registerEqualsComparator< QskSizePolicy >();
23Q_CONSTRUCTOR_FUNCTION( qskRegisterSizePolicy )
25QskSizePolicy::ConstraintType QskSizePolicy::constraintType() const noexcept
27 constexpr unsigned char mask = IgnoreFlag | ConstrainedFlag;
30 if ( ( ( m_horizontalPolicy & mask ) == mask )
31 || ( ( m_verticalPolicy & mask ) == mask ) )
33 qWarning() <<
"invalid policy having IgnoreFlag and ConstrainedFlag";
37 if ( ( m_horizontalPolicy & mask ) == ConstrainedFlag )
38 return QskSizePolicy::WidthForHeight;
40 if ( ( m_verticalPolicy & mask ) == ConstrainedFlag )
41 return QskSizePolicy::HeightForWidth;
43 return QskSizePolicy::Unconstrained;
46Qt::SizeHint QskSizePolicy::effectiveSizeHintType(
47 Qt::SizeHint which, Qt::Orientation orientation )
const noexcept
49 const auto policy = ( orientation == Qt::Horizontal )
50 ? horizontalPolicy() : verticalPolicy();
52 if ( which == Qt::MinimumSize )
54 if ( !( policy & ShrinkFlag ) )
55 return Qt::PreferredSize;
57 else if ( which == Qt::MaximumSize )
59 if ( !( policy & ( GrowFlag | ExpandFlag ) ) )
60 return Qt::PreferredSize;
66void QskSizePolicy::transpose() noexcept
68 std::swap( m_horizontalPolicy, m_verticalPolicy );
71#ifndef QT_NO_DEBUG_STREAM
77 QDebugStateSaver saver( debug );
79 debug <<
"SizePolicy" <<
'(';
80 debug << policy.horizontalPolicy() <<
", " << policy.verticalPolicy();
88#include "moc_QskSizePolicy.cpp"