From 61b4cb7ffa1fc73421c6f5f452457cbd6249db89 Mon Sep 17 00:00:00 2001
From: dt <qtc-committer@nokia.com>
Date: Fri, 24 Sep 2010 13:17:43 +0200
Subject: [PATCH] CMakeProjectManager: Add Ui completion

That is get code completion without saving the file or building.

Task-Nr: QTCREATORBUG-1657
---
 .../CMakeProjectManager.pluginspec            |   1 +
 .../cmakeprojectmanager/cmakeproject.cpp      | 180 +++++++++++++++++-
 .../cmakeprojectmanager/cmakeproject.h        |  16 ++
 .../cmakeprojectmanager.pro                   |   6 +-
 .../cmakeprojectmanager_dependencies.pri      |   1 +
 .../cmakeuicodemodelsupport.cpp               |  64 +++++++
 .../cmakeuicodemodelsupport.h                 |  61 ++++++
 .../cpptools/uicodecompletionsupport.cpp      |  12 +-
 .../cpptools/uicodecompletionsupport.h        |   3 +-
 src/plugins/plugins.pro                       |   2 +-
 .../qtuicodemodelsupport.cpp                  |   2 +-
 .../qt4projectmanager/qtuicodemodelsupport.h  |   4 +-
 12 files changed, 340 insertions(+), 12 deletions(-)
 create mode 100644 src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.cpp
 create mode 100644 src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.h

diff --git a/src/plugins/cmakeprojectmanager/CMakeProjectManager.pluginspec b/src/plugins/cmakeprojectmanager/CMakeProjectManager.pluginspec
index 14aac19a504..3259c8f3080 100644
--- a/src/plugins/cmakeprojectmanager/CMakeProjectManager.pluginspec
+++ b/src/plugins/cmakeprojectmanager/CMakeProjectManager.pluginspec
@@ -18,5 +18,6 @@ Alternatively, this plugin may be used under the terms of the GNU Lesser General
         <dependency name="ProjectExplorer" version="2.1.81"/>
         <dependency name="CppTools" version="2.1.81"/>
         <dependency name="CppEditor" version="2.1.81"/>
+        <dependency name="Designer" version="2.1.81"/>
     </dependencyList>
 </plugin>
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index 14c65d6eb34..a6c62ef9fcc 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -35,14 +35,19 @@
 #include "makestep.h"
 #include "cmakeopenprojectwizard.h"
 #include "cmakebuildconfiguration.h"
+#include "cmakeuicodemodelsupport.h"
 
 #include <projectexplorer/projectexplorerconstants.h>
+#include <projectexplorer/projectexplorer.h>
 #include <projectexplorer/buildenvironmentwidget.h>
 #include <projectexplorer/buildsteplist.h>
+#include <projectexplorer/buildmanager.h>
 #include <cpptools/cppmodelmanagerinterface.h>
 #include <extensionsystem/pluginmanager.h>
+#include <designer/formwindoweditor.h>
 #include <utils/qtcassert.h>
 #include <coreplugin/icore.h>
+#include <coreplugin/editormanager/editormanager.h>
 
 #include <QtCore/QMap>
 #include <QtCore/QDebug>
@@ -74,7 +79,8 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
       m_fileName(fileName),
       m_rootNode(new CMakeProjectNode(m_fileName)),
       m_insideFileChanged(false),
-      m_targetFactory(new CMakeTargetFactory(this))
+      m_targetFactory(new CMakeTargetFactory(this)),
+      m_lastEditor(0)
 {
     m_file = new CMakeFile(this, fileName);
 
@@ -84,6 +90,17 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
 
 CMakeProject::~CMakeProject()
 {
+    // Remove CodeModel support
+    CppTools::CppModelManagerInterface *modelManager
+            = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
+    QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it, end;
+    it = m_uiCodeModelSupport.constBegin();
+    end = m_uiCodeModelSupport.constEnd();
+    for (; it!=end; ++it) {
+        modelManager->removeEditorSupport(it.value());
+        delete it.value();
+    }
+
     m_codeModelFuture.cancel();
     delete m_rootNode;
 }
@@ -229,7 +246,24 @@ bool CMakeProject::parseCMakeLists()
 //            qDebug()<<"";
 //        }
 
+
+    // TOOD this code ain't very pretty ...
+    m_uicCommand.clear();
+    QFile cmakeCache(activeBC->buildDirectory() + "/CMakeCache.txt");
+    cmakeCache.open(QIODevice::ReadOnly);
+    while (!cmakeCache.atEnd()) {
+        QString line = cmakeCache.readLine();
+        if (line.startsWith("QT_UIC_EXECUTABLE")) {
+            if (int pos = line.indexOf('=')) {
+                m_uicCommand = line.mid(pos + 1).trimmed();
+            }
+            break;
+        }
+    }
+    cmakeCache.close();
+
     //qDebug()<<"Updating CodeModel";
+    createUiCodeModelSupport();
 
     QStringList allIncludePaths;
     QStringList allFrameworkPaths;
@@ -533,6 +567,16 @@ bool CMakeProject::fromMap(const QVariantMap &map)
         connect(t, SIGNAL(environmentChanged()),
                 this, SLOT(changeEnvironment()));
     }
+
+    connect(Core::EditorManager::instance(), SIGNAL(editorAboutToClose(Core::IEditor*)),
+            this, SLOT(editorAboutToClose(Core::IEditor*)));
+
+    connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
+            this, SLOT(editorChanged(Core::IEditor*)));
+
+    connect(ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager(), SIGNAL(buildStateChanged(ProjectExplorer::Project*)),
+            this, SLOT(buildStateChanged(ProjectExplorer::Project*)));
+
     return true;
 }
 
@@ -544,6 +588,140 @@ CMakeBuildTarget CMakeProject::buildTargetForTitle(const QString &title)
     return CMakeBuildTarget();
 }
 
+QString CMakeProject::uicCommand() const
+{
+    return m_uicCommand;
+}
+
+QString CMakeProject::uiHeaderFile(const QString &uiFile)
+{
+    QDir srcDirRoot = QDir(projectDirectory());
+    QString relativePath = srcDirRoot.relativeFilePath(uiFile);
+    QDir buildDir = QDir(activeTarget()->activeBuildConfiguration()->buildDirectory());
+    QString uiHeaderFilePath = buildDir.absoluteFilePath(relativePath);
+
+    QFileInfo fi(uiHeaderFilePath);
+    uiHeaderFilePath = fi.absolutePath();
+    uiHeaderFilePath += QLatin1String("/ui_");
+    uiHeaderFilePath += fi.completeBaseName();
+    uiHeaderFilePath += QLatin1String(".h");
+    return QDir::cleanPath(uiHeaderFilePath);
+}
+
+void CMakeProject::createUiCodeModelSupport()
+{
+//    qDebug()<<"creatUiCodeModelSupport()";
+    CppTools::CppModelManagerInterface *modelManager
+            = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
+
+    // First move all to
+    QMap<QString, CMakeUiCodeModelSupport *> oldCodeModelSupport;
+    oldCodeModelSupport = m_uiCodeModelSupport;
+    m_uiCodeModelSupport.clear();
+
+    // Find all ui files
+    foreach (const QString &uiFile, m_files) {
+        if (uiFile.endsWith(".ui")) {
+            // UI file, not convert to
+            QString uiHeaderFilePath = uiHeaderFile(uiFile);
+            QMap<QString, CMakeUiCodeModelSupport *>::iterator it
+                    = oldCodeModelSupport.find(uiFile);
+            if (it != oldCodeModelSupport.end()) {
+                //                qDebug()<<"updated old codemodelsupport";
+                CMakeUiCodeModelSupport *cms = it.value();
+                cms->setFileName(uiHeaderFilePath);
+                m_uiCodeModelSupport.insert(it.key(), cms);
+                oldCodeModelSupport.erase(it);
+            } else {
+                //                qDebug()<<"adding new codemodelsupport";
+                CMakeUiCodeModelSupport *cms = new CMakeUiCodeModelSupport(modelManager, this, uiFile, uiHeaderFilePath);
+                m_uiCodeModelSupport.insert(uiFile, cms);
+                modelManager->addEditorSupport(cms);
+            }
+        }
+    }
+
+    // Remove old
+    QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it, end;
+    end = oldCodeModelSupport.constEnd();
+    for (it = oldCodeModelSupport.constBegin(); it!=end; ++it) {
+        modelManager->removeEditorSupport(it.value());
+        delete it.value();
+    }
+}
+
+void CMakeProject::updateCodeModelSupportFromEditor(const QString &uiFileName,
+                                                    const QString &contents)
+{
+    const QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it =
+            m_uiCodeModelSupport.constFind(uiFileName);
+    if (it != m_uiCodeModelSupport.constEnd())
+        it.value()->updateFromEditor(contents);
+}
+
+void CMakeProject::editorChanged(Core::IEditor *editor)
+{
+    // Handle old editor
+    Designer::FormWindowEditor *lastFormEditor = qobject_cast<Designer::FormWindowEditor *>(m_lastEditor);
+    if (lastFormEditor) {
+        disconnect(lastFormEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged()));
+
+        if (m_dirtyUic) {
+            const QString contents = lastFormEditor->contents();
+            updateCodeModelSupportFromEditor(lastFormEditor->file()->fileName(), contents);
+            m_dirtyUic = false;
+        }
+    }
+
+    m_lastEditor = editor;
+
+    // Handle new editor
+    if (Designer::FormWindowEditor *fw = qobject_cast<Designer::FormWindowEditor *>(editor))
+        connect(fw, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged()));
+}
+
+void CMakeProject::editorAboutToClose(Core::IEditor *editor)
+{
+    if (m_lastEditor == editor) {
+        // Oh no our editor is going to be closed
+        // get the content first
+        Designer::FormWindowEditor *lastEditor = qobject_cast<Designer::FormWindowEditor *>(m_lastEditor);
+        if (lastEditor) {
+            disconnect(lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged()));
+            if (m_dirtyUic) {
+                const QString contents = lastEditor->contents();
+                updateCodeModelSupportFromEditor(lastEditor->file()->fileName(), contents);
+                m_dirtyUic = false;
+            }
+        }
+        m_lastEditor = 0;
+    }
+}
+
+void CMakeProject::uiEditorContentsChanged()
+{
+    // cast sender, get filename
+    if (m_dirtyUic)
+        return;
+    Designer::FormWindowEditor *fw = qobject_cast<Designer::FormWindowEditor *>(sender());
+    if (!fw)
+        return;
+    m_dirtyUic = true;
+}
+
+void CMakeProject::buildStateChanged(ProjectExplorer::Project *project)
+{
+    if (project == this) {
+        if (!ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager()->isBuilding(this)) {
+            QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it, end;
+            end = m_uiCodeModelSupport.constEnd();
+            for (it = m_uiCodeModelSupport.constBegin(); it != end; ++it) {
+                it.value()->updateFromBuild();
+            }
+        }
+    }
+}
+
 // CMakeFile
 
 CMakeFile::CMakeFile(CMakeProject *parent, QString fileName)
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h
index d9128daebd7..f927b699354 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.h
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.h
@@ -43,6 +43,7 @@
 #include <projectexplorer/filewatcher.h>
 #include <projectexplorer/buildconfiguration.h>
 #include <coreplugin/ifile.h>
+#include <coreplugin/editormanager/ieditor.h>
 
 #include <QtCore/QXmlStreamReader>
 #include <QtGui/QPushButton>
@@ -53,6 +54,7 @@ namespace Internal {
 
 class CMakeFile;
 class CMakeBuildSettingsWidget;
+class CMakeUiCodeModelSupport;
 
 struct CMakeBuildTarget
 {
@@ -100,6 +102,8 @@ public:
 
     bool parseCMakeLists();
 
+    QString uicCommand() const;
+
 signals:
     /// emitted after parsing
     void buildTargetsChanged();
@@ -115,15 +119,23 @@ private slots:
     void changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*);
     void targetAdded(ProjectExplorer::Target *);
 
+    void editorChanged(Core::IEditor *editor);
+    void editorAboutToClose(Core::IEditor *editor);
+    void uiEditorContentsChanged();
+    void buildStateChanged(ProjectExplorer::Project *project);
 private:
     void buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
     void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list);
     ProjectExplorer::FolderNode *findOrCreateFolder(CMakeProjectNode *rootNode, QString directory);
+    void updateCodeModelSupportFromEditor(const QString &uiFileName, const QString &contents);
+    void createUiCodeModelSupport();
+    QString uiHeaderFile(const QString &uiFile);
 
     CMakeManager *m_manager;
     QString m_fileName;
     CMakeFile *m_file;
     QString m_projectName;
+    QString m_uicCommand;
 
     // TODO probably need a CMake specific node structure
     CMakeProjectNode *m_rootNode;
@@ -134,6 +146,10 @@ private:
     QSet<QString> m_watchedFiles;
     CMakeTargetFactory *m_targetFactory;
     QFuture<void> m_codeModelFuture;
+
+    QMap<QString, CMakeUiCodeModelSupport *> m_uiCodeModelSupport;
+    Core::IEditor *m_lastEditor;
+    bool m_dirtyUic;
 };
 
 class CMakeCbpParser : public QXmlStreamReader
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
index 8a94e4a77a1..1f54025a5e9 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
@@ -14,7 +14,8 @@ HEADERS = cmakeproject.h \
     cmakebuildconfiguration.h \
     cmakeeditorfactory.h \
     cmakeeditor.h \
-    cmakehighlighter.h
+    cmakehighlighter.h \
+    cmakeuicodemodelsupport.h
 SOURCES = cmakeproject.cpp \
     cmakeprojectplugin.cpp \
     cmakeprojectmanager.cpp \
@@ -26,7 +27,8 @@ SOURCES = cmakeproject.cpp \
     cmakebuildconfiguration.cpp \
     cmakeeditorfactory.cpp \
     cmakeeditor.cpp \
-    cmakehighlighter.cpp
+    cmakehighlighter.cpp \
+    cmakeuicodemodelsupport.cpp
 RESOURCES += cmakeproject.qrc
 FORMS +=
 
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager_dependencies.pri b/src/plugins/cmakeprojectmanager/cmakeprojectmanager_dependencies.pri
index 80118ad122e..ec3ff820cac 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager_dependencies.pri
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager_dependencies.pri
@@ -2,3 +2,4 @@ include(../../plugins/projectexplorer/projectexplorer.pri)
 include(../../plugins/cpptools/cpptools.pri)
 include(../../plugins/cppeditor/cppeditor.pri)
 include(../../plugins/texteditor/texteditor.pri)
+include(../../plugins/designer/designer.pri)
diff --git a/src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.cpp b/src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.cpp
new file mode 100644
index 00000000000..e6736f54ceb
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.cpp
@@ -0,0 +1,64 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#include "cmakeuicodemodelsupport.h"
+#include "cmakeproject.h"
+#include "cmaketarget.h"
+#include "cmakebuildconfiguration.h"
+
+#include <QtCore/QProcess>
+
+using namespace CMakeProjectManager;
+using namespace Internal;
+
+CMakeUiCodeModelSupport::CMakeUiCodeModelSupport(CppTools::CppModelManagerInterface *modelmanager,
+                                             CMakeProject *project,
+                                             const QString &source,
+                                             const QString &uiHeaderFile)
+    : CppTools::UiCodeModelSupport(modelmanager, source, uiHeaderFile),
+      m_project(project)
+{
+
+}
+
+CMakeUiCodeModelSupport::~CMakeUiCodeModelSupport()
+{
+
+}
+
+QString CMakeUiCodeModelSupport::uicCommand() const
+{
+    return m_project->uicCommand();
+}
+
+QStringList CMakeUiCodeModelSupport::environment() const
+{
+    CMakeBuildConfiguration *bc = m_project->activeTarget()->activeBuildConfiguration();
+    return bc->environment().toStringList();
+}
diff --git a/src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.h b/src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.h
new file mode 100644
index 00000000000..dc297d39b7b
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.h
@@ -0,0 +1,61 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#ifndef CMAKEUICODEMODELSUPPORT_H
+#define CMAKEUICODEMODELSUPPORT_H
+
+#include <cpptools/cppmodelmanagerinterface.h>
+#include <cpptools/uicodecompletionsupport.h>
+
+#include <QtCore/QDateTime>
+
+namespace CMakeProjectManager {
+namespace Internal {
+
+class CMakeProject;
+
+class CMakeUiCodeModelSupport : public CppTools::UiCodeModelSupport
+{
+public:
+    CMakeUiCodeModelSupport(CppTools::CppModelManagerInterface *modelmanager,
+                          CMakeProject *project,
+                          const QString &sourceFile,
+                          const QString &uiHeaderFile);
+    ~CMakeUiCodeModelSupport();
+protected:
+    virtual QString uicCommand() const;
+    virtual QStringList environment() const;
+private:
+    CMakeProject *m_project;
+};
+
+
+} // Internal
+} // Qt4ProjectManager
+#endif // CMAKEUICODEMODELSUPPORT_H
diff --git a/src/plugins/cpptools/uicodecompletionsupport.cpp b/src/plugins/cpptools/uicodecompletionsupport.cpp
index 36af62f4a31..dc226b09a38 100644
--- a/src/plugins/cpptools/uicodecompletionsupport.cpp
+++ b/src/plugins/cpptools/uicodecompletionsupport.cpp
@@ -40,11 +40,11 @@ UiCodeModelSupport::UiCodeModelSupport(CppTools::CppModelManagerInterface *model
     : CppTools::AbstractEditorSupport(modelmanager),
       m_sourceName(source),
       m_fileName(uiHeaderFile),
-      m_updateIncludingFiles(false)
+      m_updateIncludingFiles(false),
+      m_initialized(false)
 {
     if (debug)
         qDebug()<<"ctor UiCodeModelSupport for"<<m_sourceName<<uiHeaderFile;
-    init();
 }
 
 UiCodeModelSupport::~UiCodeModelSupport()
@@ -53,8 +53,9 @@ UiCodeModelSupport::~UiCodeModelSupport()
         qDebug()<<"dtor ~UiCodeModelSupport for"<<m_sourceName;
 }
 
-void UiCodeModelSupport::init()
+void UiCodeModelSupport::init() const
 {
+    m_initialized = true;
     QDateTime sourceTime = QFileInfo(m_sourceName).lastModified();
     QFileInfo uiHeaderFileInfo(m_fileName);
     QDateTime uiHeaderTime = uiHeaderFileInfo.exists() ? uiHeaderFileInfo.lastModified() : QDateTime();
@@ -84,7 +85,7 @@ void UiCodeModelSupport::init()
             // uic run was unsuccesfull
             if (debug)
                 qDebug()<<"uic run wasn't succesfull";
-            m_cacheTime = QDateTime();
+            m_cacheTime = QDateTime ();
             m_contents = QByteArray();
             // and if the header file wasn't there, next time we need to update
             // all of the files that include this header
@@ -101,6 +102,9 @@ void UiCodeModelSupport::init()
 
 QByteArray UiCodeModelSupport::contents() const
 {
+    if (!m_initialized)
+        init();
+
     return m_contents;
 }
 
diff --git a/src/plugins/cpptools/uicodecompletionsupport.h b/src/plugins/cpptools/uicodecompletionsupport.h
index a274b540da0..b03294960d6 100644
--- a/src/plugins/cpptools/uicodecompletionsupport.h
+++ b/src/plugins/cpptools/uicodecompletionsupport.h
@@ -55,11 +55,12 @@ protected:
     virtual QString uicCommand() const = 0;
     virtual QStringList environment() const = 0;
 private:
-    void init();
+    void init() const;
     bool runUic(const QString &ui) const;
     QString m_sourceName;
     QString m_fileName;
     mutable bool m_updateIncludingFiles;
+    mutable bool m_initialized;
     mutable QByteArray m_contents;
     mutable QDateTime m_cacheTime;
 };
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 5ab95441864..d8582794727 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -120,7 +120,6 @@ plugin_projectexplorer.depends = plugin_locator
 plugin_projectexplorer.depends += plugin_find
 plugin_projectexplorer.depends += plugin_coreplugin
 plugin_projectexplorer.depends += plugin_texteditor
-plugin_projectexplorer.depends += plugin_cpptools
 
 plugin_qt4projectmanager.subdir = qt4projectmanager
 plugin_qt4projectmanager.depends = plugin_texteditor
@@ -187,6 +186,7 @@ plugin_cmakeprojectmanager.depends = plugin_texteditor
 plugin_cmakeprojectmanager.depends += plugin_projectexplorer
 plugin_cmakeprojectmanager.depends += plugin_cpptools
 plugin_cmakeprojectmanager.depends += plugin_cppeditor
+plugin_cmakeprojectmanager.depends += plugin_designer
 
 plugin_genericprojectmanager.subdir = genericprojectmanager
 plugin_genericprojectmanager.depends = plugin_texteditor
diff --git a/src/plugins/qt4projectmanager/qtuicodemodelsupport.cpp b/src/plugins/qt4projectmanager/qtuicodemodelsupport.cpp
index 31907c3e02d..d9640b28c13 100644
--- a/src/plugins/qt4projectmanager/qtuicodemodelsupport.cpp
+++ b/src/plugins/qt4projectmanager/qtuicodemodelsupport.cpp
@@ -44,7 +44,7 @@ Qt4UiCodeModelSupport::Qt4UiCodeModelSupport(CppTools::CppModelManagerInterface
                                              Qt4Project *project,
                                              const QString &source,
                                              const QString &uiHeaderFile)
-    : UiCodeModelSupport(modelmanager, source, uiHeaderFile),
+    : CppTools::UiCodeModelSupport(modelmanager, source, uiHeaderFile),
       m_project(project)
 {
 
diff --git a/src/plugins/qt4projectmanager/qtuicodemodelsupport.h b/src/plugins/qt4projectmanager/qtuicodemodelsupport.h
index ed36d9787f3..b938009739d 100644
--- a/src/plugins/qt4projectmanager/qtuicodemodelsupport.h
+++ b/src/plugins/qt4projectmanager/qtuicodemodelsupport.h
@@ -31,7 +31,7 @@
 #define QTUICODEMODELSUPPORT_H
 
 #include <cpptools/cppmodelmanagerinterface.h>
-#include <projectexplorer/uicodecompletionsupport.h>
+#include <cpptools/uicodecompletionsupport.h>
 
 #include <QtCore/QDateTime>
 
@@ -39,7 +39,7 @@ namespace Qt4ProjectManager {
 class Qt4Project;
 namespace Internal {
 
-class Qt4UiCodeModelSupport : public ProjectExplorer::UiCodeModelSupport
+class Qt4UiCodeModelSupport : public CppTools::UiCodeModelSupport
 {
 public:
     Qt4UiCodeModelSupport(CppTools::CppModelManagerInterface *modelmanager,
-- 
GitLab