diff options
author | Jarek Kobus <jkobus@trolltech.com> | 2011-09-23 12:19:02 +0200 |
---|---|---|
committer | Jarek Kobus <jkobus@trolltech.com> | 2011-09-23 12:19:02 +0200 |
commit | a6f87c60ed135c8f92a0de846dba5734fa7cf6c6 (patch) | |
tree | 71df2f312c74c27e17802753e05e6a2228b1cdfe /tools/designer/src | |
parent | 48f64fc7ae9f0e9e8ab07ab60ccd55d3b053dfab (diff) | |
download | qt4-tools-a6f87c60ed135c8f92a0de846dba5734fa7cf6c6.tar.gz |
Don't store the alignment attribute for spacers
And for QLayoutWidget as it is not allowed and will create
a code which doesn't compile
Reviewed-by: con <qtc-committer@nokia.com>
Task-number: QTBUG-21575
Diffstat (limited to 'tools/designer/src')
-rw-r--r-- | tools/designer/src/lib/uilib/abstractformbuilder.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp index 81f1a3b38e..665badb184 100644 --- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp @@ -1452,6 +1452,8 @@ struct FormBuilderSaveLayoutEntry { explicit FormBuilderSaveLayoutEntry(QLayoutItem *li = 0) : item(li), row(-1), column(-1), rowSpan(0), columnSpan(0), alignment(0) {} + void setAlignment(Qt::Alignment al); + QLayoutItem *item; int row; int column; @@ -1460,6 +1462,20 @@ struct FormBuilderSaveLayoutEntry { Qt::Alignment alignment; }; +// filter out the case of "Spacer" and "QLayoutWidget" widgets +void FormBuilderSaveLayoutEntry::setAlignment(Qt::Alignment al) +{ + if (!item->widget()) + return; + + const QString className = item->widget()->metaObject()->className(); + if (className == QLatin1String("Spacer") + || className == QLatin1String("QLayoutWidget")) + return; + + alignment = al; +} + // Create list from standard box layout static QList<FormBuilderSaveLayoutEntry> saveLayoutEntries(const QLayout *layout) { @@ -1469,7 +1485,7 @@ static QList<FormBuilderSaveLayoutEntry> saveLayoutEntries(const QLayout *layout for (int idx = 0; idx < count; ++idx) { QLayoutItem *item = layout->itemAt(idx); FormBuilderSaveLayoutEntry entry(item); - entry.alignment = item->alignment(); + entry.setAlignment(item->alignment()); rc.append(entry); } } @@ -1486,7 +1502,7 @@ static QList<FormBuilderSaveLayoutEntry> saveGridLayoutEntries(QGridLayout *grid QLayoutItem *item = gridLayout->itemAt(idx); FormBuilderSaveLayoutEntry entry(item); gridLayout->getItemPosition(idx, &entry.row, &entry.column, &entry.rowSpan,&entry.columnSpan); - entry.alignment = item->alignment(); + entry.setAlignment(item->alignment()); rc.append(entry); } } |