forked from qt-creator/qt-creator
Android: Adding libraries to subdirs projects
Task-number: QTCREATORBUG-11625 Change-Id: I1017546463e819fc05846af74582cb9f5739ff08 Reviewed-by: BogDan Vatra <bogdan@kde.org>
This commit is contained in:
@@ -30,23 +30,33 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "androidextralibrarylistmodel.h"
|
#include "androidextralibrarylistmodel.h"
|
||||||
|
#include "qmakeandroidrunconfiguration.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
#include <qmakeprojectmanager/qmakeproject.h>
|
#include <qmakeprojectmanager/qmakeproject.h>
|
||||||
#include <qmakeprojectmanager/qmakenodes.h>
|
#include <qmakeprojectmanager/qmakenodes.h>
|
||||||
#include <proparser/prowriter.h>
|
#include <proparser/prowriter.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace QmakeAndroidSupport;
|
using namespace QmakeAndroidSupport;
|
||||||
using namespace Internal;
|
using namespace Internal;
|
||||||
|
using QmakeProjectManager::QmakeProject;
|
||||||
|
|
||||||
AndroidExtraLibraryListModel::AndroidExtraLibraryListModel(QmakeProjectManager::QmakeProject *project,
|
AndroidExtraLibraryListModel::AndroidExtraLibraryListModel(ProjectExplorer::Target *target,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent),
|
||||||
, m_project(project)
|
m_target(target)
|
||||||
{
|
{
|
||||||
QmakeProjectManager::QmakeProFileNode *node = m_project->rootQmakeProjectNode();
|
|
||||||
proFileUpdated(node, node->validParse(), node->parseInProgress());
|
|
||||||
|
|
||||||
connect(m_project, SIGNAL(proFileUpdated(QmakeProjectManager::QmakeProFileNode*,bool,bool)),
|
activeRunConfigurationChanged();
|
||||||
this, SLOT(proFileUpdated(QmakeProjectManager::QmakeProFileNode*,bool,bool)));
|
|
||||||
|
auto project = static_cast<QmakeProject *>(target->project());
|
||||||
|
connect(project, &QmakeProject::proFileUpdated,
|
||||||
|
this, &AndroidExtraLibraryListModel::proFileUpdated);
|
||||||
|
|
||||||
|
connect(target, &ProjectExplorer::Target::activeRunConfigurationChanged,
|
||||||
|
this, &AndroidExtraLibraryListModel::activeRunConfigurationChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex AndroidExtraLibraryListModel::index(int row, int column, const QModelIndex &) const
|
QModelIndex AndroidExtraLibraryListModel::index(int row, int column, const QModelIndex &) const
|
||||||
@@ -79,24 +89,21 @@ QVariant AndroidExtraLibraryListModel::data(const QModelIndex &index, int role)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidExtraLibraryListModel::proFileUpdated(QmakeProjectManager::QmakeProFileNode *node, bool success, bool parseInProgress)
|
void AndroidExtraLibraryListModel::activeRunConfigurationChanged()
|
||||||
{
|
{
|
||||||
QmakeProjectManager::QmakeProFileNode *root = m_project->rootQmakeProjectNode();
|
const QmakeProjectManager::QmakeProFileNode *node = activeNode();
|
||||||
if (node != root)
|
if (!node || node->parseInProgress()) {
|
||||||
|
emit enabledChanged(false);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_scope = QLatin1String("contains(ANDROID_TARGET_ARCH,")
|
m_scope = QLatin1String("contains(ANDROID_TARGET_ARCH,")
|
||||||
+ node->singleVariableValue(QmakeProjectManager::AndroidArchVar)
|
+ node->singleVariableValue(QmakeProjectManager::AndroidArchVar)
|
||||||
+ QLatin1Char(')');
|
+ QLatin1Char(')');
|
||||||
|
|
||||||
if (parseInProgress) {
|
|
||||||
emit enabledChanged(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool enabled;
|
bool enabled;
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
if (success && root->projectType() == QmakeProjectManager::ApplicationTemplate) {
|
if (node->validParse() && node->projectType() == QmakeProjectManager::ApplicationTemplate) {
|
||||||
m_entries = node->variableValue(QmakeProjectManager::AndroidExtraLibs);
|
m_entries = node->variableValue(QmakeProjectManager::AndroidExtraLibs);
|
||||||
enabled = true;
|
enabled = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -109,27 +116,47 @@ void AndroidExtraLibraryListModel::proFileUpdated(QmakeProjectManager::QmakeProF
|
|||||||
emit enabledChanged(enabled);
|
emit enabledChanged(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QmakeProjectManager::QmakeProFileNode *AndroidExtraLibraryListModel::activeNode() const
|
||||||
|
{
|
||||||
|
ProjectExplorer::RunConfiguration *rc = m_target->activeRunConfiguration();
|
||||||
|
QmakeAndroidRunConfiguration *qarc = qobject_cast<QmakeAndroidRunConfiguration *>(rc);
|
||||||
|
if (!qarc)
|
||||||
|
return 0;
|
||||||
|
auto project = static_cast<QmakeProject *>(m_target->project());
|
||||||
|
return project->rootQmakeProjectNode()->findProFileFor(qarc->proFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AndroidExtraLibraryListModel::proFileUpdated(QmakeProjectManager::QmakeProFileNode *node)
|
||||||
|
{
|
||||||
|
if (node != activeNode())
|
||||||
|
return;
|
||||||
|
activeRunConfigurationChanged();
|
||||||
|
}
|
||||||
|
|
||||||
bool AndroidExtraLibraryListModel::isEnabled() const
|
bool AndroidExtraLibraryListModel::isEnabled() const
|
||||||
{
|
{
|
||||||
QmakeProjectManager::QmakeProFileNode *root = m_project->rootQmakeProjectNode();
|
QmakeProjectManager::QmakeProFileNode *node = activeNode();
|
||||||
if (root->parseInProgress())
|
if (!node)
|
||||||
return false;
|
return false;
|
||||||
if (root->projectType() != QmakeProjectManager::ApplicationTemplate)
|
if (node->parseInProgress())
|
||||||
|
return false;
|
||||||
|
if (node->projectType() != QmakeProjectManager::ApplicationTemplate)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidExtraLibraryListModel::addEntries(const QStringList &list)
|
void AndroidExtraLibraryListModel::addEntries(const QStringList &list)
|
||||||
{
|
{
|
||||||
if (m_project->rootQmakeProjectNode()->projectType() != QmakeProjectManager::ApplicationTemplate)
|
QmakeProjectManager::QmakeProFileNode *node = activeNode();
|
||||||
|
if (!node || node->projectType() != QmakeProjectManager::ApplicationTemplate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
beginInsertRows(QModelIndex(), m_entries.size(), m_entries.size() + list.size());
|
beginInsertRows(QModelIndex(), m_entries.size(), m_entries.size() + list.size());
|
||||||
|
|
||||||
foreach (const QString &path, list)
|
foreach (const QString &path, list)
|
||||||
m_entries += QLatin1String("$$PWD/") + QDir(m_project->projectDirectory().toString()).relativeFilePath(path);
|
m_entries += QLatin1String("$$PWD/")
|
||||||
|
+ node->path().toFileInfo().absoluteDir().relativeFilePath(path);
|
||||||
|
|
||||||
QmakeProjectManager::QmakeProFileNode *node = m_project->rootQmakeProjectNode();
|
|
||||||
node->setProVariable(QLatin1String("ANDROID_EXTRA_LIBS"), m_entries, m_scope,
|
node->setProVariable(QLatin1String("ANDROID_EXTRA_LIBS"), m_entries, m_scope,
|
||||||
QmakeProjectManager::Internal::ProWriter::ReplaceValues
|
QmakeProjectManager::Internal::ProWriter::ReplaceValues
|
||||||
| QmakeProjectManager::Internal::ProWriter::MultiLine);
|
| QmakeProjectManager::Internal::ProWriter::MultiLine);
|
||||||
@@ -144,7 +171,8 @@ bool greaterModelIndexByRow(const QModelIndex &a, const QModelIndex &b)
|
|||||||
|
|
||||||
void AndroidExtraLibraryListModel::removeEntries(QModelIndexList list)
|
void AndroidExtraLibraryListModel::removeEntries(QModelIndexList list)
|
||||||
{
|
{
|
||||||
if (list.isEmpty() || m_project->rootQmakeProjectNode()->projectType() != QmakeProjectManager::ApplicationTemplate)
|
QmakeProjectManager::QmakeProFileNode *node = activeNode();
|
||||||
|
if (list.isEmpty() || !node || node->projectType() != QmakeProjectManager::ApplicationTemplate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::sort(list.begin(), list.end(), greaterModelIndexByRow);
|
std::sort(list.begin(), list.end(), greaterModelIndexByRow);
|
||||||
@@ -163,6 +191,5 @@ void AndroidExtraLibraryListModel::removeEntries(QModelIndexList list)
|
|||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
QmakeProjectManager::QmakeProFileNode *node = m_project->rootQmakeProjectNode();
|
|
||||||
node->setProVariable(QLatin1String("ANDROID_EXTRA_LIBS"), m_entries, m_scope);
|
node->setProVariable(QLatin1String("ANDROID_EXTRA_LIBS"), m_entries, m_scope);
|
||||||
}
|
}
|
||||||
|
@@ -35,11 +35,13 @@
|
|||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
namespace QmakeProjectManager {
|
namespace ProjectExplorer {
|
||||||
class QmakeProject;
|
class RunConfiguration;
|
||||||
class QmakeProFileNode;
|
class Target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace QmakeProjectManager { class QmakeProFileNode; }
|
||||||
|
|
||||||
namespace QmakeAndroidSupport {
|
namespace QmakeAndroidSupport {
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -47,7 +49,7 @@ class AndroidExtraLibraryListModel : public QAbstractItemModel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit AndroidExtraLibraryListModel(QmakeProjectManager::QmakeProject *project,
|
explicit AndroidExtraLibraryListModel(ProjectExplorer::Target *target,
|
||||||
QObject *parent = 0);
|
QObject *parent = 0);
|
||||||
|
|
||||||
QModelIndex index(int row, int column, const QModelIndex &parent) const;
|
QModelIndex index(int row, int column, const QModelIndex &parent) const;
|
||||||
@@ -64,11 +66,12 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void enabledChanged(bool);
|
void enabledChanged(bool);
|
||||||
|
|
||||||
private slots:
|
|
||||||
void proFileUpdated(QmakeProjectManager::QmakeProFileNode *node, bool success, bool parseInProgress);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QmakeProjectManager::QmakeProject *m_project;
|
void proFileUpdated(QmakeProjectManager::QmakeProFileNode *node);
|
||||||
|
void activeRunConfigurationChanged();
|
||||||
|
QmakeProjectManager::QmakeProFileNode *activeNode() const;
|
||||||
|
|
||||||
|
ProjectExplorer::Target *m_target;
|
||||||
QStringList m_entries;
|
QStringList m_entries;
|
||||||
QString m_scope;
|
QString m_scope;
|
||||||
};
|
};
|
||||||
|
@@ -84,7 +84,7 @@ QmakeAndroidBuildApkWidget::QmakeAndroidBuildApkWidget(QmakeAndroidBuildApkStep
|
|||||||
oldFilesWarningIcon->setVisible(oldFiles);
|
oldFilesWarningIcon->setVisible(oldFiles);
|
||||||
oldFilesWarningLabel->setVisible(oldFiles);
|
oldFilesWarningLabel->setVisible(oldFiles);
|
||||||
|
|
||||||
m_extraLibraryListModel = new AndroidExtraLibraryListModel(static_cast<QmakeProject *>(m_step->project()), this);
|
m_extraLibraryListModel = new AndroidExtraLibraryListModel(m_step->target(), this);
|
||||||
m_ui->androidExtraLibsListView->setModel(m_extraLibraryListModel);
|
m_ui->androidExtraLibsListView->setModel(m_extraLibraryListModel);
|
||||||
|
|
||||||
connect(m_ui->createAndroidTemplatesButton, SIGNAL(clicked()),
|
connect(m_ui->createAndroidTemplatesButton, SIGNAL(clicked()),
|
||||||
|
@@ -1527,13 +1527,13 @@ namespace {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const QmakeProFileNode *QmakeProFileNode::findProFileFor(const FileName &fileName) const
|
QmakeProFileNode *QmakeProFileNode::findProFileFor(const FileName &fileName) const
|
||||||
{
|
{
|
||||||
if (fileName == path())
|
if (fileName == path())
|
||||||
return this;
|
return const_cast<QmakeProFileNode *>(this);
|
||||||
foreach (ProjectNode *pn, subProjectNodes())
|
foreach (ProjectNode *pn, subProjectNodes())
|
||||||
if (QmakeProFileNode *qmakeProFileNode = dynamic_cast<QmakeProFileNode *>(pn))
|
if (QmakeProFileNode *qmakeProFileNode = dynamic_cast<QmakeProFileNode *>(pn))
|
||||||
if (const QmakeProFileNode *result = qmakeProFileNode->findProFileFor(fileName))
|
if (QmakeProFileNode *result = qmakeProFileNode->findProFileFor(fileName))
|
||||||
return result;
|
return result;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -357,7 +357,7 @@ public:
|
|||||||
static QString uiHeaderFile(const QString &uiDir, const Utils::FileName &formFile);
|
static QString uiHeaderFile(const QString &uiDir, const Utils::FileName &formFile);
|
||||||
QHash<QString, QString> uiFiles() const;
|
QHash<QString, QString> uiFiles() const;
|
||||||
|
|
||||||
const QmakeProFileNode *findProFileFor(const Utils::FileName &string) const;
|
QmakeProFileNode *findProFileFor(const Utils::FileName &string) const;
|
||||||
TargetInformation targetInformation() const;
|
TargetInformation targetInformation() const;
|
||||||
|
|
||||||
InstallsList installsList() const;
|
InstallsList installsList() const;
|
||||||
|
Reference in New Issue
Block a user