forked from qt-creator/qt-creator
ProjectExplorer: Allow more runconfigs to be used as clone data source
I believe this can be useful to copy (parts of) run configurations between related targets, that are not exactly the same, e.g. two related, but formally independent test binaries. Change-Id: I5da13098d460671c81acd61a02d18a7b48fdba06 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "projectconfiguration.h"
|
#include "projectconfiguration.h"
|
||||||
|
|
||||||
|
#include "projectexplorerconstants.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
@@ -12,9 +13,6 @@
|
|||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
const char CONFIGURATION_ID_KEY[] = "ProjectExplorer.ProjectConfiguration.Id";
|
|
||||||
const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DisplayName";
|
|
||||||
|
|
||||||
// ProjectConfiguration
|
// ProjectConfiguration
|
||||||
|
|
||||||
ProjectConfiguration::ProjectConfiguration(Target *target, Id id)
|
ProjectConfiguration::ProjectConfiguration(Target *target, Id id)
|
||||||
@@ -71,8 +69,8 @@ QString ProjectConfiguration::toolTip() const
|
|||||||
void ProjectConfiguration::toMap(Store &map) const
|
void ProjectConfiguration::toMap(Store &map) const
|
||||||
{
|
{
|
||||||
QTC_CHECK(m_id.isValid());
|
QTC_CHECK(m_id.isValid());
|
||||||
map.insert(CONFIGURATION_ID_KEY, m_id.toSetting());
|
map.insert(Constants::CONFIGURATION_ID_KEY, m_id.toSetting());
|
||||||
m_displayName.toMap(map, DISPLAY_NAME_KEY);
|
m_displayName.toMap(map, Constants::DISPLAY_NAME_KEY);
|
||||||
AspectContainer::toMap(map);
|
AspectContainer::toMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,18 +81,18 @@ Target *ProjectConfiguration::target() const
|
|||||||
|
|
||||||
void ProjectConfiguration::fromMap(const Store &map)
|
void ProjectConfiguration::fromMap(const Store &map)
|
||||||
{
|
{
|
||||||
Id id = Id::fromSetting(map.value(CONFIGURATION_ID_KEY));
|
Id id = Id::fromSetting(map.value(Constants::CONFIGURATION_ID_KEY));
|
||||||
// Note: This is only "startsWith", not ==, as RunConfigurations currently still
|
// Note: This is only "startsWith", not ==, as RunConfigurations currently still
|
||||||
// mangle in their build keys.
|
// mangle in their build keys.
|
||||||
QTC_ASSERT(id.name().startsWith(m_id.name()), reportError(); return);
|
QTC_ASSERT(id.name().startsWith(m_id.name()), reportError(); return);
|
||||||
|
|
||||||
m_displayName.fromMap(map, DISPLAY_NAME_KEY);
|
m_displayName.fromMap(map, Constants::DISPLAY_NAME_KEY);
|
||||||
AspectContainer::fromMap(map);
|
AspectContainer::fromMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
Id ProjectExplorer::idFromMap(const Store &map)
|
Id ProjectExplorer::idFromMap(const Store &map)
|
||||||
{
|
{
|
||||||
return Id::fromSetting(map.value(CONFIGURATION_ID_KEY));
|
return Id::fromSetting(map.value(Constants::CONFIGURATION_ID_KEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ProjectConfiguration::expandedDisplayName() const
|
QString ProjectConfiguration::expandedDisplayName() const
|
||||||
|
@@ -128,6 +128,10 @@ const char COPY_DIRECTORY_STEP[] = "ProjectExplorer.CopyDirectoryStep";
|
|||||||
const char DEVICE_CHECK_STEP[] = "ProjectExplorer.DeviceCheckBuildStep";
|
const char DEVICE_CHECK_STEP[] = "ProjectExplorer.DeviceCheckBuildStep";
|
||||||
const char CUSTOM_PROCESS_STEP[] = "ProjectExplorer.ProcessStep";
|
const char CUSTOM_PROCESS_STEP[] = "ProjectExplorer.ProcessStep";
|
||||||
|
|
||||||
|
// Project Configuration
|
||||||
|
const char CONFIGURATION_ID_KEY[] = "ProjectExplorer.ProjectConfiguration.Id";
|
||||||
|
const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DisplayName";
|
||||||
|
|
||||||
// Language
|
// Language
|
||||||
|
|
||||||
// Keep these short: These constants are exposed to the MacroExplorer!
|
// Keep these short: These constants are exposed to the MacroExplorer!
|
||||||
|
@@ -420,19 +420,15 @@ RunConfiguration *RunConfiguration::clone(BuildConfiguration *bc)
|
|||||||
|
|
||||||
void RunConfiguration::cloneFromOther(const RunConfiguration *rc)
|
void RunConfiguration::cloneFromOther(const RunConfiguration *rc)
|
||||||
{
|
{
|
||||||
Store map;
|
Store ownData;
|
||||||
rc->toMap(map);
|
toMap(ownData);
|
||||||
fromMap(map);
|
|
||||||
|
|
||||||
// Same build config? Then uniquify the name.
|
Store copyData;
|
||||||
if (rc->buildConfiguration() == buildConfiguration()) {
|
rc->toMap(copyData);
|
||||||
QList<RunConfiguration *> others = buildConfiguration()->runConfigurations();
|
copyData.insert(Constants::CONFIGURATION_ID_KEY, ownData.value(Constants::CONFIGURATION_ID_KEY));
|
||||||
others.removeOne(this);
|
copyData.insert(Constants::DISPLAY_NAME_KEY, ownData.value(Constants::DISPLAY_NAME_KEY));
|
||||||
const QStringList otherNames = Utils::transform(others, [](const RunConfiguration *rc) {
|
copyData.insert(BUILD_KEY, ownData.value(BUILD_KEY));
|
||||||
return rc->displayName();
|
fromMap(copyData);
|
||||||
});
|
|
||||||
setDisplayName(makeUniquelyNumbered(rc->displayName(), otherNames));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildTargetInfo RunConfiguration::buildTargetInfo() const
|
BuildTargetInfo RunConfiguration::buildTargetInfo() const
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
#include <QFont>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
@@ -55,7 +56,7 @@ public:
|
|||||||
for (const BuildConfiguration * const bc : t->buildConfigurations()) {
|
for (const BuildConfiguration * const bc : t->buildConfigurations()) {
|
||||||
RCList rcsForBuildConfig;
|
RCList rcsForBuildConfig;
|
||||||
for (const RunConfiguration * const rc : bc->runConfigurations()) {
|
for (const RunConfiguration * const rc : bc->runConfigurations()) {
|
||||||
if (rc != thisRc && rc->buildKey() == thisRc->buildKey())
|
if (rc != thisRc)
|
||||||
rcsForBuildConfig << rc;
|
rcsForBuildConfig << rc;
|
||||||
}
|
}
|
||||||
if (!rcsForBuildConfig.isEmpty())
|
if (!rcsForBuildConfig.isEmpty())
|
||||||
@@ -69,27 +70,30 @@ public:
|
|||||||
// to removal of any configurations while the dialog is running.
|
// to removal of any configurations while the dialog is running.
|
||||||
if (eligibleRcs.isEmpty()) {
|
if (eligibleRcs.isEmpty()) {
|
||||||
m_rcModel->rootItem()->appendChild(new StaticTreeItem(
|
m_rcModel->rootItem()->appendChild(new StaticTreeItem(
|
||||||
Tr::tr("There are no other run configurations for this application.")));
|
Tr::tr("There are no other run configurations.")));
|
||||||
|
m_rcView->setSelectionMode(TreeView::NoSelection);
|
||||||
} else {
|
} else {
|
||||||
for (auto targetIt = eligibleRcs.cbegin(); targetIt != eligibleRcs.cend(); ++targetIt) {
|
for (auto targetIt = eligibleRcs.cbegin(); targetIt != eligibleRcs.cend(); ++targetIt) {
|
||||||
const auto targetItem = new StaticTreeItem(targetIt.key()->displayName());
|
const auto targetItem = new StaticTreeItem(targetIt.key()->displayName());
|
||||||
for (auto bcIt = targetIt.value().cbegin(); bcIt != targetIt.value().cend();
|
for (auto bcIt = targetIt.value().cbegin(); bcIt != targetIt.value().cend();
|
||||||
++bcIt) {
|
++bcIt) {
|
||||||
const auto bcItem = new StaticTreeItem(bcIt.key()->displayName());
|
const auto bcItem = new StaticTreeItem(bcIt.key()->displayName());
|
||||||
for (const RunConfiguration *const rc : std::as_const(bcIt.value()))
|
for (const RunConfiguration *const rc : std::as_const(bcIt.value())) {
|
||||||
bcItem->appendChild(new RCTreeItem(rc));
|
bcItem->appendChild(
|
||||||
|
new RCTreeItem(rc, rc->buildKey() == thisRc->buildKey()));
|
||||||
|
}
|
||||||
targetItem->appendChild(bcItem);
|
targetItem->appendChild(bcItem);
|
||||||
}
|
}
|
||||||
m_rcModel->rootItem()->appendChild(targetItem);
|
m_rcModel->rootItem()->appendChild(targetItem);
|
||||||
}
|
}
|
||||||
|
m_rcView->setSelectionMode(TreeView::SingleSelection);
|
||||||
|
m_rcView->setSelectionBehavior(TreeView::SelectItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI
|
// UI
|
||||||
m_rcView->setModel(m_rcModel);
|
m_rcView->setModel(m_rcModel);
|
||||||
m_rcView->expandAll();
|
m_rcView->expandAll();
|
||||||
setWindowTitle(Tr::tr("Clone From Run Configuration"));
|
setWindowTitle(Tr::tr("Clone From Run Configuration"));
|
||||||
m_rcView->setSelectionMode(TreeView::SingleSelection);
|
|
||||||
m_rcView->setSelectionBehavior(TreeView::SelectItems);
|
|
||||||
m_rcView->setSortingEnabled(true);
|
m_rcView->setSortingEnabled(true);
|
||||||
m_rcView->resizeColumnToContents(0);
|
m_rcView->resizeColumnToContents(0);
|
||||||
m_rcView->sortByColumn(0, Qt::AscendingOrder);
|
m_rcView->sortByColumn(0, Qt::AscendingOrder);
|
||||||
@@ -116,10 +120,23 @@ private:
|
|||||||
class RCTreeItem : public StaticTreeItem
|
class RCTreeItem : public StaticTreeItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RCTreeItem(const RunConfiguration *rc): StaticTreeItem(rc->displayName()), m_rc(rc) {}
|
RCTreeItem(const RunConfiguration *rc, bool sameBuildKey)
|
||||||
|
: StaticTreeItem(rc->displayName()), m_rc(rc), m_sameBuildKey(sameBuildKey) {}
|
||||||
const RunConfiguration *runConfig() const { return m_rc; }
|
const RunConfiguration *runConfig() const { return m_rc; }
|
||||||
private:
|
private:
|
||||||
QPointer<const RunConfiguration> m_rc;
|
QVariant data(int column, int role) const override
|
||||||
|
{
|
||||||
|
QTC_ASSERT(column == 0, return {});
|
||||||
|
if (role == Qt::FontRole && m_sameBuildKey) {
|
||||||
|
QFont f = StaticTreeItem::data(column, role).value<QFont>();
|
||||||
|
f.setBold(true);
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
return StaticTreeItem::data(column, role);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QPointer<const RunConfiguration> m_rc;
|
||||||
|
const bool m_sameBuildKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
void accept() override
|
void accept() override
|
||||||
|
Reference in New Issue
Block a user