diff --git a/qtcreator.pro b/qtcreator.pro index e3aeb6950d2..f6ec3585afd 100644 --- a/qtcreator.pro +++ b/qtcreator.pro @@ -12,3 +12,10 @@ CONFIG += ordered SUBDIRS = src share WITH_TESTS:SUBDIRS += tests + + +target.path += \ + /usr/local/bin + +INSTALLS += \ + target \ No newline at end of file diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp index a8a26ae248b..63ec8eea3f1 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp @@ -29,51 +29,33 @@ #include "maemodeployablelistmodel.h" -#include "maemopackagecreationstep.h" -#include "maemotoolchain.h" #include "profilewrapper.h" -#include -#include -#include +#include #include -#include #include namespace Qt4ProjectManager { namespace Internal { -MaemoDeployableListModel::MaemoDeployableListModel(MaemoPackageCreationStep *packageStep) - : QAbstractTableModel(packageStep), - m_packageStep(packageStep), - m_modified(false), - m_initialized(false) +MaemoDeployableListModel::MaemoDeployableListModel(const Qt4ProFileNode *proFileNode, + QObject *parent) + : QAbstractTableModel(parent), m_proFileNode(proFileNode), m_modified(false) { + buildModel(); } MaemoDeployableListModel::~MaemoDeployableListModel() {} -bool MaemoDeployableListModel::buildModel() const +bool MaemoDeployableListModel::buildModel() { - if (m_initialized) - return true; - m_deployables.clear(); - // TODO: The pro file path comes from the outside. - if (!m_proFileWrapper) { - const Qt4ProFileNode * const proFileNode = m_packageStep - ->qt4BuildConfiguration()->qt4Target()->qt4Project() - ->rootProjectNode(); - m_proFileWrapper.reset(new ProFileWrapper(proFileNode->path())); - } + m_proFileWrapper.reset(new ProFileWrapper(m_proFileNode->path())); const ProFileWrapper::InstallsList &installs = m_proFileWrapper->installs(); if (installs.targetPath.isEmpty()) { - const Qt4ProFileNode * const proFileNode - = m_packageStep->qt4BuildConfiguration()->qt4Target() - ->qt4Project()->rootProjectNode(); - const QString remoteDir = proFileNode->projectType() == LibraryTemplate + const QString remoteDir = m_proFileNode->projectType() == LibraryTemplate ? QLatin1String("/usr/local/lib") : QLatin1String("/usr/local/bin"); m_deployables.prepend(MaemoDeployable(localExecutableFilePath(), @@ -93,7 +75,6 @@ bool MaemoDeployableListModel::buildModel() const } } - m_initialized = true; m_modified = true; // ??? return true; } @@ -143,7 +124,6 @@ bool MaemoDeployableListModel::removeDeployableAt(int row, QString *error) int MaemoDeployableListModel::rowCount(const QModelIndex &parent) const { - buildModel(); return parent.isValid() ? 0 : m_deployables.count(); } @@ -203,26 +183,41 @@ QVariant MaemoDeployableListModel::headerData(int section, QString MaemoDeployableListModel::localExecutableFilePath() const { - // TODO: This information belongs to this class. - return m_packageStep->localExecutableFilePath(); + const TargetInformation &ti = m_proFileNode->targetInformation(); + if (!ti.valid) + return QString(); + + const bool isLib = m_proFileNode->projectType() == LibraryTemplate; + bool isStatic; + QString fileName; + if (isLib) { + fileName += QLatin1String("lib"); + const QStringList &config + = m_proFileWrapper->varValues(QLatin1String("CONFIG")); + isStatic = config.contains(QLatin1String("static")) + || config.contains(QLatin1String("staticlib")) + || config.contains(QLatin1String("plugin")); + } + fileName += ti.target; + if (isLib) + fileName += QLatin1String(isStatic ? ".a" : ".so"); + return ti.buildDir + '/' + fileName; } QString MaemoDeployableListModel::remoteExecutableFilePath() const { - return buildModel() ? deployableAt(0).remoteDir + '/' - + m_packageStep->executableFileName() : QString(); + return deployableAt(0).remoteDir + '/' + + QFileInfo(localExecutableFilePath()).fileName(); } QString MaemoDeployableListModel::projectName() const { - // TODO: This must return our own sub project name. - return m_packageStep->qt4BuildConfiguration()->qt4Target()->qt4Project() - ->rootProjectNode()->displayName(); + return m_proFileNode->displayName(); } QString MaemoDeployableListModel::projectDir() const { - return m_proFileWrapper->projectDir(); + return m_proFileNode->path(); } } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h index c441e92a4f2..3d3466fbead 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h @@ -40,14 +40,15 @@ namespace Qt4ProjectManager { namespace Internal { -class MaemoPackageCreationStep; class ProFileWrapper; +class Qt4ProFileNode; class MaemoDeployableListModel : public QAbstractTableModel { Q_OBJECT public: - MaemoDeployableListModel(MaemoPackageCreationStep *packageStep); + MaemoDeployableListModel(const Qt4ProFileNode *proFileNode, + QObject *parent); ~MaemoDeployableListModel(); virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; @@ -72,13 +73,12 @@ private: virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - bool buildModel() const; + bool buildModel(); - const MaemoPackageCreationStep * const m_packageStep; - mutable QList m_deployables; + const Qt4ProFileNode * const m_proFileNode; + QList m_deployables; mutable bool m_modified; - mutable bool m_initialized; - mutable QScopedPointer m_proFileWrapper; + QScopedPointer m_proFileWrapper; }; } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.cpp index 77232277441..82fb469485a 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.cpp @@ -81,7 +81,6 @@ MaemoDeployableListWidget::~MaemoDeployableListWidget() void MaemoDeployableListWidget::addFile() { - // TODO: Make all this stuff subproject-specific. const QString title = tr("Choose a local file"); const QString localFile = QFileDialog::getOpenFileName(this, title, m_model->projectDir()); // TODO: Support directories. if (localFile.isEmpty()) diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.cpp index c670c1bb131..8ea23849add 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.cpp @@ -42,16 +42,55 @@ #include "maemodeployables.h" #include "maemodeployablelistmodel.h" +#include "maemopackagecreationstep.h" + +#include +#include +#include +#include + +#include namespace Qt4ProjectManager { namespace Internal { MaemoDeployables::MaemoDeployables(MaemoPackageCreationStep *packagingStep) + : m_packagingStep(packagingStep) { - // TODO: Enumerate sub projects and create one list model for each app or lib template. - // Their constructurs will then take this object as parent and the - // project node - m_listModels << new MaemoDeployableListModel(packagingStep); + QTimer::singleShot(0, this, SLOT(createModels())); +} + +void MaemoDeployables::createModels() +{ + const Qt4ProFileNode *rootNode = m_packagingStep->qt4BuildConfiguration() + ->qt4Target()->qt4Project()->rootProjectNode(); + createModels(rootNode); + emit modelsCreated(); +} + +void MaemoDeployables::createModels(const Qt4ProFileNode *proFileNode) +{ + const Qt4ProjectType type = proFileNode->projectType() ; + switch (type) { + case ApplicationTemplate: + case LibraryTemplate: + case ScriptTemplate: + m_listModels << new MaemoDeployableListModel(proFileNode, this); + break; + case SubDirsTemplate: { + const QList &subProjects + = proFileNode->subProjectNodes(); + foreach (const ProjectExplorer::ProjectNode *subProject, subProjects) { + const Qt4ProFileNode * const qt4SubProject + = qobject_cast(subProject); + if (qt4SubProject && !qt4SubProject->path() + .endsWith(QLatin1String(".pri"))) + createModels(qt4SubProject); + } + } + default: + break; + } } void MaemoDeployables::setUnmodified() diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.h index bc0dc2fe63c..7c66c5d39ee 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.h @@ -51,6 +51,7 @@ namespace Qt4ProjectManager { namespace Internal { class MaemoDeployableListModel; class MaemoPackageCreationStep; +class Qt4ProFileNode; class MaemoDeployables : public QObject { @@ -65,8 +66,15 @@ public: int modelCount() const { return m_listModels.count(); } MaemoDeployableListModel *modelAt(int i) const { return m_listModels.at(i); } +signals: + void modelsCreated(); + private: + Q_SLOT void createModels(); + void createModels(const Qt4ProFileNode *proFileNode); + QList m_listModels; + MaemoPackageCreationStep * const m_packagingStep; }; } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp index c275b9ecf52..76ac7327a3f 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp @@ -179,7 +179,7 @@ bool MaemoPackageCreationStep::createPackage() if (!QFileInfo(buildDir + QLatin1String("/debian")).exists()) { const QString command = QLatin1String("dh_make -s -n -p ") - % executableFileName().toLower() % QLatin1Char('_') % versionString(); + % projectName() % QLatin1Char('_') % versionString(); if (!runCommand(command)) return false; @@ -297,35 +297,15 @@ const Qt4BuildConfiguration *MaemoPackageCreationStep::qt4BuildConfiguration() c return static_cast(buildConfiguration()); } -QString MaemoPackageCreationStep::localExecutableFilePath() const -{ - const TargetInformation &ti = qt4BuildConfiguration()->qt4Target() - ->qt4Project()->rootProjectNode()->targetInformation(); - if (!ti.valid) - return QString(); - return QDir::toNativeSeparators(QDir::cleanPath(ti.workingDir - + QLatin1Char('/') + executableFileName())); -} - QString MaemoPackageCreationStep::buildDirectory() const { - const TargetInformation &ti = qt4BuildConfiguration()->qt4Target() - ->qt4Project()->rootProjectNode()->targetInformation(); - return ti.valid ? ti.buildDir : QString(); + return qt4BuildConfiguration()->buildDirectory(); } -QString MaemoPackageCreationStep::executableFileName() const +QString MaemoPackageCreationStep::projectName() const { - const Qt4Project * const project - = qt4BuildConfiguration()->qt4Target()->qt4Project(); - const TargetInformation &ti - = project->rootProjectNode()->targetInformation(); - if (!ti.valid) - return QString(); - - return project->rootProjectNode()->projectType() == LibraryTemplate - ? QLatin1String("lib") + ti.target + QLatin1String(".so") - : ti.target; + return qt4BuildConfiguration()->qt4Target()->qt4Project() + ->rootProjectNode()->displayName().toLower(); } const MaemoToolChain *MaemoPackageCreationStep::maemoToolChain() const @@ -362,7 +342,7 @@ bool MaemoPackageCreationStep::packagingNeeded() const QString MaemoPackageCreationStep::packageFilePath() const { - return buildDirectory() % '/' % executableFileName().toLower() + return buildDirectory() % '/' % projectName() % QLatin1Char('_') % versionString() % QLatin1String("_armel.deb"); } diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h index 37b32355ef6..6f0d0d09ee5 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h @@ -69,8 +69,6 @@ public: ~MaemoPackageCreationStep(); QString packageFilePath() const; - QString localExecutableFilePath() const; - QString executableFileName() const; MaemoDeployables *deployables() const { return m_deployables; } const Qt4BuildConfiguration *qt4BuildConfiguration() const; @@ -104,6 +102,7 @@ private: void raiseError(const QString &shortMsg, const QString &detailedMsg = QString()); QString buildDirectory() const; + QString projectName() const; static const QLatin1String CreatePackageId; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.cpp index 76a999466fd..4360badbbfe 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.cpp @@ -69,12 +69,13 @@ MaemoPackageCreationWidget::MaemoPackageCreationWidget(MaemoPackageCreationStep m_ui->major->setValue(list.value(0, QLatin1String("0")).toInt()); m_ui->minor->setValue(list.value(1, QLatin1String("0")).toInt()); m_ui->patch->setValue(list.value(2, QLatin1String("0")).toInt()); - versionInfoChanged(); // workaround for missing minor and patch update notifications - for (int i = 0; i < step->deployables()->modelCount(); ++i) { - MaemoDeployableListModel * const model - = step->deployables()->modelAt(i); - m_ui->tabWidget->addTab(new MaemoDeployableListWidget(this, model), - model->projectName()); + versionInfoChanged(); + + if (step->deployables()->modelCount() > 0) { + handleModelsCreated(); + } else { + connect(m_step->deployables(), SIGNAL(modelsCreated()), this, + SLOT(handleModelsCreated())); } } @@ -104,5 +105,15 @@ void MaemoPackageCreationWidget::versionInfoChanged() emit updateSummary(); } +void MaemoPackageCreationWidget::handleModelsCreated() +{ + for (int i = 0; i < m_step->deployables()->modelCount(); ++i) { + MaemoDeployableListModel * const model + = m_step->deployables()->modelAt(i); + m_ui->tabWidget->addTab(new MaemoDeployableListWidget(this, model), + model->projectName()); + } +} + } // namespace Internal } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.h b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.h index 6f01bdeaa76..560a9ac1ee1 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.h @@ -66,6 +66,7 @@ public: private slots: void handleSkipButtonToggled(bool checked); void versionInfoChanged(); + void handleModelsCreated(); private: MaemoPackageCreationStep * const m_step; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp index 7b622f50963..8ca88c0637e 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp @@ -238,10 +238,9 @@ QString AbstractMaemoRunControl::packageFilePath() const QString AbstractMaemoRunControl::executableFilePathOnTarget() const { - // TODO: The local executable is known directly by us (from RunConfiguration::target(), - // so we must not rely on the packaging step for this information (which will - // no longer provide it, anyway)/ - return m_runConfig->packageStep()->deployables()->remoteExecutableFilePath(m_runConfig->packageStep()->localExecutableFilePath()); + const MaemoDeployables * const deployables + = m_runConfig->packageStep()->deployables(); + return deployables->remoteExecutableFilePath(m_runConfig->executable()); } bool AbstractMaemoRunControl::isCleaning() const diff --git a/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.cpp b/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.cpp index e874972e641..105e778f66e 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.cpp @@ -136,6 +136,9 @@ QStringList ProFileWrapper::varValues(const QString &var) const bool ProFileWrapper::addVarValue(const QString &var, const QString &value) { + if (varValues(var).contains(value)) + return true; + if (!readProFileContents()) return false; ProWriter::addVarValues(m_proFile, &m_proFileContents, m_proDir, diff --git a/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.h b/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.h index 7f2d4512143..e82c03c2231 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.h +++ b/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.h @@ -53,7 +53,6 @@ public: const QString &newValue); QString absFilePath(const QString &relFilePath) const; - QString projectDir() const { return m_proDir.path(); } private: enum ParseType { ParseFromFile, ParseFromLines };