forked from qt-creator/qt-creator
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:
@@ -35,7 +35,6 @@
|
||||
#include "cmakerunconfiguration.h"
|
||||
#include "makestep.h"
|
||||
#include "cmakeopenprojectwizard.h"
|
||||
#include "cmakeuicodemodelsupport.h"
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
@@ -51,6 +50,7 @@
|
||||
#include <qtsupport/customexecutablerunconfiguration.h>
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/uicodemodelsupport.h>
|
||||
#include <cpptools/cppmodelmanagerinterface.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -124,7 +124,7 @@ CMakeProject::~CMakeProject()
|
||||
// Remove CodeModel support
|
||||
CppTools::CppModelManagerInterface *modelManager
|
||||
= CppTools::CppModelManagerInterface::instance();
|
||||
QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it, end;
|
||||
QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it, end;
|
||||
it = m_uiCodeModelSupport.constBegin();
|
||||
end = m_uiCodeModelSupport.constEnd();
|
||||
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();
|
||||
|
||||
Kit *k = activeTarget()->kit();
|
||||
@@ -692,11 +678,6 @@ CMakeBuildTarget CMakeProject::buildTargetForTitle(const QString &title)
|
||||
return CMakeBuildTarget();
|
||||
}
|
||||
|
||||
QString CMakeProject::uicCommand() const
|
||||
{
|
||||
return m_uicCommand;
|
||||
}
|
||||
|
||||
QString CMakeProject::uiHeaderFile(const QString &uiFile)
|
||||
{
|
||||
QFileInfo fi(uiFile);
|
||||
@@ -794,7 +775,7 @@ void CMakeProject::createUiCodeModelSupport()
|
||||
= CppTools::CppModelManagerInterface::instance();
|
||||
|
||||
// First move all to
|
||||
QMap<QString, CMakeUiCodeModelSupport *> oldCodeModelSupport;
|
||||
QMap<QString, QtSupport::UiCodeModelSupport *> oldCodeModelSupport;
|
||||
oldCodeModelSupport = m_uiCodeModelSupport;
|
||||
m_uiCodeModelSupport.clear();
|
||||
|
||||
@@ -803,17 +784,17 @@ void CMakeProject::createUiCodeModelSupport()
|
||||
if (uiFile.endsWith(QLatin1String(".ui"))) {
|
||||
// UI file, not convert to
|
||||
QString uiHeaderFilePath = uiHeaderFile(uiFile);
|
||||
QMap<QString, CMakeUiCodeModelSupport *>::iterator it
|
||||
QMap<QString, QtSupport::UiCodeModelSupport *>::iterator it
|
||||
= oldCodeModelSupport.find(uiFile);
|
||||
if (it != oldCodeModelSupport.end()) {
|
||||
// qDebug()<<"updated old codemodelsupport";
|
||||
CMakeUiCodeModelSupport *cms = it.value();
|
||||
QtSupport::UiCodeModelSupport *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);
|
||||
QtSupport::UiCodeModelSupport *cms = new QtSupport::UiCodeModelSupport(modelManager, this, uiFile, uiHeaderFilePath);
|
||||
m_uiCodeModelSupport.insert(uiFile, cms);
|
||||
modelManager->addEditorSupport(cms);
|
||||
}
|
||||
@@ -821,7 +802,7 @@ void CMakeProject::createUiCodeModelSupport()
|
||||
}
|
||||
|
||||
// Remove old
|
||||
QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it, end;
|
||||
QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it, end;
|
||||
end = oldCodeModelSupport.constEnd();
|
||||
for (it = oldCodeModelSupport.constBegin(); it!=end; ++it) {
|
||||
modelManager->removeEditorSupport(it.value());
|
||||
@@ -832,7 +813,7 @@ void CMakeProject::createUiCodeModelSupport()
|
||||
void CMakeProject::updateCodeModelSupportFromEditor(const QString &uiFileName,
|
||||
const QString &contents)
|
||||
{
|
||||
const QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it =
|
||||
const QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it =
|
||||
m_uiCodeModelSupport.constFind(uiFileName);
|
||||
if (it != m_uiCodeModelSupport.constEnd())
|
||||
it.value()->updateFromEditor(contents);
|
||||
@@ -885,7 +866,7 @@ void CMakeProject::buildStateChanged(ProjectExplorer::Project *project)
|
||||
{
|
||||
if (project == 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();
|
||||
for (it = m_uiCodeModelSupport.constBegin(); it != end; ++it) {
|
||||
it.value()->updateFromBuild();
|
||||
|
||||
@@ -52,13 +52,13 @@ class QFileSystemWatcher;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer { class Target; }
|
||||
namespace QtSupport { class UiCodeModelSupport; }
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class CMakeFile;
|
||||
class CMakeBuildSettingsWidget;
|
||||
class CMakeUiCodeModelSupport;
|
||||
|
||||
struct CMakeBuildTarget
|
||||
{
|
||||
@@ -97,8 +97,6 @@ public:
|
||||
QString shadowBuildDirectory(const QString &projectFilePath, const ProjectExplorer::Kit *k,
|
||||
const QString &bcName);
|
||||
|
||||
QString uicCommand() const;
|
||||
|
||||
bool isProjectFile(const QString &fileName);
|
||||
|
||||
bool parseCMakeLists();
|
||||
@@ -139,7 +137,6 @@ private:
|
||||
QString m_fileName;
|
||||
CMakeFile *m_file;
|
||||
QString m_projectName;
|
||||
QString m_uicCommand;
|
||||
|
||||
// TODO probably need a CMake specific node structure
|
||||
CMakeProjectNode *m_rootNode;
|
||||
@@ -149,7 +146,7 @@ private:
|
||||
QSet<QString> m_watchedFiles;
|
||||
QFuture<void> m_codeModelFuture;
|
||||
|
||||
QMap<QString, CMakeUiCodeModelSupport *> m_uiCodeModelSupport;
|
||||
QMap<QString, QtSupport::UiCodeModelSupport *> m_uiCodeModelSupport;
|
||||
Core::IEditor *m_lastEditor;
|
||||
bool m_dirtyUic;
|
||||
};
|
||||
|
||||
@@ -12,7 +12,6 @@ HEADERS = cmakeproject.h \
|
||||
cmakeeditorfactory.h \
|
||||
cmakeeditor.h \
|
||||
cmakehighlighter.h \
|
||||
cmakeuicodemodelsupport.h \
|
||||
cmakelocatorfilter.h \
|
||||
cmakefilecompletionassist.h \
|
||||
cmakevalidator.h
|
||||
@@ -28,7 +27,6 @@ SOURCES = cmakeproject.cpp \
|
||||
cmakeeditorfactory.cpp \
|
||||
cmakeeditor.cpp \
|
||||
cmakehighlighter.cpp \
|
||||
cmakeuicodemodelsupport.cpp \
|
||||
cmakelocatorfilter.cpp \
|
||||
cmakefilecompletionassist.cpp \
|
||||
cmakevalidator.cpp
|
||||
|
||||
@@ -46,8 +46,6 @@ QtcPlugin {
|
||||
"cmakeprojectplugin.h",
|
||||
"cmakerunconfiguration.cpp",
|
||||
"cmakerunconfiguration.h",
|
||||
"cmakeuicodemodelsupport.cpp",
|
||||
"cmakeuicodemodelsupport.h",
|
||||
"cmakevalidator.cpp",
|
||||
"cmakevalidator.h",
|
||||
"makestep.cpp",
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user