forked from qt-creator/qt-creator
Fixes: Put the Ui:: class in the same namespace as the form class (was broken for namespaces)
This commit is contained in:
@@ -62,8 +62,15 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build the ui class (Ui::Foo) name relative to the namespace (which is the same):
|
||||||
|
const QString colonColon = QLatin1String("::");
|
||||||
|
const int lastSeparator = uiClassName.lastIndexOf(colonColon);
|
||||||
|
if (lastSeparator != -1)
|
||||||
|
uiClassName.remove(0, lastSeparator + colonColon.size());
|
||||||
|
uiClassName.insert(0, QLatin1String(uiNamespaceC) + colonColon);
|
||||||
|
|
||||||
// Do we have namespaces?
|
// Do we have namespaces?
|
||||||
QStringList namespaceList = className.split(QLatin1String("::"));
|
QStringList namespaceList = className.split(colonColon);
|
||||||
if (namespaceList.empty()) // Paranoia!
|
if (namespaceList.empty()) // Paranoia!
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -94,18 +101,21 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString namespaceIndent = Core::Utils::writeOpeningNameSpaces(namespaceList, indent, headerStr);
|
||||||
|
|
||||||
// Forward-declare the UI class
|
// Forward-declare the UI class
|
||||||
if (embedding == PointerAggregatedUiClass) {
|
if (embedding == PointerAggregatedUiClass) {
|
||||||
headerStr << "\nnamespace " << uiNamespaceC << " {\n"
|
headerStr << '\n'
|
||||||
<< indent << "class " << uiClassName << ";\n}\n";
|
<< namespaceIndent << "namespace " << uiNamespaceC << " {\n"
|
||||||
|
<< namespaceIndent << indent << "class " << FormTemplateWizardPagePage::stripNamespaces(uiClassName) << ";\n"
|
||||||
|
<< namespaceIndent << "}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString namespaceIndent = Core::Utils::writeOpeningNameSpaces(namespaceList, indent, headerStr);
|
|
||||||
// Class declaration
|
// Class declaration
|
||||||
headerStr << '\n' << namespaceIndent << "class " << unqualifiedClassName
|
headerStr << '\n' << namespaceIndent << "class " << unqualifiedClassName
|
||||||
<< " : public " << formBaseClass;
|
<< " : public " << formBaseClass;
|
||||||
if (embedding == InheritedUiClass) {
|
if (embedding == InheritedUiClass) {
|
||||||
headerStr << ", private " << uiNamespaceC << "::" << uiClassName;
|
headerStr << ", private " << uiClassName;
|
||||||
}
|
}
|
||||||
headerStr << " {\n" << namespaceIndent << indent << "Q_OBJECT\n"
|
headerStr << " {\n" << namespaceIndent << indent << "Q_OBJECT\n"
|
||||||
<< namespaceIndent << indent << "Q_DISABLE_COPY(" << unqualifiedClassName << ")\n"
|
<< namespaceIndent << indent << "Q_DISABLE_COPY(" << unqualifiedClassName << ")\n"
|
||||||
@@ -120,7 +130,7 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
|
|||||||
// Member variable
|
// Member variable
|
||||||
if (embedding != InheritedUiClass) {
|
if (embedding != InheritedUiClass) {
|
||||||
headerStr << '\n' << namespaceIndent << "private:\n"
|
headerStr << '\n' << namespaceIndent << "private:\n"
|
||||||
<< namespaceIndent << indent << uiNamespaceC << "::" << uiClassName << ' ';
|
<< namespaceIndent << indent << uiClassName << ' ';
|
||||||
if (embedding == PointerAggregatedUiClass)
|
if (embedding == PointerAggregatedUiClass)
|
||||||
headerStr << '*';
|
headerStr << '*';
|
||||||
headerStr << uiMemberC << ";\n";
|
headerStr << uiMemberC << ";\n";
|
||||||
@@ -140,7 +150,7 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
|
|||||||
sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::" << unqualifiedClassName << "(QWidget *parent) :\n"
|
sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::" << unqualifiedClassName << "(QWidget *parent) :\n"
|
||||||
<< namespaceIndent << indent << formBaseClass << "(parent)";
|
<< namespaceIndent << indent << formBaseClass << "(parent)";
|
||||||
if (embedding == PointerAggregatedUiClass)
|
if (embedding == PointerAggregatedUiClass)
|
||||||
sourceStr << ",\n" << namespaceIndent << indent << uiMemberC << "(new " << uiNamespaceC << "::" << uiClassName << ")\n";
|
sourceStr << ",\n" << namespaceIndent << indent << uiMemberC << "(new " << uiClassName << ")\n";
|
||||||
sourceStr << namespaceIndent << "{\n" << namespaceIndent << indent;
|
sourceStr << namespaceIndent << "{\n" << namespaceIndent << indent;
|
||||||
if (embedding != InheritedUiClass)
|
if (embedding != InheritedUiClass)
|
||||||
sourceStr << uiMemberC << (embedding == PointerAggregatedUiClass ? "->" : ".");
|
sourceStr << uiMemberC << (embedding == PointerAggregatedUiClass ? "->" : ".");
|
||||||
|
|||||||
Reference in New Issue
Block a user