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
|
// Build name of the class as generated by uic, insert Ui namespace
|
||||||
// "foo::bar::form" -> "foo::bar::Ui::form"
|
// "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 indexOfScope = formObjectName.lastIndexOf("::");
|
||||||
const int uiNameSpaceInsertionPos = indexOfScope >= 0 ? indexOfScope + 2 : 0;
|
const int uiNameSpaceInsertionPos = indexOfScope >= 0 ? indexOfScope + 2 : 0;
|
||||||
|
QString alt = formObjectName;
|
||||||
formObjectName.insert(uiNameSpaceInsertionPos, "Ui::");
|
formObjectName.insert(uiNameSpaceInsertionPos, "Ui::");
|
||||||
return formObjectName;
|
alt.insert(uiNameSpaceInsertionPos, "Ui_");
|
||||||
|
return {formObjectName, alt};
|
||||||
}
|
}
|
||||||
|
|
||||||
static Document::Ptr getParsedDocument(const QString &fileName,
|
static Document::Ptr getParsedDocument(const QString &fileName,
|
||||||
@@ -485,28 +487,34 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
|
|||||||
|
|
||||||
QDesignerFormWindowInterface *fwi = FormEditorW::activeWidgetHost()->formWindow();
|
QDesignerFormWindowInterface *fwi = FormEditorW::activeWidgetHost()->formWindow();
|
||||||
|
|
||||||
const QString uiClass = uiClassName(fwi->mainContainer()->objectName());
|
QString uiClass;
|
||||||
|
|
||||||
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).
|
|
||||||
const Class *cl = nullptr;
|
const Class *cl = nullptr;
|
||||||
Document::Ptr declDoc;
|
Document::Ptr declDoc;
|
||||||
for (const Document::Ptr &d : qAsConst(docMap)) {
|
for (const QString &candidate : uiClassNames(fwi->mainContainer()->objectName())) {
|
||||||
LookupContext context(d, docTable);
|
if (Designer::Constants::Internal::debug)
|
||||||
const ClassDocumentPtrPair cd = findClassRecursively(context, uiClass, 1u);
|
qDebug() << "Checking docs for " << candidate;
|
||||||
if (cd.first) {
|
|
||||||
cl = cd.first;
|
// Find the class definition (ui class defined as member or base class)
|
||||||
declDoc = cd.second;
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (errorMessage->isEmpty())
|
||||||
|
*errorMessage = msgClassNotFound(candidate, docList);
|
||||||
}
|
}
|
||||||
if (!cl) {
|
if (!cl)
|
||||||
*errorMessage = msgClassNotFound(uiClass, docList);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
const QString functionName = "on_" + objectName + '_' + signalSignature;
|
const QString functionName = "on_" + objectName + '_' + signalSignature;
|
||||||
const QString functionNameWithParameterNames = addParameterNames(functionName, parameterNames);
|
const QString functionNameWithParameterNames = addParameterNames(functionName, parameterNames);
|
||||||
|
Reference in New Issue
Block a user