forked from qt-creator/qt-creator
ProjectExplorer: Do not create replacement kits automatically
Instead keep a list of "vanished targets". These are shown in Projects mode in a separate list under the list of kits. Via the context menus of those items (or with single-click), the user can choose to either copy the steps of the vanished target to another kit (already configured or not), or to create a new replacement kit for it (similar to the previous replacement kits, with the same device type and the steps restored, but no other parameters from the kit restored - the project doesn't save that information), or remove them. The vanished targets are not removed from the project's settings as long as the user doesn't create a kit or copy the steps, so if the kit re-appears on a later run of Qt Creator, the original target is restored for that kit and the entry in the "vanished targets" list automatically vanishes. This has the advantage that in contrast to the replacement kits, the vanished targets are clearly separate from "normal" kits, and that they are local to the project. Nothing is left behind after closing the project. Change-Id: Iccec04fea38cd55ff683665c9cf4edc9a2388c82 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -768,11 +768,6 @@ void Kit::kitUpdated()
|
|||||||
|
|
||||||
static Id replacementKey() { return "IsReplacementKit"; }
|
static Id replacementKey() { return "IsReplacementKit"; }
|
||||||
|
|
||||||
void ProjectExplorer::Kit::makeReplacementKit()
|
|
||||||
{
|
|
||||||
setValueSilently(replacementKey(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Kit::isReplacementKit() const
|
bool Kit::isReplacementKit() const
|
||||||
{
|
{
|
||||||
return value(replacementKey()).toBool();
|
return value(replacementKey()).toBool();
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ public:
|
|||||||
void setMutable(Utils::Id id, bool b);
|
void setMutable(Utils::Id id, bool b);
|
||||||
bool isMutable(Utils::Id id) const;
|
bool isMutable(Utils::Id id) const;
|
||||||
|
|
||||||
void makeReplacementKit();
|
|
||||||
bool isReplacementKit() const;
|
bool isReplacementKit() const;
|
||||||
|
|
||||||
void setRelevantAspects(const QSet<Utils::Id> &relevant);
|
void setRelevantAspects(const QSet<Utils::Id> &relevant);
|
||||||
|
|||||||
@@ -195,6 +195,8 @@ public:
|
|||||||
mutable QVector<const Node *> m_sortedNodeList;
|
mutable QVector<const Node *> m_sortedNodeList;
|
||||||
|
|
||||||
Store m_extraData;
|
Store m_extraData;
|
||||||
|
|
||||||
|
QList<Store> m_vanishedTargets;
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectPrivate::~ProjectPrivate()
|
ProjectPrivate::~ProjectPrivate()
|
||||||
@@ -442,6 +444,54 @@ void Project::setActiveTarget(Target *target, SetActive cascade)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Store> Project::vanishedTargets() const
|
||||||
|
{
|
||||||
|
return d->m_vanishedTargets;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Project::removeVanishedTarget(int index)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(index >= 0 && index < d->m_vanishedTargets.size(), return);
|
||||||
|
d->m_vanishedTargets.removeAt(index);
|
||||||
|
emit vanishedTargetsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Project::removeAllVanishedTargets()
|
||||||
|
{
|
||||||
|
d->m_vanishedTargets.clear();
|
||||||
|
emit vanishedTargetsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
Target *Project::createKitAndTargetFromStore(const Utils::Store &store)
|
||||||
|
{
|
||||||
|
const Id id = idFromMap(store);
|
||||||
|
Id deviceTypeId = Id::fromSetting(store.value(Target::deviceTypeKey()));
|
||||||
|
if (!deviceTypeId.isValid())
|
||||||
|
deviceTypeId = Constants::DESKTOP_DEVICE_TYPE;
|
||||||
|
const QString formerKitName = store.value(Target::displayNameKey()).toString();
|
||||||
|
Kit *k = KitManager::registerKit(
|
||||||
|
[deviceTypeId, &formerKitName](Kit *kit) {
|
||||||
|
const QString kitName = makeUniquelyNumbered(formerKitName,
|
||||||
|
transform(KitManager::kits(),
|
||||||
|
&Kit::unexpandedDisplayName));
|
||||||
|
kit->setUnexpandedDisplayName(kitName);
|
||||||
|
DeviceTypeKitAspect::setDeviceTypeId(kit, deviceTypeId);
|
||||||
|
kit->setup();
|
||||||
|
},
|
||||||
|
id);
|
||||||
|
QTC_ASSERT(k, return nullptr);
|
||||||
|
auto t = std::make_unique<Target>(this, k, Target::_constructor_tag{});
|
||||||
|
if (!t->fromMap(store))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
if (t->runConfigurations().isEmpty() && t->buildConfigurations().isEmpty())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto pointer = t.get();
|
||||||
|
addTarget(std::move(t));
|
||||||
|
return pointer;
|
||||||
|
}
|
||||||
|
|
||||||
Tasks Project::projectIssues(const Kit *k) const
|
Tasks Project::projectIssues(const Kit *k) const
|
||||||
{
|
{
|
||||||
Tasks result;
|
Tasks result;
|
||||||
@@ -566,6 +616,23 @@ bool Project::copySteps(Target *sourceTarget, Target *newTarget)
|
|||||||
return !fatalError;
|
return !fatalError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Project::copySteps(const Utils::Store &store, Kit *targetKit)
|
||||||
|
{
|
||||||
|
Target *t = target(targetKit->id());
|
||||||
|
if (!t) {
|
||||||
|
auto t = std::make_unique<Target>(this, targetKit, Target::_constructor_tag{});
|
||||||
|
if (!t->fromMap(store))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (t->runConfigurations().isEmpty() && t->buildConfigurations().isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
addTarget(std::move(t));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return t->addConfigurationsFromMap(store, /*setActiveConfigurations=*/false);
|
||||||
|
}
|
||||||
|
|
||||||
bool Project::setupTarget(Target *t)
|
bool Project::setupTarget(Target *t)
|
||||||
{
|
{
|
||||||
if (d->m_needsBuildConfigurations)
|
if (d->m_needsBuildConfigurations)
|
||||||
@@ -700,11 +767,19 @@ FilePaths Project::files(const NodeMatcher &filter) const
|
|||||||
void Project::toMap(Store &map) const
|
void Project::toMap(Store &map) const
|
||||||
{
|
{
|
||||||
const QList<Target *> ts = targets();
|
const QList<Target *> ts = targets();
|
||||||
|
const QList<Store> vts = vanishedTargets();
|
||||||
|
|
||||||
map.insert(ACTIVE_TARGET_KEY, ts.indexOf(d->m_activeTarget));
|
map.insert(ACTIVE_TARGET_KEY, ts.indexOf(d->m_activeTarget));
|
||||||
map.insert(TARGET_COUNT_KEY, ts.size());
|
map.insert(TARGET_COUNT_KEY, ts.size() + vts.size());
|
||||||
for (int i = 0; i < ts.size(); ++i)
|
int index = 0;
|
||||||
map.insert(numberedKey(TARGET_KEY_PREFIX, i), variantFromStore(ts.at(i)->toMap()));
|
for (Target *t : ts) {
|
||||||
|
map.insert(numberedKey(TARGET_KEY_PREFIX, index), variantFromStore(t->toMap()));
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
for (const Store &store : vts) {
|
||||||
|
map.insert(numberedKey(TARGET_KEY_PREFIX, index), variantFromStore(store));
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
|
||||||
map.insert(EDITOR_SETTINGS_KEY, variantFromStore(d->m_editorConfiguration.toMap()));
|
map.insert(EDITOR_SETTINGS_KEY, variantFromStore(d->m_editorConfiguration.toMap()));
|
||||||
if (!d->m_pluginSettings.isEmpty())
|
if (!d->m_pluginSettings.isEmpty())
|
||||||
@@ -826,32 +901,16 @@ void Project::createTargetFromMap(const Store &map, int index)
|
|||||||
if (ICore::isQtDesignStudio())
|
if (ICore::isQtDesignStudio())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Id deviceTypeId = Id::fromSetting(targetMap.value(Target::deviceTypeKey()));
|
d->m_vanishedTargets.append(targetMap);
|
||||||
if (!deviceTypeId.isValid())
|
|
||||||
deviceTypeId = Constants::DESKTOP_DEVICE_TYPE;
|
|
||||||
const QString formerKitName = targetMap.value(Target::displayNameKey()).toString();
|
const QString formerKitName = targetMap.value(Target::displayNameKey()).toString();
|
||||||
k = KitManager::registerKit(
|
|
||||||
[deviceTypeId, &formerKitName](Kit *kit) {
|
|
||||||
const QString kitNameSuggestion
|
|
||||||
= formerKitName.contains(::PE::Tr::tr("Replacement for"))
|
|
||||||
? formerKitName
|
|
||||||
: ::PE::Tr::tr("Replacement for \"%1\"").arg(formerKitName);
|
|
||||||
const QString tempKitName = makeUniquelyNumbered(kitNameSuggestion,
|
|
||||||
transform(KitManager::kits(), &Kit::unexpandedDisplayName));
|
|
||||||
kit->setUnexpandedDisplayName(tempKitName);
|
|
||||||
DeviceTypeKitAspect::setDeviceTypeId(kit, deviceTypeId);
|
|
||||||
kit->makeReplacementKit();
|
|
||||||
kit->setup();
|
|
||||||
},
|
|
||||||
id);
|
|
||||||
QTC_ASSERT(k, return);
|
|
||||||
TaskHub::addTask(BuildSystemTask(
|
TaskHub::addTask(BuildSystemTask(
|
||||||
Task::Warning,
|
Task::Warning,
|
||||||
::PE::Tr::tr(
|
::PE::Tr::tr(
|
||||||
"Project \"%1\" was configured for "
|
"Project \"%1\" was configured for "
|
||||||
"kit \"%2\" with id %3, which does not exist anymore. The new kit \"%4\" was "
|
"kit \"%2\" with id %3, which does not exist anymore. You can create a new kit "
|
||||||
"created in its place, in an attempt not to lose custom project settings.")
|
"or copy the steps of the vanished kit to another kit in %4 mode.")
|
||||||
.arg(displayName(), formerKitName, id.toString(), k->displayName())));
|
.arg(displayName(), formerKitName, id.toString(), Tr::tr("Projects"))));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto t = std::make_unique<Target>(this, k, Target::_constructor_tag{});
|
auto t = std::make_unique<Target>(this, k, Target::_constructor_tag{});
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ public:
|
|||||||
virtual Tasks projectIssues(const Kit *k) const;
|
virtual Tasks projectIssues(const Kit *k) const;
|
||||||
|
|
||||||
static bool copySteps(Target *sourceTarget, Target *newTarget);
|
static bool copySteps(Target *sourceTarget, Target *newTarget);
|
||||||
|
bool copySteps(const Utils::Store &store, Kit *targetKit);
|
||||||
|
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
enum class RestoreResult { Ok, Error, UserAbort };
|
enum class RestoreResult { Ok, Error, UserAbort };
|
||||||
@@ -179,6 +180,11 @@ public:
|
|||||||
Utils::MacroExpander *expander,
|
Utils::MacroExpander *expander,
|
||||||
const std::function<Project *()> &projectGetter);
|
const std::function<Project *()> &projectGetter);
|
||||||
|
|
||||||
|
QList<Utils::Store> vanishedTargets() const;
|
||||||
|
void removeVanishedTarget(int index);
|
||||||
|
void removeAllVanishedTargets();
|
||||||
|
Target *createKitAndTargetFromStore(const Utils::Store &store);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void projectFileIsDirty(const Utils::FilePath &path);
|
void projectFileIsDirty(const Utils::FilePath &path);
|
||||||
|
|
||||||
@@ -193,6 +199,8 @@ signals:
|
|||||||
void removedTarget(ProjectExplorer::Target *target);
|
void removedTarget(ProjectExplorer::Target *target);
|
||||||
void addedTarget(ProjectExplorer::Target *target);
|
void addedTarget(ProjectExplorer::Target *target);
|
||||||
|
|
||||||
|
void vanishedTargetsChanged();
|
||||||
|
|
||||||
void settingsLoaded();
|
void settingsLoaded();
|
||||||
void aboutToSaveSettings();
|
void aboutToSaveSettings();
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include "projectwindow.h"
|
#include "projectwindow.h"
|
||||||
|
|
||||||
#include "buildinfo.h"
|
#include "buildinfo.h"
|
||||||
|
#include "devicesupport/idevicefactory.h"
|
||||||
|
|
||||||
#include "kit.h"
|
#include "kit.h"
|
||||||
#include "kitmanager.h"
|
#include "kitmanager.h"
|
||||||
#include "kitoptionspage.h"
|
#include "kitoptionspage.h"
|
||||||
@@ -204,6 +206,154 @@ void BuildSystemOutputWindow::updateFilter()
|
|||||||
m_invertFilterAction.isChecked());
|
m_invertFilterAction.isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class VanishedTargetPanelItem : public TreeItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VanishedTargetPanelItem(const Store &store, Project *project)
|
||||||
|
: m_store(store)
|
||||||
|
, m_project(project)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QVariant data(int column, int role) const override;
|
||||||
|
bool setData(int column, const QVariant &data, int role) override;
|
||||||
|
Qt::ItemFlags flags(int column) const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Store m_store;
|
||||||
|
QPointer<Project> m_project;
|
||||||
|
};
|
||||||
|
|
||||||
|
static QString deviceTypeDisplayName(const Store &store)
|
||||||
|
{
|
||||||
|
Id deviceTypeId = Id::fromSetting(store.value(Target::deviceTypeKey()));
|
||||||
|
if (!deviceTypeId.isValid())
|
||||||
|
deviceTypeId = Constants::DESKTOP_DEVICE_TYPE;
|
||||||
|
|
||||||
|
QString typeDisplayName = Tr::tr("Unknown device type");
|
||||||
|
if (deviceTypeId.isValid()) {
|
||||||
|
if (IDeviceFactory *factory = IDeviceFactory::find(deviceTypeId))
|
||||||
|
typeDisplayName = factory->displayName();
|
||||||
|
}
|
||||||
|
return typeDisplayName;
|
||||||
|
}
|
||||||
|
static QString msgOptionsForRestoringSettings()
|
||||||
|
{
|
||||||
|
return "<html>"
|
||||||
|
+ Tr::tr("The project was configured for kits that no longer exist. Select one of the "
|
||||||
|
"following options in the context menu to restore the project's settings:")
|
||||||
|
+ "<ul><li>"
|
||||||
|
+ Tr::tr("Create a new kit with the same name for the same device type, with the "
|
||||||
|
"original build, deploy, and run steps. Other kit settings are not restored.")
|
||||||
|
+ "</li><li>" + Tr::tr("Copy the build, deploy, and run steps to another kit.")
|
||||||
|
+ "</li></ul></html>";
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant VanishedTargetPanelItem::data(int column, int role) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(column)
|
||||||
|
switch (role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
//: vanished target display role: vanished target name (device type name)
|
||||||
|
return Tr::tr("%1 (%2)").arg(m_store.value(Target::displayNameKey()).toString(),
|
||||||
|
deviceTypeDisplayName(m_store));
|
||||||
|
case Qt::ToolTipRole:
|
||||||
|
return msgOptionsForRestoringSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VanishedTargetPanelItem::setData(int column, const QVariant &data, int role)
|
||||||
|
{
|
||||||
|
Q_UNUSED(column)
|
||||||
|
|
||||||
|
const auto addToMenu = [this](QMenu *menu) {
|
||||||
|
const int index = indexInParent();
|
||||||
|
menu->addAction(Tr::tr("Create a New Kit"),
|
||||||
|
m_project.data(),
|
||||||
|
[index, store = m_store, project = m_project] {
|
||||||
|
Target *t = project->createKitAndTargetFromStore(store);
|
||||||
|
if (t) {
|
||||||
|
project->setActiveTarget(t, SetActive::Cascade);
|
||||||
|
project->removeVanishedTarget(index);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
QMenu *copyMenu = menu->addMenu(Tr::tr("Copy Steps to Another Kit"));
|
||||||
|
const QList<Kit *> kits = KitManager::kits();
|
||||||
|
for (Kit *kit : kits) {
|
||||||
|
QAction *copyAction = copyMenu->addAction(kit->displayName());
|
||||||
|
QObject::connect(copyAction,
|
||||||
|
&QAction::triggered,
|
||||||
|
[index, store = m_store, project = m_project, kit] {
|
||||||
|
if (project->copySteps(store, kit))
|
||||||
|
project->removeVanishedTarget(index);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
menu->addSeparator();
|
||||||
|
menu->addAction(Tr::tr("Remove Vanished Target \"%1\"")
|
||||||
|
.arg(m_store.value(Target::displayNameKey()).toString()),
|
||||||
|
m_project.data(),
|
||||||
|
[index, project = m_project] { project->removeVanishedTarget(index); });
|
||||||
|
menu->addAction(Tr::tr("Remove All Vanished Targets"),
|
||||||
|
m_project.data(),
|
||||||
|
[project = m_project] { project->removeAllVanishedTargets(); });
|
||||||
|
};
|
||||||
|
|
||||||
|
if (role == ContextMenuItemAdderRole) {
|
||||||
|
auto *menu = data.value<QMenu *>();
|
||||||
|
addToMenu(menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (role == ItemActivatedDirectlyRole) {
|
||||||
|
QMenu menu;
|
||||||
|
addToMenu(&menu);
|
||||||
|
menu.exec(QCursor::pos());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags VanishedTargetPanelItem::flags(int column) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(column)
|
||||||
|
return Qt::ItemIsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The middle part of the second tree level, i.e. the list of vanished configured kits/targets.
|
||||||
|
class VanishedTargetsGroupItem : public TreeItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit VanishedTargetsGroupItem(Project *project)
|
||||||
|
: m_project(project)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_project, return);
|
||||||
|
rebuild();
|
||||||
|
}
|
||||||
|
|
||||||
|
void rebuild()
|
||||||
|
{
|
||||||
|
removeChildren();
|
||||||
|
for (const Store &store : m_project->vanishedTargets())
|
||||||
|
appendChild(new VanishedTargetPanelItem(store, m_project));
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags flags(int) const override { return Qt::NoItemFlags; }
|
||||||
|
|
||||||
|
QVariant data(int column, int role) const override
|
||||||
|
{
|
||||||
|
Q_UNUSED(column)
|
||||||
|
switch (role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
return Tr::tr("Vanished Targets");
|
||||||
|
case Qt::ToolTipRole:
|
||||||
|
return msgOptionsForRestoringSettings();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<Project> m_project;
|
||||||
|
};
|
||||||
|
|
||||||
// Standard third level for the generic case: i.e. all except for the Build/Run page
|
// Standard third level for the generic case: i.e. all except for the Build/Run page
|
||||||
class MiscSettingsPanelItem : public TreeItem // TypedTreeItem<TreeItem, MiscSettingsGroupItem>
|
class MiscSettingsPanelItem : public TreeItem // TypedTreeItem<TreeItem, MiscSettingsGroupItem>
|
||||||
{
|
{
|
||||||
@@ -338,9 +488,26 @@ public:
|
|||||||
: m_project(project), m_changeListener(changeListener)
|
: m_project(project), m_changeListener(changeListener)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_project, return);
|
QTC_ASSERT(m_project, return);
|
||||||
QString display = Tr::tr("Build & Run");
|
appendChild(m_targetsItem = new TargetGroupItem(Tr::tr("Build & Run"), m_project));
|
||||||
appendChild(m_targetsItem = new TargetGroupItem(display, project));
|
if (!m_project->vanishedTargets().isEmpty())
|
||||||
appendChild(m_miscItem = new MiscSettingsGroupItem(project));
|
appendChild(m_vanishedTargetsItem = new VanishedTargetsGroupItem(m_project));
|
||||||
|
appendChild(m_miscItem = new MiscSettingsGroupItem(m_project));
|
||||||
|
QObject::connect(
|
||||||
|
m_project,
|
||||||
|
&Project::vanishedTargetsChanged,
|
||||||
|
&m_guard,
|
||||||
|
[this] { rebuildVanishedTargets(); },
|
||||||
|
Qt::QueuedConnection /* this is triggered by a child item, so queue */);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rebuildVanishedTargets()
|
||||||
|
{
|
||||||
|
if (m_vanishedTargetsItem) {
|
||||||
|
if (m_project->vanishedTargets().isEmpty())
|
||||||
|
removeChildAt(indexOf(m_vanishedTargetsItem));
|
||||||
|
else
|
||||||
|
m_vanishedTargetsItem->rebuild();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant data(int column, int role) const override
|
QVariant data(int column, int role) const override
|
||||||
@@ -423,9 +590,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QObject m_guard;
|
||||||
int m_currentChildIndex = 0; // Start with Build & Run.
|
int m_currentChildIndex = 0; // Start with Build & Run.
|
||||||
Project *m_project = nullptr;
|
Project *m_project = nullptr;
|
||||||
TargetGroupItem *m_targetsItem = nullptr;
|
TargetGroupItem *m_targetsItem = nullptr;
|
||||||
|
VanishedTargetsGroupItem *m_vanishedTargetsItem;
|
||||||
MiscSettingsGroupItem *m_miscItem = nullptr;
|
MiscSettingsGroupItem *m_miscItem = nullptr;
|
||||||
const std::function<void ()> m_changeListener;
|
const std::function<void ()> m_changeListener;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -889,15 +889,26 @@ bool Target::fromMap(const Store &map)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(d->m_kit == KitManager::kit(id()), return false);
|
QTC_ASSERT(d->m_kit == KitManager::kit(id()), return false);
|
||||||
|
|
||||||
|
if (!addConfigurationsFromMap(map, /*setActiveConfigurations=*/true))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (map.contains(PLUGIN_SETTINGS_KEY))
|
||||||
|
d->m_pluginSettings = storeFromVariant(map.value(PLUGIN_SETTINGS_KEY));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Target::addConfigurationsFromMap(const Utils::Store &map, bool setActiveConfigurations)
|
||||||
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
int bcCount = map.value(BC_COUNT_KEY, 0).toInt(&ok);
|
int bcCount = map.value(BC_COUNT_KEY, 0).toInt(&ok);
|
||||||
if (!ok || bcCount < 0)
|
if (!ok || bcCount < 0)
|
||||||
bcCount = 0;
|
bcCount = 0;
|
||||||
int activeConfiguration = map.value(ACTIVE_BC_KEY, 0).toInt(&ok);
|
int activeConfiguration = map.value(ACTIVE_BC_KEY, 0).toInt(&ok);
|
||||||
if (!ok || activeConfiguration < 0)
|
if (!ok || 0 > activeConfiguration || bcCount < activeConfiguration)
|
||||||
activeConfiguration = 0;
|
|
||||||
if (0 > activeConfiguration || bcCount < activeConfiguration)
|
|
||||||
activeConfiguration = 0;
|
activeConfiguration = 0;
|
||||||
|
if (!setActiveConfigurations)
|
||||||
|
activeConfiguration = -1;
|
||||||
|
|
||||||
for (int i = 0; i < bcCount; ++i) {
|
for (int i = 0; i < bcCount; ++i) {
|
||||||
const Key key = numberedKey(BC_KEY_PREFIX, i);
|
const Key key = numberedKey(BC_KEY_PREFIX, i);
|
||||||
@@ -921,10 +932,10 @@ bool Target::fromMap(const Store &map)
|
|||||||
if (!ok || dcCount < 0)
|
if (!ok || dcCount < 0)
|
||||||
dcCount = 0;
|
dcCount = 0;
|
||||||
activeConfiguration = map.value(ACTIVE_DC_KEY, 0).toInt(&ok);
|
activeConfiguration = map.value(ACTIVE_DC_KEY, 0).toInt(&ok);
|
||||||
if (!ok || activeConfiguration < 0)
|
if (!ok || 0 > activeConfiguration || dcCount < activeConfiguration)
|
||||||
activeConfiguration = 0;
|
|
||||||
if (0 > activeConfiguration || dcCount < activeConfiguration)
|
|
||||||
activeConfiguration = 0;
|
activeConfiguration = 0;
|
||||||
|
if (!setActiveConfigurations)
|
||||||
|
activeConfiguration = -1;
|
||||||
|
|
||||||
for (int i = 0; i < dcCount; ++i) {
|
for (int i = 0; i < dcCount; ++i) {
|
||||||
const Key key = numberedKey(DC_KEY_PREFIX, i);
|
const Key key = numberedKey(DC_KEY_PREFIX, i);
|
||||||
@@ -948,10 +959,10 @@ bool Target::fromMap(const Store &map)
|
|||||||
if (!ok || rcCount < 0)
|
if (!ok || rcCount < 0)
|
||||||
rcCount = 0;
|
rcCount = 0;
|
||||||
activeConfiguration = map.value(ACTIVE_RC_KEY, 0).toInt(&ok);
|
activeConfiguration = map.value(ACTIVE_RC_KEY, 0).toInt(&ok);
|
||||||
if (!ok || activeConfiguration < 0)
|
if (!ok || 0 > activeConfiguration || rcCount < activeConfiguration)
|
||||||
activeConfiguration = 0;
|
|
||||||
if (0 > activeConfiguration || rcCount < activeConfiguration)
|
|
||||||
activeConfiguration = 0;
|
activeConfiguration = 0;
|
||||||
|
if (!setActiveConfigurations)
|
||||||
|
activeConfiguration = -1;
|
||||||
|
|
||||||
for (int i = 0; i < rcCount; ++i) {
|
for (int i = 0; i < rcCount; ++i) {
|
||||||
const Key key = numberedKey(RC_KEY_PREFIX, i);
|
const Key key = numberedKey(RC_KEY_PREFIX, i);
|
||||||
@@ -972,9 +983,6 @@ bool Target::fromMap(const Store &map)
|
|||||||
setActiveRunConfiguration(rc);
|
setActiveRunConfiguration(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map.contains(PLUGIN_SETTINGS_KEY))
|
|
||||||
d->m_pluginSettings = storeFromVariant(map.value(PLUGIN_SETTINGS_KEY));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool fromMap(const Utils::Store &map);
|
bool fromMap(const Utils::Store &map);
|
||||||
|
bool addConfigurationsFromMap(const Utils::Store &map, bool setActiveConfigurations);
|
||||||
|
|
||||||
void updateDeviceState();
|
void updateDeviceState();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user