uic/Python: Import base class for flag values
Extend the logic extracting enum base classes to flags
to handle things like QAbstractItemView::EditTriggers.
Exclude the Qt namespace.
Amends de15836dbf
.
Fixes: PYSIDE-1773
Task-number: PYSIDE-1404
Pick-to: 6.2 6.2.3 6.3
Change-Id: Ib0cd0836a91f330e5bc3307690062a965abec7eb
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
This commit is contained in:
parent
7719fcea4b
commit
e376c229e9
@ -233,16 +233,31 @@ void WriteImports::addPythonCustomWidget(const QString &className, const DomCust
|
||||
|
||||
void WriteImports::acceptProperty(DomProperty *node)
|
||||
{
|
||||
if (node->kind() == DomProperty::Enum) {
|
||||
// Add base classes like QFrame for QLabel::frameShape()
|
||||
const QString &enumV = node->elementEnum();
|
||||
const auto colonPos = enumV.indexOf(u"::");
|
||||
if (colonPos > 0)
|
||||
addQtClass(enumV.left(colonPos));
|
||||
switch (node->kind()) {
|
||||
case DomProperty::Enum:
|
||||
addEnumBaseClass(node->elementEnum());
|
||||
break;
|
||||
case DomProperty::Set:
|
||||
addEnumBaseClass(node->elementSet());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WriteIncludesBase::acceptProperty(node);
|
||||
}
|
||||
|
||||
void WriteImports::addEnumBaseClass(const QString &v)
|
||||
{
|
||||
// Add base classes like QFrame for QLabel::frameShape()
|
||||
const auto colonPos = v.indexOf(u"::");
|
||||
if (colonPos > 0) {
|
||||
const QString base = v.left(colonPos);
|
||||
if (base.startsWith(u'Q') && base != u"Qt")
|
||||
addQtClass(base);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Python
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -55,6 +55,7 @@ protected:
|
||||
private:
|
||||
void addPythonCustomWidget(const QString &className, const DomCustomWidget *dcw);
|
||||
bool addQtClass(const QString &className);
|
||||
void addEnumBaseClass(const QString &v);
|
||||
void writeImport(const QString &module);
|
||||
|
||||
QHash<QString, QString> m_classToModule;
|
||||
|
Loading…
Reference in New Issue
Block a user