[Kde-bindings] [qyoto] tools/uics: Apply a patch form Dimitar Dobrev:
Arno Rehn
arno at arnorehn.de
Sun Jan 8 18:22:48 UTC 2012
Git commit d43e84ac8aad66f66b879b92c79079260682a263 by Arno Rehn.
Committed on 08/01/2012 at 19:21.
Pushed by arnorehn into branch 'master'.
Apply a patch form Dimitar Dobrev:
This patch writes the names of layouts in the ui file, if any, in
the generated C# and also replaces the invalid AddLayout method of
QFormLayout with SetLayout and the proper parameters.
CCMAIL: kde-bindings at kde.org
M +15 -1 tools/uics/cs/cswriteinitialization.cpp
M +1 -1 tools/uics/driver.cpp
M +5 -0 tools/uics/ui4.cpp
M +8 -0 tools/uics/ui4.h
http://commits.kde.org/qyoto/d43e84ac8aad66f66b879b92c79079260682a263
diff --git a/tools/uics/cs/cswriteinitialization.cpp b/tools/uics/cs/cswriteinitialization.cpp
index b82c68b..985a9cf 100644
--- a/tools/uics/cs/cswriteinitialization.cpp
+++ b/tools/uics/cs/cswriteinitialization.cpp
@@ -766,7 +766,21 @@ void WriteInitialization::acceptLayoutItem(DomLayoutItem *node)
method = QLatin1String("AddWidget");
break;
case DomLayoutItem::Layout:
- method = QLatin1String("AddLayout");
+ if (layout->attributeClass() == QLatin1String("QFormLayout")) {
+ method = QLatin1String("SetLayout");
+ QString itemRole;
+ if (node->attributeRowSpan() == 2) {
+ itemRole = "QFormLayout.ItemRole.SpanningRole";
+ } else if (node->attributeColumn() == 0) {
+ itemRole = "QFormLayout.ItemRole.LabelRole";
+ } else {
+ itemRole = "QFormLayout.ItemRole.FieldRole";
+ }
+ m_output << "\n" << m_option.indent << layoutName << "." << method << "(" << node->attributeRow() << ", " << itemRole << ", " << varName << opt << ");\n\n";
+ return;
+ } else {
+ method = QLatin1String("AddLayout");
+ }
break;
case DomLayoutItem::Spacer:
method = QLatin1String("AddItem");
diff --git a/tools/uics/driver.cpp b/tools/uics/driver.cpp
index 1461c17..a88bb09 100644
--- a/tools/uics/driver.cpp
+++ b/tools/uics/driver.cpp
@@ -56,7 +56,7 @@ QString Driver::findOrInsertSpacer(DomSpacer *ui_spacer)
QString Driver::findOrInsertLayout(DomLayout *ui_layout)
{
if (!m_layouts.contains(ui_layout))
- m_layouts.insert(ui_layout, unique(QString(), ui_layout->attributeClass()));
+ m_layouts.insert(ui_layout, unique(ui_layout->attributeName(), ui_layout->attributeClass()));
return m_layouts.value(ui_layout);
}
diff --git a/tools/uics/ui4.cpp b/tools/uics/ui4.cpp
index d067aab..65fc948 100644
--- a/tools/uics/ui4.cpp
+++ b/tools/uics/ui4.cpp
@@ -2085,6 +2085,8 @@ void DomLayout::read(const QDomElement &node)
{
if (node.hasAttribute(QLatin1String("class")))
setAttributeClass(node.attribute(QLatin1String("class")));
+ if (node.hasAttribute(QLatin1String("name")))
+ setAttributeName(node.attribute(QLatin1String("name")));
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
if (!n.isElement())
@@ -2127,6 +2129,9 @@ QDomElement DomLayout::write(QDomDocument &doc, const QString &tagName) const
if (hasAttributeClass())
e.setAttribute(QLatin1String("class"), attributeClass());
+ if (hasAttributeName())
+ e.setAttribute(QLatin1String("name"), attributeName());
+
for (int i = 0; i < m_property.size(); ++i) {
DomProperty* v = m_property[i];
QDomNode child = v->write(doc, QLatin1String("property"));
diff --git a/tools/uics/ui4.h b/tools/uics/ui4.h
index 15f824b..e088003 100644
--- a/tools/uics/ui4.h
+++ b/tools/uics/ui4.h
@@ -1017,6 +1017,11 @@ public:
inline void setAttributeClass(const QString& a) { m_attr_class = a; m_has_attr_class = true; }
inline void clearAttributeClass() { m_has_attr_class = false; }
+ inline bool hasAttributeName() const { return m_has_attr_name; }
+ inline QString attributeName() const { return m_attr_name; }
+ inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; }
+ inline void clearAttributeName() { m_has_attr_name = false; }
+
// child element accessors
inline QList<DomProperty*> elementProperty() const { return m_property; }
void setElementProperty(const QList<DomProperty*>& a);
@@ -1035,6 +1040,9 @@ private:
QString m_attr_class;
bool m_has_attr_class;
+ QString m_attr_name;
+ bool m_has_attr_name;
+
// child element data
QList<DomProperty*> m_property;
QList<DomProperty*> m_attribute;
More information about the Kde-bindings
mailing list