forked from qt-creator/qt-creator
Android: Simplify code in manifest editor
Change-Id: I1a54cc1d59b9fdf03083363cc26c25f72e893006 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -86,15 +86,15 @@ bool checkPackageName(const QString &packageName)
|
||||
return QRegExp(packageNameRegExp).exactMatch(packageName);
|
||||
}
|
||||
|
||||
Project *androidProject(const Utils::FilePath &fileName)
|
||||
Target *androidTarget(const Utils::FilePath &fileName)
|
||||
{
|
||||
for (Project *project : SessionManager::projects()) {
|
||||
if (!project->activeTarget())
|
||||
continue;
|
||||
Kit *kit = project->activeTarget()->kit();
|
||||
if (Target *target = project->activeTarget()) {
|
||||
Kit *kit = target->kit();
|
||||
if (DeviceTypeKitAspect::deviceTypeId(kit) == Android::Constants::ANDROID_DEVICE_TYPE
|
||||
&& fileName.isChildOf(project->projectDirectory()))
|
||||
return project;
|
||||
return target;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -489,18 +489,14 @@ void AndroidManifestEditorWidget::focusInEvent(QFocusEvent *event)
|
||||
|
||||
void AndroidManifestEditorWidget::updateTargetComboBox()
|
||||
{
|
||||
Project *project = androidProject(m_textEditorWidget->textDocument()->filePath());
|
||||
QStringList items;
|
||||
if (project) {
|
||||
Kit *kit = project->activeTarget()->kit();
|
||||
if (DeviceTypeKitAspect::deviceTypeId(kit) == Constants::ANDROID_DEVICE_TYPE) {
|
||||
ProjectNode *root = project->rootProjectNode();
|
||||
if (Target *target = androidTarget(m_textEditorWidget->textDocument()->filePath())) {
|
||||
ProjectNode *root = target->project()->rootProjectNode();
|
||||
root->forEachProjectNode([&items](const ProjectNode *projectNode) {
|
||||
items << projectNode->targetApplications();
|
||||
});
|
||||
items.sort();
|
||||
}
|
||||
}
|
||||
|
||||
// QComboBox randomly resets what the user has entered
|
||||
// if all rows are removed, thus we ensure that the current text
|
||||
@@ -606,9 +602,7 @@ void AndroidManifestEditorWidget::preSave()
|
||||
void AndroidManifestEditorWidget::postSave()
|
||||
{
|
||||
const Utils::FilePath docPath = m_textEditorWidget->textDocument()->filePath();
|
||||
ProjectExplorer::Project *project = androidProject(docPath);
|
||||
if (project) {
|
||||
if (Target *target = project->activeTarget()) {
|
||||
if (Target *target = androidTarget(docPath)) {
|
||||
if (BuildConfiguration *bc = target->activeBuildConfiguration()) {
|
||||
QString androidNdkPlatform = AndroidConfigurations::currentConfig()
|
||||
.bestNdkPlatformMatch(AndroidManager::minimumSDK(target));
|
||||
@@ -619,7 +613,6 @@ void AndroidManifestEditorWidget::postSave()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Core::IEditor *AndroidManifestEditorWidget::editor() const
|
||||
|
Reference in New Issue
Block a user