diff options
author | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-06-24 14:51:06 (GMT) |
---|---|---|
committer | Eduardo M. Fleury <eduardo.fleury@openbossa.org> | 2009-07-22 18:04:36 (GMT) |
commit | 4424171fc41601831089b08d774813f3985ed5a7 (patch) | |
tree | 3fa50c5d8741d0e8fe8f04a28dbe5dda007e4dd4 /examples | |
parent | ca3ab7615d08742cb81dcc6fab723b89355ac82a (diff) | |
download | Qt-4424171fc41601831089b08d774813f3985ed5a7.zip Qt-4424171fc41601831089b08d774813f3985ed5a7.tar.gz Qt-4424171fc41601831089b08d774813f3985ed5a7.tar.bz2 |
Use whitespaces and newlines when saving the xml file.
Some whitespace cleanup.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/layouts/anchorlayout/window.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/examples/layouts/anchorlayout/window.cpp b/examples/layouts/anchorlayout/window.cpp index 8658d06..32efa69 100644 --- a/examples/layouts/anchorlayout/window.cpp +++ b/examples/layouts/anchorlayout/window.cpp @@ -98,7 +98,7 @@ void Window::on_actionSave_layout_triggered(bool ) if (!fileName.isEmpty()) saveLayout(fileName); } - + void Window::on_itemName_textEdited(const QString & ) { updateItem(); @@ -193,7 +193,7 @@ void Window::rebuildLayout() QGraphicsAnchorLayout::Edge endEdge = (QGraphicsAnchorLayout::Edge)(m_ui.anchors->item(i, 3)->data(Qt::UserRole).toInt(&ok)); if (!ok) continue; - + m_layout->anchor(startItem, startEdge, endItem, endEdge); } } @@ -219,14 +219,14 @@ QGraphicsLayoutItem *Window::addItem(const QString &name) return layoutItem; } -static const char *strEdges[] = {"Left", - "HCenter", - "Right", - "Top", - "VCenter", +static const char *strEdges[] = {"Left", + "HCenter", + "Right", + "Top", + "VCenter", "Bottom"}; -void Window::setAnchorData(QGraphicsLayoutItem *startItem, const QString &startName, QGraphicsAnchorLayout::Edge startEdge, +void Window::setAnchorData(QGraphicsLayoutItem *startItem, const QString &startName, QGraphicsAnchorLayout::Edge startEdge, QGraphicsLayoutItem *endItem, const QString &endName, QGraphicsAnchorLayout::Edge endEdge, int row /*= -1*/) { if (row == -1) { @@ -305,6 +305,7 @@ bool Window::saveLayout(const QString& fileName) ok = out.open(QIODevice::WriteOnly); if (ok) { QXmlStreamWriter xml(&out); + xml.setAutoFormatting(true); xml.writeStartDocument(); xml.writeStartElement(QLatin1String("anchorlayout")); int i; @@ -319,8 +320,8 @@ bool Window::saveLayout(const QString& fileName) const char *propertyNames[] = {"minimumSize", "preferredSize", "maximumSize"}; int b; typedef QSizeF (QGraphicsLayoutItem::*QGLISizeGetter)(void) const; - QGLISizeGetter sizeGetters[] = { &QGraphicsLayoutItem::minimumSize, - &QGraphicsLayoutItem::preferredSize, + QGLISizeGetter sizeGetters[] = { &QGraphicsLayoutItem::minimumSize, + &QGraphicsLayoutItem::preferredSize, &QGraphicsLayoutItem::maximumSize}; QSizeF size = ((*item).*(sizeGetters[p])) (); xml.writeStartElement(QLatin1String("property")); @@ -355,7 +356,7 @@ bool Window::saveLayout(const QString& fileName) QGraphicsAnchorLayout::Edge endEdge = (QGraphicsAnchorLayout::Edge)(m_ui.anchors->item(i, 3)->data(Qt::UserRole).toInt(&ok)); if (!ok) continue; - + QString strStart = nodeName(startItem); if (strStart == QLatin1String("layout")) strStart = QLatin1String("this"); @@ -391,7 +392,7 @@ static bool parseProperty(QXmlStreamReader *xml, QString *name, QSizeF *size) if (ok) { sz.setWidth(w); } - + float h = sw.toFloat(&ok); if (ok) { sz.setHeight(h); @@ -404,7 +405,7 @@ static bool parseProperty(QXmlStreamReader *xml, QString *name, QSizeF *size) *size = sz; return true; } - } + } } return false; } @@ -467,7 +468,7 @@ bool Window::loadLayout(const QString& fileName, QGraphicsAnchorLayout *layout) break; case QXmlStreamReader::StartElement: if (level == 0 && xml.name() == str_anchorlayout) { - + } else if (level == 1 && xml.name() == str_item) { item_id = xml.attributes().value("id").toString(); } else if (level == 1 && xml.name() == QLatin1String("anchor")) { @@ -503,7 +504,7 @@ bool Window::loadLayout(const QString& fileName, QGraphicsAnchorLayout *layout) qWarning("%s is not a valid edge description", qPrintable(second)); break; } - setAnchorData( startItem, startID, startEdge, + setAnchorData( startItem, startID, startEdge, endItem, endID, endEdge, -1); } else if (level == 2 && xml.name() == str_property) { QString name; |