forked from qt-creator/qt-creator
CMakeProjectManager: Add Ui completion
That is get code completion without saving the file or building. Task-Nr: QTCREATORBUG-1657
This commit is contained in:
@@ -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="ProjectExplorer" version="2.1.81"/>
|
||||||
<dependency name="CppTools" version="2.1.81"/>
|
<dependency name="CppTools" version="2.1.81"/>
|
||||||
<dependency name="CppEditor" version="2.1.81"/>
|
<dependency name="CppEditor" version="2.1.81"/>
|
||||||
|
<dependency name="Designer" version="2.1.81"/>
|
||||||
</dependencyList>
|
</dependencyList>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
@@ -35,14 +35,19 @@
|
|||||||
#include "makestep.h"
|
#include "makestep.h"
|
||||||
#include "cmakeopenprojectwizard.h"
|
#include "cmakeopenprojectwizard.h"
|
||||||
#include "cmakebuildconfiguration.h"
|
#include "cmakebuildconfiguration.h"
|
||||||
|
#include "cmakeuicodemodelsupport.h"
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/buildenvironmentwidget.h>
|
#include <projectexplorer/buildenvironmentwidget.h>
|
||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
|
#include <projectexplorer/buildmanager.h>
|
||||||
#include <cpptools/cppmodelmanagerinterface.h>
|
#include <cpptools/cppmodelmanagerinterface.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
#include <designer/formwindoweditor.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
|
||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
@@ -74,7 +79,8 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
|
|||||||
m_fileName(fileName),
|
m_fileName(fileName),
|
||||||
m_rootNode(new CMakeProjectNode(m_fileName)),
|
m_rootNode(new CMakeProjectNode(m_fileName)),
|
||||||
m_insideFileChanged(false),
|
m_insideFileChanged(false),
|
||||||
m_targetFactory(new CMakeTargetFactory(this))
|
m_targetFactory(new CMakeTargetFactory(this)),
|
||||||
|
m_lastEditor(0)
|
||||||
{
|
{
|
||||||
m_file = new CMakeFile(this, fileName);
|
m_file = new CMakeFile(this, fileName);
|
||||||
|
|
||||||
@@ -84,6 +90,17 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
|
|||||||
|
|
||||||
CMakeProject::~CMakeProject()
|
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();
|
m_codeModelFuture.cancel();
|
||||||
delete m_rootNode;
|
delete m_rootNode;
|
||||||
}
|
}
|
||||||
@@ -229,7 +246,24 @@ bool CMakeProject::parseCMakeLists()
|
|||||||
// qDebug()<<"";
|
// 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";
|
//qDebug()<<"Updating CodeModel";
|
||||||
|
createUiCodeModelSupport();
|
||||||
|
|
||||||
QStringList allIncludePaths;
|
QStringList allIncludePaths;
|
||||||
QStringList allFrameworkPaths;
|
QStringList allFrameworkPaths;
|
||||||
@@ -533,6 +567,16 @@ bool CMakeProject::fromMap(const QVariantMap &map)
|
|||||||
connect(t, SIGNAL(environmentChanged()),
|
connect(t, SIGNAL(environmentChanged()),
|
||||||
this, SLOT(changeEnvironment()));
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,6 +588,140 @@ CMakeBuildTarget CMakeProject::buildTargetForTitle(const QString &title)
|
|||||||
return CMakeBuildTarget();
|
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::CMakeFile(CMakeProject *parent, QString fileName)
|
CMakeFile::CMakeFile(CMakeProject *parent, QString fileName)
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include <projectexplorer/filewatcher.h>
|
#include <projectexplorer/filewatcher.h>
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <coreplugin/ifile.h>
|
#include <coreplugin/ifile.h>
|
||||||
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
|
|
||||||
#include <QtCore/QXmlStreamReader>
|
#include <QtCore/QXmlStreamReader>
|
||||||
#include <QtGui/QPushButton>
|
#include <QtGui/QPushButton>
|
||||||
@@ -53,6 +54,7 @@ namespace Internal {
|
|||||||
|
|
||||||
class CMakeFile;
|
class CMakeFile;
|
||||||
class CMakeBuildSettingsWidget;
|
class CMakeBuildSettingsWidget;
|
||||||
|
class CMakeUiCodeModelSupport;
|
||||||
|
|
||||||
struct CMakeBuildTarget
|
struct CMakeBuildTarget
|
||||||
{
|
{
|
||||||
@@ -100,6 +102,8 @@ public:
|
|||||||
|
|
||||||
bool parseCMakeLists();
|
bool parseCMakeLists();
|
||||||
|
|
||||||
|
QString uicCommand() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/// emitted after parsing
|
/// emitted after parsing
|
||||||
void buildTargetsChanged();
|
void buildTargetsChanged();
|
||||||
@@ -115,15 +119,23 @@ private slots:
|
|||||||
void changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*);
|
void changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*);
|
||||||
void targetAdded(ProjectExplorer::Target *);
|
void targetAdded(ProjectExplorer::Target *);
|
||||||
|
|
||||||
|
void editorChanged(Core::IEditor *editor);
|
||||||
|
void editorAboutToClose(Core::IEditor *editor);
|
||||||
|
void uiEditorContentsChanged();
|
||||||
|
void buildStateChanged(ProjectExplorer::Project *project);
|
||||||
private:
|
private:
|
||||||
void buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
|
void buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
|
||||||
void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list);
|
void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list);
|
||||||
ProjectExplorer::FolderNode *findOrCreateFolder(CMakeProjectNode *rootNode, QString directory);
|
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;
|
CMakeManager *m_manager;
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
CMakeFile *m_file;
|
CMakeFile *m_file;
|
||||||
QString m_projectName;
|
QString m_projectName;
|
||||||
|
QString m_uicCommand;
|
||||||
|
|
||||||
// TODO probably need a CMake specific node structure
|
// TODO probably need a CMake specific node structure
|
||||||
CMakeProjectNode *m_rootNode;
|
CMakeProjectNode *m_rootNode;
|
||||||
@@ -134,6 +146,10 @@ private:
|
|||||||
QSet<QString> m_watchedFiles;
|
QSet<QString> m_watchedFiles;
|
||||||
CMakeTargetFactory *m_targetFactory;
|
CMakeTargetFactory *m_targetFactory;
|
||||||
QFuture<void> m_codeModelFuture;
|
QFuture<void> m_codeModelFuture;
|
||||||
|
|
||||||
|
QMap<QString, CMakeUiCodeModelSupport *> m_uiCodeModelSupport;
|
||||||
|
Core::IEditor *m_lastEditor;
|
||||||
|
bool m_dirtyUic;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMakeCbpParser : public QXmlStreamReader
|
class CMakeCbpParser : public QXmlStreamReader
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ HEADERS = cmakeproject.h \
|
|||||||
cmakebuildconfiguration.h \
|
cmakebuildconfiguration.h \
|
||||||
cmakeeditorfactory.h \
|
cmakeeditorfactory.h \
|
||||||
cmakeeditor.h \
|
cmakeeditor.h \
|
||||||
cmakehighlighter.h
|
cmakehighlighter.h \
|
||||||
|
cmakeuicodemodelsupport.h
|
||||||
SOURCES = cmakeproject.cpp \
|
SOURCES = cmakeproject.cpp \
|
||||||
cmakeprojectplugin.cpp \
|
cmakeprojectplugin.cpp \
|
||||||
cmakeprojectmanager.cpp \
|
cmakeprojectmanager.cpp \
|
||||||
@@ -26,7 +27,8 @@ SOURCES = cmakeproject.cpp \
|
|||||||
cmakebuildconfiguration.cpp \
|
cmakebuildconfiguration.cpp \
|
||||||
cmakeeditorfactory.cpp \
|
cmakeeditorfactory.cpp \
|
||||||
cmakeeditor.cpp \
|
cmakeeditor.cpp \
|
||||||
cmakehighlighter.cpp
|
cmakehighlighter.cpp \
|
||||||
|
cmakeuicodemodelsupport.cpp
|
||||||
RESOURCES += cmakeproject.qrc
|
RESOURCES += cmakeproject.qrc
|
||||||
FORMS +=
|
FORMS +=
|
||||||
|
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ include(../../plugins/projectexplorer/projectexplorer.pri)
|
|||||||
include(../../plugins/cpptools/cpptools.pri)
|
include(../../plugins/cpptools/cpptools.pri)
|
||||||
include(../../plugins/cppeditor/cppeditor.pri)
|
include(../../plugins/cppeditor/cppeditor.pri)
|
||||||
include(../../plugins/texteditor/texteditor.pri)
|
include(../../plugins/texteditor/texteditor.pri)
|
||||||
|
include(../../plugins/designer/designer.pri)
|
||||||
|
|||||||
64
src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.cpp
Normal file
64
src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.cpp
Normal file
@@ -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();
|
||||||
|
}
|
||||||
61
src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.h
Normal file
61
src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.h
Normal file
@@ -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
|
||||||
@@ -40,11 +40,11 @@ UiCodeModelSupport::UiCodeModelSupport(CppTools::CppModelManagerInterface *model
|
|||||||
: CppTools::AbstractEditorSupport(modelmanager),
|
: CppTools::AbstractEditorSupport(modelmanager),
|
||||||
m_sourceName(source),
|
m_sourceName(source),
|
||||||
m_fileName(uiHeaderFile),
|
m_fileName(uiHeaderFile),
|
||||||
m_updateIncludingFiles(false)
|
m_updateIncludingFiles(false),
|
||||||
|
m_initialized(false)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug()<<"ctor UiCodeModelSupport for"<<m_sourceName<<uiHeaderFile;
|
qDebug()<<"ctor UiCodeModelSupport for"<<m_sourceName<<uiHeaderFile;
|
||||||
init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UiCodeModelSupport::~UiCodeModelSupport()
|
UiCodeModelSupport::~UiCodeModelSupport()
|
||||||
@@ -53,8 +53,9 @@ UiCodeModelSupport::~UiCodeModelSupport()
|
|||||||
qDebug()<<"dtor ~UiCodeModelSupport for"<<m_sourceName;
|
qDebug()<<"dtor ~UiCodeModelSupport for"<<m_sourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UiCodeModelSupport::init()
|
void UiCodeModelSupport::init() const
|
||||||
{
|
{
|
||||||
|
m_initialized = true;
|
||||||
QDateTime sourceTime = QFileInfo(m_sourceName).lastModified();
|
QDateTime sourceTime = QFileInfo(m_sourceName).lastModified();
|
||||||
QFileInfo uiHeaderFileInfo(m_fileName);
|
QFileInfo uiHeaderFileInfo(m_fileName);
|
||||||
QDateTime uiHeaderTime = uiHeaderFileInfo.exists() ? uiHeaderFileInfo.lastModified() : QDateTime();
|
QDateTime uiHeaderTime = uiHeaderFileInfo.exists() ? uiHeaderFileInfo.lastModified() : QDateTime();
|
||||||
@@ -84,7 +85,7 @@ void UiCodeModelSupport::init()
|
|||||||
// uic run was unsuccesfull
|
// uic run was unsuccesfull
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug()<<"uic run wasn't succesfull";
|
qDebug()<<"uic run wasn't succesfull";
|
||||||
m_cacheTime = QDateTime();
|
m_cacheTime = QDateTime ();
|
||||||
m_contents = QByteArray();
|
m_contents = QByteArray();
|
||||||
// and if the header file wasn't there, next time we need to update
|
// and if the header file wasn't there, next time we need to update
|
||||||
// all of the files that include this header
|
// all of the files that include this header
|
||||||
@@ -101,6 +102,9 @@ void UiCodeModelSupport::init()
|
|||||||
|
|
||||||
QByteArray UiCodeModelSupport::contents() const
|
QByteArray UiCodeModelSupport::contents() const
|
||||||
{
|
{
|
||||||
|
if (!m_initialized)
|
||||||
|
init();
|
||||||
|
|
||||||
return m_contents;
|
return m_contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,11 +55,12 @@ protected:
|
|||||||
virtual QString uicCommand() const = 0;
|
virtual QString uicCommand() const = 0;
|
||||||
virtual QStringList environment() const = 0;
|
virtual QStringList environment() const = 0;
|
||||||
private:
|
private:
|
||||||
void init();
|
void init() const;
|
||||||
bool runUic(const QString &ui) const;
|
bool runUic(const QString &ui) const;
|
||||||
QString m_sourceName;
|
QString m_sourceName;
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
mutable bool m_updateIncludingFiles;
|
mutable bool m_updateIncludingFiles;
|
||||||
|
mutable bool m_initialized;
|
||||||
mutable QByteArray m_contents;
|
mutable QByteArray m_contents;
|
||||||
mutable QDateTime m_cacheTime;
|
mutable QDateTime m_cacheTime;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ plugin_projectexplorer.depends = plugin_locator
|
|||||||
plugin_projectexplorer.depends += plugin_find
|
plugin_projectexplorer.depends += plugin_find
|
||||||
plugin_projectexplorer.depends += plugin_coreplugin
|
plugin_projectexplorer.depends += plugin_coreplugin
|
||||||
plugin_projectexplorer.depends += plugin_texteditor
|
plugin_projectexplorer.depends += plugin_texteditor
|
||||||
plugin_projectexplorer.depends += plugin_cpptools
|
|
||||||
|
|
||||||
plugin_qt4projectmanager.subdir = qt4projectmanager
|
plugin_qt4projectmanager.subdir = qt4projectmanager
|
||||||
plugin_qt4projectmanager.depends = plugin_texteditor
|
plugin_qt4projectmanager.depends = plugin_texteditor
|
||||||
@@ -187,6 +186,7 @@ plugin_cmakeprojectmanager.depends = plugin_texteditor
|
|||||||
plugin_cmakeprojectmanager.depends += plugin_projectexplorer
|
plugin_cmakeprojectmanager.depends += plugin_projectexplorer
|
||||||
plugin_cmakeprojectmanager.depends += plugin_cpptools
|
plugin_cmakeprojectmanager.depends += plugin_cpptools
|
||||||
plugin_cmakeprojectmanager.depends += plugin_cppeditor
|
plugin_cmakeprojectmanager.depends += plugin_cppeditor
|
||||||
|
plugin_cmakeprojectmanager.depends += plugin_designer
|
||||||
|
|
||||||
plugin_genericprojectmanager.subdir = genericprojectmanager
|
plugin_genericprojectmanager.subdir = genericprojectmanager
|
||||||
plugin_genericprojectmanager.depends = plugin_texteditor
|
plugin_genericprojectmanager.depends = plugin_texteditor
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ Qt4UiCodeModelSupport::Qt4UiCodeModelSupport(CppTools::CppModelManagerInterface
|
|||||||
Qt4Project *project,
|
Qt4Project *project,
|
||||||
const QString &source,
|
const QString &source,
|
||||||
const QString &uiHeaderFile)
|
const QString &uiHeaderFile)
|
||||||
: UiCodeModelSupport(modelmanager, source, uiHeaderFile),
|
: CppTools::UiCodeModelSupport(modelmanager, source, uiHeaderFile),
|
||||||
m_project(project)
|
m_project(project)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
#define QTUICODEMODELSUPPORT_H
|
#define QTUICODEMODELSUPPORT_H
|
||||||
|
|
||||||
#include <cpptools/cppmodelmanagerinterface.h>
|
#include <cpptools/cppmodelmanagerinterface.h>
|
||||||
#include <projectexplorer/uicodecompletionsupport.h>
|
#include <cpptools/uicodecompletionsupport.h>
|
||||||
|
|
||||||
#include <QtCore/QDateTime>
|
#include <QtCore/QDateTime>
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ namespace Qt4ProjectManager {
|
|||||||
class Qt4Project;
|
class Qt4Project;
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class Qt4UiCodeModelSupport : public ProjectExplorer::UiCodeModelSupport
|
class Qt4UiCodeModelSupport : public CppTools::UiCodeModelSupport
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Qt4UiCodeModelSupport(CppTools::CppModelManagerInterface *modelmanager,
|
Qt4UiCodeModelSupport(CppTools::CppModelManagerInterface *modelmanager,
|
||||||
|
|||||||
Reference in New Issue
Block a user