forked from qt-creator/qt-creator
Designer: Consider alternative class name
... in "Go to Slot". The class can be referred to as Ui::<class> or UI_<class>. Fixes: QTCREATORBUG-26013 Change-Id: Ib539855b0360ce5fe06fb3cac664af3967695206 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -392,12 +392,14 @@ void QtCreatorIntegration::slotNavigateToSlot(const QString &objectName, const Q
|
||||
// Build name of the class as generated by uic, insert Ui namespace
|
||||
// "foo::bar::form" -> "foo::bar::Ui::form"
|
||||
|
||||
static inline QString uiClassName(QString formObjectName)
|
||||
static inline const QStringList uiClassNames(QString formObjectName)
|
||||
{
|
||||
const int indexOfScope = formObjectName.lastIndexOf("::");
|
||||
const int uiNameSpaceInsertionPos = indexOfScope >= 0 ? indexOfScope + 2 : 0;
|
||||
QString alt = formObjectName;
|
||||
formObjectName.insert(uiNameSpaceInsertionPos, "Ui::");
|
||||
return formObjectName;
|
||||
alt.insert(uiNameSpaceInsertionPos, "Ui_");
|
||||
return {formObjectName, alt};
|
||||
}
|
||||
|
||||
static Document::Ptr getParsedDocument(const QString &fileName,
|
||||
@@ -485,28 +487,34 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
|
||||
|
||||
QDesignerFormWindowInterface *fwi = FormEditorW::activeWidgetHost()->formWindow();
|
||||
|
||||
const QString uiClass = uiClassName(fwi->mainContainer()->objectName());
|
||||
|
||||
if (Designer::Constants::Internal::debug)
|
||||
qDebug() << "Checking docs for " << uiClass;
|
||||
|
||||
// Find the class definition (ui class defined as member or base class)
|
||||
// in the file itself or in the directly included files (order 1).
|
||||
QString uiClass;
|
||||
const Class *cl = nullptr;
|
||||
Document::Ptr declDoc;
|
||||
for (const Document::Ptr &d : qAsConst(docMap)) {
|
||||
LookupContext context(d, docTable);
|
||||
const ClassDocumentPtrPair cd = findClassRecursively(context, uiClass, 1u);
|
||||
if (cd.first) {
|
||||
cl = cd.first;
|
||||
declDoc = cd.second;
|
||||
for (const QString &candidate : uiClassNames(fwi->mainContainer()->objectName())) {
|
||||
if (Designer::Constants::Internal::debug)
|
||||
qDebug() << "Checking docs for " << candidate;
|
||||
|
||||
// Find the class definition (ui class defined as member or base class)
|
||||
// in the file itself or in the directly included files (order 1).
|
||||
for (const Document::Ptr &d : qAsConst(docMap)) {
|
||||
LookupContext context(d, docTable);
|
||||
const ClassDocumentPtrPair cd = findClassRecursively(context, candidate, 1u);
|
||||
if (cd.first) {
|
||||
cl = cd.first;
|
||||
declDoc = cd.second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cl) {
|
||||
uiClass = candidate;
|
||||
break;
|
||||
}
|
||||
|
||||
if (errorMessage->isEmpty())
|
||||
*errorMessage = msgClassNotFound(candidate, docList);
|
||||
}
|
||||
if (!cl) {
|
||||
*errorMessage = msgClassNotFound(uiClass, docList);
|
||||
if (!cl)
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString functionName = "on_" + objectName + '_' + signalSignature;
|
||||
const QString functionNameWithParameterNames = addParameterNames(functionName, parameterNames);
|
||||
|
Reference in New Issue
Block a user