diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2010-10-22 14:10:44 (GMT) |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2010-10-22 14:10:44 (GMT) |
commit | 2231e4f03c621459e1c261b2ed224a49877d2ddf (patch) | |
tree | 93abd9fbf65a69c052b53170c0628d6dd9345034 /src/tools | |
parent | 03c1445ed4be734a82cea59d107c51a4be43c5f4 (diff) | |
download | Qt-2231e4f03c621459e1c261b2ed224a49877d2ddf.zip Qt-2231e4f03c621459e1c261b2ed224a49877d2ddf.tar.gz Qt-2231e4f03c621459e1c261b2ed224a49877d2ddf.tar.bz2 |
Designer: Support alignment in box and grid layouts.
Extend ui-format by alignment-attribute for QLayoutItem,
handle it in uic and formbuilder.
Support in Designer by context menu.
Reviewed-by: Jarek Kobus <jaroslaw.kobus@nokia.com>
Task-number: QTBUG-3120
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/uic/cpp/cppwriteinitialization.cpp | 4 | ||||
-rw-r--r-- | src/tools/uic/ui4.cpp | 11 | ||||
-rw-r--r-- | src/tools/uic/ui4.h | 8 |
3 files changed, 23 insertions, 0 deletions
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index a2bc89d..e6fcd46 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1096,6 +1096,8 @@ void WriteInitialization::acceptLayoutItem(DomLayoutItem *node) const int colSpan = node->hasAttributeColSpan() ? node->attributeColSpan() : 1; addArgs = QString::fromLatin1("%1, %2, %3, %4, %5").arg(itemName).arg(row).arg(col).arg(rowSpan).arg(colSpan); + if (!node->attributeAlignment().isEmpty()) + addArgs += QLatin1String(", ") + node->attributeAlignment(); } else { if (layout->attributeClass() == QLatin1String("QFormLayout")) { methodPrefix = QLatin1String("set"); @@ -1105,6 +1107,8 @@ void WriteInitialization::acceptLayoutItem(DomLayoutItem *node) addArgs = QString::fromLatin1("%1, %2, %3").arg(row).arg(role).arg(itemName); } else { addArgs = itemName; + if (layout->attributeClass().contains(QLatin1String("Box")) && !node->attributeAlignment().isEmpty()) + addArgs += QLatin1String(", 0, ") + node->attributeAlignment(); } } diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp index 1988696..e094eaf 100644 --- a/src/tools/uic/ui4.cpp +++ b/src/tools/uic/ui4.cpp @@ -3673,6 +3673,7 @@ void DomLayoutItem::clear(bool clear_all) m_attr_rowSpan = 0; m_has_attr_colSpan = false; m_attr_colSpan = 0; + m_has_attr_alignment = false; } m_kind = Unknown; @@ -3694,6 +3695,7 @@ DomLayoutItem::DomLayoutItem() m_attr_rowSpan = 0; m_has_attr_colSpan = false; m_attr_colSpan = 0; + m_has_attr_alignment = false; m_widget = 0; m_layout = 0; m_spacer = 0; @@ -3727,6 +3729,10 @@ void DomLayoutItem::read(QXmlStreamReader &reader) setAttributeColSpan(attribute.value().toString().toInt()); continue; } + if (name == QLatin1String("alignment")) { + setAttributeAlignment(attribute.value().toString()); + continue; + } reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); } @@ -3779,6 +3785,8 @@ void DomLayoutItem::read(const QDomElement &node) setAttributeRowSpan(node.attribute(QLatin1String("rowspan")).toInt()); if (node.hasAttribute(QLatin1String("colspan"))) setAttributeColSpan(node.attribute(QLatin1String("colspan")).toInt()); + if (node.hasAttribute(QLatin1String("alignment"))) + setAttributeAlignment(node.attribute(QLatin1String("alignment"))); for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { if (!n.isElement()) @@ -3828,6 +3836,9 @@ void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) cons if (hasAttributeColSpan()) writer.writeAttribute(QLatin1String("colspan"), QString::number(attributeColSpan())); + if (hasAttributeAlignment()) + writer.writeAttribute(QLatin1String("alignment"), attributeAlignment()); + switch (kind()) { case Widget: { DomWidget* v = elementWidget(); diff --git a/src/tools/uic/ui4.h b/src/tools/uic/ui4.h index a464a89..836175e 100644 --- a/src/tools/uic/ui4.h +++ b/src/tools/uic/ui4.h @@ -1427,6 +1427,11 @@ public: inline void setAttributeColSpan(int a) { m_attr_colSpan = a; m_has_attr_colSpan = true; } inline void clearAttributeColSpan() { m_has_attr_colSpan = false; } + inline bool hasAttributeAlignment() const { return m_has_attr_alignment; } + inline QString attributeAlignment() const { return m_attr_alignment; } + inline void setAttributeAlignment(const QString& a) { m_attr_alignment = a; m_has_attr_alignment = true; } + inline void clearAttributeAlignment() { m_has_attr_alignment = false; } + // child element accessors enum Kind { Unknown = 0, Widget, Layout, Spacer }; inline Kind kind() const { return m_kind; } @@ -1460,6 +1465,9 @@ private: int m_attr_colSpan; bool m_has_attr_colSpan; + QString m_attr_alignment; + bool m_has_attr_alignment; + // child element data Kind m_kind; DomWidget* m_widget; |