diff --git a/share/qtcreator/templates/qt4project/widget.ui b/share/qtcreator/templates/qt4project/widget.ui index 6c78aeebc497dbdc6024b0a041a7c421a327163a..91d5fa37d593d3a9e19f7b674ecf38833e637cb5 100644 --- a/share/qtcreator/templates/qt4project/widget.ui +++ b/share/qtcreator/templates/qt4project/widget.ui @@ -1,9 +1,6 @@ -<ui version="4.0" stdsetdef="1" > +<ui version="4.0"> <class>%CLASS%Class</class> <widget class="%BASECLASS%" name="%CLASS%Class" > - <property name="objectName" > - <cstring>%CLASS%Class</cstring> - </property> <property name="geometry" > <rect> <x>0</x> diff --git a/src/plugins/designer/formtemplatewizardpage.cpp b/src/plugins/designer/formtemplatewizardpage.cpp index 55729095391566fb6a66edbea5b07cd871920a92..6bb4dc1244f9af4ef41a56c52373842a9d55a2c1 100644 --- a/src/plugins/designer/formtemplatewizardpage.cpp +++ b/src/plugins/designer/formtemplatewizardpage.cpp @@ -29,6 +29,7 @@ #include "formtemplatewizardpage.h" #include "formeditorw.h" +#include "designerconstants.h" #include <qt_private/abstractnewformwidget_p.h> @@ -278,6 +279,8 @@ namespace { QString FormTemplateWizardPage::changeUiClassName(const QString &uiXml, const QString &newUiClassName) { + if (Designer::Constants::Internal::debug) + qDebug() << '>' << Q_FUNC_INFO << newUiClassName; QDomDocument domUi; if (!domUi.setContent(uiXml)) { qWarning("Failed to parse:\n%s", uiXml.toUtf8().constData()); @@ -320,6 +323,8 @@ QString FormTemplateWizardPage::changeUiClassName(const QString &uiXml, const QS } } const QString rc = domUi.toString(); + if (Designer::Constants::Internal::debug > 1) + qDebug() << '<' << Q_FUNC_INFO << newUiClassName << rc; return rc; } #endif // USE_XSLT diff --git a/src/plugins/designer/settingsmanager.cpp b/src/plugins/designer/settingsmanager.cpp index 588a69214881754861f2d4524058bd44b5459185..2eeaf1a1db8b3b2009acbca53162eb4972d44088 100644 --- a/src/plugins/designer/settingsmanager.cpp +++ b/src/plugins/designer/settingsmanager.cpp @@ -36,14 +36,14 @@ using namespace Designer::Internal; void SettingsManager::beginGroup(const QString &prefix) { - if (Designer::Constants::Internal::debug) + if (Designer::Constants::Internal::debug > 1) qDebug() << Q_FUNC_INFO << addPrefix(prefix); m_settings.beginGroup(addPrefix(prefix)); } void SettingsManager::endGroup() { - if (Designer::Constants::Internal::debug) + if (Designer::Constants::Internal::debug > 1) qDebug() << Q_FUNC_INFO; m_settings.endGroup(); } @@ -55,7 +55,7 @@ bool SettingsManager::contains(const QString &key) const void SettingsManager::setValue(const QString &key, const QVariant &value) { - if (Designer::Constants::Internal::debug) + if (Designer::Constants::Internal::debug > 1) qDebug() << Q_FUNC_INFO << addPrefix(key) << ": " << value; m_settings.setValue(addPrefix(key), value); } @@ -63,7 +63,7 @@ void SettingsManager::setValue(const QString &key, const QVariant &value) QVariant SettingsManager::value(const QString &key, const QVariant &defaultValue) const { QVariant result = m_settings.value(addPrefix(key), defaultValue); - if (Designer::Constants::Internal::debug) + if (Designer::Constants::Internal::debug > 1) qDebug() << Q_FUNC_INFO << addPrefix(key) << ": " << result; return result; } diff --git a/src/plugins/designer/workbenchintegration.cpp b/src/plugins/designer/workbenchintegration.cpp index 3f85d0117c41a550e8d2d063349d10ce0d9e5510..4e264e7a7193cad8b6e9b3add8d9cfabf9c2ae6c 100644 --- a/src/plugins/designer/workbenchintegration.cpp +++ b/src/plugins/designer/workbenchintegration.cpp @@ -125,6 +125,16 @@ static QList<Document::Ptr> findDocumentsIncluding(const CPlusPlus::Snapshot &do return docList; } +// Does klass inherit baseClass? +static bool inherits(const Overview &o, const Class *klass, const QString &baseClass) +{ + const int baseClassCount = klass->baseClassCount(); + for (int b = 0; b < baseClassCount; b++) + if (o.prettyName(klass->baseClassAt(b)->name()) == baseClass) + return true; + return false; +} + // Check for a class name where haystack is a member class of an object. // So, haystack can be shorter (can have some namespaces omitted because of a // "using namespace" declaration, for example, comparing @@ -141,7 +151,9 @@ static bool matchMemberClassName(const QString &needle, const QString &hayStack) return separatorPos > 1 && needle.at(separatorPos) == QLatin1Char(':'); } -// Find class definition in namespace +// Find class definition in namespace (that is, the outer class +// containing a member of the desired class type) or inheriting the desired class +// in case of forms using the Multiple Inheritance approach static const Class *findClass(const Namespace *parentNameSpace, const QString &className, QString *namespaceName) { if (Designer::Constants::Internal::debug) @@ -153,8 +165,9 @@ static const Class *findClass(const Namespace *parentNameSpace, const QString &c const Symbol *sym = parentNameSpace->memberAt(i); // we have found a class - we are interested in classes only if (const Class *cl = sym->asClass()) { + // 1) we go through class members const unsigned classMemberCount = cl->memberCount(); - for (unsigned j = 0; j < classMemberCount; j++) // we go through class members + for (unsigned j = 0; j < classMemberCount; j++) if (const Declaration *decl = cl->memberAt(j)->asDeclaration()) { // we want to know if the class contains a member (so we look into // a declaration) of uiClassName type @@ -166,6 +179,9 @@ static const Class *findClass(const Namespace *parentNameSpace, const QString &c if (nt && matchMemberClassName(className, o.prettyName(nt->name()))) return cl; } // decl + // 2) does it inherit the desired class + if (inherits(o, cl, className)) + return cl; } else { // Check namespaces if (const Namespace *ns = sym->asNamespace()) { @@ -386,8 +402,15 @@ static void addDeclaration(const QString &docFileName, const Class *cl, const QS // fun->column() returns always 0, what can cause trouble in case in one // line if there is: "private slots: void foo();" if (fun->isSlot() && fun->isPrivate()) { - if (ITextEditable *editable = editableAt(docFileName, fun->line(), fun->column())) - editable->insert(declaration + QLatin1String(" ")); + const int line = fun->line(); // [1..n] + const int column = fun->column(); + if (ITextEditable *editable = editableAt(docFileName, line, column)) { + // Figure out indentation (symbol - len("void ")) and insert after + editable->gotoLine(line + 1, 1); + editable->position(ITextEditor::StartOfLine); + const QString indentation = QString(qMax(0, column - 6), QLatin1Char(' ')); + editable->insert(indentation + declaration); + } return; } } @@ -483,7 +506,7 @@ static ClassDocumentPtrPair unsigned maxIncludeDepth, QString *namespaceName) { if (Designer::Constants::Internal::debug) - qDebug() << Q_FUNC_INFO << doc->fileName() << maxIncludeDepth; + qDebug() << Q_FUNC_INFO << doc->fileName() << className << maxIncludeDepth; // Check document if (const Class *cl = findClass(doc->globalNamespace(), className, namespaceName)) return ClassDocumentPtrPair(cl, doc); @@ -523,6 +546,9 @@ static inline QString uiClassName(QString formObjectName) return formObjectName; } +// Goto slot invoked by the designer context menu. Either navigates +// to an existing slot function or create a new one. + bool WorkbenchIntegration::navigateToSlot(const QString &objectName, const QString &signalSignature, const QStringList ¶meterNames, @@ -538,7 +564,7 @@ bool WorkbenchIntegration::navigateToSlot(const QString &objectName, const QFileInfo fi(currentUiFile); const QString uicedName = QLatin1String("ui_") + fi.baseName() + QLatin1String(".h"); - // take all docs + // take all docs, find the ones that include the ui_xx.h. const CPlusPlus::Snapshot docTable = cppModelManagerInstance()->snapshot(); QList<Document::Ptr> docList = findDocumentsIncluding(docTable, uicedName, true); // change to false when we know the absolute path to generated ui_<>.h file @@ -546,7 +572,7 @@ bool WorkbenchIntegration::navigateToSlot(const QString &objectName, if (Designer::Constants::Internal::debug) qDebug() << Q_FUNC_INFO << objectName << signalSignature << "Looking for " << uicedName << " returned " << docList.size(); if (docList.isEmpty()) { - *errorMessage = tr("No documents matching %1 could be found.").arg(uicedName); + *errorMessage = tr("No documents matching '%1' could be found.\nRebuilding the project might help.").arg(uicedName); return false; } @@ -557,8 +583,8 @@ bool WorkbenchIntegration::navigateToSlot(const QString &objectName, if (Designer::Constants::Internal::debug) qDebug() << "Checking docs for " << uiClass; - // Find the class definition in the file itself or in the directly - // included files (order 1). + // 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 namespaceName; const Class *cl = 0; Document::Ptr doc; @@ -578,6 +604,8 @@ bool WorkbenchIntegration::navigateToSlot(const QString &objectName, Overview o; const QString className = namespaceName + o.prettyName(cl->name()); + if (Designer::Constants::Internal::debug) + qDebug() << "Found class " << className << doc->fileName(); const QString functionName = QLatin1String("on_") + objectName + QLatin1Char('_') + signalSignature; const QString functionNameWithParameterNames = addParameterNames(functionName, parameterNames); diff --git a/src/plugins/projectexplorer/projectwindow.h b/src/plugins/projectexplorer/projectwindow.h index 18d19f749c9f5295da5bc984eaa8722a879a8d8b..a868067bd71b7a7d86fa8adde60f196df9af28e0 100644 --- a/src/plugins/projectexplorer/projectwindow.h +++ b/src/plugins/projectexplorer/projectwindow.h @@ -61,8 +61,6 @@ private slots: void restoreStatus(); void saveStatus(); - void updateTreeWidget(); - void updateTreeWidgetStatupProjectChanged(ProjectExplorer::Project *startupProject); void updateTreeWidgetProjectAdded(ProjectExplorer::Project *addedProject); void updateTreeWidgetProjectRemoved(ProjectExplorer::Project *removedProject); diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index b0fec5a6847269e5bd024d24796b337785eeffcc..10f1a0328e748d9733d8f29811d01bd660494ed6 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -334,8 +334,9 @@ void TaskWindow::showTaskInFile(const QModelIndex &index) if (file.isEmpty() || line == -1) return; - if (QFileInfo(file).exists()) { - TextEditor::BaseTextEditor::openEditorAt(file, line); + QFileInfo fi(file); + if (fi.exists()) { + TextEditor::BaseTextEditor::openEditorAt(fi.canonicalFilePath(), line); Core::EditorManager::instance()->ensureEditorManagerVisible(); } else