Commit 94d13080 authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Exchange pathToQt with Kit

Change-Id: If21d3c55ec62d22c3bdb623ecd21def276ef383d
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent fbb36843
......@@ -44,6 +44,7 @@
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <projectexplorer/session.h>
#include <projectexplorer/kit.h>
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtsupportconstants.h>
#include <qtsupport/qtversionmanager.h>
......@@ -74,7 +75,7 @@ DesignDocument::DesignDocument(QObject *parent) :
m_subComponentManager(new SubComponentManager(m_documentModel.data(), this)),
m_rewriterView (new RewriterView(RewriterView::Amend, m_documentModel.data())),
m_documentLoaded(false),
m_qtVersionId(-1)
m_currentKit(0)
{
}
......@@ -100,17 +101,6 @@ QWidget *DesignDocument::centralWidget() const
return qobject_cast<QWidget*>(parent());
}
QString DesignDocument::pathToQt() const
{
QtSupport::BaseQtVersion *activeQtVersion = QtSupport::QtVersionManager::version(m_qtVersionId);
if (activeQtVersion && (activeQtVersion->qtVersion() >= QtSupport::QtVersionNumber(4, 7, 1))
&& (activeQtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)
|| activeQtVersion->type() == QLatin1String(QtSupport::Constants::SIMULATORQT)))
return activeQtVersion->qmakeProperty("QT_INSTALL_DATA");
return QString();
}
const ViewManager &DesignDocument::viewManager() const
{
return QmlDesignerPlugin::instance()->viewManager();
......@@ -221,9 +211,9 @@ QString DesignDocument::fileName() const
return editor()->document()->filePath();
}
int DesignDocument::qtVersionId() const
ProjectExplorer::Kit *DesignDocument::currentKit() const
{
return m_qtVersionId;
return m_currentKit;
}
bool DesignDocument::isDocumentLoaded() const
......@@ -646,7 +636,7 @@ static bool isFileInProject(DesignDocument *designDocument, ProjectExplorer::Pro
return false;
}
static inline QtSupport::BaseQtVersion *getActiveQtVersion(DesignDocument *designDocument)
static inline ProjectExplorer::Kit *getActiveKit(DesignDocument *designDocument)
{
ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
ProjectExplorer::Project *currentProject = projectExplorer->currentProject();
......@@ -672,24 +662,14 @@ static inline QtSupport::BaseQtVersion *getActiveQtVersion(DesignDocument *desig
return 0;
designDocument->connect(target, SIGNAL(kitChanged()), designDocument, SLOT(updateActiveQtVersion()));
return QtSupport::QtKitInformation::qtVersion(target->kit());
return target->kit();
}
void DesignDocument::updateActiveQtVersion()
{
QtSupport::BaseQtVersion *newQtVersion = getActiveQtVersion(this);
if (!newQtVersion ) {
m_qtVersionId = -1;
return;
}
if (m_qtVersionId == newQtVersion->uniqueId())
return;
m_qtVersionId = newQtVersion->uniqueId();
viewManager().setNodeInstanceViewQtPath(pathToQt());
m_currentKit = getActiveKit(this);
viewManager().setNodeInstanceViewKit(m_currentKit);
}
QString DesignDocument::contextHelpId() const
......
......@@ -50,6 +50,10 @@ class QPlainTextEdit;
class QDeclarativeError;
QT_END_NAMESPACE
namespace ProjectExplorer {
class Kit;
}
namespace QmlDesigner {
class ModelNode;
......@@ -92,7 +96,7 @@ public:
TextEditor::ITextEditor *textEditor() const;
QPlainTextEdit *plainTextEdit() const;
QString fileName() const;
int qtVersionId() const; // maybe that is not working, because the id should be not cached!!!
ProjectExplorer::Kit *currentKit() const;
bool isDocumentLoaded() const;
void resetToDocumentModel();
......@@ -151,7 +155,7 @@ private: // variables
QScopedPointer<RewriterView> m_rewriterView;
bool m_documentLoaded;
int m_qtVersionId;
ProjectExplorer::Kit *m_currentKit;
};
} // namespace QmlDesigner
......
......@@ -51,6 +51,10 @@ class QFileSystemWatcher;
class QPainter;
QT_END_NAMESPACE
namespace ProjectExplorer {
class Kit;
}
namespace QmlDesigner {
class NodeInstanceServerInterface;
......@@ -144,7 +148,7 @@ public:
QImage statePreviewImage(const ModelNode &stateNode) const;
void setPathToQt(const QString &pathToQt);
void setKit(ProjectExplorer::Kit *kit);
void sendToken(const QString &token, int number, const QVector<ModelNode> &nodeVector);
......@@ -212,7 +216,7 @@ private: //variables
QImage m_baseStatePreviewImage;
QTime m_lastCrashTime;
NodeInstanceServerInterface::RunModus m_runModus;
QString m_pathToQt;
ProjectExplorer::Kit *m_currentKit;
};
} // namespace ProxyNodeInstanceView
......
......@@ -34,6 +34,10 @@
#include <QWidgetAction>
namespace ProjectExplorer {
class Kit;
}
namespace QmlDesigner {
class DesignDocument;
......@@ -63,7 +67,7 @@ public:
void setItemLibraryViewResourcePath(const QString &resourcePath);
void setComponentNode(const ModelNode &componentNode);
void setComponentViewToMaster();
void setNodeInstanceViewQtPath(const QString & qtPath);
void setNodeInstanceViewKit(ProjectExplorer::Kit *kit);
void resetPropertyEditorView();
......
......@@ -77,6 +77,10 @@
#include <coreplugin/icore.h>
#include <utils/hostosinfo.h>
#include <projectexplorer/kit.h>
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtsupportconstants.h>
#include <QMessageBox>
......@@ -157,7 +161,18 @@ bool NodeInstanceServerProxy::checkPuppetVersion(const QString &qmlPuppetPath)
return canConvert && versionNumber == 2;
}
NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceView, RunModus runModus, const QString &pathToQt)
static QString getPathToQt(ProjectExplorer::Kit *kit)
{
QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitInformation::qtVersion(kit);
if (currentQtVersion && (currentQtVersion->qtVersion() >= QtSupport::QtVersionNumber(4, 7, 1))
&& (currentQtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)
|| currentQtVersion->type() == QLatin1String(QtSupport::Constants::SIMULATORQT)))
return currentQtVersion->qmakeProperty("QT_INSTALL_DATA");
return QString();
}
NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceView, RunModus runModus, ProjectExplorer::Kit *kit)
: NodeInstanceServerInterface(nodeInstanceView),
m_localServer(new QLocalServer(this)),
m_nodeInstanceView(nodeInstanceView),
......@@ -171,6 +186,8 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
m_runModus(runModus),
m_synchronizeId(-1)
{
QString pathToQt = getPathToQt(kit);
QString applicationPath = pathToQt + QLatin1String("/bin");
if (runModus == TestModus) {
applicationPath = QCoreApplication::applicationDirPath()
......
......@@ -42,6 +42,10 @@ class QLocalSocket;
class QProcess;
QT_END_NAMESPACE
namespace ProjectExplorer {
class Kit;
}
namespace QmlDesigner {
class NodeInstanceClientInterface;
......@@ -52,7 +56,7 @@ class NodeInstanceServerProxy : public NodeInstanceServerInterface
{
Q_OBJECT
public:
explicit NodeInstanceServerProxy(NodeInstanceView *nodeInstanceView, RunModus runModus = NormalModus, const QString &pathToQt = QString());
explicit NodeInstanceServerProxy(NodeInstanceView *nodeInstanceView, RunModus runModus = NormalModus, ProjectExplorer::Kit *kit = 0);
~NodeInstanceServerProxy();
void createInstances(const CreateInstancesCommand &command);
void changeFileUrl(const ChangeFileUrlCommand &command);
......
......@@ -102,7 +102,8 @@ namespace QmlDesigner {
NodeInstanceView::NodeInstanceView(QObject *parent, NodeInstanceServerInterface::RunModus runModus)
: AbstractView(parent),
m_baseStatePreviewImage(QSize(100, 100), QImage::Format_ARGB32),
m_runModus(runModus)
m_runModus(runModus),
m_currentKit(0)
{
m_baseStatePreviewImage.fill(0xFFFFFF);
}
......@@ -115,6 +116,7 @@ NodeInstanceView::~NodeInstanceView()
{
removeAllInstanceNodeRelationships();
delete nodeInstanceServer();
m_currentKit = 0;
}
//\{
......@@ -148,7 +150,7 @@ bool isSkippedNode(const ModelNode &node)
void NodeInstanceView::modelAttached(Model *model)
{
AbstractView::modelAttached(model);
m_nodeInstanceServer = new NodeInstanceServerProxy(this, m_runModus, m_pathToQt);
m_nodeInstanceServer = new NodeInstanceServerProxy(this, m_runModus, m_currentKit);
m_lastCrashTime.start();
connect(m_nodeInstanceServer.data(), SIGNAL(processCrashed()), this, SLOT(handleChrash()));
......@@ -193,7 +195,7 @@ void NodeInstanceView::restartProcess()
if (model()) {
delete nodeInstanceServer();
m_nodeInstanceServer = new NodeInstanceServerProxy(this, m_runModus, m_pathToQt);
m_nodeInstanceServer = new NodeInstanceServerProxy(this, m_runModus, m_currentKit);
connect(m_nodeInstanceServer.data(), SIGNAL(processCrashed()), this, SLOT(handleChrash()));
if (!isSkippedRootNode(rootModelNode()))
......@@ -1111,10 +1113,10 @@ QImage NodeInstanceView::statePreviewImage(const ModelNode &stateNode) const
return m_statePreviewImage.value(stateNode);
}
void NodeInstanceView::setPathToQt(const QString &pathToQt)
void NodeInstanceView::setKit(ProjectExplorer::Kit *newKit)
{
if (m_pathToQt != pathToQt) {
m_pathToQt = pathToQt;
if (m_currentKit != newKit) {
m_currentKit = newKit;
restartProcess();
}
}
......
......@@ -18,8 +18,6 @@
#include <qmldesigner/qmldesignerplugin.h>
#include <qtsupport/qtversionmanager.h>
#include <qtsupport/qtsupportconstants.h>
namespace QmlDesigner {
......@@ -63,20 +61,9 @@ DesignDocument *ViewManager::currentDesignDocument() const
return QmlDesignerPlugin::instance()->documentManager().currentDesignDocument();
}
QString ViewManager::pathToQt() const
{
QtSupport::BaseQtVersion *activeQtVersion = QtSupport::QtVersionManager::version(currentDesignDocument()->qtVersionId());
if (activeQtVersion && (activeQtVersion->qtVersion() >= QtSupport::QtVersionNumber(4, 7, 1))
&& (activeQtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)
|| activeQtVersion->type() == QLatin1String(QtSupport::Constants::SIMULATORQT)))
return activeQtVersion->qmakeProperty("QT_INSTALL_DATA");
return QString();
}
void ViewManager::attachNodeInstanceView()
{
setNodeInstanceViewQtPath(pathToQt());
setNodeInstanceViewKit(currentDesignDocument()->currentKit());
currentModel()->setNodeInstanceView(&d->nodeInstanceView);
}
......@@ -206,9 +193,9 @@ void ViewManager::setComponentViewToMaster()
d->componentView.setComponentToMaster();
}
void ViewManager::setNodeInstanceViewQtPath(const QString &qtPath)
void ViewManager::setNodeInstanceViewKit(ProjectExplorer::Kit *kit)
{
d->nodeInstanceView.setPathToQt(qtPath);
d->nodeInstanceView.setKit(kit);
}
static bool widgetInfoLessThan(const WidgetInfo &firstWidgetInfo, const WidgetInfo &secondWidgetInfo)
......
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