summaryrefslogtreecommitdiffstats
path: root/src/tools/uic/driver.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-05-08 09:25:25 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-05-08 10:19:22 +0200
commit07071a23c3bc3f0444068383a57fbc9d50601240 (patch)
tree26521fdc98b501d8d7e5139927999b747a144e79 /src/tools/uic/driver.cpp
parentf48aa008e992429647968a29ef30d412f1ae379a (diff)
uic/Python: Fix tab stop/Z-Order and buddy handling
The code compared the attribute names of the properties against the m_registeredWidgets hash which contained the qualified names (self.widget) and thus reported errors without actually generating anything. Replace the m_registeredWidgets hash by a lookup of the attribute name in the m_widgets hash and add a function widgetVariableName() returning the qualified variable name for an attribute name and use that for the checks. Remove unused m_registeredActions hash and rename some variables to make it clearer. Task-number: PYSIDE-797 Change-Id: Id31d95c1141d21c51eb85bcd8f8fc63486eb36a5 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'src/tools/uic/driver.cpp')
-rw-r--r--src/tools/uic/driver.cpp38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/tools/uic/driver.cpp b/src/tools/uic/driver.cpp
index a0812932ce..eb88032e59 100644
--- a/src/tools/uic/driver.cpp
+++ b/src/tools/uic/driver.cpp
@@ -53,14 +53,24 @@ static inline QString actionClass() { return QStringLiteral("QAction"); }
static inline QString buttonGroupClass() { return QStringLiteral("QButtonGroup"); }
template <class DomClass>
+Driver::DomObjectHashConstIt<DomClass>
+ Driver::findByAttributeNameIt(const DomObjectHash<DomClass> &domHash,
+ const QString &name) const
+{
+ const auto end = domHash.cend();
+ for (auto it = domHash.cbegin(); it != end; ++it) {
+ if (it.key()->attributeName() == name)
+ return it;
+ }
+ return end;
+}
+
+template <class DomClass>
const DomClass *Driver::findByAttributeName(const DomObjectHash<DomClass> &domHash,
const QString &name) const
{
- for (auto it = domHash.cbegin(), end = domHash.cend(); it != end; ++it) {
- if (it.key()->attributeName() == name)
- return it.key();
- }
- return nullptr;
+ auto it = findByAttributeNameIt(domHash, name);
+ return it != domHash.cend() ? it.key() : nullptr;
}
template <class DomClass>
@@ -299,19 +309,25 @@ bool Driver::uic(const QString &fileName, QTextStream *out)
return rtn;
}
-const DomWidget *Driver::widgetByName(const QString &name) const
+const DomWidget *Driver::widgetByName(const QString &attributeName) const
+{
+ return findByAttributeName(m_widgets, attributeName);
+}
+
+QString Driver::widgetVariableName(const QString &attributeName) const
{
- return findByAttributeName(m_widgets, name);
+ auto it = findByAttributeNameIt(m_widgets, attributeName);
+ return it != m_widgets.cend() ? it.value() : QString();
}
-const DomActionGroup *Driver::actionGroupByName(const QString &name) const
+const DomActionGroup *Driver::actionGroupByName(const QString &attributeName) const
{
- return findByAttributeName(m_actionGroups, name);
+ return findByAttributeName(m_actionGroups, attributeName);
}
-const DomAction *Driver::actionByName(const QString &name) const
+const DomAction *Driver::actionByName(const QString &attributeName) const
{
- return findByAttributeName(m_actions, name);
+ return findByAttributeName(m_actions, attributeName);
}
QT_END_NAMESPACE