2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "qt4projectmanager.h"
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "qt4projectmanagerconstants.h"
|
|
|
|
|
#include "qt4projectmanagerplugin.h"
|
|
|
|
|
#include "qt4nodes.h"
|
|
|
|
|
#include "qt4project.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "qt4target.h"
|
2011-04-13 13:54:15 +02:00
|
|
|
#include "profileeditor.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "qmakestep.h"
|
2009-12-08 13:09:16 +01:00
|
|
|
#include "qt4buildconfiguration.h"
|
2011-04-13 13:54:15 +02:00
|
|
|
#include "addlibrarywizard.h"
|
2011-02-06 16:23:02 +01:00
|
|
|
#include "wizards/qtquickapp.h"
|
2011-02-06 19:32:39 +01:00
|
|
|
#include "wizards/html5app.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-20 11:52:04 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/basefilewizard.h>
|
2011-09-05 16:10:37 +02:00
|
|
|
#include <coreplugin/id.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2011-01-10 16:29:06 +01:00
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
2010-12-08 12:03:33 +01:00
|
|
|
#include <coreplugin/variablemanager.h>
|
2010-03-17 17:45:33 +01:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2009-01-14 15:08:46 +01:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2009-09-25 11:35:44 +02:00
|
|
|
#include <projectexplorer/session.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <projectexplorer/project.h>
|
2009-01-14 15:08:46 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2011-10-28 10:15:04 +00:00
|
|
|
#include <projectexplorer/toolchainmanager.h>
|
|
|
|
|
#include <projectexplorer/toolchain.h>
|
2009-12-08 12:48:43 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2011-05-20 21:40:53 +02:00
|
|
|
#include <qtsupport/profilereader.h>
|
2011-10-28 10:15:04 +00:00
|
|
|
#include <qtsupport/baseqtversion.h>
|
|
|
|
|
#include <qtsupport/qtversionmanager.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QVariant>
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QMessageBox>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace Qt4ProjectManager;
|
|
|
|
|
using namespace Qt4ProjectManager::Internal;
|
|
|
|
|
|
|
|
|
|
using ProjectExplorer::BuildStep;
|
|
|
|
|
using ProjectExplorer::FileType;
|
|
|
|
|
using ProjectExplorer::HeaderType;
|
|
|
|
|
using ProjectExplorer::SourceType;
|
|
|
|
|
using ProjectExplorer::FormType;
|
|
|
|
|
using ProjectExplorer::ResourceType;
|
|
|
|
|
using ProjectExplorer::UnknownFileType;
|
|
|
|
|
|
2011-05-10 15:19:38 +02:00
|
|
|
static const char kInstallBins[] = "CurrentProject:QT_INSTALL_BINS";
|
2011-02-10 20:58:17 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// Known file types of a Qt 4 project
|
2009-01-16 16:30:22 +01:00
|
|
|
static const char* qt4FileTypes[] = {
|
|
|
|
|
"CppHeaderFiles",
|
|
|
|
|
"CppSourceFiles",
|
|
|
|
|
"Qt4FormFiles",
|
|
|
|
|
"Qt4ResourceFiles"
|
|
|
|
|
};
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-01-10 16:29:06 +01:00
|
|
|
// Test for form editor (loosely coupled)
|
|
|
|
|
static inline bool isFormWindowEditor(const QObject *o)
|
|
|
|
|
{
|
|
|
|
|
return o && !qstrcmp(o->metaObject()->className(), "Designer::FormWindowEditor");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return contents of form editor (loosely coupled)
|
|
|
|
|
static inline QString formWindowEditorContents(const QObject *editor)
|
|
|
|
|
{
|
|
|
|
|
const QVariant contentV = editor->property("contents");
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(contentV.isValid(), return QString());
|
2011-01-10 16:29:06 +01:00
|
|
|
return contentV.toString();
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-20 15:31:33 +01:00
|
|
|
Qt4Manager::Qt4Manager(Qt4ProjectManagerPlugin *plugin)
|
2009-12-08 12:48:43 +01:00
|
|
|
: m_plugin(plugin),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_contextProject(0),
|
2009-05-12 14:12:20 +02:00
|
|
|
m_lastEditor(0),
|
|
|
|
|
m_dirty(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4Manager::~Qt4Manager()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 18:14:06 +01:00
|
|
|
void Qt4Manager::registerProject(Qt4Project *project)
|
|
|
|
|
{
|
|
|
|
|
m_projects.append(project);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Manager::unregisterProject(Qt4Project *project)
|
|
|
|
|
{
|
|
|
|
|
m_projects.removeOne(project);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Manager::notifyChanged(const QString &name)
|
|
|
|
|
{
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (Qt4Project *pro, m_projects)
|
2008-12-02 18:14:06 +01:00
|
|
|
pro->notifyChanged(name);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Qt4Manager::init()
|
|
|
|
|
{
|
2009-05-12 14:12:20 +02:00
|
|
|
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*)));
|
2010-12-08 12:03:33 +01:00
|
|
|
|
2011-02-10 20:58:17 +01:00
|
|
|
Core::VariableManager *vm = Core::VariableManager::instance();
|
2011-12-21 11:29:35 +01:00
|
|
|
vm->registerVariable(kInstallBins,
|
2012-01-20 16:23:06 +01:00
|
|
|
tr("Full path to the bin directory of the current project's Qt version."));
|
2011-12-21 11:29:35 +01:00
|
|
|
connect(vm, SIGNAL(variableUpdateRequested(QByteArray)),
|
|
|
|
|
this, SLOT(updateVariable(QByteArray)));
|
2011-10-28 10:15:04 +00:00
|
|
|
|
|
|
|
|
QSettings *settings = Core::ICore::instance()->settings();
|
|
|
|
|
settings->beginGroup("Qt4ProjectManager");
|
|
|
|
|
m_unConfiguredVersionId = settings->value("QtVersionId", -1).toInt();
|
|
|
|
|
m_unconfiguredToolChainId = settings->value("ToolChainId", QString()).toString();
|
|
|
|
|
settings->endGroup();
|
2009-05-12 14:12:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Manager::editorChanged(Core::IEditor *editor)
|
|
|
|
|
{
|
|
|
|
|
// Handle old editor
|
2011-01-10 16:29:06 +01:00
|
|
|
if (isFormWindowEditor(m_lastEditor)) {
|
|
|
|
|
disconnect(m_lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged()));
|
2009-05-12 14:12:20 +02:00
|
|
|
|
|
|
|
|
if (m_dirty) {
|
2011-01-10 16:29:06 +01:00
|
|
|
const QString contents = formWindowEditorContents(m_lastEditor);
|
2009-05-12 14:12:20 +02:00
|
|
|
foreach(Qt4Project *project, m_projects)
|
2012-02-14 16:43:51 +01:00
|
|
|
project->rootQt4ProjectNode()->updateCodeModelSupportFromEditor(m_lastEditor->document()->fileName(), contents);
|
2009-05-12 14:12:20 +02:00
|
|
|
m_dirty = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_lastEditor = editor;
|
|
|
|
|
|
|
|
|
|
// Handle new editor
|
2011-01-10 16:29:06 +01:00
|
|
|
if (isFormWindowEditor(m_lastEditor))
|
|
|
|
|
connect(m_lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged()));
|
2009-05-12 14:12:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Manager::editorAboutToClose(Core::IEditor *editor)
|
|
|
|
|
{
|
|
|
|
|
if (m_lastEditor == editor) {
|
|
|
|
|
// Oh no our editor is going to be closed
|
|
|
|
|
// get the content first
|
2011-01-10 16:29:06 +01:00
|
|
|
if (isFormWindowEditor(m_lastEditor)) {
|
|
|
|
|
disconnect(m_lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged()));
|
2009-05-12 14:12:20 +02:00
|
|
|
if (m_dirty) {
|
2011-01-10 16:29:06 +01:00
|
|
|
const QString contents = formWindowEditorContents(m_lastEditor);
|
2009-05-12 14:12:20 +02:00
|
|
|
foreach(Qt4Project *project, m_projects)
|
2012-02-14 16:43:51 +01:00
|
|
|
project->rootQt4ProjectNode()->updateCodeModelSupportFromEditor(m_lastEditor->document()->fileName(), contents);
|
2009-05-12 14:12:20 +02:00
|
|
|
m_dirty = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_lastEditor = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-21 11:29:35 +01:00
|
|
|
void Qt4Manager::updateVariable(const QByteArray &variable)
|
2010-12-08 12:03:33 +01:00
|
|
|
{
|
2011-12-21 11:29:35 +01:00
|
|
|
if (variable == kInstallBins) {
|
2012-01-24 18:57:39 +01:00
|
|
|
Qt4Project *qt4pro = qobject_cast<Qt4Project *>(ProjectExplorer::ProjectExplorerPlugin::currentProject());
|
2010-12-08 12:03:33 +01:00
|
|
|
if (!qt4pro) {
|
2011-12-21 11:29:35 +01:00
|
|
|
Core::VariableManager::instance()->remove(kInstallBins);
|
2010-12-08 12:03:33 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2011-05-04 13:14:46 +02:00
|
|
|
QString value;
|
2012-03-13 09:26:30 +01:00
|
|
|
const QtSupport::BaseQtVersion *qtv = 0;
|
2011-10-28 10:15:04 +00:00
|
|
|
if (Qt4BaseTarget *t = qt4pro->activeTarget()) {
|
|
|
|
|
if (Qt4BuildConfiguration *bc = t->activeQt4BuildConfiguration())
|
|
|
|
|
qtv = bc->qtVersion();
|
|
|
|
|
} else {
|
|
|
|
|
qtv = unconfiguredSettings().version;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-04 13:14:46 +02:00
|
|
|
if (qtv)
|
|
|
|
|
value = qtv->versionInfo().value(QLatin1String("QT_INSTALL_BINS"));
|
2011-12-21 11:29:35 +01:00
|
|
|
Core::VariableManager::instance()->insert(kInstallBins, value);
|
2010-12-08 12:03:33 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-12 14:12:20 +02:00
|
|
|
void Qt4Manager::uiEditorContentsChanged()
|
|
|
|
|
{
|
|
|
|
|
// cast sender, get filename
|
2011-01-10 16:29:06 +01:00
|
|
|
if (!m_dirty && isFormWindowEditor(sender()))
|
|
|
|
|
m_dirty = true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Qt4Manager::mimeType() const
|
|
|
|
|
{
|
2009-12-08 12:48:43 +01:00
|
|
|
return QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-04 15:04:44 +01:00
|
|
|
static void updateBoilerPlateCodeFiles(const AbstractMobileApp *app, const QString &proFile)
|
2010-08-27 17:53:02 +02:00
|
|
|
{
|
2011-02-03 19:46:41 +01:00
|
|
|
const QList<AbstractGeneratedFileInfo> updates =
|
2011-02-04 09:47:35 +01:00
|
|
|
app->fileUpdates(proFile);
|
2010-08-27 17:53:02 +02:00
|
|
|
if (!updates.empty()) {
|
2011-02-14 16:36:05 +01:00
|
|
|
const QString title = Qt4Manager::tr("Update of Generated Files");
|
2011-02-04 15:04:44 +01:00
|
|
|
QStringList fileNames;
|
|
|
|
|
foreach (const AbstractGeneratedFileInfo &info, updates)
|
|
|
|
|
fileNames.append(QDir::toNativeSeparators(info.fileInfo.fileName()));
|
|
|
|
|
const QString message =
|
|
|
|
|
Qt4Manager::tr("The following files are either outdated or have been modified:<br><br>%1"
|
|
|
|
|
"<br><br>Do you want Qt Creator to update the files? Any changes will be lost.")
|
|
|
|
|
.arg(fileNames.join(QLatin1String(", ")));
|
2010-08-27 17:53:02 +02:00
|
|
|
if (QMessageBox::question(0, title, message, QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
|
|
|
|
QString error;
|
2011-02-04 09:47:35 +01:00
|
|
|
if (!app->updateFiles(updates, error))
|
2010-08-27 17:53:02 +02:00
|
|
|
QMessageBox::critical(0, title, error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-05 13:47:29 +02:00
|
|
|
ProjectExplorer::Project *Qt4Manager::openProject(const QString &fileName, QString *errorString)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
// TODO Make all file paths relative & remove this hack
|
|
|
|
|
// We convert the path to an absolute one here because qt4project.cpp
|
|
|
|
|
// && profileevaluator use absolute/canonical file paths all over the place
|
|
|
|
|
// Correct fix would be to remove these calls ...
|
|
|
|
|
QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath();
|
|
|
|
|
|
|
|
|
|
if (canonicalFilePath.isEmpty()) {
|
2011-09-05 13:47:29 +02:00
|
|
|
if (errorString)
|
|
|
|
|
*errorString = tr("Failed opening project '%1': Project file does not exist").arg(QDir::toNativeSeparators(fileName));
|
2008-12-02 12:01:29 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (ProjectExplorer::Project *pi, projectExplorer()->session()->projects()) {
|
2012-02-14 16:43:51 +01:00
|
|
|
if (canonicalFilePath == pi->document()->fileName()) {
|
2011-09-05 13:47:29 +02:00
|
|
|
if (errorString)
|
|
|
|
|
*errorString = tr("Failed opening project '%1': Project already open").arg(QDir::toNativeSeparators(canonicalFilePath));
|
2008-12-02 12:01:29 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-06 19:32:39 +01:00
|
|
|
const QtQuickApp qtQuickApp;
|
|
|
|
|
updateBoilerPlateCodeFiles(&qtQuickApp, canonicalFilePath);
|
|
|
|
|
const Html5App html5App;
|
|
|
|
|
updateBoilerPlateCodeFiles(&html5App, canonicalFilePath);
|
2010-08-27 17:53:02 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
Qt4Project *pro = new Qt4Project(this, canonicalFilePath);
|
|
|
|
|
return pro;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::ProjectExplorerPlugin *Qt4Manager::projectExplorer() const
|
|
|
|
|
{
|
2009-12-08 12:48:43 +01:00
|
|
|
return ProjectExplorer::ProjectExplorerPlugin::instance();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::Node *Qt4Manager::contextNode() const
|
|
|
|
|
{
|
|
|
|
|
return m_contextNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Manager::setContextNode(ProjectExplorer::Node *node)
|
|
|
|
|
{
|
|
|
|
|
m_contextNode = node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Manager::setContextProject(ProjectExplorer::Project *project)
|
|
|
|
|
{
|
|
|
|
|
m_contextProject = project;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::Project *Qt4Manager::contextProject() const
|
|
|
|
|
{
|
|
|
|
|
return m_contextProject;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-13 13:54:15 +02:00
|
|
|
void Qt4Manager::addLibrary()
|
|
|
|
|
{
|
|
|
|
|
Core::EditorManager *em = Core::EditorManager::instance();
|
|
|
|
|
ProFileEditorWidget *editor = qobject_cast<ProFileEditorWidget*>(em->currentEditor()->widget());
|
|
|
|
|
if (editor)
|
2012-02-14 16:43:51 +01:00
|
|
|
addLibrary(editor->editorDocument()->fileName(), editor);
|
2011-04-13 13:54:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Manager::addLibraryContextMenu()
|
|
|
|
|
{
|
|
|
|
|
ProjectExplorer::Node *node = ProjectExplorer::ProjectExplorerPlugin::instance()->currentNode();
|
|
|
|
|
if (qobject_cast<Qt4ProFileNode *>(node))
|
|
|
|
|
addLibrary(node->path());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Manager::addLibrary(const QString &fileName, ProFileEditorWidget *editor)
|
|
|
|
|
{
|
|
|
|
|
AddLibraryWizard wizard(fileName, Core::EditorManager::instance());
|
|
|
|
|
if (wizard.exec() != QDialog::Accepted)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
TextEditor::BaseTextEditor *editable = 0;
|
|
|
|
|
if (editor) {
|
|
|
|
|
editable = editor->editor();
|
|
|
|
|
} else {
|
|
|
|
|
Core::EditorManager *em = Core::EditorManager::instance();
|
|
|
|
|
editable = qobject_cast<TextEditor::BaseTextEditor *>
|
|
|
|
|
(em->openEditor(fileName, Qt4ProjectManager::Constants::PROFILE_EDITOR_ID));
|
|
|
|
|
}
|
|
|
|
|
if (!editable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const int endOfDoc = editable->position(TextEditor::ITextEditor::EndOfDoc);
|
|
|
|
|
editable->setCursorPosition(endOfDoc);
|
|
|
|
|
QString snippet = wizard.snippet();
|
|
|
|
|
|
|
|
|
|
// add extra \n in case the last line is not empty
|
|
|
|
|
int line, column;
|
|
|
|
|
editable->convertPosition(endOfDoc, &line, &column);
|
|
|
|
|
if (!editable->textAt(endOfDoc - column, column).simplified().isEmpty())
|
|
|
|
|
snippet = QLatin1Char('\n') + snippet;
|
|
|
|
|
|
|
|
|
|
editable->insert(snippet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Qt4Manager::runQMake()
|
|
|
|
|
{
|
2011-03-11 16:32:02 +01:00
|
|
|
runQMake(projectExplorer()->startupProject(), 0);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Manager::runQMakeContextMenu()
|
|
|
|
|
{
|
2010-01-13 18:00:02 +01:00
|
|
|
runQMake(m_contextProject, m_contextNode);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-13 18:00:02 +01:00
|
|
|
void Qt4Manager::runQMake(ProjectExplorer::Project *p, ProjectExplorer::Node *node)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-09 16:07:45 +02:00
|
|
|
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->saveModifiedFiles())
|
|
|
|
|
return;
|
2009-12-08 13:09:16 +01:00
|
|
|
Qt4Project *qt4pro = qobject_cast<Qt4Project *>(p);
|
|
|
|
|
QTC_ASSERT(qt4pro, return);
|
2010-01-13 18:00:02 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!qt4pro->activeTarget() ||
|
|
|
|
|
!qt4pro->activeTarget()->activeBuildConfiguration())
|
2012-01-17 16:52:32 +01:00
|
|
|
return;
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-08-18 16:46:44 +02:00
|
|
|
Qt4BuildConfiguration *bc = qt4pro->activeTarget()->activeQt4BuildConfiguration();
|
2009-12-08 13:09:16 +01:00
|
|
|
QMakeStep *qs = bc->qmakeStep();
|
2009-10-27 14:16:28 +01:00
|
|
|
|
2009-07-21 15:01:16 +02:00
|
|
|
if (!qs)
|
|
|
|
|
return;
|
2008-12-02 12:01:29 +01:00
|
|
|
//found qmakeStep, now use it
|
2009-07-21 15:01:16 +02:00
|
|
|
qs->setForced(true);
|
2010-01-13 18:00:02 +01:00
|
|
|
|
|
|
|
|
if (node != 0 && node != qt4pro->rootProjectNode())
|
|
|
|
|
if (Qt4ProFileNode *profile = qobject_cast<Qt4ProFileNode *>(node))
|
|
|
|
|
bc->setSubNodeBuild(profile);
|
|
|
|
|
|
2011-11-07 16:16:31 +01:00
|
|
|
projectExplorer()->buildManager()->appendStep(qs, tr("QMake"));
|
2010-01-13 18:00:02 +01:00
|
|
|
bc->setSubNodeBuild(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Manager::buildSubDirContextMenu()
|
2010-04-30 11:50:04 +02:00
|
|
|
{
|
2012-04-30 22:26:20 +03:00
|
|
|
handleSubDirContextMenu(BUILD);
|
2010-04-30 11:50:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Manager::cleanSubDirContextMenu()
|
|
|
|
|
{
|
2012-04-30 22:26:20 +03:00
|
|
|
handleSubDirContextMenu(CLEAN);
|
2010-04-30 11:50:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Manager::rebuildSubDirContextMenu()
|
|
|
|
|
{
|
2012-04-30 22:26:20 +03:00
|
|
|
handleSubDirContextMenu(REBUILD);
|
2010-04-30 11:50:04 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-30 22:26:20 +03:00
|
|
|
void Qt4Manager::handleSubDirContextMenu(Qt4Manager::Action action)
|
2010-01-13 18:00:02 +01:00
|
|
|
{
|
|
|
|
|
Qt4Project *qt4pro = qobject_cast<Qt4Project *>(m_contextProject);
|
|
|
|
|
QTC_ASSERT(qt4pro, return);
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!qt4pro->activeTarget() ||
|
|
|
|
|
!qt4pro->activeTarget()->activeBuildConfiguration())
|
|
|
|
|
return;
|
|
|
|
|
|
2011-08-18 16:46:44 +02:00
|
|
|
Qt4BuildConfiguration *bc = qt4pro->activeTarget()->activeQt4BuildConfiguration();
|
2010-01-13 18:00:02 +01:00
|
|
|
if (m_contextNode != 0 && m_contextNode != qt4pro->rootProjectNode())
|
|
|
|
|
if (Qt4ProFileNode *profile = qobject_cast<Qt4ProFileNode *>(m_contextNode))
|
|
|
|
|
bc->setSubNodeBuild(profile);
|
|
|
|
|
|
2010-04-30 11:50:04 +02:00
|
|
|
if (projectExplorer()->saveModifiedFiles()) {
|
2012-03-15 17:17:40 +01:00
|
|
|
const Core::Id buildStep = Core::Id(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
|
|
|
|
const Core::Id cleanStep = Core::Id(ProjectExplorer::Constants::BUILDSTEPS_CLEAN);
|
2010-07-16 14:00:41 +02:00
|
|
|
if (action == BUILD) {
|
2012-01-13 14:20:45 +01:00
|
|
|
const QString name = ProjectExplorer::ProjectExplorerPlugin::displayNameForStepId(buildStep);
|
|
|
|
|
projectExplorer()->buildManager()->buildList(bc->stepList(buildStep), name);
|
2010-07-16 14:00:41 +02:00
|
|
|
} else if (action == CLEAN) {
|
2012-01-13 14:20:45 +01:00
|
|
|
const QString name = ProjectExplorer::ProjectExplorerPlugin::displayNameForStepId(cleanStep);
|
|
|
|
|
projectExplorer()->buildManager()->buildList(bc->stepList(cleanStep), name);
|
2010-07-16 14:00:41 +02:00
|
|
|
} else if (action == REBUILD) {
|
2011-11-07 16:16:31 +01:00
|
|
|
QStringList names;
|
2012-01-13 14:20:45 +01:00
|
|
|
names << ProjectExplorer::ProjectExplorerPlugin::displayNameForStepId(cleanStep)
|
|
|
|
|
<< ProjectExplorer::ProjectExplorerPlugin::displayNameForStepId(buildStep);
|
2011-11-07 16:16:31 +01:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
QList<ProjectExplorer::BuildStepList *> stepLists;
|
2012-01-13 14:20:45 +01:00
|
|
|
stepLists << bc->stepList(cleanStep) << bc->stepList(buildStep);
|
2011-11-07 16:16:31 +01:00
|
|
|
projectExplorer()->buildManager()->buildLists(stepLists, names);
|
2010-04-30 11:50:04 +02:00
|
|
|
}
|
|
|
|
|
}
|
2010-01-13 18:00:02 +01:00
|
|
|
|
|
|
|
|
bc->setSubNodeBuild(0);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Qt4Manager::fileTypeId(ProjectExplorer::FileType type)
|
|
|
|
|
{
|
|
|
|
|
switch (type) {
|
|
|
|
|
case HeaderType:
|
|
|
|
|
return QLatin1String(qt4FileTypes[0]);
|
|
|
|
|
case SourceType:
|
|
|
|
|
return QLatin1String(qt4FileTypes[1]);
|
|
|
|
|
case FormType:
|
|
|
|
|
return QLatin1String(qt4FileTypes[2]);
|
|
|
|
|
case ResourceType:
|
|
|
|
|
return QLatin1String(qt4FileTypes[3]);
|
|
|
|
|
case UnknownFileType:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
2010-12-08 12:03:33 +01:00
|
|
|
|
2011-10-28 10:15:04 +00:00
|
|
|
UnConfiguredSettings Qt4Manager::unconfiguredSettings() const
|
|
|
|
|
{
|
|
|
|
|
if (m_unConfiguredVersionId == -1 && m_unconfiguredToolChainId.isEmpty()) {
|
|
|
|
|
// Choose a good default qtversion and try to find a toolchain that fit
|
|
|
|
|
QtSupport::BaseQtVersion *version = 0;
|
|
|
|
|
ProjectExplorer::ToolChain *toolChain = 0;
|
|
|
|
|
QList<QtSupport::BaseQtVersion *> versions = QtSupport::QtVersionManager::instance()->validVersions();
|
|
|
|
|
if (!versions.isEmpty()) {
|
|
|
|
|
version = versions.first();
|
|
|
|
|
|
|
|
|
|
foreach (ProjectExplorer::ToolChain *tc, ProjectExplorer::ToolChainManager::instance()->toolChains()) {
|
2012-02-07 18:05:09 +01:00
|
|
|
if (tc->mkspecList().contains(version->mkspec())) {
|
2011-10-28 10:15:04 +00:00
|
|
|
toolChain = tc;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!toolChain) {
|
|
|
|
|
foreach (ProjectExplorer::ToolChain *tc, ProjectExplorer::ToolChainManager::instance()->toolChains()) {
|
|
|
|
|
if (version->qtAbis().contains(tc->targetAbi())) {
|
|
|
|
|
toolChain = tc;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_unConfiguredVersionId = version->uniqueId();
|
2012-03-08 14:35:25 +08:00
|
|
|
if (toolChain)
|
|
|
|
|
m_unconfiguredToolChainId = toolChain->id();
|
2011-10-28 10:15:04 +00:00
|
|
|
}
|
|
|
|
|
UnConfiguredSettings us;
|
|
|
|
|
us.version = version;
|
|
|
|
|
us.toolchain = toolChain;
|
|
|
|
|
return us;
|
|
|
|
|
}
|
|
|
|
|
UnConfiguredSettings us;
|
|
|
|
|
us.version = QtSupport::QtVersionManager::instance()->version(m_unConfiguredVersionId);
|
|
|
|
|
us.toolchain = ProjectExplorer::ToolChainManager::instance()->findToolChain(m_unconfiguredToolChainId);
|
|
|
|
|
return us;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Manager::setUnconfiguredSettings(const UnConfiguredSettings &setting)
|
|
|
|
|
{
|
|
|
|
|
m_unConfiguredVersionId = setting.version ? setting.version->uniqueId() : -1;
|
|
|
|
|
m_unconfiguredToolChainId = setting.toolchain ? setting.toolchain->id() : QString();
|
|
|
|
|
|
|
|
|
|
QSettings *settings = Core::ICore::instance()->settings();
|
|
|
|
|
settings->beginGroup("Qt4ProjectManager");
|
|
|
|
|
settings->setValue("QtVersionId", m_unConfiguredVersionId);
|
|
|
|
|
settings->setValue("ToolChainId", m_unconfiguredToolChainId);
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
|
|
|
|
|
foreach (Qt4Project *pro, m_projects)
|
|
|
|
|
if (pro->targets().isEmpty())
|
|
|
|
|
pro->scheduleAsyncUpdate();
|
|
|
|
|
emit unconfiguredSettingsChanged();
|
|
|
|
|
}
|