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
|
||||
@@ -19,7 +19,6 @@ HEADERS += completionsettingspage.h \
|
||||
cppfindreferences.h \
|
||||
cppcodeformatter.h \
|
||||
symbolsfindfilter.h \
|
||||
uicodecompletionsupport.h \
|
||||
insertionpointlocator.h \
|
||||
cpprefactoringchanges.h \
|
||||
abstracteditorsupport.h \
|
||||
@@ -65,7 +64,6 @@ SOURCES += completionsettingspage.cpp \
|
||||
cppfindreferences.cpp \
|
||||
cppcodeformatter.cpp \
|
||||
symbolsfindfilter.cpp \
|
||||
uicodecompletionsupport.cpp \
|
||||
insertionpointlocator.cpp \
|
||||
cpprefactoringchanges.cpp \
|
||||
cppcompletionassist.cpp \
|
||||
|
||||
@@ -102,8 +102,6 @@ QtcPlugin {
|
||||
"symbolsfindfilter.h",
|
||||
"typehierarchybuilder.cpp",
|
||||
"typehierarchybuilder.h",
|
||||
"uicodecompletionsupport.cpp",
|
||||
"uicodecompletionsupport.h",
|
||||
"builtinindexingsupport.cpp",
|
||||
"builtinindexingsupport.h",
|
||||
"cpppreprocessor.cpp",
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "qt4project.h"
|
||||
#include "qt4projectmanager.h"
|
||||
#include "qt4projectmanagerconstants.h"
|
||||
#include "qtuicodemodelsupport.h"
|
||||
#include "qt4buildconfiguration.h"
|
||||
#include "qmakerunconfigurationfactory.h"
|
||||
|
||||
@@ -50,6 +49,7 @@
|
||||
#include <projectexplorer/target.h>
|
||||
#include <qtsupport/profilereader.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/uicodemodelsupport.h>
|
||||
|
||||
#include <cpptools/cppmodelmanagerinterface.h>
|
||||
#include <cpptools/cpptoolsconstants.h>
|
||||
@@ -1470,7 +1470,7 @@ Qt4ProFileNode::~Qt4ProFileNode()
|
||||
{
|
||||
CppTools::CppModelManagerInterface *modelManager
|
||||
= CppTools::CppModelManagerInterface::instance();
|
||||
QMap<QString, Internal::Qt4UiCodeModelSupport *>::const_iterator it, end;
|
||||
QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it, end;
|
||||
end = m_uiCodeModelSupport.constEnd();
|
||||
for (it = m_uiCodeModelSupport.constBegin(); it != end; ++it) {
|
||||
modelManager->removeEditorSupport(it.value());
|
||||
@@ -2253,7 +2253,7 @@ QString Qt4ProFileNode::buildDir(Qt4BuildConfiguration *bc) const
|
||||
|
||||
void Qt4ProFileNode::updateCodeModelSupportFromBuild()
|
||||
{
|
||||
QMap<QString, Internal::Qt4UiCodeModelSupport *>::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();
|
||||
@@ -2262,7 +2262,7 @@ void Qt4ProFileNode::updateCodeModelSupportFromBuild()
|
||||
void Qt4ProFileNode::updateCodeModelSupportFromEditor(const QString &uiFileName,
|
||||
const QString &contents)
|
||||
{
|
||||
const QMap<QString, Internal::Qt4UiCodeModelSupport *>::const_iterator it =
|
||||
const QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it =
|
||||
m_uiCodeModelSupport.constFind(uiFileName);
|
||||
if (it != m_uiCodeModelSupport.constEnd())
|
||||
it.value()->updateFromEditor(contents);
|
||||
@@ -2295,7 +2295,7 @@ void Qt4ProFileNode::createUiCodeModelSupport()
|
||||
= CppTools::CppModelManagerInterface::instance();
|
||||
|
||||
// First move all to
|
||||
QMap<QString, Internal::Qt4UiCodeModelSupport *> oldCodeModelSupport;
|
||||
QMap<QString, QtSupport::UiCodeModelSupport *> oldCodeModelSupport;
|
||||
oldCodeModelSupport = m_uiCodeModelSupport;
|
||||
m_uiCodeModelSupport.clear();
|
||||
|
||||
@@ -2314,23 +2314,23 @@ void Qt4ProFileNode::createUiCodeModelSupport()
|
||||
const QString uiHeaderFilePath = uiHeaderFile(uiDir, uiFile->path());
|
||||
m_uiHeaderFiles << 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()) {
|
||||
// qDebug()<<"updated old codemodelsupport";
|
||||
Internal::Qt4UiCodeModelSupport *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";
|
||||
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);
|
||||
modelManager->addEditorSupport(cms);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove old
|
||||
QMap<QString, Internal::Qt4UiCodeModelSupport *>::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());
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <qtsupport/uicodemodelsupport.h>
|
||||
|
||||
#include <QHash>
|
||||
#include <QStringList>
|
||||
@@ -126,7 +127,6 @@ using ProjectExplorer::ProjectFileType;
|
||||
using ProjectExplorer::FileType;
|
||||
|
||||
namespace Internal {
|
||||
class Qt4UiCodeModelSupport;
|
||||
class Qt4PriFile;
|
||||
struct InternalNode;
|
||||
}
|
||||
@@ -204,7 +204,7 @@ private:
|
||||
QString m_projectFilePath;
|
||||
QString m_projectDir;
|
||||
|
||||
QMap<QString, Internal::Qt4UiCodeModelSupport *> m_uiCodeModelSupport;
|
||||
QMap<QString, QtSupport::UiCodeModelSupport *> m_uiCodeModelSupport;
|
||||
Internal::Qt4PriFile *m_qt4PriFile;
|
||||
|
||||
// Memory is cheap...
|
||||
|
||||
@@ -53,7 +53,6 @@ HEADERS += \
|
||||
qmakestep.h \
|
||||
qtmodulesinfo.h \
|
||||
qt4projectconfigwidget.h \
|
||||
qtuicodemodelsupport.h \
|
||||
externaleditors.h \
|
||||
qt4buildconfiguration.h \
|
||||
qmakeparser.h \
|
||||
@@ -116,7 +115,6 @@ SOURCES += \
|
||||
qmakestep.cpp \
|
||||
qtmodulesinfo.cpp \
|
||||
qt4projectconfigwidget.cpp \
|
||||
qtuicodemodelsupport.cpp \
|
||||
externaleditors.cpp \
|
||||
qt4buildconfiguration.cpp \
|
||||
qmakeparser.cpp \
|
||||
|
||||
@@ -82,8 +82,6 @@ QtcPlugin {
|
||||
"qt4targetsetupwidget.h",
|
||||
"qtmodulesinfo.cpp",
|
||||
"qtmodulesinfo.h",
|
||||
"qtuicodemodelsupport.cpp",
|
||||
"qtuicodemodelsupport.h",
|
||||
"unconfiguredprojectpanel.cpp",
|
||||
"unconfiguredprojectpanel.h",
|
||||
"winceqtversion.cpp",
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
virtual Utils::Environment qmakeRunEnvironment() const;
|
||||
|
||||
virtual Utils::FileName sourcePath() const;
|
||||
// used by QtUiCodeModelSupport
|
||||
// used by UiCodeModelSupport
|
||||
virtual QString uicCommand() const;
|
||||
virtual QString designerCommand() const;
|
||||
virtual QString linguistCommand() const;
|
||||
|
||||
@@ -14,6 +14,7 @@ HEADERS += \
|
||||
qtoutputformatter.h \
|
||||
qtversionmanager.h \
|
||||
qtversionfactory.h \
|
||||
uicodemodelsupport.h \
|
||||
baseqtversion.h \
|
||||
qmldumptool.h \
|
||||
qmlobservertool.h \
|
||||
@@ -39,6 +40,7 @@ SOURCES += \
|
||||
qtoutputformatter.cpp \
|
||||
qtversionmanager.cpp \
|
||||
qtversionfactory.cpp \
|
||||
uicodemodelsupport.cpp \
|
||||
baseqtversion.cpp \
|
||||
qmldumptool.cpp \
|
||||
qmlobservertool.cpp \
|
||||
|
||||
@@ -10,6 +10,7 @@ QtcPlugin {
|
||||
Depends { name: "ProjectExplorer" }
|
||||
Depends { name: "TextEditor" }
|
||||
Depends { name: "QmlJS" }
|
||||
Depends { name: "CppTools" }
|
||||
|
||||
cpp.includePaths: base.concat([
|
||||
"../../shared",
|
||||
@@ -94,6 +95,8 @@ QtcPlugin {
|
||||
"qtsupportconstants.h",
|
||||
"qtsupportplugin.cpp",
|
||||
"qtsupportplugin.h",
|
||||
"qtuicodemodelsupport.cpp",
|
||||
"qtuicodemodelsupport.h",
|
||||
"qtversionfactory.cpp",
|
||||
"qtversionfactory.h",
|
||||
"qtversioninfo.ui",
|
||||
|
||||
@@ -4,6 +4,7 @@ QTC_LIB_DEPENDS += \
|
||||
utils
|
||||
QTC_PLUGIN_DEPENDS += \
|
||||
coreplugin \
|
||||
cpptools \
|
||||
projectexplorer \
|
||||
texteditor
|
||||
DEFINES *= \
|
||||
|
||||
@@ -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 <QFileInfo>
|
||||
|
||||
enum { debug = 0 };
|
||||
|
||||
using namespace CppTools;
|
||||
using namespace CPlusPlus;
|
||||
|
||||
UiCodeModelSupport::UiCodeModelSupport(CppModelManagerInterface *modelmanager,
|
||||
namespace QtSupport {
|
||||
|
||||
UiCodeModelSupport::UiCodeModelSupport(CppTools::CppModelManagerInterface *modelmanager,
|
||||
ProjectExplorer::Project *project,
|
||||
const QString &source,
|
||||
const QString &uiHeaderFile)
|
||||
: AbstractEditorSupport(modelmanager),
|
||||
: CppTools::AbstractEditorSupport(modelmanager),
|
||||
m_project(project),
|
||||
m_sourceName(source),
|
||||
m_fileName(uiHeaderFile),
|
||||
m_state(BARE)
|
||||
@@ -178,34 +186,6 @@ void UiCodeModelSupport::updateFromEditor(const QString &formEditorContents)
|
||||
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()
|
||||
{
|
||||
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
|
||||
@@ -27,42 +27,52 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef UICODEMODELSUPPORT_H
|
||||
#define UICODEMODELSUPPORT_H
|
||||
|
||||
#ifndef UICODECOMPLETIONSUPPORT_H
|
||||
#define UICODECOMPLETIONSUPPORT_H
|
||||
#include "qtsupport_global.h"
|
||||
|
||||
#include "cpptools_global.h"
|
||||
#include "abstracteditorsupport.h"
|
||||
#include "cppmodelmanagerinterface.h"
|
||||
#include <cpptools/abstracteditorsupport.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#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
|
||||
|
||||
public:
|
||||
UiCodeModelSupport(CppTools::CppModelManagerInterface *modelmanager,
|
||||
ProjectExplorer::Project *project,
|
||||
const QString &sourceFile,
|
||||
const QString &uiHeaderFile);
|
||||
~UiCodeModelSupport();
|
||||
|
||||
void setFileName(const QString &name);
|
||||
void setSourceName(const QString &name);
|
||||
virtual QByteArray contents() const;
|
||||
virtual QString fileName() const;
|
||||
QByteArray contents() const;
|
||||
QString fileName() const;
|
||||
void updateFromEditor(const QString &formEditorContents);
|
||||
void updateFromBuild();
|
||||
protected:
|
||||
virtual QString uicCommand() const = 0;
|
||||
virtual QStringList environment() const = 0;
|
||||
|
||||
private:
|
||||
QString uicCommand() const;
|
||||
QStringList environment() const;
|
||||
|
||||
private slots:
|
||||
bool finishProcess() const;
|
||||
|
||||
private:
|
||||
ProjectExplorer::Project *m_project;
|
||||
enum State { BARE, RUNNING, FINISHED };
|
||||
|
||||
void init() const;
|
||||
bool runUic(const QString &ui) const;
|
||||
Q_SLOT bool finishProcess() const;
|
||||
mutable QProcess m_process;
|
||||
QString m_sourceName;
|
||||
QString m_fileName;
|
||||
@@ -72,6 +82,6 @@ private:
|
||||
static QList<UiCodeModelSupport *> m_waitingForStart;
|
||||
};
|
||||
|
||||
} // CppTools
|
||||
} // QtSupport
|
||||
|
||||
#endif // UICODECOMPLETIONSUPPORT_H
|
||||
#endif // UICODEMODELSUPPORT_H
|
||||
Reference in New Issue
Block a user