forked from qt-creator/qt-creator
Let the user choose which kit settings to display
Almost every single aspect of a kit is probably irrelevant to some users, so let them configure which ones they want to see. Fixes: QTCREATORBUG-9134 Change-Id: I218d43bd1d00479130278259dff552c9624afa30 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
163
src/plugins/projectexplorer/filterkitaspectsdialog.cpp
Normal file
163
src/plugins/projectexplorer/filterkitaspectsdialog.cpp
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2019 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "filterkitaspectsdialog.h"
|
||||||
|
|
||||||
|
#include "kitmanager.h"
|
||||||
|
|
||||||
|
#include <utils/itemviews.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/treemodel.h>
|
||||||
|
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QString>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class FilterTreeItem : public TreeItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FilterTreeItem(const KitAspect *aspect, bool enabled) : m_aspect(aspect), m_enabled(enabled)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
QString displayName() const { return m_aspect->displayName(); }
|
||||||
|
Core::Id id() const { return m_aspect->id(); }
|
||||||
|
bool enabled() const { return m_enabled; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVariant data(int column, int role) const override
|
||||||
|
{
|
||||||
|
QTC_ASSERT(column < 2, return QVariant());
|
||||||
|
if (column == 0 && role == Qt::DisplayRole)
|
||||||
|
return displayName();
|
||||||
|
if (column == 1 && role == Qt::CheckStateRole)
|
||||||
|
return m_enabled ? Qt::Checked : Qt::Unchecked;
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool setData(int column, const QVariant &data, int role) override
|
||||||
|
{
|
||||||
|
QTC_ASSERT(column == 1 && !m_aspect->isEssential(), return false);
|
||||||
|
if (role == Qt::CheckStateRole) {
|
||||||
|
m_enabled = data.toInt() == Qt::Checked;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags flags(int column) const override
|
||||||
|
{
|
||||||
|
QTC_ASSERT(column < 2, return Qt::ItemFlags());
|
||||||
|
Qt::ItemFlags flags = Qt::ItemIsSelectable;
|
||||||
|
if (column == 0 || !m_aspect->isEssential())
|
||||||
|
flags |= Qt::ItemIsEnabled;
|
||||||
|
if (column == 1 && !m_aspect->isEssential())
|
||||||
|
flags |= Qt::ItemIsUserCheckable;
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
const KitAspect * const m_aspect;
|
||||||
|
bool m_enabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FilterKitAspectsModel : public TreeModel<TreeItem, FilterTreeItem>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FilterKitAspectsModel(const Kit *kit, QObject *parent) : TreeModel(parent)
|
||||||
|
{
|
||||||
|
setHeader({tr("Setting"), tr("Visible")});
|
||||||
|
for (const KitAspect * const aspect : KitManager::kitAspects()) {
|
||||||
|
if (kit && !aspect->isApplicableToKit(kit))
|
||||||
|
continue;
|
||||||
|
const QSet<Core::Id> irrelevantAspects = kit ? kit->irrelevantAspects()
|
||||||
|
: KitManager::irrelevantAspects();
|
||||||
|
auto * const item = new FilterTreeItem(aspect,
|
||||||
|
!irrelevantAspects.contains(aspect->id()));
|
||||||
|
rootItem()->appendChild(item);
|
||||||
|
}
|
||||||
|
static const auto cmp = [](const TreeItem *item1, const TreeItem *item2) {
|
||||||
|
return static_cast<const FilterTreeItem *>(item1)->displayName()
|
||||||
|
< static_cast<const FilterTreeItem *>(item2)->displayName();
|
||||||
|
};
|
||||||
|
rootItem()->sortChildren(cmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSet<Core::Id> disabledItems() const
|
||||||
|
{
|
||||||
|
QSet<Core::Id> ids;
|
||||||
|
for (int i = 0; i < rootItem()->childCount(); ++i) {
|
||||||
|
const FilterTreeItem * const item
|
||||||
|
= static_cast<FilterTreeItem *>(rootItem()->childAt(i));
|
||||||
|
if (!item->enabled())
|
||||||
|
ids << item->id();
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class FilterTreeView : public TreeView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FilterTreeView(QWidget *parent) : TreeView(parent)
|
||||||
|
{
|
||||||
|
setUniformRowHeights(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSize sizeHint() const override
|
||||||
|
{
|
||||||
|
const int width = columnWidth(0) + columnWidth(1);
|
||||||
|
const int height = model()->rowCount() * rowHeight(model()->index(0, 0))
|
||||||
|
+ header()->sizeHint().height();
|
||||||
|
return {width, height};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
FilterKitAspectsDialog::FilterKitAspectsDialog(const Kit *kit, QWidget *parent)
|
||||||
|
: QDialog(parent), m_model(new FilterKitAspectsModel(kit, this))
|
||||||
|
{
|
||||||
|
auto * const layout = new QVBoxLayout(this);
|
||||||
|
auto * const view = new FilterTreeView(this);
|
||||||
|
view->setModel(m_model);
|
||||||
|
view->resizeColumnToContents(0);
|
||||||
|
layout->addWidget(view);
|
||||||
|
auto * const buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
layout->addWidget(buttonBox);
|
||||||
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSet<Core::Id> FilterKitAspectsDialog::irrelevantAspects() const
|
||||||
|
{
|
||||||
|
return static_cast<FilterKitAspectsModel *>(m_model)->disabledItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace ProjectExplorer
|
49
src/plugins/projectexplorer/filterkitaspectsdialog.h
Normal file
49
src/plugins/projectexplorer/filterkitaspectsdialog.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2019 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <coreplugin/id.h>
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace Utils { class BaseTreeModel; }
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
class Kit;
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class FilterKitAspectsDialog : public QDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FilterKitAspectsDialog(const Kit *kit, QWidget *parent);
|
||||||
|
QSet<Core::Id> irrelevantAspects() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utils::BaseTreeModel * const m_model;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace ProjectExplorer
|
@@ -36,6 +36,7 @@
|
|||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/icon.h>
|
#include <utils/icon.h>
|
||||||
#include <utils/macroexpander.h>
|
#include <utils/macroexpander.h>
|
||||||
|
#include <utils/optional.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@@ -58,6 +59,7 @@ const char DATA_KEY[] = "PE.Profile.Data";
|
|||||||
const char ICON_KEY[] = "PE.Profile.Icon";
|
const char ICON_KEY[] = "PE.Profile.Icon";
|
||||||
const char MUTABLE_INFO_KEY[] = "PE.Profile.MutableInfo";
|
const char MUTABLE_INFO_KEY[] = "PE.Profile.MutableInfo";
|
||||||
const char STICKY_INFO_KEY[] = "PE.Profile.StickyInfo";
|
const char STICKY_INFO_KEY[] = "PE.Profile.StickyInfo";
|
||||||
|
const char IRRELEVANT_ASPECTS_KEY[] = "PE.Kit.IrrelevantAspects";
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -122,6 +124,7 @@ public:
|
|||||||
QHash<Id, QVariant> m_data;
|
QHash<Id, QVariant> m_data;
|
||||||
QSet<Id> m_sticky;
|
QSet<Id> m_sticky;
|
||||||
QSet<Id> m_mutable;
|
QSet<Id> m_mutable;
|
||||||
|
optional<QSet<Id>> m_irrelevantAspects;
|
||||||
MacroExpander m_macroExpander;
|
MacroExpander m_macroExpander;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -158,6 +161,9 @@ Kit::Kit(const QVariantMap &data) :
|
|||||||
d->m_fileSystemFriendlyName = data.value(QLatin1String(FILESYSTEMFRIENDLYNAME_KEY)).toString();
|
d->m_fileSystemFriendlyName = data.value(QLatin1String(FILESYSTEMFRIENDLYNAME_KEY)).toString();
|
||||||
d->m_iconPath = FileName::fromString(data.value(QLatin1String(ICON_KEY),
|
d->m_iconPath = FileName::fromString(data.value(QLatin1String(ICON_KEY),
|
||||||
d->m_iconPath.toString()).toString());
|
d->m_iconPath.toString()).toString());
|
||||||
|
const auto it = data.constFind(IRRELEVANT_ASPECTS_KEY);
|
||||||
|
if (it != data.constEnd())
|
||||||
|
d->m_irrelevantAspects = transform<QSet<Id>>(it.value().toList(), &Id::fromSetting);
|
||||||
|
|
||||||
QVariantMap extra = data.value(QLatin1String(DATA_KEY)).toMap();
|
QVariantMap extra = data.value(QLatin1String(DATA_KEY)).toMap();
|
||||||
d->m_data.clear(); // remove default values
|
d->m_data.clear(); // remove default values
|
||||||
@@ -206,6 +212,7 @@ Kit *Kit::clone(bool keepName) const
|
|||||||
k->d->m_iconPath = d->m_iconPath;
|
k->d->m_iconPath = d->m_iconPath;
|
||||||
k->d->m_sticky = d->m_sticky;
|
k->d->m_sticky = d->m_sticky;
|
||||||
k->d->m_mutable = d->m_mutable;
|
k->d->m_mutable = d->m_mutable;
|
||||||
|
k->d->m_irrelevantAspects = d->m_irrelevantAspects;
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,6 +229,7 @@ void Kit::copyFrom(const Kit *k)
|
|||||||
d->m_mustNotify = true;
|
d->m_mustNotify = true;
|
||||||
d->m_sticky = k->d->m_sticky;
|
d->m_sticky = k->d->m_sticky;
|
||||||
d->m_mutable = k->d->m_mutable;
|
d->m_mutable = k->d->m_mutable;
|
||||||
|
d->m_irrelevantAspects = k->d->m_irrelevantAspects;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Kit::isValid() const
|
bool Kit::isValid() const
|
||||||
@@ -461,8 +469,8 @@ bool Kit::isEqual(const Kit *other) const
|
|||||||
&& d->m_iconPath == other->d->m_iconPath
|
&& d->m_iconPath == other->d->m_iconPath
|
||||||
&& d->m_unexpandedDisplayName == other->d->m_unexpandedDisplayName
|
&& d->m_unexpandedDisplayName == other->d->m_unexpandedDisplayName
|
||||||
&& d->m_fileSystemFriendlyName == other->d->m_fileSystemFriendlyName
|
&& d->m_fileSystemFriendlyName == other->d->m_fileSystemFriendlyName
|
||||||
|
&& d->m_irrelevantAspects == other->d->m_irrelevantAspects
|
||||||
&& d->m_mutable == other->d->m_mutable;
|
&& d->m_mutable == other->d->m_mutable;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap Kit::toMap() const
|
QVariantMap Kit::toMap() const
|
||||||
@@ -489,6 +497,11 @@ QVariantMap Kit::toMap() const
|
|||||||
stickyInfo << id.toString();
|
stickyInfo << id.toString();
|
||||||
data.insert(QLatin1String(STICKY_INFO_KEY), stickyInfo);
|
data.insert(QLatin1String(STICKY_INFO_KEY), stickyInfo);
|
||||||
|
|
||||||
|
if (d->m_irrelevantAspects) {
|
||||||
|
data.insert(IRRELEVANT_ASPECTS_KEY, transform<QVariantList>(d->m_irrelevantAspects.value(),
|
||||||
|
&Id::toSetting));
|
||||||
|
}
|
||||||
|
|
||||||
QVariantMap extra;
|
QVariantMap extra;
|
||||||
|
|
||||||
const IdVariantConstIt cend = d->m_data.constEnd();
|
const IdVariantConstIt cend = d->m_data.constEnd();
|
||||||
@@ -611,6 +624,16 @@ bool Kit::isMutable(Id id) const
|
|||||||
return d->m_mutable.contains(id);
|
return d->m_mutable.contains(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Kit::setIrrelevantAspects(const QSet<Id> &irrelevant)
|
||||||
|
{
|
||||||
|
d->m_irrelevantAspects = irrelevant;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSet<Id> Kit::irrelevantAspects() const
|
||||||
|
{
|
||||||
|
return d->m_irrelevantAspects.value_or(KitManager::irrelevantAspects());
|
||||||
|
}
|
||||||
|
|
||||||
QSet<Id> Kit::supportedPlatforms() const
|
QSet<Id> Kit::supportedPlatforms() const
|
||||||
{
|
{
|
||||||
QSet<Id> platforms;
|
QSet<Id> platforms;
|
||||||
|
@@ -123,6 +123,9 @@ public:
|
|||||||
void setMutable(Core::Id id, bool b);
|
void setMutable(Core::Id id, bool b);
|
||||||
bool isMutable(Core::Id id) const;
|
bool isMutable(Core::Id id) const;
|
||||||
|
|
||||||
|
void setIrrelevantAspects(const QSet<Core::Id> &irrelevant);
|
||||||
|
QSet<Core::Id> irrelevantAspects() const;
|
||||||
|
|
||||||
QSet<Core::Id> supportedPlatforms() const;
|
QSet<Core::Id> supportedPlatforms() const;
|
||||||
QSet<Core::Id> availableFeatures() const;
|
QSet<Core::Id> availableFeatures() const;
|
||||||
bool hasFeatures(const QSet<Core::Id> &features) const;
|
bool hasFeatures(const QSet<Core::Id> &features) const;
|
||||||
|
@@ -810,6 +810,7 @@ DeviceTypeKitAspect::DeviceTypeKitAspect()
|
|||||||
setDisplayName(tr("Device type"));
|
setDisplayName(tr("Device type"));
|
||||||
setDescription(tr("The type of device to run applications on."));
|
setDescription(tr("The type of device to run applications on."));
|
||||||
setPriority(33000);
|
setPriority(33000);
|
||||||
|
makeEssential();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DeviceTypeKitAspect::defaultValue(const Kit *k) const
|
QVariant DeviceTypeKitAspect::defaultValue(const Kit *k) const
|
||||||
|
@@ -54,6 +54,7 @@ const char KIT_DATA_KEY[] = "Profile.";
|
|||||||
const char KIT_COUNT_KEY[] = "Profile.Count";
|
const char KIT_COUNT_KEY[] = "Profile.Count";
|
||||||
const char KIT_FILE_VERSION_KEY[] = "Version";
|
const char KIT_FILE_VERSION_KEY[] = "Version";
|
||||||
const char KIT_DEFAULT_KEY[] = "Profile.Default";
|
const char KIT_DEFAULT_KEY[] = "Profile.Default";
|
||||||
|
const char KIT_IRRELEVANT_ASPECTS_KEY[] = "Kit.IrrelevantAspects";
|
||||||
const char KIT_FILENAME[] = "/profiles.xml";
|
const char KIT_FILENAME[] = "/profiles.xml";
|
||||||
|
|
||||||
static FileName settingsFileName()
|
static FileName settingsFileName()
|
||||||
@@ -73,6 +74,7 @@ public:
|
|||||||
std::vector<std::unique_ptr<KitAspect>> m_informationList;
|
std::vector<std::unique_ptr<KitAspect>> m_informationList;
|
||||||
std::vector<std::unique_ptr<Kit>> m_kitList;
|
std::vector<std::unique_ptr<Kit>> m_kitList;
|
||||||
std::unique_ptr<PersistentSettingsWriter> m_writer;
|
std::unique_ptr<PersistentSettingsWriter> m_writer;
|
||||||
|
QSet<Id> m_irrelevantAspects;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
@@ -220,6 +222,8 @@ void KitManager::saveKits()
|
|||||||
data.insert(QLatin1String(KIT_COUNT_KEY), count);
|
data.insert(QLatin1String(KIT_COUNT_KEY), count);
|
||||||
data.insert(QLatin1String(KIT_DEFAULT_KEY),
|
data.insert(QLatin1String(KIT_DEFAULT_KEY),
|
||||||
d->m_defaultKit ? QString::fromLatin1(d->m_defaultKit->id().name()) : QString());
|
d->m_defaultKit ? QString::fromLatin1(d->m_defaultKit->id().name()) : QString());
|
||||||
|
data.insert(KIT_IRRELEVANT_ASPECTS_KEY,
|
||||||
|
transform<QVariantList>(d->m_irrelevantAspects, &Id::toSetting));
|
||||||
d->m_writer->save(data, ICore::mainWindow());
|
d->m_writer->save(data, ICore::mainWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,6 +339,9 @@ KitManager::KitList KitManager::restoreKits(const FileName &fileName)
|
|||||||
|
|
||||||
if (Utils::contains(result.kits, [id](const std::unique_ptr<Kit> &k) { return k->id() == id; }))
|
if (Utils::contains(result.kits, [id](const std::unique_ptr<Kit> &k) { return k->id() == id; }))
|
||||||
result.defaultKit = id;
|
result.defaultKit = id;
|
||||||
|
const auto it = data.constFind(KIT_IRRELEVANT_ASPECTS_KEY);
|
||||||
|
if (it != data.constEnd())
|
||||||
|
d->m_irrelevantAspects = transform<QSet<Id>>(it.value().toList(), &Id::fromSetting);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -370,6 +377,16 @@ const QList<KitAspect *> KitManager::kitAspects()
|
|||||||
return Utils::toRawPointer<QList>(d->m_informationList);
|
return Utils::toRawPointer<QList>(d->m_informationList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QSet<Id> KitManager::irrelevantAspects()
|
||||||
|
{
|
||||||
|
return d->m_irrelevantAspects;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KitManager::setIrrelevantAspects(const QSet<Id> &aspects)
|
||||||
|
{
|
||||||
|
d->m_irrelevantAspects = aspects;
|
||||||
|
}
|
||||||
|
|
||||||
void KitManager::notifyAboutUpdate(Kit *k)
|
void KitManager::notifyAboutUpdate(Kit *k)
|
||||||
{
|
{
|
||||||
if (!k || !isLoaded())
|
if (!k || !isLoaded())
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
@@ -76,6 +77,7 @@ public:
|
|||||||
int priority() const { return m_priority; }
|
int priority() const { return m_priority; }
|
||||||
QString displayName() const { return m_displayName; }
|
QString displayName() const { return m_displayName; }
|
||||||
QString description() const { return m_description; }
|
QString description() const { return m_description; }
|
||||||
|
bool isEssential() const { return m_essential; }
|
||||||
|
|
||||||
virtual QVariant defaultValue(const Kit *) const = 0;
|
virtual QVariant defaultValue(const Kit *) const = 0;
|
||||||
|
|
||||||
@@ -108,6 +110,7 @@ protected:
|
|||||||
void setId(Core::Id id) { m_id = id; }
|
void setId(Core::Id id) { m_id = id; }
|
||||||
void setDisplayName(const QString &name) { m_displayName = name; }
|
void setDisplayName(const QString &name) { m_displayName = name; }
|
||||||
void setDescription(const QString &desc) { m_description = desc; }
|
void setDescription(const QString &desc) { m_description = desc; }
|
||||||
|
void makeEssential() { m_essential = true; }
|
||||||
void setPriority(int priority) { m_priority = priority; }
|
void setPriority(int priority) { m_priority = priority; }
|
||||||
void notifyAboutUpdate(Kit *k);
|
void notifyAboutUpdate(Kit *k);
|
||||||
|
|
||||||
@@ -116,6 +119,7 @@ private:
|
|||||||
QString m_description;
|
QString m_description;
|
||||||
Core::Id m_id;
|
Core::Id m_id;
|
||||||
int m_priority = 0; // The higher the closer to the top.
|
int m_priority = 0; // The higher the closer to the top.
|
||||||
|
bool m_essential = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT KitAspectWidget : public QObject
|
class PROJECTEXPLORER_EXPORT KitAspectWidget : public QObject
|
||||||
@@ -166,6 +170,8 @@ public:
|
|||||||
static Kit *defaultKit();
|
static Kit *defaultKit();
|
||||||
|
|
||||||
static const QList<KitAspect *> kitAspects();
|
static const QList<KitAspect *> kitAspects();
|
||||||
|
static const QSet<Core::Id> irrelevantAspects();
|
||||||
|
static void setIrrelevantAspects(const QSet<Core::Id> &aspects);
|
||||||
|
|
||||||
static bool registerKit(std::unique_ptr<Kit> &&k);
|
static bool registerKit(std::unique_ptr<Kit> &&k);
|
||||||
static void deregisterKit(Kit *k);
|
static void deregisterKit(Kit *k);
|
||||||
|
@@ -45,6 +45,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
#include <QSizePolicy>
|
#include <QSizePolicy>
|
||||||
@@ -262,7 +263,8 @@ void KitManagerConfigWidget::updateVisibility()
|
|||||||
int count = m_widgets.count();
|
int count = m_widgets.count();
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
KitAspectWidget *widget = m_widgets.at(i);
|
KitAspectWidget *widget = m_widgets.at(i);
|
||||||
bool visible = widget->visibleInKit();
|
const bool visible = widget->visibleInKit()
|
||||||
|
&& !m_modifiedKit->irrelevantAspects().contains(widget->kitInformationId());
|
||||||
widget->mainWidget()->setVisible(visible);
|
widget->mainWidget()->setVisible(visible);
|
||||||
if (widget->buttonWidget())
|
if (widget->buttonWidget())
|
||||||
widget->buttonWidget()->setVisible(visible);
|
widget->buttonWidget()->setVisible(visible);
|
||||||
|
@@ -266,6 +266,13 @@ Kit *KitModel::markForAddition(Kit *baseKit)
|
|||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KitModel::updateVisibility()
|
||||||
|
{
|
||||||
|
forItemsAtLevel<2>([](const TreeItem *ti) {
|
||||||
|
static_cast<const KitNode *>(ti)->widget->updateVisibility();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
KitNode *KitModel::findWorkingCopy(Kit *k) const
|
KitNode *KitModel::findWorkingCopy(Kit *k) const
|
||||||
{
|
{
|
||||||
return findItemAtLevel<2>([k](KitNode *n) { return n->widget->workingCopy() == k; });
|
return findItemAtLevel<2>([k](KitNode *n) { return n->widget->workingCopy() == k; });
|
||||||
|
@@ -69,6 +69,8 @@ public:
|
|||||||
void markForRemoval(Kit *k);
|
void markForRemoval(Kit *k);
|
||||||
Kit *markForAddition(Kit *baseKit);
|
Kit *markForAddition(Kit *baseKit);
|
||||||
|
|
||||||
|
void updateVisibility();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void kitStateChanged();
|
void kitStateChanged();
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "kitoptionspage.h"
|
#include "kitoptionspage.h"
|
||||||
|
|
||||||
|
#include "filterkitaspectsdialog.h"
|
||||||
#include "kitmodel.h"
|
#include "kitmodel.h"
|
||||||
#include "kit.h"
|
#include "kit.h"
|
||||||
#include "projectexplorerconstants.h"
|
#include "projectexplorerconstants.h"
|
||||||
@@ -32,6 +33,8 @@
|
|||||||
#include "kitmanagerconfigwidget.h"
|
#include "kitmanagerconfigwidget.h"
|
||||||
#include "kitmanager.h"
|
#include "kitmanager.h"
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
@@ -67,10 +70,12 @@ public:
|
|||||||
QPushButton *m_cloneButton = nullptr;
|
QPushButton *m_cloneButton = nullptr;
|
||||||
QPushButton *m_delButton = nullptr;
|
QPushButton *m_delButton = nullptr;
|
||||||
QPushButton *m_makeDefaultButton = nullptr;
|
QPushButton *m_makeDefaultButton = nullptr;
|
||||||
|
QPushButton *m_filterButton = nullptr;
|
||||||
|
QPushButton *m_defaultFilterButton = nullptr;
|
||||||
|
|
||||||
KitModel *m_model = nullptr;
|
KitModel *m_model = nullptr;
|
||||||
QItemSelectionModel *m_selectionModel = nullptr;
|
QItemSelectionModel *m_selectionModel = nullptr;
|
||||||
QWidget *m_currentWidget = nullptr;
|
KitManagerConfigWidget *m_currentWidget = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
KitOptionsPageWidget::KitOptionsPageWidget()
|
KitOptionsPageWidget::KitOptionsPageWidget()
|
||||||
@@ -85,6 +90,12 @@ KitOptionsPageWidget::KitOptionsPageWidget()
|
|||||||
m_cloneButton = new QPushButton(KitOptionsPage::tr("Clone"), this);
|
m_cloneButton = new QPushButton(KitOptionsPage::tr("Clone"), this);
|
||||||
m_delButton = new QPushButton(KitOptionsPage::tr("Remove"), this);
|
m_delButton = new QPushButton(KitOptionsPage::tr("Remove"), this);
|
||||||
m_makeDefaultButton = new QPushButton(KitOptionsPage::tr("Make Default"), this);
|
m_makeDefaultButton = new QPushButton(KitOptionsPage::tr("Make Default"), this);
|
||||||
|
m_filterButton = new QPushButton(KitOptionsPage::tr("Settings Filter..."), this);
|
||||||
|
m_filterButton->setToolTip(KitOptionsPage::tr(
|
||||||
|
"Choose which settings to display for this kit."));
|
||||||
|
m_defaultFilterButton = new QPushButton(KitOptionsPage::tr("Default Settings Filter..."), this);
|
||||||
|
m_defaultFilterButton->setToolTip(KitOptionsPage::tr(
|
||||||
|
"Choose which kit settings to display by default."));
|
||||||
|
|
||||||
auto buttonLayout = new QVBoxLayout;
|
auto buttonLayout = new QVBoxLayout;
|
||||||
buttonLayout->setSpacing(6);
|
buttonLayout->setSpacing(6);
|
||||||
@@ -93,6 +104,8 @@ KitOptionsPageWidget::KitOptionsPageWidget()
|
|||||||
buttonLayout->addWidget(m_cloneButton);
|
buttonLayout->addWidget(m_cloneButton);
|
||||||
buttonLayout->addWidget(m_delButton);
|
buttonLayout->addWidget(m_delButton);
|
||||||
buttonLayout->addWidget(m_makeDefaultButton);
|
buttonLayout->addWidget(m_makeDefaultButton);
|
||||||
|
buttonLayout->addWidget(m_filterButton);
|
||||||
|
buttonLayout->addWidget(m_defaultFilterButton);
|
||||||
buttonLayout->addStretch();
|
buttonLayout->addStretch();
|
||||||
|
|
||||||
auto horizontalLayout = new QHBoxLayout;
|
auto horizontalLayout = new QHBoxLayout;
|
||||||
@@ -131,14 +144,28 @@ KitOptionsPageWidget::KitOptionsPageWidget()
|
|||||||
this, &KitOptionsPageWidget::removeKit);
|
this, &KitOptionsPageWidget::removeKit);
|
||||||
connect(m_makeDefaultButton, &QAbstractButton::clicked,
|
connect(m_makeDefaultButton, &QAbstractButton::clicked,
|
||||||
this, &KitOptionsPageWidget::makeDefaultKit);
|
this, &KitOptionsPageWidget::makeDefaultKit);
|
||||||
|
connect(m_filterButton, &QAbstractButton::clicked, this, [this] {
|
||||||
|
QTC_ASSERT(m_currentWidget, return);
|
||||||
|
FilterKitAspectsDialog dlg(m_currentWidget->workingCopy(), this);
|
||||||
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
|
m_currentWidget->workingCopy()->setIrrelevantAspects(dlg.irrelevantAspects());
|
||||||
|
m_currentWidget->updateVisibility();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(m_defaultFilterButton, &QAbstractButton::clicked, this, [this] {
|
||||||
|
FilterKitAspectsDialog dlg(nullptr, this);
|
||||||
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
|
KitManager::setIrrelevantAspects(dlg.irrelevantAspects());
|
||||||
|
m_model->updateVisibility();
|
||||||
|
}
|
||||||
|
});
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KitOptionsPageWidget::kitSelectionChanged()
|
void KitOptionsPageWidget::kitSelectionChanged()
|
||||||
{
|
{
|
||||||
QModelIndex current = currentIndex();
|
QModelIndex current = currentIndex();
|
||||||
QWidget *newWidget = m_model->widget(current);
|
KitManagerConfigWidget * const newWidget = m_model->widget(current);
|
||||||
if (newWidget == m_currentWidget)
|
if (newWidget == m_currentWidget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -216,6 +243,7 @@ void KitOptionsPageWidget::updateState()
|
|||||||
m_cloneButton->setEnabled(canCopy);
|
m_cloneButton->setEnabled(canCopy);
|
||||||
m_delButton->setEnabled(canDelete);
|
m_delButton->setEnabled(canDelete);
|
||||||
m_makeDefaultButton->setEnabled(canMakeDefault);
|
m_makeDefaultButton->setEnabled(canMakeDefault);
|
||||||
|
m_filterButton->setEnabled(canCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex KitOptionsPageWidget::currentIndex() const
|
QModelIndex KitOptionsPageWidget::currentIndex() const
|
||||||
|
@@ -17,6 +17,7 @@ HEADERS += projectexplorer.h \
|
|||||||
environmentaspect.h \
|
environmentaspect.h \
|
||||||
environmentaspectwidget.h \
|
environmentaspectwidget.h \
|
||||||
extraabi.h \
|
extraabi.h \
|
||||||
|
filterkitaspectsdialog.h \
|
||||||
gcctoolchain.h \
|
gcctoolchain.h \
|
||||||
importwidget.h \
|
importwidget.h \
|
||||||
userfileaccessor.h \
|
userfileaccessor.h \
|
||||||
@@ -168,6 +169,7 @@ SOURCES += projectexplorer.cpp \
|
|||||||
environmentaspect.cpp \
|
environmentaspect.cpp \
|
||||||
environmentaspectwidget.cpp \
|
environmentaspectwidget.cpp \
|
||||||
extraabi.cpp \
|
extraabi.cpp \
|
||||||
|
filterkitaspectsdialog.cpp \
|
||||||
gcctoolchain.cpp \
|
gcctoolchain.cpp \
|
||||||
importwidget.cpp \
|
importwidget.cpp \
|
||||||
projectconfigurationmodel.cpp \
|
projectconfigurationmodel.cpp \
|
||||||
|
@@ -69,6 +69,7 @@ Project {
|
|||||||
"expanddata.cpp", "expanddata.h",
|
"expanddata.cpp", "expanddata.h",
|
||||||
"extraabi.cpp", "extraabi.h",
|
"extraabi.cpp", "extraabi.h",
|
||||||
"extracompiler.cpp", "extracompiler.h",
|
"extracompiler.cpp", "extracompiler.h",
|
||||||
|
"filterkitaspectsdialog.cpp", "filterkitaspectsdialog.h",
|
||||||
"foldernavigationwidget.cpp", "foldernavigationwidget.h",
|
"foldernavigationwidget.cpp", "foldernavigationwidget.h",
|
||||||
"gccparser.cpp", "gccparser.h",
|
"gccparser.cpp", "gccparser.h",
|
||||||
"gcctoolchain.cpp", "gcctoolchain.h",
|
"gcctoolchain.cpp", "gcctoolchain.h",
|
||||||
|
Reference in New Issue
Block a user