dump method added

This commit is contained in:
Uwe Rathmann 2019-09-23 13:20:56 +02:00
parent 4e4b440a09
commit 5b094af452
6 changed files with 118 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#include "QskGridLayoutEngine.h"
#include "QskEvent.h"
#include "QskQuick.h"
#include <qdebug.h>
#include <algorithm>
static void qskSetItemActive( QObject* receiver, const QQuickItem* item, bool on )
@ -470,4 +471,53 @@ bool QskGridBox::event( QEvent* event )
return Inherited::event( event );
}
void QskGridBox::dump()
{
const auto& engine = m_data->engine;
auto debug = qDebug();
QDebugStateSaver saver( debug );
debug.nospace();
const auto constraint = sizeConstraint();
debug << "QskGridBox"
<< "[" << engine.columnCount() << "," << engine.rowCount() << "] w:"
<< constraint.width() << " h:" << constraint.height() << '\n';
for ( int i = 0; i < engine.count(); i++ )
{
const auto grid = engine.gridAt( i );
debug << " [";
debug << grid.left();
if ( grid.width() > 1 )
debug << "-" << grid.right();
debug << ",";
debug << grid.top();
if ( grid.height() > 1 )
debug << "->" << grid.bottom();
debug << "]: ";
if ( auto item = engine.itemAt( i ) )
{
const auto constraint = qskSizeConstraint( item, Qt::PreferredSize );
debug << item->metaObject()->className()
<< " w:" << constraint.width() << " h:" << constraint.height();
}
else
{
const auto size = engine.spacerAt( i );
debug << "spacer w:" << size.width() << " h:" << size.height();
}
debug << '\n';
}
}
#include "moc_QskGridBox.cpp"

View File

@ -108,6 +108,8 @@ class QSK_EXPORT QskGridBox : public QskBox
Q_INVOKABLE void setRowFixedHeight( int row, qreal height );
Q_INVOKABLE void setColumnFixedWidth( int column, qreal width );
void dump();
public Q_SLOTS:
void invalidate();
void clear( bool autoDelete = false );

View File

@ -532,4 +532,37 @@ int QskLinearBox::stretchFactor( const QQuickItem* item ) const
return stretchFactor( indexOf( item ) );
}
void QskLinearBox::dump()
{
const auto& engine = m_data->engine;
auto debug = qDebug();
QDebugStateSaver saver( debug );
debug.nospace();
const auto constraint = sizeConstraint();
debug << "QskLinearBox" << engine.orientation()
<< " w:" << constraint.width() << " h:" << constraint.height() << '\n';
for ( int i = 0; i < engine.count(); i++ )
{
debug << " " << i << ": ";
if ( auto item = engine.itemAt( i ) )
{
const auto constraint = qskSizeConstraint( item, Qt::PreferredSize );
debug << item->metaObject()->className()
<< " w:" << constraint.width() << " h:" << constraint.height();
}
else
{
debug << "spacer: " << engine.spacerAt( i );
}
debug << '\n';
}
}
#include "moc_QskLinearBox.cpp"

View File

@ -88,6 +88,8 @@ class QSK_EXPORT QskLinearBox : public QskIndexedLayoutBox
void setStretchFactor( const QQuickItem*, int stretchFactor );
int stretchFactor( const QQuickItem* ) const;
void dump();
public Q_SLOTS:
void transpose();
void activate();

View File

@ -404,4 +404,33 @@ bool QskStackBox::event( QEvent* event )
return Inherited::event( event );
}
void QskStackBox::dump()
{
auto debug = qDebug();
QDebugStateSaver saver( debug );
debug.nospace();
const auto constraint = sizeConstraint();
debug << "QskStackBox"
<< " w:" << constraint.width() << " h:" << constraint.height() << '\n';
for ( int i = 0; i < m_data->items.count(); i++ )
{
const auto item = m_data->items[i];
debug << " " << i << ": ";
const auto constraint = qskSizeConstraint( item, Qt::PreferredSize );
debug << item->metaObject()->className()
<< " w:" << constraint.width() << " h:" << constraint.height();
if ( i == m_data->currentIndex )
debug << " [X]";
debug << '\n';
}
}
#include "moc_QskStackBox.cpp"

View File

@ -55,6 +55,8 @@ class QSK_EXPORT QskStackBox : public QskIndexedLayoutBox
QRectF geometryForItemAt( int index ) const;
void dump();
Q_SIGNALS:
void defaultAlignmentChanged( Qt::Alignment );