Move Ui code model support into QtSupport

* Move basic ui code model support from CppTools into QtSupport
* Use Kit infrastructure to retrieve uicCommand and environment
* Remove specialization for cmake projects (no longer needed)
* Remove specialization for qmake based projects (no longer needed)

Change-Id: I8569cc01acb46a540883c2da235d169bebf7db39
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Tobias Hunger
2013-07-09 16:41:57 +02:00
parent 062b8f5d31
commit 81eba6f984
20 changed files with 121 additions and 367 deletions

View File

@@ -35,7 +35,6 @@
#include "cmakerunconfiguration.h" #include "cmakerunconfiguration.h"
#include "makestep.h" #include "makestep.h"
#include "cmakeopenprojectwizard.h" #include "cmakeopenprojectwizard.h"
#include "cmakeuicodemodelsupport.h"
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
@@ -51,6 +50,7 @@
#include <qtsupport/customexecutablerunconfiguration.h> #include <qtsupport/customexecutablerunconfiguration.h>
#include <qtsupport/baseqtversion.h> #include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h> #include <qtsupport/qtkitinformation.h>
#include <qtsupport/uicodemodelsupport.h>
#include <cpptools/cppmodelmanagerinterface.h> #include <cpptools/cppmodelmanagerinterface.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -124,7 +124,7 @@ CMakeProject::~CMakeProject()
// Remove CodeModel support // Remove CodeModel support
CppTools::CppModelManagerInterface *modelManager CppTools::CppModelManagerInterface *modelManager
= CppTools::CppModelManagerInterface::instance(); = CppTools::CppModelManagerInterface::instance();
QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it, end; QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it, end;
it = m_uiCodeModelSupport.constBegin(); it = m_uiCodeModelSupport.constBegin();
end = m_uiCodeModelSupport.constEnd(); end = m_uiCodeModelSupport.constEnd();
for (; it!=end; ++it) { for (; it!=end; ++it) {
@@ -289,20 +289,6 @@ bool CMakeProject::parseCMakeLists()
// } // }
// TOOD this code ain't very pretty ...
m_uicCommand.clear();
QFile cmakeCache(activeBC->buildDirectory() + QLatin1String("/CMakeCache.txt"));
cmakeCache.open(QIODevice::ReadOnly);
while (!cmakeCache.atEnd()) {
QByteArray line = cmakeCache.readLine();
if (line.startsWith("QT_UIC_EXECUTABLE")) {
if (int pos = line.indexOf('='))
m_uicCommand = QString::fromLocal8Bit(line.mid(pos + 1).trimmed());
break;
}
}
cmakeCache.close();
createUiCodeModelSupport(); createUiCodeModelSupport();
Kit *k = activeTarget()->kit(); Kit *k = activeTarget()->kit();
@@ -692,11 +678,6 @@ CMakeBuildTarget CMakeProject::buildTargetForTitle(const QString &title)
return CMakeBuildTarget(); return CMakeBuildTarget();
} }
QString CMakeProject::uicCommand() const
{
return m_uicCommand;
}
QString CMakeProject::uiHeaderFile(const QString &uiFile) QString CMakeProject::uiHeaderFile(const QString &uiFile)
{ {
QFileInfo fi(uiFile); QFileInfo fi(uiFile);
@@ -794,7 +775,7 @@ void CMakeProject::createUiCodeModelSupport()
= CppTools::CppModelManagerInterface::instance(); = CppTools::CppModelManagerInterface::instance();
// First move all to // First move all to
QMap<QString, CMakeUiCodeModelSupport *> oldCodeModelSupport; QMap<QString, QtSupport::UiCodeModelSupport *> oldCodeModelSupport;
oldCodeModelSupport = m_uiCodeModelSupport; oldCodeModelSupport = m_uiCodeModelSupport;
m_uiCodeModelSupport.clear(); m_uiCodeModelSupport.clear();
@@ -803,17 +784,17 @@ void CMakeProject::createUiCodeModelSupport()
if (uiFile.endsWith(QLatin1String(".ui"))) { if (uiFile.endsWith(QLatin1String(".ui"))) {
// UI file, not convert to // UI file, not convert to
QString uiHeaderFilePath = uiHeaderFile(uiFile); QString uiHeaderFilePath = uiHeaderFile(uiFile);
QMap<QString, CMakeUiCodeModelSupport *>::iterator it QMap<QString, QtSupport::UiCodeModelSupport *>::iterator it
= oldCodeModelSupport.find(uiFile); = oldCodeModelSupport.find(uiFile);
if (it != oldCodeModelSupport.end()) { if (it != oldCodeModelSupport.end()) {
// qDebug()<<"updated old codemodelsupport"; // qDebug()<<"updated old codemodelsupport";
CMakeUiCodeModelSupport *cms = it.value(); QtSupport::UiCodeModelSupport *cms = it.value();
cms->setFileName(uiHeaderFilePath); cms->setFileName(uiHeaderFilePath);
m_uiCodeModelSupport.insert(it.key(), cms); m_uiCodeModelSupport.insert(it.key(), cms);
oldCodeModelSupport.erase(it); oldCodeModelSupport.erase(it);
} else { } else {
// qDebug()<<"adding new codemodelsupport"; // qDebug()<<"adding new codemodelsupport";
CMakeUiCodeModelSupport *cms = new CMakeUiCodeModelSupport(modelManager, this, uiFile, uiHeaderFilePath); QtSupport::UiCodeModelSupport *cms = new QtSupport::UiCodeModelSupport(modelManager, this, uiFile, uiHeaderFilePath);
m_uiCodeModelSupport.insert(uiFile, cms); m_uiCodeModelSupport.insert(uiFile, cms);
modelManager->addEditorSupport(cms); modelManager->addEditorSupport(cms);
} }
@@ -821,7 +802,7 @@ void CMakeProject::createUiCodeModelSupport()
} }
// Remove old // Remove old
QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it, end; QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it, end;
end = oldCodeModelSupport.constEnd(); end = oldCodeModelSupport.constEnd();
for (it = oldCodeModelSupport.constBegin(); it!=end; ++it) { for (it = oldCodeModelSupport.constBegin(); it!=end; ++it) {
modelManager->removeEditorSupport(it.value()); modelManager->removeEditorSupport(it.value());
@@ -832,7 +813,7 @@ void CMakeProject::createUiCodeModelSupport()
void CMakeProject::updateCodeModelSupportFromEditor(const QString &uiFileName, void CMakeProject::updateCodeModelSupportFromEditor(const QString &uiFileName,
const QString &contents) const QString &contents)
{ {
const QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it = const QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it =
m_uiCodeModelSupport.constFind(uiFileName); m_uiCodeModelSupport.constFind(uiFileName);
if (it != m_uiCodeModelSupport.constEnd()) if (it != m_uiCodeModelSupport.constEnd())
it.value()->updateFromEditor(contents); it.value()->updateFromEditor(contents);
@@ -885,7 +866,7 @@ void CMakeProject::buildStateChanged(ProjectExplorer::Project *project)
{ {
if (project == this) { if (project == this) {
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager()->isBuilding(this)) { if (!ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager()->isBuilding(this)) {
QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it, end; QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it, end;
end = m_uiCodeModelSupport.constEnd(); end = m_uiCodeModelSupport.constEnd();
for (it = m_uiCodeModelSupport.constBegin(); it != end; ++it) { for (it = m_uiCodeModelSupport.constBegin(); it != end; ++it) {
it.value()->updateFromBuild(); it.value()->updateFromBuild();

View File

@@ -52,13 +52,13 @@ class QFileSystemWatcher;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace ProjectExplorer { class Target; } namespace ProjectExplorer { class Target; }
namespace QtSupport { class UiCodeModelSupport; }
namespace CMakeProjectManager { namespace CMakeProjectManager {
namespace Internal { namespace Internal {
class CMakeFile; class CMakeFile;
class CMakeBuildSettingsWidget; class CMakeBuildSettingsWidget;
class CMakeUiCodeModelSupport;
struct CMakeBuildTarget struct CMakeBuildTarget
{ {
@@ -97,8 +97,6 @@ public:
QString shadowBuildDirectory(const QString &projectFilePath, const ProjectExplorer::Kit *k, QString shadowBuildDirectory(const QString &projectFilePath, const ProjectExplorer::Kit *k,
const QString &bcName); const QString &bcName);
QString uicCommand() const;
bool isProjectFile(const QString &fileName); bool isProjectFile(const QString &fileName);
bool parseCMakeLists(); bool parseCMakeLists();
@@ -139,7 +137,6 @@ private:
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;
@@ -149,7 +146,7 @@ private:
QSet<QString> m_watchedFiles; QSet<QString> m_watchedFiles;
QFuture<void> m_codeModelFuture; QFuture<void> m_codeModelFuture;
QMap<QString, CMakeUiCodeModelSupport *> m_uiCodeModelSupport; QMap<QString, QtSupport::UiCodeModelSupport *> m_uiCodeModelSupport;
Core::IEditor *m_lastEditor; Core::IEditor *m_lastEditor;
bool m_dirtyUic; bool m_dirtyUic;
}; };

View File

@@ -12,7 +12,6 @@ HEADERS = cmakeproject.h \
cmakeeditorfactory.h \ cmakeeditorfactory.h \
cmakeeditor.h \ cmakeeditor.h \
cmakehighlighter.h \ cmakehighlighter.h \
cmakeuicodemodelsupport.h \
cmakelocatorfilter.h \ cmakelocatorfilter.h \
cmakefilecompletionassist.h \ cmakefilecompletionassist.h \
cmakevalidator.h cmakevalidator.h
@@ -28,7 +27,6 @@ SOURCES = cmakeproject.cpp \
cmakeeditorfactory.cpp \ cmakeeditorfactory.cpp \
cmakeeditor.cpp \ cmakeeditor.cpp \
cmakehighlighter.cpp \ cmakehighlighter.cpp \
cmakeuicodemodelsupport.cpp \
cmakelocatorfilter.cpp \ cmakelocatorfilter.cpp \
cmakefilecompletionassist.cpp \ cmakefilecompletionassist.cpp \
cmakevalidator.cpp cmakevalidator.cpp

View File

@@ -46,8 +46,6 @@ QtcPlugin {
"cmakeprojectplugin.h", "cmakeprojectplugin.h",
"cmakerunconfiguration.cpp", "cmakerunconfiguration.cpp",
"cmakerunconfiguration.h", "cmakerunconfiguration.h",
"cmakeuicodemodelsupport.cpp",
"cmakeuicodemodelsupport.h",
"cmakevalidator.cpp", "cmakevalidator.cpp",
"cmakevalidator.h", "cmakevalidator.h",
"makestep.cpp", "makestep.cpp",

View File

@@ -1,63 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "cmakeuicodemodelsupport.h"
#include "cmakeproject.h"
#include "cmakebuildconfiguration.h"
#include <cpptools/cppmodelmanagerinterface.h>
#include <projectexplorer/target.h>
#include <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
{
if (!m_project || !m_project->activeTarget() || !m_project->activeTarget()->activeBuildConfiguration())
return QStringList();
return m_project->activeTarget()->activeBuildConfiguration()->environment().toStringList();
}

View File

@@ -1,63 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CMAKEUICODEMODELSUPPORT_H
#define CMAKEUICODEMODELSUPPORT_H
#include <cpptools/uicodecompletionsupport.h>
#include <QDateTime>
namespace CppTools { class CppModelManagerInterface; }
namespace CMakeProjectManager {
namespace Internal {
class CMakeProject;
class CMakeUiCodeModelSupport : public CppTools::UiCodeModelSupport
{
Q_OBJECT
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

View File

@@ -19,7 +19,6 @@ HEADERS += completionsettingspage.h \
cppfindreferences.h \ cppfindreferences.h \
cppcodeformatter.h \ cppcodeformatter.h \
symbolsfindfilter.h \ symbolsfindfilter.h \
uicodecompletionsupport.h \
insertionpointlocator.h \ insertionpointlocator.h \
cpprefactoringchanges.h \ cpprefactoringchanges.h \
abstracteditorsupport.h \ abstracteditorsupport.h \
@@ -65,7 +64,6 @@ SOURCES += completionsettingspage.cpp \
cppfindreferences.cpp \ cppfindreferences.cpp \
cppcodeformatter.cpp \ cppcodeformatter.cpp \
symbolsfindfilter.cpp \ symbolsfindfilter.cpp \
uicodecompletionsupport.cpp \
insertionpointlocator.cpp \ insertionpointlocator.cpp \
cpprefactoringchanges.cpp \ cpprefactoringchanges.cpp \
cppcompletionassist.cpp \ cppcompletionassist.cpp \

View File

@@ -102,8 +102,6 @@ QtcPlugin {
"symbolsfindfilter.h", "symbolsfindfilter.h",
"typehierarchybuilder.cpp", "typehierarchybuilder.cpp",
"typehierarchybuilder.h", "typehierarchybuilder.h",
"uicodecompletionsupport.cpp",
"uicodecompletionsupport.h",
"builtinindexingsupport.cpp", "builtinindexingsupport.cpp",
"builtinindexingsupport.h", "builtinindexingsupport.h",
"cpppreprocessor.cpp", "cpppreprocessor.cpp",

View File

@@ -31,7 +31,6 @@
#include "qt4project.h" #include "qt4project.h"
#include "qt4projectmanager.h" #include "qt4projectmanager.h"
#include "qt4projectmanagerconstants.h" #include "qt4projectmanagerconstants.h"
#include "qtuicodemodelsupport.h"
#include "qt4buildconfiguration.h" #include "qt4buildconfiguration.h"
#include "qmakerunconfigurationfactory.h" #include "qmakerunconfigurationfactory.h"
@@ -50,6 +49,7 @@
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <qtsupport/profilereader.h> #include <qtsupport/profilereader.h>
#include <qtsupport/qtkitinformation.h> #include <qtsupport/qtkitinformation.h>
#include <qtsupport/uicodemodelsupport.h>
#include <cpptools/cppmodelmanagerinterface.h> #include <cpptools/cppmodelmanagerinterface.h>
#include <cpptools/cpptoolsconstants.h> #include <cpptools/cpptoolsconstants.h>
@@ -1470,7 +1470,7 @@ Qt4ProFileNode::~Qt4ProFileNode()
{ {
CppTools::CppModelManagerInterface *modelManager CppTools::CppModelManagerInterface *modelManager
= CppTools::CppModelManagerInterface::instance(); = CppTools::CppModelManagerInterface::instance();
QMap<QString, Internal::Qt4UiCodeModelSupport *>::const_iterator it, end; QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it, end;
end = m_uiCodeModelSupport.constEnd(); end = m_uiCodeModelSupport.constEnd();
for (it = m_uiCodeModelSupport.constBegin(); it != end; ++it) { for (it = m_uiCodeModelSupport.constBegin(); it != end; ++it) {
modelManager->removeEditorSupport(it.value()); modelManager->removeEditorSupport(it.value());
@@ -2253,7 +2253,7 @@ QString Qt4ProFileNode::buildDir(Qt4BuildConfiguration *bc) const
void Qt4ProFileNode::updateCodeModelSupportFromBuild() void Qt4ProFileNode::updateCodeModelSupportFromBuild()
{ {
QMap<QString, Internal::Qt4UiCodeModelSupport *>::const_iterator it, end; QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it, end;
end = m_uiCodeModelSupport.constEnd(); end = m_uiCodeModelSupport.constEnd();
for (it = m_uiCodeModelSupport.constBegin(); it != end; ++it) for (it = m_uiCodeModelSupport.constBegin(); it != end; ++it)
it.value()->updateFromBuild(); it.value()->updateFromBuild();
@@ -2262,7 +2262,7 @@ void Qt4ProFileNode::updateCodeModelSupportFromBuild()
void Qt4ProFileNode::updateCodeModelSupportFromEditor(const QString &uiFileName, void Qt4ProFileNode::updateCodeModelSupportFromEditor(const QString &uiFileName,
const QString &contents) const QString &contents)
{ {
const QMap<QString, Internal::Qt4UiCodeModelSupport *>::const_iterator it = const QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it =
m_uiCodeModelSupport.constFind(uiFileName); m_uiCodeModelSupport.constFind(uiFileName);
if (it != m_uiCodeModelSupport.constEnd()) if (it != m_uiCodeModelSupport.constEnd())
it.value()->updateFromEditor(contents); it.value()->updateFromEditor(contents);
@@ -2295,7 +2295,7 @@ void Qt4ProFileNode::createUiCodeModelSupport()
= CppTools::CppModelManagerInterface::instance(); = CppTools::CppModelManagerInterface::instance();
// First move all to // First move all to
QMap<QString, Internal::Qt4UiCodeModelSupport *> oldCodeModelSupport; QMap<QString, QtSupport::UiCodeModelSupport *> oldCodeModelSupport;
oldCodeModelSupport = m_uiCodeModelSupport; oldCodeModelSupport = m_uiCodeModelSupport;
m_uiCodeModelSupport.clear(); m_uiCodeModelSupport.clear();
@@ -2314,23 +2314,23 @@ void Qt4ProFileNode::createUiCodeModelSupport()
const QString uiHeaderFilePath = uiHeaderFile(uiDir, uiFile->path()); const QString uiHeaderFilePath = uiHeaderFile(uiDir, uiFile->path());
m_uiHeaderFiles << uiHeaderFilePath; m_uiHeaderFiles << uiHeaderFilePath;
// qDebug()<<"code model support for "<<uiFile->path()<<" "<<uiHeaderFilePath; // qDebug()<<"code model support for "<<uiFile->path()<<" "<<uiHeaderFilePath;
QMap<QString, Internal::Qt4UiCodeModelSupport *>::iterator it = oldCodeModelSupport.find(uiFile->path()); QMap<QString, QtSupport::UiCodeModelSupport *>::iterator it = oldCodeModelSupport.find(uiFile->path());
if (it != oldCodeModelSupport.end()) { if (it != oldCodeModelSupport.end()) {
// qDebug()<<"updated old codemodelsupport"; // qDebug()<<"updated old codemodelsupport";
Internal::Qt4UiCodeModelSupport *cms = it.value(); QtSupport::UiCodeModelSupport *cms = it.value();
cms->setFileName(uiHeaderFilePath); cms->setFileName(uiHeaderFilePath);
m_uiCodeModelSupport.insert(it.key(), cms); m_uiCodeModelSupport.insert(it.key(), cms);
oldCodeModelSupport.erase(it); oldCodeModelSupport.erase(it);
} else { } else {
// qDebug()<<"adding new codemodelsupport"; // qDebug()<<"adding new codemodelsupport";
Internal::Qt4UiCodeModelSupport *cms = new Internal::Qt4UiCodeModelSupport(modelManager, m_project, uiFile->path(), uiHeaderFilePath); QtSupport::UiCodeModelSupport *cms = new QtSupport::UiCodeModelSupport(modelManager, m_project, uiFile->path(), uiHeaderFilePath);
m_uiCodeModelSupport.insert(uiFile->path(), cms); m_uiCodeModelSupport.insert(uiFile->path(), cms);
modelManager->addEditorSupport(cms); modelManager->addEditorSupport(cms);
} }
} }
} }
// Remove old // Remove old
QMap<QString, Internal::Qt4UiCodeModelSupport *>::const_iterator it, end; QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it, end;
end = oldCodeModelSupport.constEnd(); end = oldCodeModelSupport.constEnd();
for (it = oldCodeModelSupport.constBegin(); it!=end; ++it) { for (it = oldCodeModelSupport.constBegin(); it!=end; ++it) {
modelManager->removeEditorSupport(it.value()); modelManager->removeEditorSupport(it.value());

View File

@@ -34,6 +34,7 @@
#include <coreplugin/idocument.h> #include <coreplugin/idocument.h>
#include <projectexplorer/projectnodes.h> #include <projectexplorer/projectnodes.h>
#include <qtsupport/uicodemodelsupport.h>
#include <QHash> #include <QHash>
#include <QStringList> #include <QStringList>
@@ -126,7 +127,6 @@ using ProjectExplorer::ProjectFileType;
using ProjectExplorer::FileType; using ProjectExplorer::FileType;
namespace Internal { namespace Internal {
class Qt4UiCodeModelSupport;
class Qt4PriFile; class Qt4PriFile;
struct InternalNode; struct InternalNode;
} }
@@ -204,7 +204,7 @@ private:
QString m_projectFilePath; QString m_projectFilePath;
QString m_projectDir; QString m_projectDir;
QMap<QString, Internal::Qt4UiCodeModelSupport *> m_uiCodeModelSupport; QMap<QString, QtSupport::UiCodeModelSupport *> m_uiCodeModelSupport;
Internal::Qt4PriFile *m_qt4PriFile; Internal::Qt4PriFile *m_qt4PriFile;
// Memory is cheap... // Memory is cheap...

View File

@@ -53,7 +53,6 @@ HEADERS += \
qmakestep.h \ qmakestep.h \
qtmodulesinfo.h \ qtmodulesinfo.h \
qt4projectconfigwidget.h \ qt4projectconfigwidget.h \
qtuicodemodelsupport.h \
externaleditors.h \ externaleditors.h \
qt4buildconfiguration.h \ qt4buildconfiguration.h \
qmakeparser.h \ qmakeparser.h \
@@ -116,7 +115,6 @@ SOURCES += \
qmakestep.cpp \ qmakestep.cpp \
qtmodulesinfo.cpp \ qtmodulesinfo.cpp \
qt4projectconfigwidget.cpp \ qt4projectconfigwidget.cpp \
qtuicodemodelsupport.cpp \
externaleditors.cpp \ externaleditors.cpp \
qt4buildconfiguration.cpp \ qt4buildconfiguration.cpp \
qmakeparser.cpp \ qmakeparser.cpp \

View File

@@ -82,8 +82,6 @@ QtcPlugin {
"qt4targetsetupwidget.h", "qt4targetsetupwidget.h",
"qtmodulesinfo.cpp", "qtmodulesinfo.cpp",
"qtmodulesinfo.h", "qtmodulesinfo.h",
"qtuicodemodelsupport.cpp",
"qtuicodemodelsupport.h",
"unconfiguredprojectpanel.cpp", "unconfiguredprojectpanel.cpp",
"unconfiguredprojectpanel.h", "unconfiguredprojectpanel.h",
"winceqtversion.cpp", "winceqtversion.cpp",

View File

@@ -1,74 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "qtuicodemodelsupport.h"
#include "qt4buildconfiguration.h"
#include "qt4project.h"
#include <projectexplorer/target.h>
#include <qtsupport/qtkitinformation.h>
using namespace Qt4ProjectManager;
using namespace Internal;
Qt4UiCodeModelSupport::Qt4UiCodeModelSupport(CppTools::CppModelManagerInterface *modelmanager,
Qt4Project *project,
const QString &source,
const QString &uiHeaderFile)
: CppTools::UiCodeModelSupport(modelmanager, source, uiHeaderFile),
m_project(project)
{ }
Qt4UiCodeModelSupport::~Qt4UiCodeModelSupport()
{ }
QString Qt4UiCodeModelSupport::uicCommand() const
{
QtSupport::BaseQtVersion *version;
if (m_project->needsConfiguration()) {
version = QtSupport::QtKitInformation::qtVersion(ProjectExplorer::KitManager::instance()->defaultKit());
} else {
ProjectExplorer::Target *target = m_project->activeTarget();
version = QtSupport::QtKitInformation::qtVersion(target->kit());
}
return version ? version->uicCommand() : QString();
}
QStringList Qt4UiCodeModelSupport::environment() const
{
if (m_project->needsConfiguration()) {
return Utils::Environment::systemEnvironment().toStringList();
} else {
ProjectExplorer::Target *target = m_project->activeTarget();
if (!target)
return QStringList();
ProjectExplorer::BuildConfiguration *bc = target->activeBuildConfiguration();
return bc ? bc->environment().toStringList() : QStringList();
}
}

View File

@@ -1,62 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QTUICODEMODELSUPPORT_H
#define QTUICODEMODELSUPPORT_H
#include <cpptools/uicodecompletionsupport.h>
namespace CPlusPlus {
class CppModelManagerInterface;
}
namespace Qt4ProjectManager {
class Qt4Project;
namespace Internal {
class Qt4UiCodeModelSupport : public CppTools::UiCodeModelSupport
{
Q_OBJECT
public:
Qt4UiCodeModelSupport(CppTools::CppModelManagerInterface *modelmanager,
Qt4Project *project,
const QString &sourceFile,
const QString &uiHeaderFile);
virtual ~Qt4UiCodeModelSupport();
protected:
virtual QString uicCommand() const;
virtual QStringList environment() const;
private:
Qt4Project *m_project;
};
} // Internal
} // Qt4ProjectManager
#endif // QTUICODEMODELSUPPORT_H

View File

@@ -129,7 +129,7 @@ public:
virtual Utils::Environment qmakeRunEnvironment() const; virtual Utils::Environment qmakeRunEnvironment() const;
virtual Utils::FileName sourcePath() const; virtual Utils::FileName sourcePath() const;
// used by QtUiCodeModelSupport // used by UiCodeModelSupport
virtual QString uicCommand() const; virtual QString uicCommand() const;
virtual QString designerCommand() const; virtual QString designerCommand() const;
virtual QString linguistCommand() const; virtual QString linguistCommand() const;

View File

@@ -14,6 +14,7 @@ HEADERS += \
qtoutputformatter.h \ qtoutputformatter.h \
qtversionmanager.h \ qtversionmanager.h \
qtversionfactory.h \ qtversionfactory.h \
uicodemodelsupport.h \
baseqtversion.h \ baseqtversion.h \
qmldumptool.h \ qmldumptool.h \
qmlobservertool.h \ qmlobservertool.h \
@@ -39,6 +40,7 @@ SOURCES += \
qtoutputformatter.cpp \ qtoutputformatter.cpp \
qtversionmanager.cpp \ qtversionmanager.cpp \
qtversionfactory.cpp \ qtversionfactory.cpp \
uicodemodelsupport.cpp \
baseqtversion.cpp \ baseqtversion.cpp \
qmldumptool.cpp \ qmldumptool.cpp \
qmlobservertool.cpp \ qmlobservertool.cpp \

View File

@@ -10,6 +10,7 @@ QtcPlugin {
Depends { name: "ProjectExplorer" } Depends { name: "ProjectExplorer" }
Depends { name: "TextEditor" } Depends { name: "TextEditor" }
Depends { name: "QmlJS" } Depends { name: "QmlJS" }
Depends { name: "CppTools" }
cpp.includePaths: base.concat([ cpp.includePaths: base.concat([
"../../shared", "../../shared",
@@ -94,6 +95,8 @@ QtcPlugin {
"qtsupportconstants.h", "qtsupportconstants.h",
"qtsupportplugin.cpp", "qtsupportplugin.cpp",
"qtsupportplugin.h", "qtsupportplugin.h",
"qtuicodemodelsupport.cpp",
"qtuicodemodelsupport.h",
"qtversionfactory.cpp", "qtversionfactory.cpp",
"qtversionfactory.h", "qtversionfactory.h",
"qtversioninfo.ui", "qtversioninfo.ui",

View File

@@ -4,6 +4,7 @@ QTC_LIB_DEPENDS += \
utils utils
QTC_PLUGIN_DEPENDS += \ QTC_PLUGIN_DEPENDS += \
coreplugin \ coreplugin \
cpptools \
projectexplorer \ projectexplorer \
texteditor texteditor
DEFINES *= \ DEFINES *= \

View File

@@ -27,21 +27,29 @@
** **
****************************************************************************/ ****************************************************************************/
#include "uicodecompletionsupport.h" #include "uicodemodelsupport.h"
#include "qtkitinformation.h"
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <QProcess>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
enum { debug = 0 }; enum { debug = 0 };
using namespace CppTools;
using namespace CPlusPlus; using namespace CPlusPlus;
UiCodeModelSupport::UiCodeModelSupport(CppModelManagerInterface *modelmanager, namespace QtSupport {
UiCodeModelSupport::UiCodeModelSupport(CppTools::CppModelManagerInterface *modelmanager,
ProjectExplorer::Project *project,
const QString &source, const QString &source,
const QString &uiHeaderFile) const QString &uiHeaderFile)
: AbstractEditorSupport(modelmanager), : CppTools::AbstractEditorSupport(modelmanager),
m_project(project),
m_sourceName(source), m_sourceName(source),
m_fileName(uiHeaderFile), m_fileName(uiHeaderFile),
m_state(BARE) m_state(BARE)
@@ -178,34 +186,6 @@ void UiCodeModelSupport::updateFromEditor(const QString &formEditorContents)
updateDocument(); updateDocument();
} }
bool UiCodeModelSupport::finishProcess() const
{
if (m_state != RUNNING)
return false;
if (!m_process.waitForFinished(3000)
&& m_process.exitStatus() != QProcess::NormalExit
&& m_process.exitCode() != 0) {
if (m_state != RUNNING) // waitForFinished can recurse into finishProcess
return false;
if (debug)
qDebug() << "failed" << m_process.readAllStandardError();
m_process.kill();
m_state = FINISHED;
return false;
}
if (m_state != RUNNING) // waitForFinished can recurse into finishProcess
return true;
m_contents = m_process.readAllStandardOutput();
m_cacheTime = QDateTime::currentDateTime();
if (debug)
qDebug() << "ok" << m_contents.size() << "bytes.";
m_state = FINISHED;
return true;
}
void UiCodeModelSupport::updateFromBuild() void UiCodeModelSupport::updateFromBuild()
{ {
if (debug) if (debug)
@@ -244,3 +224,57 @@ void UiCodeModelSupport::updateFromBuild()
} }
} }
QString UiCodeModelSupport::uicCommand() const
{
QtSupport::BaseQtVersion *version;
if (m_project->needsConfiguration()) {
version = QtSupport::QtKitInformation::qtVersion(ProjectExplorer::KitManager::instance()->defaultKit());
} else {
ProjectExplorer::Target *target = m_project->activeTarget();
version = QtSupport::QtKitInformation::qtVersion(target->kit());
}
return version ? version->uicCommand() : QString();
}
QStringList UiCodeModelSupport::environment() const
{
if (m_project->needsConfiguration()) {
return Utils::Environment::systemEnvironment().toStringList();
} else {
ProjectExplorer::Target *target = m_project->activeTarget();
if (!target)
return QStringList();
ProjectExplorer::BuildConfiguration *bc = target->activeBuildConfiguration();
return bc ? bc->environment().toStringList() : QStringList();
}
}
bool UiCodeModelSupport::finishProcess() const
{
if (m_state != RUNNING)
return false;
if (!m_process.waitForFinished(3000)
&& m_process.exitStatus() != QProcess::NormalExit
&& m_process.exitCode() != 0) {
if (m_state != RUNNING) // waitForFinished can recurse into finishProcess
return false;
if (debug)
qDebug() << "failed" << m_process.readAllStandardError();
m_process.kill();
m_state = FINISHED;
return false;
}
if (m_state != RUNNING) // waitForFinished can recurse into finishProcess
return true;
m_contents = m_process.readAllStandardOutput();
m_cacheTime = QDateTime::currentDateTime();
if (debug)
qDebug() << "ok" << m_contents.size() << "bytes.";
m_state = FINISHED;
return true;
}
} // namespace QtSupport

View File

@@ -27,42 +27,52 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef UICODEMODELSUPPORT_H
#define UICODEMODELSUPPORT_H
#ifndef UICODECOMPLETIONSUPPORT_H #include "qtsupport_global.h"
#define UICODECOMPLETIONSUPPORT_H
#include "cpptools_global.h" #include <cpptools/abstracteditorsupport.h>
#include "abstracteditorsupport.h"
#include "cppmodelmanagerinterface.h"
#include <QDateTime> #include <QDateTime>
#include <QProcess> #include <QProcess>
namespace CppTools { namespace CPlusPlus { class CppModelManagerInterface; }
namespace ProjectExplorer { class Project; }
class CPPTOOLS_EXPORT UiCodeModelSupport : public AbstractEditorSupport namespace QtSupport {
class QTSUPPORT_EXPORT UiCodeModelSupport : public CppTools::AbstractEditorSupport
{ {
Q_OBJECT Q_OBJECT
public: public:
UiCodeModelSupport(CppTools::CppModelManagerInterface *modelmanager, UiCodeModelSupport(CppTools::CppModelManagerInterface *modelmanager,
ProjectExplorer::Project *project,
const QString &sourceFile, const QString &sourceFile,
const QString &uiHeaderFile); const QString &uiHeaderFile);
~UiCodeModelSupport(); ~UiCodeModelSupport();
void setFileName(const QString &name); void setFileName(const QString &name);
void setSourceName(const QString &name); void setSourceName(const QString &name);
virtual QByteArray contents() const; QByteArray contents() const;
virtual QString fileName() const; QString fileName() const;
void updateFromEditor(const QString &formEditorContents); void updateFromEditor(const QString &formEditorContents);
void updateFromBuild(); void updateFromBuild();
protected:
virtual QString uicCommand() const = 0;
virtual QStringList environment() const = 0;
private: private:
QString uicCommand() const;
QStringList environment() const;
private slots:
bool finishProcess() const;
private:
ProjectExplorer::Project *m_project;
enum State { BARE, RUNNING, FINISHED }; enum State { BARE, RUNNING, FINISHED };
void init() const; void init() const;
bool runUic(const QString &ui) const; bool runUic(const QString &ui) const;
Q_SLOT bool finishProcess() const;
mutable QProcess m_process; mutable QProcess m_process;
QString m_sourceName; QString m_sourceName;
QString m_fileName; QString m_fileName;
@@ -72,6 +82,6 @@ private:
static QList<UiCodeModelSupport *> m_waitingForStart; static QList<UiCodeModelSupport *> m_waitingForStart;
}; };
} // CppTools } // QtSupport
#endif // UICODECOMPLETIONSUPPORT_H #endif // UICODEMODELSUPPORT_H