From 11d09519243c8fba68bb9b6835ab1a4eb2edc8a3 Mon Sep 17 00:00:00 2001 From: ck <qt-info@nokia.com> Date: Tue, 27 Jul 2010 17:27:04 +0200 Subject: [PATCH] Maemo: Fix ProFileOption settings, write INSTALLS in maemo scope. Task-number: QTCREATORBUG-1951 Reviewed-by: kh1 --- .../qt-maemo/maemodeployablelistmodel.cpp | 17 ++++++++++++++--- .../qt-maemo/maemodeployablelistmodel.h | 7 ++++++- .../qt-maemo/maemodeployables.cpp | 19 +++++++++---------- .../qt-maemo/maemodeployables.h | 7 +++++++ .../qt-maemo/maemosshrunner.cpp | 2 +- .../qt-maemo/profilewrapper.cpp | 6 +++--- .../qt-maemo/profilewrapper.h | 6 ++++-- 7 files changed, 44 insertions(+), 20 deletions(-) diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp index 2d1be63adf4..79bb7a101d4 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp @@ -34,17 +34,18 @@ #include <qt4projectmanager/qt4nodes.h> #include <QtCore/QCryptographicHash> +#include <QtCore/QFile> #include <QtCore/QFileInfo> namespace Qt4ProjectManager { namespace Internal { MaemoDeployableListModel::MaemoDeployableListModel(const Qt4ProFileNode *proFileNode, - const QString &qConfigFile, QObject *parent) + const QSharedPointer<ProFileOption> &proFileOption, QObject *parent) : QAbstractTableModel(parent), m_proFileNode(proFileNode), m_modified(false), - m_proFileWrapper(new ProFileWrapper(m_proFileNode->path(), qConfigFile)) + m_proFileWrapper(new ProFileWrapper(m_proFileNode->path(), proFileOption)) { buildModel(); } @@ -62,8 +63,18 @@ bool MaemoDeployableListModel::buildModel() : QLatin1String("/usr/local/bin"); m_deployables.prepend(MaemoDeployable(localExecutableFilePath(), remoteDir)); - if (!m_proFileWrapper->addInstallsTarget(remoteDir)) + QFile projectFile(m_proFileNode->path()); + if (!projectFile.open(QIODevice::WriteOnly | QIODevice::Append)) { qWarning("Error updating .pro file."); + return false; + } + QString installsString + = QLatin1String("maemo5|maemo6 {\n target.path = ") + + remoteDir + QLatin1String("\n INSTALLS += target\n}\n"); + if (!projectFile.write(installsString.toLocal8Bit())) { + qWarning("Error updating .pro file."); + return false; + } } else { m_deployables.prepend(MaemoDeployable(localExecutableFilePath(), installs.targetPath)); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h index a7354e0960b..3a994c81f10 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h @@ -36,8 +36,13 @@ #include <QtCore/QHash> #include <QtCore/QList> #include <QtCore/QScopedPointer> +#include <QtCore/QSharedPointer> #include <QtCore/QString> +QT_BEGIN_NAMESPACE +class ProFileOption; +QT_END_NAMESPACE + namespace Qt4ProjectManager { namespace Internal { class ProFileWrapper; @@ -48,7 +53,7 @@ class MaemoDeployableListModel : public QAbstractTableModel Q_OBJECT public: MaemoDeployableListModel(const Qt4ProFileNode *proFileNode, - const QString &qConfigFile, QObject *parent); + const QSharedPointer<ProFileOption> &proFileOption, QObject *parent); ~MaemoDeployableListModel(); virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.cpp index 9f8d878afef..85b96f6e94e 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.cpp @@ -42,8 +42,8 @@ #include "maemodeployables.h" #include "maemodeployablelistmodel.h" -#include "maemotoolchain.h" +#include <profileevaluator.h> #include <projectexplorer/buildstep.h> #include <qt4projectmanager/qt4buildconfiguration.h> #include <qt4projectmanager/qt4project.h> @@ -55,13 +55,17 @@ namespace Qt4ProjectManager { namespace Internal { MaemoDeployables::MaemoDeployables(const ProjectExplorer::BuildStep *buildStep) - : m_buildStep(buildStep) + : m_proFileOption(new ProFileOption), m_buildStep(buildStep) { QTimer::singleShot(0, this, SLOT(init())); } +MaemoDeployables::~MaemoDeployables() {} + void MaemoDeployables::init() { + m_proFileOption->properties + = qt4BuildConfiguration()->qtVersion()->versionInfo(); createModels(); connect(qt4BuildConfiguration()->qt4Target()->qt4Project(), SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)), @@ -82,15 +86,10 @@ void MaemoDeployables::createModels(const Qt4ProFileNode *proFileNode) switch (type) { case ApplicationTemplate: case LibraryTemplate: - case ScriptTemplate: { - const MaemoToolChain * const tc - = dynamic_cast<MaemoToolChain *>(qt4BuildConfiguration()->toolChain()); - Q_ASSERT(tc); - const QString qConfigFile = tc->sysrootRoot() - + QLatin1String("/usr/share/qt/mkspecs/qconfig.pri"); - m_listModels << new MaemoDeployableListModel(proFileNode, qConfigFile, this); + case ScriptTemplate: + m_listModels + << new MaemoDeployableListModel(proFileNode, m_proFileOption, this); break; - } case SubDirsTemplate: { const QList<ProjectExplorer::ProjectNode *> &subProjects = proFileNode->subProjectNodes(); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.h index 9e4351f1d04..46540b533a7 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.h @@ -46,6 +46,11 @@ #include <QtCore/QList> #include <QtCore/QObject> +#include <QtCore/QSharedPointer> + +QT_BEGIN_NAMESPACE +class ProFileOption; +QT_END_NAMESPACE namespace ProjectExplorer { class BuildStep; } @@ -61,6 +66,7 @@ class MaemoDeployables : public QObject Q_OBJECT public: MaemoDeployables(const ProjectExplorer::BuildStep *buildStep); + ~MaemoDeployables(); void setUnmodified(); bool isModified() const; int deployableCount() const; @@ -79,6 +85,7 @@ private: const Qt4BuildConfiguration *qt4BuildConfiguration() const; QList<MaemoDeployableListModel *> m_listModels; + const QSharedPointer<ProFileOption> m_proFileOption; const ProjectExplorer::BuildStep * const m_buildStep; }; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp index 5ab95cc117b..bf6f99da468 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp @@ -79,7 +79,7 @@ void MaemoSshRunner::start() { m_stop = false; if (m_connection) - disconnect(m_connection.data(), 0, this, 0); + disconnect(m_connection.data(), 0, this, 0); const bool reUse = m_connection && m_connection->state() == SshConnection::Connected && m_connection->connectionParameters() == m_devConfig.server; diff --git a/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.cpp b/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.cpp index 58b5be01ffe..c33c4cacc56 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.cpp @@ -27,11 +27,10 @@ namespace { ProFileWrapper::ProFileWrapper(const QString &proFileName, - const QString &qConfigFile) + const QSharedPointer<ProFileOption> &proFileOption) : m_proFileName(proFileName), m_proDir(QFileInfo(m_proFileName).dir()), - m_proFileOption(new ProFileOption) + m_proFileOption(proFileOption) { - m_proFileOption->cachefile = qConfigFile; parseProFile(ParseFromFile); } @@ -226,6 +225,7 @@ void ProFileWrapper::parseProFile(ParseType type) const { m_proFileReader.reset(new ProFileReader(m_proFileOption.data())); m_proFileReader->setCumulative(false); + // TODO: Set output dir to build dir? if (type == ParseFromLines) { m_proFile = m_proFileReader->parsedProFile(m_proFileName, false, m_proFileContents.join("\n")); diff --git a/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.h b/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.h index d6455d39bf1..7c65e1050cb 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.h +++ b/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.h @@ -3,6 +3,7 @@ #include <QtCore/QDir> #include <QtCore/QScopedPointer> +#include <QtCore/QSharedPointer> #include <QtCore/QString> #include <QtCore/QString> @@ -18,7 +19,8 @@ class ProFileReader; class ProFileWrapper { public: - ProFileWrapper(const QString &proFileName, const QString &qConfigFile); + ProFileWrapper(const QString &proFileName, + const QSharedPointer<ProFileOption> &proFileOption); ~ProFileWrapper(); void reload(); @@ -66,8 +68,8 @@ private: const QString m_proFileName; const QDir m_proDir; + const QSharedPointer<ProFileOption> m_proFileOption; mutable QStringList m_proFileContents; - const QScopedPointer<ProFileOption> m_proFileOption; mutable QScopedPointer<ProFileReader> m_proFileReader; mutable ProFile *m_proFile; }; -- GitLab