forked from qt-creator/qt-creator
Android: Move AndroidExtraLibraryListModel to base
Instead of having the full class build-system dependent, by relying on four more AndroidQtSupport functions for now. Change-Id: I26842f3ec70b875ba4481ae36d8c85f86366cb88 Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
This commit is contained in:
@@ -53,7 +53,8 @@ HEADERS += \
|
|||||||
androidsdkpackage.h \
|
androidsdkpackage.h \
|
||||||
androidsdkmodel.h \
|
androidsdkmodel.h \
|
||||||
androidsdkmanagerwidget.h \
|
androidsdkmanagerwidget.h \
|
||||||
androidpackageinstallationstep.h
|
androidpackageinstallationstep.h \
|
||||||
|
androidextralibrarylistmodel.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
androidconfigurations.cpp \
|
androidconfigurations.cpp \
|
||||||
@@ -100,7 +101,8 @@ SOURCES += \
|
|||||||
androidsdkpackage.cpp \
|
androidsdkpackage.cpp \
|
||||||
androidsdkmodel.cpp \
|
androidsdkmodel.cpp \
|
||||||
androidsdkmanagerwidget.cpp \
|
androidsdkmanagerwidget.cpp \
|
||||||
androidpackageinstallationstep.cpp
|
androidpackageinstallationstep.cpp \
|
||||||
|
androidextralibrarylistmodel.cpp
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
androidsettingswidget.ui \
|
androidsettingswidget.ui \
|
||||||
|
@@ -55,6 +55,8 @@ Project {
|
|||||||
"androiddevicefactory.h",
|
"androiddevicefactory.h",
|
||||||
"androiderrormessage.h",
|
"androiderrormessage.h",
|
||||||
"androiderrormessage.cpp",
|
"androiderrormessage.cpp",
|
||||||
|
"androidextralibrarylistmodel.cpp",
|
||||||
|
"androidextralibrarylistmodel.h",
|
||||||
"androidgdbserverkitinformation.cpp",
|
"androidgdbserverkitinformation.cpp",
|
||||||
"androidgdbserverkitinformation.h",
|
"androidgdbserverkitinformation.h",
|
||||||
"androidglobal.h",
|
"androidglobal.h",
|
||||||
|
@@ -26,18 +26,14 @@
|
|||||||
|
|
||||||
#include "androidextralibrarylistmodel.h"
|
#include "androidextralibrarylistmodel.h"
|
||||||
|
|
||||||
|
#include <android/androidqtsupport.h>
|
||||||
|
#include <android/androidmanager.h>
|
||||||
|
|
||||||
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
#include <qmakeprojectmanager/qmakeproject.h>
|
namespace Android {
|
||||||
#include <qmakeprojectmanager/qmakenodes.h>
|
|
||||||
|
|
||||||
#include <proparser/prowriter.h>
|
|
||||||
|
|
||||||
|
|
||||||
using namespace QmakeAndroidSupport;
|
|
||||||
using namespace Internal;
|
|
||||||
using QmakeProjectManager::QmakeProject;
|
|
||||||
|
|
||||||
AndroidExtraLibraryListModel::AndroidExtraLibraryListModel(ProjectExplorer::Target *target,
|
AndroidExtraLibraryListModel::AndroidExtraLibraryListModel(ProjectExplorer::Target *target,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
@@ -86,20 +82,18 @@ QVariant AndroidExtraLibraryListModel::data(const QModelIndex &index, int role)
|
|||||||
|
|
||||||
void AndroidExtraLibraryListModel::updateModel()
|
void AndroidExtraLibraryListModel::updateModel()
|
||||||
{
|
{
|
||||||
QmakeProjectManager::QmakeProFile *pro = activeProFile();
|
AndroidQtSupport *qtSupport = Android::AndroidManager::androidQtSupport(m_target);
|
||||||
if (!pro || pro->parseInProgress()) {
|
QTC_ASSERT(qtSupport, return);
|
||||||
|
|
||||||
|
if (qtSupport->parseInProgress(m_target)) {
|
||||||
emit enabledChanged(false);
|
emit enabledChanged(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_scope = QLatin1String("contains(ANDROID_TARGET_ARCH,")
|
|
||||||
+ pro->singleVariableValue(QmakeProjectManager::Variable::AndroidArch)
|
|
||||||
+ QLatin1Char(')');
|
|
||||||
|
|
||||||
bool enabled;
|
bool enabled;
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
if (pro->validParse() && pro->projectType() == QmakeProjectManager::ProjectType::ApplicationTemplate) {
|
if (qtSupport->validParse(m_target)) {
|
||||||
m_entries = pro->variableValue(QmakeProjectManager::Variable::AndroidExtraLibs);
|
m_entries = qtSupport->targetData(Constants::AndroidExtraLibs, m_target);
|
||||||
enabled = true;
|
enabled = true;
|
||||||
} else {
|
} else {
|
||||||
// parsing error or not a application template
|
// parsing error or not a application template
|
||||||
@@ -111,37 +105,19 @@ void AndroidExtraLibraryListModel::updateModel()
|
|||||||
emit enabledChanged(enabled);
|
emit enabledChanged(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmakeProjectManager::QmakeProFile *AndroidExtraLibraryListModel::activeProFile() const
|
|
||||||
{
|
|
||||||
ProjectExplorer::RunConfiguration *rc = m_target->activeRunConfiguration();
|
|
||||||
if (!rc)
|
|
||||||
return nullptr;
|
|
||||||
auto project = static_cast<QmakeProject *>(m_target->project());
|
|
||||||
return project->rootProFile()->findProFile(Utils::FileName::fromString(rc->buildKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AndroidExtraLibraryListModel::isEnabled() const
|
|
||||||
{
|
|
||||||
QmakeProjectManager::QmakeProFile *pro = activeProFile();
|
|
||||||
return pro && !pro->parseInProgress() && pro->projectType() == QmakeProjectManager::ProjectType::ApplicationTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AndroidExtraLibraryListModel::addEntries(const QStringList &list)
|
void AndroidExtraLibraryListModel::addEntries(const QStringList &list)
|
||||||
{
|
{
|
||||||
QmakeProjectManager::QmakeProFile *pro = activeProFile();
|
AndroidQtSupport *qtSupport = Android::AndroidManager::androidQtSupport(m_target);
|
||||||
if (!pro || pro->projectType() != QmakeProjectManager::ProjectType::ApplicationTemplate)
|
QTC_ASSERT(qtSupport, return);
|
||||||
return;
|
Utils::FileName projectFilePath = qtSupport->projectFilePath(m_target);
|
||||||
|
|
||||||
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)
|
const QDir dir = qtSupport->projectFilePath(m_target).toFileInfo().absoluteDir();
|
||||||
m_entries += QLatin1String("$$PWD/")
|
for (const QString &path : list)
|
||||||
+ pro->filePath().toFileInfo().absoluteDir().relativeFilePath(path);
|
m_entries += "$$PWD/" + dir.relativeFilePath(path);
|
||||||
|
|
||||||
pro->setProVariable("ANDROID_EXTRA_LIBS", m_entries, m_scope,
|
|
||||||
QmakeProjectManager::Internal::ProWriter::ReplaceValues
|
|
||||||
| QmakeProjectManager::Internal::ProWriter::MultiLine);
|
|
||||||
|
|
||||||
|
qtSupport->setTargetData(Constants::AndroidExtraLibs, m_entries, m_target);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,10 +128,7 @@ bool greaterModelIndexByRow(const QModelIndex &a, const QModelIndex &b)
|
|||||||
|
|
||||||
void AndroidExtraLibraryListModel::removeEntries(QModelIndexList list)
|
void AndroidExtraLibraryListModel::removeEntries(QModelIndexList list)
|
||||||
{
|
{
|
||||||
QmakeProjectManager::QmakeProFile *pro = activeProFile();
|
if (list.isEmpty())
|
||||||
if (!pro)
|
|
||||||
return;
|
|
||||||
if (list.isEmpty() || !pro || pro->projectType() != QmakeProjectManager::ProjectType::ApplicationTemplate)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::sort(list.begin(), list.end(), greaterModelIndexByRow);
|
std::sort(list.begin(), list.end(), greaterModelIndexByRow);
|
||||||
@@ -174,5 +147,9 @@ void AndroidExtraLibraryListModel::removeEntries(QModelIndexList list)
|
|||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
pro->setProVariable(QLatin1String("ANDROID_EXTRA_LIBS"), m_entries, m_scope);
|
AndroidQtSupport *qtSupport = AndroidManager::androidQtSupport(m_target);
|
||||||
|
QTC_ASSERT(qtSupport, return);
|
||||||
|
qtSupport->setTargetData(Constants::AndroidExtraLibs, m_entries, m_target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // Android
|
@@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "android_global.h"
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
@@ -34,12 +36,9 @@ class RunConfiguration;
|
|||||||
class Target;
|
class Target;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace QmakeProjectManager { class QmakeProFile; }
|
namespace Android {
|
||||||
|
|
||||||
namespace QmakeAndroidSupport {
|
class ANDROID_EXPORT AndroidExtraLibraryListModel : public QAbstractItemModel
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
class AndroidExtraLibraryListModel : public QAbstractItemModel
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@@ -55,19 +54,14 @@ public:
|
|||||||
void removeEntries(QModelIndexList list);
|
void removeEntries(QModelIndexList list);
|
||||||
void addEntries(const QStringList &list);
|
void addEntries(const QStringList &list);
|
||||||
|
|
||||||
bool isEnabled() const;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void enabledChanged(bool);
|
void enabledChanged(bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateModel();
|
void updateModel();
|
||||||
QmakeProjectManager::QmakeProFile *activeProFile() const;
|
|
||||||
|
|
||||||
ProjectExplorer::Target *m_target;
|
ProjectExplorer::Target *m_target;
|
||||||
QStringList m_entries;
|
QStringList m_entries;
|
||||||
QString m_scope;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Android
|
||||||
} // namespace QmakeAndroidSupport
|
|
@@ -47,6 +47,7 @@ namespace Constants {
|
|||||||
const char AndroidPackageSourceDir[] = "AndroidPackageSourceDir";
|
const char AndroidPackageSourceDir[] = "AndroidPackageSourceDir";
|
||||||
const char AndroidDeploySettingsFile[] = "AndroidDeploySettingsFile";
|
const char AndroidDeploySettingsFile[] = "AndroidDeploySettingsFile";
|
||||||
const char AndroidExtraLibs[] = "AndroidExtraLibs";
|
const char AndroidExtraLibs[] = "AndroidExtraLibs";
|
||||||
|
const char AndroidArch[] = "AndroidArch";
|
||||||
|
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
|
|
||||||
@@ -73,6 +74,13 @@ public:
|
|||||||
|
|
||||||
virtual QString targetDataItem(Core::Id role, const ProjectExplorer::Target *target) const = 0;
|
virtual QString targetDataItem(Core::Id role, const ProjectExplorer::Target *target) const = 0;
|
||||||
virtual QStringList targetData(Core::Id role, const ProjectExplorer::Target *target) const = 0;
|
virtual QStringList targetData(Core::Id role, const ProjectExplorer::Target *target) const = 0;
|
||||||
|
virtual bool setTargetData(Core::Id role, const QStringList &values,
|
||||||
|
const ProjectExplorer::Target *target) const = 0;
|
||||||
|
|
||||||
|
virtual bool parseInProgress(const ProjectExplorer::Target *target) const = 0;
|
||||||
|
virtual bool validParse(const ProjectExplorer::Target *target) const = 0;
|
||||||
|
virtual bool extraLibraryEnabled(const ProjectExplorer::Target *target) const = 0;
|
||||||
|
virtual Utils::FileName projectFilePath(const ProjectExplorer::Target *target) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Android
|
} // namespace Android
|
||||||
|
@@ -41,6 +41,8 @@
|
|||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
using namespace Android;
|
||||||
|
|
||||||
namespace QmakeAndroidSupport {
|
namespace QmakeAndroidSupport {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -108,7 +110,9 @@ QmakeAndroidBuildApkWidget::QmakeAndroidBuildApkWidget(Android::AndroidBuildApkS
|
|||||||
connect(m_extraLibraryListModel, &AndroidExtraLibraryListModel::enabledChanged,
|
connect(m_extraLibraryListModel, &AndroidExtraLibraryListModel::enabledChanged,
|
||||||
additionalLibrariesGroupBox, &QWidget::setEnabled);
|
additionalLibrariesGroupBox, &QWidget::setEnabled);
|
||||||
|
|
||||||
additionalLibrariesGroupBox->setEnabled(m_extraLibraryListModel->isEnabled());
|
AndroidQtSupport *qtSupport = AndroidManager::androidQtSupport(m_step->target());
|
||||||
|
QTC_ASSERT(qtSupport, return);
|
||||||
|
additionalLibrariesGroupBox->setEnabled(qtSupport->extraLibraryEnabled(m_step->target()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeAndroidBuildApkWidget::createAndroidTemplatesButton()
|
void QmakeAndroidBuildApkWidget::createAndroidTemplatesButton()
|
||||||
|
@@ -25,10 +25,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "androidextralibrarylistmodel.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/buildstep.h>
|
#include <projectexplorer/buildstep.h>
|
||||||
|
|
||||||
#include <android/androidbuildapkstep.h>
|
#include <android/androidbuildapkstep.h>
|
||||||
|
#include <android/androidextralibrarylistmodel.h>
|
||||||
|
#include <android/androidqtsupport.h>
|
||||||
|
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
@@ -57,7 +58,7 @@ private:
|
|||||||
QToolButton *m_removeAndroidExtraLibButton = nullptr;
|
QToolButton *m_removeAndroidExtraLibButton = nullptr;
|
||||||
|
|
||||||
Android::AndroidBuildApkStep *m_step = nullptr;
|
Android::AndroidBuildApkStep *m_step = nullptr;
|
||||||
AndroidExtraLibraryListModel *m_extraLibraryListModel = nullptr;
|
Android::AndroidExtraLibraryListModel *m_extraLibraryListModel = nullptr;
|
||||||
bool m_ignoreChange = false;
|
bool m_ignoreChange = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -74,12 +74,67 @@ QStringList QmakeAndroidSupport::targetData(Core::Id role, const Target *target)
|
|||||||
var = Variable::AndroidDeploySettingsFile;
|
var = Variable::AndroidDeploySettingsFile;
|
||||||
else if (role == Android::Constants::AndroidExtraLibs)
|
else if (role == Android::Constants::AndroidExtraLibs)
|
||||||
var = Variable::AndroidExtraLibs;
|
var = Variable::AndroidExtraLibs;
|
||||||
|
else if (role == Android::Constants::AndroidArch)
|
||||||
|
var = Variable::AndroidArch;
|
||||||
else
|
else
|
||||||
QTC_CHECK(false);
|
QTC_CHECK(false);
|
||||||
|
|
||||||
return profileNode->variableValue(var);
|
return profileNode->variableValue(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QmakeProFile *applicationProFile(const Target *target)
|
||||||
|
{
|
||||||
|
ProjectExplorer::RunConfiguration *rc = target->activeRunConfiguration();
|
||||||
|
if (!rc)
|
||||||
|
return nullptr;
|
||||||
|
auto project = static_cast<QmakeProject *>(target->project());
|
||||||
|
return project->rootProFile()->findProFile(FileName::fromString(rc->buildKey()));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QmakeAndroidSupport::parseInProgress(const Target *target) const
|
||||||
|
{
|
||||||
|
QmakeProjectManager::QmakeProFile *pro = applicationProFile(target);
|
||||||
|
return !pro || pro->parseInProgress();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QmakeAndroidSupport::validParse(const Target *target) const
|
||||||
|
{
|
||||||
|
QmakeProjectManager::QmakeProFile *pro = applicationProFile(target);
|
||||||
|
return pro->validParse() && pro->projectType() == ProjectType::ApplicationTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QmakeAndroidSupport::extraLibraryEnabled(const Target *target) const
|
||||||
|
{
|
||||||
|
QmakeProFile *pro = applicationProFile(target);
|
||||||
|
return pro && !pro->parseInProgress();
|
||||||
|
}
|
||||||
|
|
||||||
|
FileName QmakeAndroidSupport::projectFilePath(const Target *target) const
|
||||||
|
{
|
||||||
|
QmakeProFile *pro = applicationProFile(target);
|
||||||
|
return pro ? pro->filePath() : FileName();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QmakeAndroidSupport::setTargetData(Core::Id role, const QStringList &values, const Target *target) const
|
||||||
|
{
|
||||||
|
QmakeProFile *pro = applicationProFile(target);
|
||||||
|
if (!pro)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QString var;
|
||||||
|
if (role == Android::Constants::AndroidExtraLibs)
|
||||||
|
var = "ANDROID_EXTRA_LIBS";
|
||||||
|
|
||||||
|
if (var.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const QString arch = pro->singleVariableValue(Variable::AndroidArch);
|
||||||
|
const QString scope = "contains(ANDROID_TARGET_ARCH," + arch + ')';
|
||||||
|
return pro->setProVariable(var, values, scope,
|
||||||
|
QmakeProjectManager::Internal::ProWriter::ReplaceValues
|
||||||
|
| QmakeProjectManager::Internal::ProWriter::MultiLine);
|
||||||
|
}
|
||||||
|
|
||||||
QString QmakeAndroidSupport::targetDataItem(Core::Id role, const Target *target) const
|
QString QmakeAndroidSupport::targetDataItem(Core::Id role, const Target *target) const
|
||||||
{
|
{
|
||||||
const QStringList data = targetData(role, target);
|
const QStringList data = targetData(role, target);
|
||||||
|
@@ -42,6 +42,13 @@ public:
|
|||||||
|
|
||||||
QString targetDataItem(Core::Id role, const ProjectExplorer::Target *target) const override;
|
QString targetDataItem(Core::Id role, const ProjectExplorer::Target *target) const override;
|
||||||
QStringList targetData(Core::Id role, const ProjectExplorer::Target *target) const override;
|
QStringList targetData(Core::Id role, const ProjectExplorer::Target *target) const override;
|
||||||
|
bool setTargetData(Core::Id role, const QStringList &values,
|
||||||
|
const ProjectExplorer::Target *target) const override;
|
||||||
|
|
||||||
|
bool parseInProgress(const ProjectExplorer::Target *target) const override;
|
||||||
|
bool validParse(const ProjectExplorer::Target *target) const override;
|
||||||
|
bool extraLibraryEnabled(const ProjectExplorer::Target *target) const override;
|
||||||
|
Utils::FileName projectFilePath(const ProjectExplorer::Target *target) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -5,7 +5,6 @@ DEFINES += \
|
|||||||
QMAKEANDROID_LIBRARY
|
QMAKEANDROID_LIBRARY
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
androidextralibrarylistmodel.h \
|
|
||||||
createandroidmanifestwizard.h \
|
createandroidmanifestwizard.h \
|
||||||
qmakeandroidsupport.h \
|
qmakeandroidsupport.h \
|
||||||
qmakeandroidbuildapkstep.h \
|
qmakeandroidbuildapkstep.h \
|
||||||
@@ -14,7 +13,6 @@ HEADERS += \
|
|||||||
qmakeandroidsupportplugin.h
|
qmakeandroidsupportplugin.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
androidextralibrarylistmodel.cpp \
|
|
||||||
createandroidmanifestwizard.cpp \
|
createandroidmanifestwizard.cpp \
|
||||||
qmakeandroidsupport.cpp \
|
qmakeandroidsupport.cpp \
|
||||||
qmakeandroidbuildapkstep.cpp \
|
qmakeandroidbuildapkstep.cpp \
|
||||||
|
@@ -16,8 +16,6 @@ QtcPlugin {
|
|||||||
Depends { name: "Qt.widgets" }
|
Depends { name: "Qt.widgets" }
|
||||||
|
|
||||||
files: [
|
files: [
|
||||||
"androidextralibrarylistmodel.cpp",
|
|
||||||
"androidextralibrarylistmodel.h",
|
|
||||||
"createandroidmanifestwizard.cpp",
|
"createandroidmanifestwizard.cpp",
|
||||||
"createandroidmanifestwizard.h",
|
"createandroidmanifestwizard.h",
|
||||||
"qmakeandroidbuildapkstep.cpp",
|
"qmakeandroidbuildapkstep.cpp",
|
||||||
|
Reference in New Issue
Block a user