summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2009-06-16 13:52:36 (GMT)
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2009-06-16 13:52:36 (GMT)
commit2543decb7ead117fcbea2ef0618ccaedf0f1b2f4 (patch)
treefc2aa2525f0e3c915ea6a369b3b9a9e67fe564ee /src
parent237a3e690f290fd8ef8ef2a51459caa7fdc7bef1 (diff)
downloadQt-2543decb7ead117fcbea2ef0618ccaedf0f1b2f4.zip
Qt-2543decb7ead117fcbea2ef0618ccaedf0f1b2f4.tar.gz
Qt-2543decb7ead117fcbea2ef0618ccaedf0f1b2f4.tar.bz2
Made uic generate QLayout::setContentsMargin instead of setMargin.
With the exception of layout functions, which is too weird. Task-number: 255846
Diffstat (limited to 'src')
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index 5a2f487..6ca017a 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -391,6 +391,13 @@ void WriteInitialization::LayoutDefaultHandler::acceptLayoutFunction(DomLayoutFu
}
}
+static inline void writeContentsMargins(const QString &indent, const QString &objectName, int value, QTextStream &str)
+{
+ QString contentsMargins;
+ QTextStream(&contentsMargins) << value << ", " << value << ", " << value << ", " << value;
+ writeSetter(indent, objectName, QLatin1String("setContentsMargins"), contentsMargins, str);
+ }
+
void WriteInitialization::LayoutDefaultHandler::writeProperty(int p, const QString &indent, const QString &objectName,
const DomPropertyMap &properties, const QString &propertyName, const QString &setter,
int defaultStyleValue, bool suppressDefault, QTextStream &str) const
@@ -408,7 +415,11 @@ void WriteInitialization::LayoutDefaultHandler::writeProperty(int p, const QStri
&& value == defaultStyleValue);
if (ifndefMac)
str << "#ifndef Q_OS_MAC\n";
- writeSetter(indent, objectName, setter, value, str);
+ if (p == Margin) { // Use setContentsMargins for numeric values
+ writeContentsMargins(indent, objectName, value, str);
+ } else {
+ writeSetter(indent, objectName, setter, value, str);
+ }
if (ifndefMac)
str << "#endif\n";
return;
@@ -416,13 +427,18 @@ void WriteInitialization::LayoutDefaultHandler::writeProperty(int p, const QStri
}
if (suppressDefault)
return;
- // get default
+ // get default.
if (m_state[p] & HasDefaultFunction) {
+ // Do not use setContentsMargins to avoid repetitive evaluations.
writeSetter(indent, objectName, setter, m_functions[p], str);
return;
}
if (m_state[p] & HasDefaultValue) {
- writeSetter(indent, objectName, setter, m_defaultValues[p], str);
+ if (p == Margin) { // Use setContentsMargins for numeric values
+ writeContentsMargins(indent, objectName, m_defaultValues[p], str);
+ } else {
+ writeSetter(indent, objectName, setter, m_defaultValues[p], str);
+ }
}
return;
}