Commit 1ca9bab2 authored by Tobias Hunger's avatar Tobias Hunger

Kit: Only make SDK-set KitInformation read-only

Leave the rest user-editable.

Task-number: QTCREATORBUG-9030
Change-Id: I77c9ff980dd9a497bff53ee04dae7e771e4e7e82
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 0ef3acc9
......@@ -81,7 +81,7 @@ ProjectExplorer::KitInformation::ItemList AndroidGdbServerKitInformation::toUser
ProjectExplorer::KitConfigWidget *AndroidGdbServerKitInformation::createConfigWidget(ProjectExplorer::Kit *kit) const
{
return new AndroidGdbServerKitInformationWidget(kit);
return new AndroidGdbServerKitInformationWidget(kit, isSticky(kit));
}
Utils::FileName AndroidGdbServerKitInformation::gdbServer(const ProjectExplorer::Kit *kit)
......@@ -109,8 +109,8 @@ Utils::FileName AndroidGdbServerKitInformation::autoDetect(ProjectExplorer::Kit
///////////////
AndroidGdbServerKitInformationWidget::AndroidGdbServerKitInformationWidget(ProjectExplorer::Kit *kit)
: ProjectExplorer::KitConfigWidget(kit),
AndroidGdbServerKitInformationWidget::AndroidGdbServerKitInformationWidget(ProjectExplorer::Kit *kit, bool sticky)
: ProjectExplorer::KitConfigWidget(kit, sticky),
m_label(new Utils::ElidingLabel),
m_button(new QPushButton(tr("Manage...")))
{
......
......@@ -46,7 +46,7 @@ class AndroidGdbServerKitInformationWidget : public ProjectExplorer::KitConfigWi
{
Q_OBJECT
public:
AndroidGdbServerKitInformationWidget(ProjectExplorer::Kit *kit);
AndroidGdbServerKitInformationWidget(ProjectExplorer::Kit *kit, bool sticky);
QString displayName() const;
QString toolTip() const;
......
......@@ -54,8 +54,8 @@ static const char debuggingToolsWikiLinkC[] = "http://qt-project.org/wiki/Qt_Cre
// DebuggerKitConfigWidget:
// -----------------------------------------------------------------------
DebuggerKitConfigWidget::DebuggerKitConfigWidget(ProjectExplorer::Kit *workingCopy)
: KitConfigWidget(workingCopy),
DebuggerKitConfigWidget::DebuggerKitConfigWidget(ProjectExplorer::Kit *workingCopy, bool sticky)
: KitConfigWidget(workingCopy, sticky),
m_main(new QWidget),
m_label(new Utils::ElidingLabel(m_main)),
m_autoDetectButton(new QPushButton(tr("Auto-detect"))),
......
......@@ -60,7 +60,7 @@ class DebuggerKitConfigWidget : public ProjectExplorer::KitConfigWidget
Q_OBJECT
public:
DebuggerKitConfigWidget(ProjectExplorer::Kit *workingCopy);
DebuggerKitConfigWidget(ProjectExplorer::Kit *workingCopy, bool sticky);
QString displayName() const;
QString toolTip() const;
......
......@@ -274,7 +274,7 @@ QList<ProjectExplorer::Task> DebuggerKitInformation::validateDebugger(const Proj
KitConfigWidget *DebuggerKitInformation::createConfigWidget(Kit *k) const
{
return new Internal::DebuggerKitConfigWidget(k);
return new Internal::DebuggerKitConfigWidget(k, isSticky(k));
}
QString DebuggerKitInformation::userOutput(const DebuggerItem &item)
......
......@@ -105,6 +105,7 @@ public:
bool m_mustNotifyAboutDisplayName;
QHash<Core::Id, QVariant> m_data;
QSet<Core::Id> m_sticky;
};
} // namespace Internal
......@@ -161,6 +162,7 @@ Kit *Kit::clone(bool keepName) const
k->d->m_isValid = d->m_isValid;
k->d->m_icon = d->m_icon;
k->d->m_iconPath = d->m_iconPath;
k->d->m_sticky = d->m_sticky;
return k;
}
......@@ -174,6 +176,7 @@ void Kit::copyFrom(const Kit *k)
d->m_displayName = k->d->m_displayName;
d->m_mustNotify = true;
d->m_mustNotifyAboutDisplayName = true;
d->m_sticky = k->d->m_sticky;
}
bool Kit::isValid() const
......@@ -337,9 +340,15 @@ void Kit::removeKey(Id key)
if (!d->m_data.contains(key))
return;
d->m_data.remove(key);
d->m_sticky.remove(key);
kitUpdated();
}
bool Kit::isSticky(Core::Id id) const
{
return d->m_sticky.contains(id);
}
bool Kit::isDataEqual(const Kit *other) const
{
return d->m_data == other->d->m_data;
......@@ -451,6 +460,7 @@ bool Kit::fromMap(const QVariantMap &data)
setIconPath(data.value(QLatin1String(ICON_KEY)).toString());
QVariantMap extra = data.value(QLatin1String(DATA_KEY)).toMap();
d->m_data.clear(); // remove default values
const QVariantMap::ConstIterator cend = extra.constEnd();
for (QVariantMap::ConstIterator it = extra.constBegin(); it != cend; ++it)
setValue(Id::fromString(it.key()), it.value());
......@@ -468,6 +478,19 @@ void Kit::setSdkProvided(bool sdkProvided)
d->m_sdkProvided = sdkProvided;
}
void Kit::makeSticky()
{
foreach (KitInformation *ki, KitManager::instance()->kitInformation()) {
if (hasValue(ki->dataId()))
makeSticky(ki->dataId());
}
}
void Kit::makeSticky(Core::Id id)
{
d->m_sticky.insert(id);
}
void Kit::kitUpdated()
{
if (d->m_nestedBlockingLevel > 0 && !d->m_mustNotifyAboutDisplayName) {
......
......@@ -87,6 +87,7 @@ public:
bool hasValue(Core::Id key) const;
void setValue(Core::Id key, const QVariant &value);
void removeKey(Core::Id key);
bool isSticky(Core::Id id) const;
bool isDataEqual(const Kit *other) const;
bool isEqual(const Kit *other) const;
......@@ -99,8 +100,12 @@ public:
void copyFrom(const Kit *k);
void setAutoDetected(bool detected);
private:
void setSdkProvided(bool sdkProvided);
void makeSticky();
void makeSticky(Core::Id id);
~Kit();
// Unimplemented.
......@@ -115,6 +120,7 @@ private:
Internal::KitPrivate *d;
friend class KitInformation;
friend class KitManager;
friend class Internal::KitModel; // needed for setAutoDetected() when cloning kits
};
......
......@@ -47,7 +47,7 @@ class PROJECTEXPLORER_EXPORT KitConfigWidget : public QObject
Q_OBJECT
public:
KitConfigWidget(Kit *kit) : m_kit(kit) { }
KitConfigWidget(Kit *kit, bool sticky) : m_kit(kit), m_isSticky(sticky) { }
virtual QString displayName() const = 0;
virtual QString toolTip() const { return QString(); }
......@@ -58,11 +58,14 @@ public:
virtual QWidget *mainWidget() const = 0;
virtual QWidget *buttonWidget() const { return 0; }
bool isSticky() { return m_isSticky; }
signals:
void dirty();
protected:
ProjectExplorer::Kit *m_kit;
bool m_isSticky;
};
} // namespace ProjectExplorer
......
......@@ -86,7 +86,7 @@ QList<Task> SysRootKitInformation::validate(const Kit *k) const
KitConfigWidget *SysRootKitInformation::createConfigWidget(Kit *k) const
{
return new Internal::SysRootInformationConfigWidget(k);
return new Internal::SysRootInformationConfigWidget(k, isSticky(k));
}
KitInformation::ItemList SysRootKitInformation::toUserOutput(const Kit *k) const
......@@ -199,7 +199,7 @@ void ToolChainKitInformation::setup(Kit *k)
KitConfigWidget *ToolChainKitInformation::createConfigWidget(Kit *k) const
{
return new Internal::ToolChainInformationConfigWidget(k);
return new Internal::ToolChainInformationConfigWidget(k, isSticky(k));
}
QString ToolChainKitInformation::displayNamePostfix(const Kit *k) const
......@@ -309,7 +309,7 @@ QList<Task> DeviceTypeKitInformation::validate(const Kit *k) const
KitConfigWidget *DeviceTypeKitInformation::createConfigWidget(Kit *k) const
{
return new Internal::DeviceTypeInformationConfigWidget(k);
return new Internal::DeviceTypeInformationConfigWidget(k, isSticky(k));
}
KitInformation::ItemList DeviceTypeKitInformation::toUserOutput(const Kit *k) const
......@@ -405,7 +405,7 @@ void DeviceKitInformation::setup(Kit *k)
KitConfigWidget *DeviceKitInformation::createConfigWidget(Kit *k) const
{
return new Internal::DeviceInformationConfigWidget(k);
return new Internal::DeviceInformationConfigWidget(k, isSticky(k));
}
QString DeviceKitInformation::displayNamePostfix(const Kit *k) const
......
......@@ -55,8 +55,8 @@ namespace Internal {
// SysRootInformationConfigWidget:
// --------------------------------------------------------------------------
SysRootInformationConfigWidget::SysRootInformationConfigWidget(Kit *k) :
KitConfigWidget(k),
SysRootInformationConfigWidget::SysRootInformationConfigWidget(Kit *k, bool sticky) :
KitConfigWidget(k, sticky),
m_ignoreChange(false)
{
m_chooser = new Utils::PathChooser;
......@@ -108,8 +108,8 @@ void SysRootInformationConfigWidget::pathWasChanged()
// ToolChainInformationConfigWidget:
// --------------------------------------------------------------------------
ToolChainInformationConfigWidget::ToolChainInformationConfigWidget(Kit *k) :
KitConfigWidget(k), m_isReadOnly(false)
ToolChainInformationConfigWidget::ToolChainInformationConfigWidget(Kit *k, bool sticky) :
KitConfigWidget(k, sticky), m_isReadOnly(false)
{
ToolChainManager *tcm = ToolChainManager::instance();
......@@ -232,8 +232,8 @@ int ToolChainInformationConfigWidget::indexOf(const ToolChain *tc)
// DeviceTypeInformationConfigWidget:
// --------------------------------------------------------------------------
DeviceTypeInformationConfigWidget::DeviceTypeInformationConfigWidget(Kit *workingCopy) :
KitConfigWidget(workingCopy), m_isReadOnly(false), m_comboBox(new QComboBox)
DeviceTypeInformationConfigWidget::DeviceTypeInformationConfigWidget(Kit *workingCopy, bool sticky) :
KitConfigWidget(workingCopy, sticky), m_isReadOnly(false), m_comboBox(new QComboBox)
{
QList<IDeviceFactory *> factories
= ExtensionSystem::PluginManager::instance()->getObjects<IDeviceFactory>();
......@@ -289,8 +289,8 @@ void DeviceTypeInformationConfigWidget::currentTypeChanged(int idx)
// DeviceInformationConfigWidget:
// --------------------------------------------------------------------------
DeviceInformationConfigWidget::DeviceInformationConfigWidget(Kit *workingCopy) :
KitConfigWidget(workingCopy),
DeviceInformationConfigWidget::DeviceInformationConfigWidget(Kit *workingCopy, bool sticky) :
KitConfigWidget(workingCopy, sticky),
m_isReadOnly(false),
m_ignoreChange(false),
m_comboBox(new QComboBox),
......
......@@ -57,7 +57,7 @@ class SysRootInformationConfigWidget : public KitConfigWidget
Q_OBJECT
public:
explicit SysRootInformationConfigWidget(Kit *k);
explicit SysRootInformationConfigWidget(Kit *k, bool sticky);
QString displayName() const;
void refresh();
......@@ -83,7 +83,7 @@ class ToolChainInformationConfigWidget : public KitConfigWidget
Q_OBJECT
public:
explicit ToolChainInformationConfigWidget(Kit *k);
explicit ToolChainInformationConfigWidget(Kit *k, bool sticky);
QString displayName() const;
void refresh();
......@@ -117,7 +117,7 @@ class DeviceTypeInformationConfigWidget : public KitConfigWidget
Q_OBJECT
public:
explicit DeviceTypeInformationConfigWidget(Kit *workingCopy);
explicit DeviceTypeInformationConfigWidget(Kit *workingCopy, bool sticky);
QWidget *mainWidget() const;
QString displayName() const;
......@@ -142,7 +142,7 @@ class DeviceInformationConfigWidget : public KitConfigWidget
Q_OBJECT
public:
explicit DeviceInformationConfigWidget(Kit *workingCopy);
explicit DeviceInformationConfigWidget(Kit *workingCopy, bool sticky);
QWidget *mainWidget() const;
QWidget *buttonWidget() const;
......
......@@ -183,6 +183,7 @@ void KitManager::restoreKits()
foreach (Kit *k, system.kits) {
k->setAutoDetected(true);
k->setSdkProvided(true);
k->makeSticky();
k->setup();
}
......@@ -215,8 +216,11 @@ void KitManager::restoreKits()
// Overwrite settings that the SDK sets to those values:
foreach (const KitInformation *ki, kitInformation()) {
if (current->hasValue(ki->dataId()))
// Copy sticky settings over:
if (current->isSticky(ki->dataId())) {
toStore->setValue(ki->dataId(), current->value(ki->dataId()));
toStore->makeSticky(ki->dataId());
}
}
delete current;
......@@ -570,6 +574,11 @@ QString KitInformation::displayNamePostfix(const Kit *k) const
return QString();
}
bool KitInformation::isSticky(const Kit *k) const
{
return k->isSticky(dataId());
}
void KitInformation::notifyAboutUpdate(Kit *k)
{
KitManager::instance()->notifyAboutUpdate(k);
......
......@@ -47,6 +47,7 @@ class Task;
class IOutputParser;
class Kit;
class KitConfigWidget;
class KitManager;
namespace Internal {
class KitManagerConfigWidget;
......@@ -91,6 +92,8 @@ public:
virtual QString displayNamePostfix(const Kit *k) const;
bool isSticky(const Kit *k) const;
protected:
void notifyAboutUpdate(Kit *k);
};
......
......@@ -201,10 +201,12 @@ void KitManagerConfigWidget::updateVisibility()
}
}
void KitManagerConfigWidget::makeReadOnly()
void KitManagerConfigWidget::makeStickySubWidgetsReadOnly()
{
foreach (KitConfigWidget *w, m_widgets)
w->makeReadOnly();
foreach (KitConfigWidget *w, m_widgets) {
if (w->isSticky())
w->makeReadOnly();
}
m_iconButton->setEnabled(false);
m_nameEdit->setEnabled(false);
}
......
......@@ -63,7 +63,7 @@ public:
bool hasWarning() const;
QString validityMessage() const;
void addConfigWidget(ProjectExplorer::KitConfigWidget *widget);
void makeReadOnly();
void makeStickySubWidgetsReadOnly();
Kit *workingCopy() const;
bool configures(ProjectExplorer::Kit *k) const;
......
......@@ -59,8 +59,8 @@ public:
widget = KitManager::instance()->createConfigWidget(k);
if (widget) {
if (k && k->isAutoDetected())
widget->makeReadOnly();
if (k)
widget->makeStickySubWidgetsReadOnly();
widget->setVisible(false);
}
}
......
......@@ -38,8 +38,8 @@
namespace Qt4ProjectManager {
namespace Internal {
QmakeKitConfigWidget::QmakeKitConfigWidget(ProjectExplorer::Kit *k) :
ProjectExplorer::KitConfigWidget(k),
QmakeKitConfigWidget::QmakeKitConfigWidget(ProjectExplorer::Kit *k, bool sticky) :
ProjectExplorer::KitConfigWidget(k, sticky),
m_lineEdit(new QLineEdit),
m_ignoreChange(false)
{
......
......@@ -44,7 +44,7 @@ class QmakeKitConfigWidget : public ProjectExplorer::KitConfigWidget
Q_OBJECT
public:
explicit QmakeKitConfigWidget(ProjectExplorer::Kit *k);
explicit QmakeKitConfigWidget(ProjectExplorer::Kit *k, bool sticky);
QWidget *mainWidget() const;
QString displayName() const;
......
......@@ -112,7 +112,7 @@ void QmakeKitInformation::setup(ProjectExplorer::Kit *k)
ProjectExplorer::KitConfigWidget *
QmakeKitInformation::createConfigWidget(ProjectExplorer::Kit *k) const
{
return new Internal::QmakeKitConfigWidget(k);
return new Internal::QmakeKitConfigWidget(k, isSticky(k));
}
ProjectExplorer::KitInformation::ItemList QmakeKitInformation::toUserOutput(const ProjectExplorer::Kit *k) const
......
......@@ -44,8 +44,8 @@
namespace QtSupport {
namespace Internal {
QtKitConfigWidget::QtKitConfigWidget(ProjectExplorer::Kit *k) :
KitConfigWidget(k)
QtKitConfigWidget::QtKitConfigWidget(ProjectExplorer::Kit *k, bool sticky) :
KitConfigWidget(k, sticky)
{
m_combo = new QComboBox;
m_combo->addItem(tr("None"), -1);
......
......@@ -45,7 +45,7 @@ class QtKitConfigWidget : public ProjectExplorer::KitConfigWidget
Q_OBJECT
public:
explicit QtKitConfigWidget(ProjectExplorer::Kit *k);
explicit QtKitConfigWidget(ProjectExplorer::Kit *k, bool sticky);
QString displayName() const;
......
......@@ -108,7 +108,7 @@ void QtKitInformation::fix(ProjectExplorer::Kit *k)
ProjectExplorer::KitConfigWidget *QtKitInformation::createConfigWidget(ProjectExplorer::Kit *k) const
{
return new Internal::QtKitConfigWidget(k);
return new Internal::QtKitConfigWidget(k, isSticky(k));
}
QString QtKitInformation::displayNamePostfix(const ProjectExplorer::Kit *k) const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment