Commit cae96802 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.documentController: keep track of the current Qt Version

Keeping track of the Qt Version and its binary path

Change-Id: I885880dd6ad45ea1fab7785cb043da1abd5aded3
Reviewed-on: http://codereview.qt.nokia.com/418

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent 85628119
......@@ -23,5 +23,8 @@ will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license>
<dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"TextEditor\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"QmlJSEditor\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"QmlProjectManager\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"Qt4ProjectManager\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"ProjectExplorer\" version=\"$$QTCREATOR_VERSION\"/>
</dependencyList>
</plugin>
......@@ -81,6 +81,13 @@
#include <QtGui/QPlainTextEdit>
#include <QtGui/QApplication>
#include <projectexplorer/projectexplorer.h>
#include <qt4projectmanager/qt4project.h>
#include <qt4projectmanager/qt4target.h>
#include <qtsupport/qtversionmanager.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <qmlprojectmanager/qmlprojectrunconfiguration.h>
enum {
debug = false
};
......@@ -113,7 +120,7 @@ public:
QUrl searchPath;
bool documentLoaded;
bool syncBlocked;
int qt_versionId;
};
/**
......@@ -128,6 +135,10 @@ DesignDocumentController::DesignDocumentController(QObject *parent) :
{
m_d->documentLoaded = false;
m_d->syncBlocked = false;
ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
connect(projectExplorer, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)), this, SLOT(activeQtVersionChanged()));
activeQtVersionChanged();
}
DesignDocumentController::~DesignDocumentController()
......@@ -162,9 +173,9 @@ void DesignDocumentController::detachNodeInstanceView()
void DesignDocumentController::attachNodeInstanceView()
{
if (m_d->nodeInstanceView)
if (m_d->nodeInstanceView) {
model()->attachView(m_d->nodeInstanceView.data());
}
}
QWidget *DesignDocumentController::centralWidget() const
......@@ -172,6 +183,14 @@ QWidget *DesignDocumentController::centralWidget() const
return qobject_cast<QWidget*>(parent());
}
QString DesignDocumentController::pathToQt() const
{
QtSupport::BaseQtVersion *activeQtVersion = QtSupport::QtVersionManager::instance()->version(m_d->qt_versionId);
if (activeQtVersion && (activeQtVersion->qtVersion().majorVersion > 3) && (activeQtVersion->supportsTargetId(Qt4ProjectManager::Constants::QT_SIMULATOR_TARGET_ID) || activeQtVersion->supportsTargetId(Qt4ProjectManager::Constants::DESKTOP_TARGET_ID)))
return activeQtVersion->versionInfo().value("QT_INSTALL_DATA");
return QString();
}
/*!
Returns whether the model is automatically updated if the text editor changes.
*/
......@@ -199,6 +218,7 @@ void DesignDocumentController::blockModelSync(bool block)
detachNodeInstanceView();
m_d->textModifier->deactivateChangeSignals();
} else {
activeQtVersionChanged();
QmlModelState state;
//We go back to base state (and back again) to avoid side effects from text editing.
if (m_d->statesEditorView && m_d->statesEditorView->model()) {
......@@ -756,6 +776,56 @@ void DesignDocumentController::redo()
m_d->textEdit->redo();
}
static inline QtSupport::BaseQtVersion *getActiveQtVersion(DesignDocumentController *controller)
{
ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
ProjectExplorer::Project *currentProject = projectExplorer->currentProject();
if (!currentProject)
return 0;
controller->disconnect(controller, SLOT(activeQtVersionChanged()));
controller->connect(projectExplorer, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)), controller, SLOT(activeQtVersionChanged()));
controller->connect(currentProject, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), controller, SLOT(activeQtVersionChanged()));
ProjectExplorer::Target *target = currentProject->activeTarget();
if (!target)
return 0;
ProjectExplorer::RunConfiguration *runConfiguration = target->activeRunConfiguration();
QmlProjectManager::QmlProjectRunConfiguration *qmlRunConfiguration = qobject_cast<QmlProjectManager::QmlProjectRunConfiguration* >(runConfiguration);
if (qmlRunConfiguration) {
controller->connect(target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)), controller, SLOT(activeQtVersionChanged()));
return qmlRunConfiguration->qtVersion();
}
Qt4ProjectManager::Qt4BuildConfiguration *activeBuildConfiguration = qobject_cast<Qt4ProjectManager::Qt4BuildConfiguration *>(target->activeBuildConfiguration());
if (activeBuildConfiguration) {
controller->connect(target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)), controller, SLOT(activeQtVersionChanged()));
return activeBuildConfiguration->qtVersion();
}
return 0;
}
void DesignDocumentController::activeQtVersionChanged()
{
QtSupport::BaseQtVersion *newQtVersion = getActiveQtVersion(this);
if (!newQtVersion ) {
m_d->qt_versionId = -1;
return;
}
m_d->qt_versionId = newQtVersion->uniqueId();
}
#ifdef ENABLE_TEXT_VIEW
void DesignDocumentController::showText()
{
......
......@@ -122,6 +122,7 @@ public slots:
void selectAll();
void undo();
void redo();
void activeQtVersionChanged();
#ifdef ENABLE_TEXT_VIEW
void showText();
......@@ -136,6 +137,8 @@ private:
void detachNodeInstanceView();
void attachNodeInstanceView();
QWidget *centralWidget() const;
QString pathToQt() const;
class DesignDocumentControllerPrivate *m_d;
};
......
......@@ -4,3 +4,6 @@ include(../../libs/qmleditorwidgets/qmleditorwidgets.pri)
include(../coreplugin/coreplugin.pri)
include(../texteditor/texteditor.pri)
include(../qmljseditor/qmljseditor.pri)
include(../qt4projectmanager/qt4projectmanager.pri)
include(../qmlprojectmanager/qmlprojectmanager.pri)
include(../projectexplorer/projectexplorer.pri)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment