forked from qt-creator/qt-creator
Kit: Improve the options page
* Update warning icon as changes happen * Make clone clone the current settings, not what used to be there before changes were made * Make sure the edited entry is visible in list view * I find the KitModel much easier to understand now Task-number: QTCREATORBUG-7862 Task-number: QTCREATORBUG-7803 Change-Id: I124c2e5a96cea7386896084e1027ba79a8be20b7 Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -64,13 +64,12 @@ static const char dgbToolsDownloadLink64C[] = "http://www.microsoft.com/whdc/dev
|
|||||||
// DebuggerKitConfigWidget:
|
// DebuggerKitConfigWidget:
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
DebuggerKitConfigWidget::DebuggerKitConfigWidget(ProjectExplorer::Kit *k,
|
DebuggerKitConfigWidget::DebuggerKitConfigWidget(ProjectExplorer::Kit *workingCopy,
|
||||||
const DebuggerKitInformation *ki,
|
const DebuggerKitInformation *ki,
|
||||||
QWidget *parent) :
|
QWidget *parent) :
|
||||||
ProjectExplorer::KitConfigWidget(parent),
|
ProjectExplorer::KitConfigWidget(parent),
|
||||||
m_kit(k),
|
m_kit(workingCopy),
|
||||||
m_info(ki),
|
m_info(ki),
|
||||||
m_dirty(false),
|
|
||||||
m_label(new QLabel(this)),
|
m_label(new QLabel(this)),
|
||||||
m_button(new QPushButton(tr("Manage..."), this))
|
m_button(new QPushButton(tr("Manage..."), this))
|
||||||
{
|
{
|
||||||
@@ -88,7 +87,7 @@ DebuggerKitConfigWidget::DebuggerKitConfigWidget(ProjectExplorer::Kit *k,
|
|||||||
connect(changeAction, SIGNAL(triggered()), this, SLOT(showDialog()));
|
connect(changeAction, SIGNAL(triggered()), this, SLOT(showDialog()));
|
||||||
m_button->setMenu(buttonMenu);
|
m_button->setMenu(buttonMenu);
|
||||||
|
|
||||||
discard();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *DebuggerKitConfigWidget::buttonWidget() const
|
QWidget *DebuggerKitConfigWidget::buttonWidget() const
|
||||||
@@ -106,45 +105,23 @@ void DebuggerKitConfigWidget::makeReadOnly()
|
|||||||
m_button->setEnabled(false);
|
m_button->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerKitConfigWidget::apply()
|
void DebuggerKitConfigWidget::refresh()
|
||||||
{
|
{
|
||||||
DebuggerKitInformation::setDebuggerItem(m_kit, m_item);
|
m_label->setText(DebuggerKitInformation::userOutput(DebuggerKitInformation::debuggerItem(m_kit)));
|
||||||
m_dirty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerKitConfigWidget::discard()
|
|
||||||
{
|
|
||||||
doSetItem(DebuggerKitInformation::debuggerItem(m_kit));
|
|
||||||
m_dirty = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerKitConfigWidget::autoDetectDebugger()
|
void DebuggerKitConfigWidget::autoDetectDebugger()
|
||||||
{
|
{
|
||||||
setItem(DebuggerKitInformation::autoDetectItem(m_kit));
|
DebuggerKitInformation::setDebuggerItem(m_kit, DebuggerKitInformation::autoDetectItem(m_kit));
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerKitConfigWidget::doSetItem(const DebuggerKitInformation::DebuggerItem &item)
|
|
||||||
{
|
|
||||||
m_item = item;
|
|
||||||
m_label->setText(DebuggerKitInformation::userOutput(m_item));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerKitConfigWidget::setItem(const DebuggerKitInformation::DebuggerItem &item)
|
|
||||||
{
|
|
||||||
if (m_item != item) {
|
|
||||||
m_dirty = true;
|
|
||||||
doSetItem(item);
|
|
||||||
emit dirty();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerKitConfigWidget::showDialog()
|
void DebuggerKitConfigWidget::showDialog()
|
||||||
{
|
{
|
||||||
DebuggerKitConfigDialog dialog;
|
DebuggerKitConfigDialog dialog;
|
||||||
dialog.setWindowTitle(tr("Debugger for \"%1\"").arg(m_kit->displayName()));
|
dialog.setWindowTitle(tr("Debugger for \"%1\"").arg(m_kit->displayName()));
|
||||||
dialog.setDebuggerItem(m_item);
|
dialog.setDebuggerItem(DebuggerKitInformation::debuggerItem(m_kit));
|
||||||
if (dialog.exec() == QDialog::Accepted)
|
if (dialog.exec() == QDialog::Accepted)
|
||||||
setItem(dialog.item());
|
DebuggerKitInformation::setDebuggerItem(m_kit, dialog.item());
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class DebuggerKitConfigWidget : public ProjectExplorer::KitConfigWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DebuggerKitConfigWidget(ProjectExplorer::Kit *k,
|
DebuggerKitConfigWidget(ProjectExplorer::Kit *workingCopy,
|
||||||
const DebuggerKitInformation *ki,
|
const DebuggerKitInformation *ki,
|
||||||
QWidget *parent = 0);
|
QWidget *parent = 0);
|
||||||
|
|
||||||
@@ -69,9 +69,8 @@ public:
|
|||||||
|
|
||||||
void makeReadOnly();
|
void makeReadOnly();
|
||||||
|
|
||||||
void apply();
|
void refresh();
|
||||||
void discard();
|
|
||||||
bool isDirty() const { return m_dirty; }
|
|
||||||
QWidget *buttonWidget() const;
|
QWidget *buttonWidget() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@@ -79,13 +78,8 @@ private slots:
|
|||||||
void showDialog();
|
void showDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setItem(const DebuggerKitInformation::DebuggerItem &item);
|
|
||||||
void doSetItem(const DebuggerKitInformation::DebuggerItem &item);
|
|
||||||
|
|
||||||
ProjectExplorer::Kit *m_kit;
|
ProjectExplorer::Kit *m_kit;
|
||||||
const DebuggerKitInformation *m_info;
|
const DebuggerKitInformation *m_info;
|
||||||
DebuggerKitInformation::DebuggerItem m_item;
|
|
||||||
bool m_dirty;
|
|
||||||
QLabel *m_label;
|
QLabel *m_label;
|
||||||
QPushButton *m_button;
|
QPushButton *m_button;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -52,10 +52,7 @@ public:
|
|||||||
|
|
||||||
virtual QString displayName() const = 0;
|
virtual QString displayName() const = 0;
|
||||||
virtual void makeReadOnly() = 0;
|
virtual void makeReadOnly() = 0;
|
||||||
|
virtual void refresh() = 0;
|
||||||
virtual void apply() = 0;
|
|
||||||
virtual void discard() = 0;
|
|
||||||
virtual bool isDirty() const = 0;
|
|
||||||
|
|
||||||
virtual QWidget *buttonWidget() const { return 0; }
|
virtual QWidget *buttonWidget() const { return 0; }
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ SysRootInformationConfigWidget::SysRootInformationConfigWidget(Kit *k, QWidget *
|
|||||||
|
|
||||||
m_chooser->setFileName(SysRootKitInformation::sysRoot(k));
|
m_chooser->setFileName(SysRootKitInformation::sysRoot(k));
|
||||||
|
|
||||||
connect(m_chooser, SIGNAL(changed(QString)), this, SIGNAL(dirty()));
|
connect(m_chooser, SIGNAL(changed(QString)), this, SLOT(pathWasChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SysRootInformationConfigWidget::displayName() const
|
QString SysRootInformationConfigWidget::displayName() const
|
||||||
@@ -77,21 +77,11 @@ QString SysRootInformationConfigWidget::displayName() const
|
|||||||
return tr("Sysroot:");
|
return tr("Sysroot:");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SysRootInformationConfigWidget::apply()
|
void SysRootInformationConfigWidget::refresh()
|
||||||
{
|
|
||||||
SysRootKitInformation::setSysRoot(m_kit, m_chooser->fileName());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SysRootInformationConfigWidget::discard()
|
|
||||||
{
|
{
|
||||||
m_chooser->setFileName(SysRootKitInformation::sysRoot(m_kit));
|
m_chooser->setFileName(SysRootKitInformation::sysRoot(m_kit));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SysRootInformationConfigWidget::isDirty() const
|
|
||||||
{
|
|
||||||
return SysRootKitInformation::sysRoot(m_kit) != m_chooser->fileName();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SysRootInformationConfigWidget::makeReadOnly()
|
void SysRootInformationConfigWidget::makeReadOnly()
|
||||||
{
|
{
|
||||||
m_chooser->setEnabled(false);
|
m_chooser->setEnabled(false);
|
||||||
@@ -102,6 +92,11 @@ QWidget *SysRootInformationConfigWidget::buttonWidget() const
|
|||||||
return m_chooser->buttonAtIndex(0);
|
return m_chooser->buttonAtIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SysRootInformationConfigWidget::pathWasChanged()
|
||||||
|
{
|
||||||
|
SysRootKitInformation::setSysRoot(m_kit, m_chooser->fileName());
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// ToolChainInformationConfigWidget:
|
// ToolChainInformationConfigWidget:
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@@ -128,8 +123,8 @@ ToolChainInformationConfigWidget::ToolChainInformationConfigWidget(Kit *k, QWidg
|
|||||||
|
|
||||||
updateComboBox();
|
updateComboBox();
|
||||||
|
|
||||||
discard();
|
refresh();
|
||||||
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dirty()));
|
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentToolChainChanged(int)));
|
||||||
|
|
||||||
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
||||||
m_manageButton->setText(tr("Manage..."));
|
m_manageButton->setText(tr("Manage..."));
|
||||||
@@ -148,25 +143,11 @@ QString ToolChainInformationConfigWidget::displayName() const
|
|||||||
return tr("Compiler:");
|
return tr("Compiler:");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolChainInformationConfigWidget::apply()
|
void ToolChainInformationConfigWidget::refresh()
|
||||||
{
|
|
||||||
const QString id = m_comboBox->itemData(m_comboBox->currentIndex()).toString();
|
|
||||||
ToolChain *tc = ToolChainManager::instance()->findToolChain(id);
|
|
||||||
ToolChainKitInformation::setToolChain(m_kit, tc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolChainInformationConfigWidget::discard()
|
|
||||||
{
|
{
|
||||||
m_comboBox->setCurrentIndex(indexOf(ToolChainKitInformation::toolChain(m_kit)));
|
m_comboBox->setCurrentIndex(indexOf(ToolChainKitInformation::toolChain(m_kit)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToolChainInformationConfigWidget::isDirty() const
|
|
||||||
{
|
|
||||||
ToolChain *tc = ToolChainKitInformation::toolChain(m_kit);
|
|
||||||
return (m_comboBox->itemData(m_comboBox->currentIndex()).toString())
|
|
||||||
!= (tc ? tc->id() : QString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolChainInformationConfigWidget::makeReadOnly()
|
void ToolChainInformationConfigWidget::makeReadOnly()
|
||||||
{
|
{
|
||||||
m_comboBox->setEnabled(false);
|
m_comboBox->setEnabled(false);
|
||||||
@@ -205,6 +186,13 @@ void ToolChainInformationConfigWidget::manageToolChains()
|
|||||||
QLatin1String(ProjectExplorer::Constants::TOOLCHAIN_SETTINGS_PAGE_ID));
|
QLatin1String(ProjectExplorer::Constants::TOOLCHAIN_SETTINGS_PAGE_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToolChainInformationConfigWidget::currentToolChainChanged(int idx)
|
||||||
|
{
|
||||||
|
const QString id = m_comboBox->itemData(idx).toString();
|
||||||
|
ToolChain *tc = ToolChainManager::instance()->findToolChain(id);
|
||||||
|
ToolChainKitInformation::setToolChain(m_kit, tc);
|
||||||
|
}
|
||||||
|
|
||||||
void ToolChainInformationConfigWidget::updateComboBox()
|
void ToolChainInformationConfigWidget::updateComboBox()
|
||||||
{
|
{
|
||||||
// remove unavailable tool chain:
|
// remove unavailable tool chain:
|
||||||
@@ -234,9 +222,9 @@ int ToolChainInformationConfigWidget::indexOf(const ToolChain *tc)
|
|||||||
// DeviceTypeInformationConfigWidget:
|
// DeviceTypeInformationConfigWidget:
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
DeviceTypeInformationConfigWidget::DeviceTypeInformationConfigWidget(Kit *k, QWidget *parent) :
|
DeviceTypeInformationConfigWidget::DeviceTypeInformationConfigWidget(Kit *workingCopy, QWidget *parent) :
|
||||||
KitConfigWidget(parent),
|
KitConfigWidget(parent),
|
||||||
m_isReadOnly(false), m_kit(k),
|
m_isReadOnly(false), m_kit(workingCopy),
|
||||||
m_comboBox(new QComboBox)
|
m_comboBox(new QComboBox)
|
||||||
{
|
{
|
||||||
setToolTip(tr("The type of device to run applications on."));
|
setToolTip(tr("The type of device to run applications on."));
|
||||||
@@ -250,12 +238,12 @@ DeviceTypeInformationConfigWidget::DeviceTypeInformationConfigWidget(Kit *k, QWi
|
|||||||
= ExtensionSystem::PluginManager::instance()->getObjects<IDeviceFactory>();
|
= ExtensionSystem::PluginManager::instance()->getObjects<IDeviceFactory>();
|
||||||
foreach (IDeviceFactory *factory, factories) {
|
foreach (IDeviceFactory *factory, factories) {
|
||||||
foreach (Core::Id id, factory->availableCreationIds()) {
|
foreach (Core::Id id, factory->availableCreationIds()) {
|
||||||
m_comboBox->addItem(factory->displayNameForId(id), QVariant::fromValue(id));
|
m_comboBox->addItem(factory->displayNameForId(id), id.uniqueIdentifier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
discard();
|
refresh();
|
||||||
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dirty()));
|
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentTypeChanged(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DeviceTypeInformationConfigWidget::displayName() const
|
QString DeviceTypeInformationConfigWidget::displayName() const
|
||||||
@@ -263,47 +251,37 @@ QString DeviceTypeInformationConfigWidget::displayName() const
|
|||||||
return tr("Device type:");
|
return tr("Device type:");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceTypeInformationConfigWidget::apply()
|
void DeviceTypeInformationConfigWidget::refresh()
|
||||||
{
|
|
||||||
Core::Id devType;
|
|
||||||
if (m_comboBox->currentIndex() >= 0)
|
|
||||||
devType = m_comboBox->itemData(m_comboBox->currentIndex()).value<Core::Id>();
|
|
||||||
DeviceTypeKitInformation::setDeviceTypeId(m_kit, devType);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceTypeInformationConfigWidget::discard()
|
|
||||||
{
|
{
|
||||||
Core::Id devType = DeviceTypeKitInformation::deviceTypeId(m_kit);
|
Core::Id devType = DeviceTypeKitInformation::deviceTypeId(m_kit);
|
||||||
if (!devType.isValid())
|
if (!devType.isValid())
|
||||||
m_comboBox->setCurrentIndex(-1);
|
m_comboBox->setCurrentIndex(-1);
|
||||||
for (int i = 0; i < m_comboBox->count(); ++i) {
|
for (int i = 0; i < m_comboBox->count(); ++i) {
|
||||||
if (m_comboBox->itemData(i).value<Core::Id>() == devType) {
|
if (m_comboBox->itemData(i).toInt() == devType.uniqueIdentifier()) {
|
||||||
m_comboBox->setCurrentIndex(i);
|
m_comboBox->setCurrentIndex(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceTypeInformationConfigWidget::isDirty() const
|
|
||||||
{
|
|
||||||
Core::Id devType;
|
|
||||||
if (m_comboBox->currentIndex() >= 0)
|
|
||||||
devType = m_comboBox->itemData(m_comboBox->currentIndex()).value<Core::Id>();
|
|
||||||
return DeviceTypeKitInformation::deviceTypeId(m_kit) != devType;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceTypeInformationConfigWidget::makeReadOnly()
|
void DeviceTypeInformationConfigWidget::makeReadOnly()
|
||||||
{
|
{
|
||||||
m_comboBox->setEnabled(false);
|
m_comboBox->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceTypeInformationConfigWidget::currentTypeChanged(int idx)
|
||||||
|
{
|
||||||
|
Core::Id type = idx < 0 ? Core::Id() : Core::Id::fromUniqueIdentifier(m_comboBox->itemData(idx).toInt());
|
||||||
|
DeviceTypeKitInformation::setDeviceTypeId(m_kit, type);
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// DeviceInformationConfigWidget:
|
// DeviceInformationConfigWidget:
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
DeviceInformationConfigWidget::DeviceInformationConfigWidget(Kit *k, QWidget *parent) :
|
DeviceInformationConfigWidget::DeviceInformationConfigWidget(Kit *workingCopy, QWidget *parent) :
|
||||||
KitConfigWidget(parent),
|
KitConfigWidget(parent),
|
||||||
m_isReadOnly(false), m_kit(k),
|
m_isReadOnly(false), m_kit(workingCopy),
|
||||||
m_comboBox(new QComboBox), m_manageButton(new QPushButton(this)),
|
m_comboBox(new QComboBox), m_manageButton(new QPushButton(this)),
|
||||||
m_model(new DeviceManagerModel(DeviceManager::instance()))
|
m_model(new DeviceManagerModel(DeviceManager::instance()))
|
||||||
{
|
{
|
||||||
@@ -323,8 +301,8 @@ DeviceInformationConfigWidget::DeviceInformationConfigWidget(Kit *k, QWidget *pa
|
|||||||
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
||||||
m_manageButton->setText(tr("Manage..."));
|
m_manageButton->setText(tr("Manage..."));
|
||||||
|
|
||||||
discard();
|
refresh();
|
||||||
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dirty()));
|
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentDeviceChanged()));
|
||||||
|
|
||||||
connect(m_manageButton, SIGNAL(clicked()), this, SLOT(manageDevices()));
|
connect(m_manageButton, SIGNAL(clicked()), this, SLOT(manageDevices()));
|
||||||
}
|
}
|
||||||
@@ -334,26 +312,12 @@ QString DeviceInformationConfigWidget::displayName() const
|
|||||||
return tr("Device:");
|
return tr("Device:");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceInformationConfigWidget::apply()
|
void DeviceInformationConfigWidget::refresh()
|
||||||
{
|
|
||||||
int idx = m_comboBox->currentIndex();
|
|
||||||
if (idx >= 0)
|
|
||||||
DeviceKitInformation::setDeviceId(m_kit, m_model->deviceId(idx));
|
|
||||||
else
|
|
||||||
DeviceKitInformation::setDeviceId(m_kit, IDevice::invalidId());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceInformationConfigWidget::discard()
|
|
||||||
{
|
{
|
||||||
|
m_model->setTypeFilter(DeviceTypeKitInformation::deviceTypeId(m_kit));
|
||||||
m_comboBox->setCurrentIndex(m_model->indexOf(DeviceKitInformation::device(m_kit)));
|
m_comboBox->setCurrentIndex(m_model->indexOf(DeviceKitInformation::device(m_kit)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceInformationConfigWidget::isDirty() const
|
|
||||||
{
|
|
||||||
Core::Id devId = DeviceKitInformation::deviceId(m_kit);
|
|
||||||
return devId != m_model->deviceId(m_comboBox->currentIndex());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceInformationConfigWidget::makeReadOnly()
|
void DeviceInformationConfigWidget::makeReadOnly()
|
||||||
{
|
{
|
||||||
m_comboBox->setEnabled(false);
|
m_comboBox->setEnabled(false);
|
||||||
@@ -380,5 +344,10 @@ void DeviceInformationConfigWidget::modelReset()
|
|||||||
m_comboBox->setCurrentIndex(m_model->indexForId(m_selectedId));
|
m_comboBox->setCurrentIndex(m_model->indexForId(m_selectedId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceInformationConfigWidget::currentDeviceChanged()
|
||||||
|
{
|
||||||
|
DeviceKitInformation::setDeviceId(m_kit, m_model->deviceId(m_comboBox->currentIndex()));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
|||||||
@@ -61,12 +61,13 @@ public:
|
|||||||
explicit SysRootInformationConfigWidget(Kit *k, QWidget *parent = 0);
|
explicit SysRootInformationConfigWidget(Kit *k, QWidget *parent = 0);
|
||||||
|
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
void apply();
|
void refresh();
|
||||||
void discard();
|
|
||||||
bool isDirty() const;
|
|
||||||
void makeReadOnly();
|
void makeReadOnly();
|
||||||
QWidget *buttonWidget() const;
|
QWidget *buttonWidget() const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void pathWasChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Kit *m_kit;
|
Kit *m_kit;
|
||||||
Utils::PathChooser *m_chooser;
|
Utils::PathChooser *m_chooser;
|
||||||
@@ -84,9 +85,7 @@ public:
|
|||||||
explicit ToolChainInformationConfigWidget(Kit *k, QWidget *parent = 0);
|
explicit ToolChainInformationConfigWidget(Kit *k, QWidget *parent = 0);
|
||||||
|
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
void apply();
|
void refresh();
|
||||||
void discard();
|
|
||||||
bool isDirty() const;
|
|
||||||
void makeReadOnly();
|
void makeReadOnly();
|
||||||
QWidget *buttonWidget() const;
|
QWidget *buttonWidget() const;
|
||||||
|
|
||||||
@@ -95,6 +94,7 @@ private slots:
|
|||||||
void toolChainRemoved(ProjectExplorer::ToolChain *tc);
|
void toolChainRemoved(ProjectExplorer::ToolChain *tc);
|
||||||
void toolChainUpdated(ProjectExplorer::ToolChain *tc);
|
void toolChainUpdated(ProjectExplorer::ToolChain *tc);
|
||||||
void manageToolChains();
|
void manageToolChains();
|
||||||
|
void currentToolChainChanged(int idx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateComboBox();
|
void updateComboBox();
|
||||||
@@ -115,14 +115,15 @@ class DeviceTypeInformationConfigWidget : public KitConfigWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DeviceTypeInformationConfigWidget(Kit *k, QWidget *parent = 0);
|
explicit DeviceTypeInformationConfigWidget(Kit *workingCopy, QWidget *parent = 0);
|
||||||
|
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
void apply();
|
void refresh();
|
||||||
void discard();
|
|
||||||
bool isDirty() const;
|
|
||||||
void makeReadOnly();
|
void makeReadOnly();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void currentTypeChanged(int idx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_isReadOnly;
|
bool m_isReadOnly;
|
||||||
Kit *m_kit;
|
Kit *m_kit;
|
||||||
@@ -138,12 +139,10 @@ class DeviceInformationConfigWidget : public KitConfigWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DeviceInformationConfigWidget(Kit *k, QWidget *parent = 0);
|
explicit DeviceInformationConfigWidget(Kit *workingCopy, QWidget *parent = 0);
|
||||||
|
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
void apply();
|
void refresh();
|
||||||
void discard();
|
|
||||||
bool isDirty() const;
|
|
||||||
void makeReadOnly();
|
void makeReadOnly();
|
||||||
QWidget *buttonWidget() const;
|
QWidget *buttonWidget() const;
|
||||||
|
|
||||||
@@ -151,6 +150,7 @@ private slots:
|
|||||||
void manageDevices();
|
void manageDevices();
|
||||||
void modelAboutToReset();
|
void modelAboutToReset();
|
||||||
void modelReset();
|
void modelReset();
|
||||||
|
void currentDeviceChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_isReadOnly;
|
bool m_isReadOnly;
|
||||||
|
|||||||
@@ -359,11 +359,9 @@ QList<KitInformation *> KitManager::kitInformation() const
|
|||||||
|
|
||||||
Internal::KitManagerConfigWidget *KitManager::createConfigWidget(Kit *k) const
|
Internal::KitManagerConfigWidget *KitManager::createConfigWidget(Kit *k) const
|
||||||
{
|
{
|
||||||
if (!k)
|
|
||||||
return 0;
|
|
||||||
Internal::KitManagerConfigWidget *result = new Internal::KitManagerConfigWidget(k);
|
Internal::KitManagerConfigWidget *result = new Internal::KitManagerConfigWidget(k);
|
||||||
foreach (KitInformation *ki, d->m_informationList)
|
foreach (KitInformation *ki, d->m_informationList)
|
||||||
result->addConfigWidget(ki->createConfigWidget(k));
|
result->addConfigWidget(ki->createConfigWidget(result->workingCopy()));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "kitmanagerconfigwidget.h"
|
#include "kitmanagerconfigwidget.h"
|
||||||
|
|
||||||
#include "kit.h"
|
#include "kit.h"
|
||||||
|
#include "kitmanager.h"
|
||||||
|
|
||||||
#include <utils/detailswidget.h>
|
#include <utils/detailswidget.h>
|
||||||
|
|
||||||
@@ -43,16 +44,20 @@
|
|||||||
#include <QSizePolicy>
|
#include <QSizePolicy>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
|
|
||||||
|
static const char WORKING_COPY_KIT_ID[] = "modified kit";
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
KitManagerConfigWidget::KitManagerConfigWidget(Kit *k, QWidget *parent) :
|
KitManagerConfigWidget::KitManagerConfigWidget(Kit *k, QWidget *parent) :
|
||||||
KitConfigWidget(parent),
|
QWidget(parent),
|
||||||
m_layout(new QGridLayout),
|
m_layout(new QGridLayout),
|
||||||
m_iconButton(new QToolButton),
|
m_iconButton(new QToolButton),
|
||||||
m_nameEdit(new QLineEdit),
|
m_nameEdit(new QLineEdit),
|
||||||
m_kit(k)
|
m_kit(k),
|
||||||
|
m_modifiedKit(new Kit(Core::Id(WORKING_COPY_KIT_ID))),
|
||||||
|
m_fixingKit(false)
|
||||||
{
|
{
|
||||||
QVBoxLayout *top = new QVBoxLayout(this);
|
QVBoxLayout *top = new QVBoxLayout(this);
|
||||||
top->setMargin(0);
|
top->setMargin(0);
|
||||||
@@ -81,7 +86,21 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k, QWidget *parent) :
|
|||||||
discard();
|
discard();
|
||||||
|
|
||||||
connect(m_iconButton, SIGNAL(clicked()), this, SLOT(setIcon()));
|
connect(m_iconButton, SIGNAL(clicked()), this, SLOT(setIcon()));
|
||||||
connect(m_nameEdit, SIGNAL(textChanged(QString)), this, SIGNAL(dirty()));
|
connect(m_nameEdit, SIGNAL(textChanged(QString)), this, SLOT(setDisplayName()));
|
||||||
|
|
||||||
|
KitManager *km = KitManager::instance();
|
||||||
|
connect(km, SIGNAL(unmanagedKitUpdated(ProjectExplorer::Kit*)),
|
||||||
|
this, SLOT(workingCopyWasUpdated(ProjectExplorer::Kit*)));
|
||||||
|
connect(km, SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
|
||||||
|
this, SLOT(kitWasUpdated(ProjectExplorer::Kit*)));
|
||||||
|
}
|
||||||
|
|
||||||
|
KitManagerConfigWidget::~KitManagerConfigWidget()
|
||||||
|
{
|
||||||
|
delete m_modifiedKit;
|
||||||
|
// Make sure our workingCopy did not get registered somehow:
|
||||||
|
foreach (const Kit *k, KitManager::instance()->kits())
|
||||||
|
Q_ASSERT(k->id() != Core::Id(WORKING_COPY_KIT_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KitManagerConfigWidget::displayName() const
|
QString KitManagerConfigWidget::displayName() const
|
||||||
@@ -91,27 +110,51 @@ QString KitManagerConfigWidget::displayName() const
|
|||||||
|
|
||||||
void KitManagerConfigWidget::apply()
|
void KitManagerConfigWidget::apply()
|
||||||
{
|
{
|
||||||
foreach (KitConfigWidget *w, m_widgets)
|
KitManager *km = KitManager::instance();
|
||||||
w->apply();
|
bool mustRegister = false;
|
||||||
m_kit->setIconPath(m_iconPath);
|
if (!m_kit) {
|
||||||
m_kit->setDisplayName(m_nameEdit->text());
|
mustRegister = true;
|
||||||
|
m_kit = new Kit;
|
||||||
|
}
|
||||||
|
m_kit->copyFrom(m_modifiedKit);
|
||||||
|
if (mustRegister)
|
||||||
|
km->registerKit(m_kit);
|
||||||
|
|
||||||
|
if (m_isDefaultKit)
|
||||||
|
km->setDefaultKit(m_kit);
|
||||||
|
emit dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KitManagerConfigWidget::discard()
|
void KitManagerConfigWidget::discard()
|
||||||
{
|
{
|
||||||
foreach (KitConfigWidget *w, m_widgets)
|
if (m_kit) {
|
||||||
w->discard();
|
m_modifiedKit->copyFrom(m_kit);
|
||||||
m_iconButton->setIcon(m_kit->icon());
|
m_isDefaultKit = (m_kit == KitManager::instance()->defaultKit());
|
||||||
m_iconPath = m_kit->iconPath();
|
} else {
|
||||||
m_nameEdit->setText(m_kit->displayName());
|
// This branch will only ever get reached once during setup of widget for a not-yet-existing
|
||||||
|
// kit.
|
||||||
|
m_isDefaultKit = false;
|
||||||
|
}
|
||||||
|
m_iconButton->setIcon(m_modifiedKit->icon());
|
||||||
|
m_nameEdit->setText(m_modifiedKit->displayName());
|
||||||
|
emit dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KitManagerConfigWidget::isDirty() const
|
bool KitManagerConfigWidget::isDirty() const
|
||||||
{
|
{
|
||||||
foreach (KitConfigWidget *w, m_widgets)
|
return !m_kit
|
||||||
if (w->isDirty())
|
|| !m_kit->isEqual(m_modifiedKit)
|
||||||
return true;
|
|| m_isDefaultKit != (KitManager::instance()->defaultKit() == m_kit);
|
||||||
return (m_kit->iconPath() != m_iconPath) || (m_kit->displayName() != m_nameEdit->text());
|
}
|
||||||
|
|
||||||
|
bool KitManagerConfigWidget::isValid() const
|
||||||
|
{
|
||||||
|
return m_modifiedKit->isValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KitManagerConfigWidget::validityMessage() const
|
||||||
|
{
|
||||||
|
return m_modifiedKit->toHtml();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KitManagerConfigWidget::addConfigWidget(ProjectExplorer::KitConfigWidget *widget)
|
void KitManagerConfigWidget::addConfigWidget(ProjectExplorer::KitConfigWidget *widget)
|
||||||
@@ -119,8 +162,6 @@ void KitManagerConfigWidget::addConfigWidget(ProjectExplorer::KitConfigWidget *w
|
|||||||
Q_ASSERT(widget);
|
Q_ASSERT(widget);
|
||||||
Q_ASSERT(!m_widgets.contains(widget));
|
Q_ASSERT(!m_widgets.contains(widget));
|
||||||
|
|
||||||
connect(widget, SIGNAL(dirty()), this, SIGNAL(dirty()));
|
|
||||||
|
|
||||||
addToLayout(widget->displayName(), widget->toolTip(), widget, widget->buttonWidget());
|
addToLayout(widget->displayName(), widget->toolTip(), widget, widget->buttonWidget());
|
||||||
m_widgets.append(widget);
|
m_widgets.append(widget);
|
||||||
}
|
}
|
||||||
@@ -133,9 +174,39 @@ void KitManagerConfigWidget::makeReadOnly()
|
|||||||
m_nameEdit->setEnabled(false);
|
m_nameEdit->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Kit *KitManagerConfigWidget::workingCopy() const
|
||||||
|
{
|
||||||
|
return m_modifiedKit;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KitManagerConfigWidget::configures(Kit *k) const
|
||||||
|
{
|
||||||
|
return m_kit == k;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KitManagerConfigWidget::setIsDefaultKit(bool d)
|
||||||
|
{
|
||||||
|
if (m_isDefaultKit != d)
|
||||||
|
return;
|
||||||
|
m_isDefaultKit = d;
|
||||||
|
emit dirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KitManagerConfigWidget::isDefaultKit() const
|
||||||
|
{
|
||||||
|
return m_isDefaultKit;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KitManagerConfigWidget::removeKit()
|
||||||
|
{
|
||||||
|
if (!m_kit)
|
||||||
|
return;
|
||||||
|
KitManager::instance()->deregisterKit(m_kit);
|
||||||
|
}
|
||||||
|
|
||||||
void KitManagerConfigWidget::setIcon()
|
void KitManagerConfigWidget::setIcon()
|
||||||
{
|
{
|
||||||
const QString path = QFileDialog::getOpenFileName(this, tr("Select Icon"), m_iconPath, tr("Images (*.png *.xpm *.jpg)"));
|
const QString path = QFileDialog::getOpenFileName(this, tr("Select Icon"), m_modifiedKit->iconPath(), tr("Images (*.png *.xpm *.jpg)"));
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -144,10 +215,37 @@ void KitManagerConfigWidget::setIcon()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_iconButton->setIcon(icon);
|
m_iconButton->setIcon(icon);
|
||||||
m_iconPath = path;
|
m_modifiedKit->setIconPath(path);
|
||||||
emit dirty();
|
emit dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KitManagerConfigWidget::setDisplayName()
|
||||||
|
{
|
||||||
|
m_modifiedKit->setDisplayName(m_nameEdit->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
void KitManagerConfigWidget::workingCopyWasUpdated(Kit *k)
|
||||||
|
{
|
||||||
|
if (k != m_modifiedKit || m_fixingKit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_fixingKit = true;
|
||||||
|
k->fix();
|
||||||
|
m_fixingKit = false;
|
||||||
|
|
||||||
|
foreach (KitConfigWidget *w, m_widgets)
|
||||||
|
w->refresh();
|
||||||
|
m_nameEdit->setText(k->displayName());
|
||||||
|
m_iconButton->setIcon(k->icon());
|
||||||
|
emit dirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KitManagerConfigWidget::kitWasUpdated(Kit *k)
|
||||||
|
{
|
||||||
|
if (m_kit == k)
|
||||||
|
discard();
|
||||||
|
}
|
||||||
|
|
||||||
void KitManagerConfigWidget::addToLayout(const QString &name, const QString &toolTip,
|
void KitManagerConfigWidget::addToLayout(const QString &name, const QString &toolTip,
|
||||||
QWidget *widget, QWidget *button)
|
QWidget *widget, QWidget *button)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,23 +44,40 @@ class Kit;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class KitManagerConfigWidget : public ProjectExplorer::KitConfigWidget
|
class KitManagerConfigWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit KitManagerConfigWidget(Kit *k, QWidget *parent = 0);
|
explicit KitManagerConfigWidget(Kit *k, QWidget *parent = 0);
|
||||||
|
~KitManagerConfigWidget();
|
||||||
|
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
|
|
||||||
void apply();
|
void apply();
|
||||||
void discard();
|
void discard();
|
||||||
bool isDirty() const;
|
bool isDirty() const;
|
||||||
|
bool isValid() const;
|
||||||
|
QString validityMessage() const;
|
||||||
void addConfigWidget(ProjectExplorer::KitConfigWidget *widget);
|
void addConfigWidget(ProjectExplorer::KitConfigWidget *widget);
|
||||||
void makeReadOnly();
|
void makeReadOnly();
|
||||||
|
|
||||||
|
Kit *workingCopy() const;
|
||||||
|
bool configures(ProjectExplorer::Kit *k) const;
|
||||||
|
void setIsDefaultKit(bool d);
|
||||||
|
bool isDefaultKit() const;
|
||||||
|
void removeKit();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void dirty();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setIcon();
|
void setIcon();
|
||||||
|
void setDisplayName();
|
||||||
|
void workingCopyWasUpdated(ProjectExplorer::Kit *k);
|
||||||
|
void kitWasUpdated(ProjectExplorer::Kit *k);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum LayoutColumns {
|
enum LayoutColumns {
|
||||||
@@ -80,7 +97,9 @@ private:
|
|||||||
QLineEdit *m_nameEdit;
|
QLineEdit *m_nameEdit;
|
||||||
QList<KitConfigWidget *> m_widgets;
|
QList<KitConfigWidget *> m_widgets;
|
||||||
Kit *m_kit;
|
Kit *m_kit;
|
||||||
QString m_iconPath;
|
Kit *m_modifiedKit;
|
||||||
|
bool m_isDefaultKit;
|
||||||
|
bool m_fixingKit;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -45,11 +45,19 @@ namespace Internal {
|
|||||||
class KitNode
|
class KitNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit KitNode(KitNode *kn, Kit *k = 0, bool c = false) :
|
KitNode(KitNode *kn) :
|
||||||
parent(kn), kit(k), changed(c)
|
parent(kn), widget(0)
|
||||||
{
|
{
|
||||||
if (kn)
|
if (kn)
|
||||||
kn->childNodes.append(this);
|
kn->childNodes.append(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
KitNode(KitNode *kn, Kit *k) :
|
||||||
|
parent(kn)
|
||||||
|
{
|
||||||
|
if (kn)
|
||||||
|
kn->childNodes.append(this);
|
||||||
|
|
||||||
widget = KitManager::instance()->createConfigWidget(k);
|
widget = KitManager::instance()->createConfigWidget(k);
|
||||||
if (widget) {
|
if (widget) {
|
||||||
if (k && k->isAutoDetected())
|
if (k && k->isAutoDetected())
|
||||||
@@ -62,6 +70,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (parent)
|
if (parent)
|
||||||
parent->childNodes.removeOne(this);
|
parent->childNodes.removeOne(this);
|
||||||
|
delete widget;
|
||||||
|
|
||||||
// deleting a child removes it from childNodes
|
// deleting a child removes it from childNodes
|
||||||
// so operate on a temporary list
|
// so operate on a temporary list
|
||||||
@@ -72,9 +81,7 @@ public:
|
|||||||
|
|
||||||
KitNode *parent;
|
KitNode *parent;
|
||||||
QList<KitNode *> childNodes;
|
QList<KitNode *> childNodes;
|
||||||
Kit *kit;
|
|
||||||
KitManagerConfigWidget *widget;
|
KitManagerConfigWidget *widget;
|
||||||
bool changed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@@ -92,8 +99,6 @@ KitModel::KitModel(QBoxLayout *parentLayout, QObject *parent) :
|
|||||||
this, SLOT(addKit(ProjectExplorer::Kit*)));
|
this, SLOT(addKit(ProjectExplorer::Kit*)));
|
||||||
connect(KitManager::instance(), SIGNAL(kitRemoved(ProjectExplorer::Kit*)),
|
connect(KitManager::instance(), SIGNAL(kitRemoved(ProjectExplorer::Kit*)),
|
||||||
this, SLOT(removeKit(ProjectExplorer::Kit*)));
|
this, SLOT(removeKit(ProjectExplorer::Kit*)));
|
||||||
connect(KitManager::instance(), SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
|
|
||||||
this, SLOT(updateKit(ProjectExplorer::Kit*)));
|
|
||||||
connect(KitManager::instance(), SIGNAL(defaultkitChanged()),
|
connect(KitManager::instance(), SIGNAL(defaultkitChanged()),
|
||||||
this, SLOT(changeDefaultKit()));
|
this, SLOT(changeDefaultKit()));
|
||||||
|
|
||||||
@@ -162,10 +167,10 @@ QVariant KitModel::data(const QModelIndex &index, int role) const
|
|||||||
return tr("Auto-detected");
|
return tr("Auto-detected");
|
||||||
if (node == m_manualRoot && role == Qt::DisplayRole)
|
if (node == m_manualRoot && role == Qt::DisplayRole)
|
||||||
return tr("Manual");
|
return tr("Manual");
|
||||||
if (node->kit) {
|
if (node->widget) {
|
||||||
if (role == Qt::FontRole) {
|
if (role == Qt::FontRole) {
|
||||||
QFont f = QApplication::font();
|
QFont f = QApplication::font();
|
||||||
if (node->changed)
|
if (node->widget->isDirty())
|
||||||
f.setBold(!f.bold());
|
f.setBold(!f.bold());
|
||||||
if (node == m_defaultNode)
|
if (node == m_defaultNode)
|
||||||
f.setItalic(f.style() != QFont::StyleItalic);
|
f.setItalic(f.style() != QFont::StyleItalic);
|
||||||
@@ -177,9 +182,9 @@ QVariant KitModel::data(const QModelIndex &index, int role) const
|
|||||||
baseName = tr("%1 (default)").arg(baseName);
|
baseName = tr("%1 (default)").arg(baseName);
|
||||||
return baseName;
|
return baseName;
|
||||||
} else if (role == Qt::DecorationRole) {
|
} else if (role == Qt::DecorationRole) {
|
||||||
return node->kit->isValid() ? QIcon() : warningIcon;
|
return node->widget->isValid() ? QIcon() : warningIcon;
|
||||||
} else if (role == Qt::ToolTipRole) {
|
} else if (role == Qt::ToolTipRole) {
|
||||||
return node->kit->toHtml();
|
return node->widget->validityMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@@ -192,7 +197,7 @@ Qt::ItemFlags KitModel::flags(const QModelIndex &index) const
|
|||||||
|
|
||||||
KitNode *node = static_cast<KitNode *>(index.internalPointer());
|
KitNode *node = static_cast<KitNode *>(index.internalPointer());
|
||||||
Q_ASSERT(node);
|
Q_ASSERT(node);
|
||||||
if (!node->kit)
|
if (!node->widget)
|
||||||
return Qt::ItemIsEnabled;
|
return Qt::ItemIsEnabled;
|
||||||
|
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
@@ -212,12 +217,12 @@ Kit *KitModel::kit(const QModelIndex &index)
|
|||||||
return 0;
|
return 0;
|
||||||
KitNode *node = static_cast<KitNode *>(index.internalPointer());
|
KitNode *node = static_cast<KitNode *>(index.internalPointer());
|
||||||
Q_ASSERT(node);
|
Q_ASSERT(node);
|
||||||
return node->kit;
|
return node->widget->workingCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex KitModel::indexOf(Kit *k) const
|
QModelIndex KitModel::indexOf(Kit *k) const
|
||||||
{
|
{
|
||||||
KitNode *n = find(k);
|
KitNode *n = findWorkingCopy(k);
|
||||||
return n ? index(n) : QModelIndex();
|
return n ? index(n) : QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +232,7 @@ void KitModel::setDefaultKit(const QModelIndex &index)
|
|||||||
return;
|
return;
|
||||||
KitNode *node = static_cast<KitNode *>(index.internalPointer());
|
KitNode *node = static_cast<KitNode *>(index.internalPointer());
|
||||||
Q_ASSERT(node);
|
Q_ASSERT(node);
|
||||||
if (node->kit)
|
if (node->widget)
|
||||||
setDefaultNode(node);
|
setDefaultNode(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +241,7 @@ bool KitModel::isDefaultKit(const QModelIndex &index)
|
|||||||
return m_defaultNode == static_cast<KitNode *>(index.internalPointer());
|
return m_defaultNode == static_cast<KitNode *>(index.internalPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
KitConfigWidget *KitModel::widget(const QModelIndex &index)
|
KitManagerConfigWidget *KitModel::widget(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
@@ -248,7 +253,7 @@ KitConfigWidget *KitModel::widget(const QModelIndex &index)
|
|||||||
bool KitModel::isDirty() const
|
bool KitModel::isDirty() const
|
||||||
{
|
{
|
||||||
foreach (KitNode *n, m_manualRoot->childNodes) {
|
foreach (KitNode *n, m_manualRoot->childNodes) {
|
||||||
if (n->changed)
|
if (n->widget->isDirty())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -256,19 +261,19 @@ bool KitModel::isDirty() const
|
|||||||
|
|
||||||
bool KitModel::isDirty(Kit *k) const
|
bool KitModel::isDirty(Kit *k) const
|
||||||
{
|
{
|
||||||
KitNode *n = find(k);
|
KitNode *n = findWorkingCopy(k);
|
||||||
return n ? !n->changed : false;
|
return n ? n->widget->isDirty() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KitModel::setDirty()
|
void KitModel::setDirty()
|
||||||
{
|
{
|
||||||
KitConfigWidget *w = qobject_cast<KitConfigWidget *>(sender());
|
KitManagerConfigWidget *w = qobject_cast<KitManagerConfigWidget *>(sender());
|
||||||
foreach (KitNode *n, m_manualRoot->childNodes) {
|
QList<KitNode *> nodes = m_manualRoot->childNodes;
|
||||||
if (n->widget == w) {
|
nodes << m_autoRoot->childNodes;
|
||||||
n->changed = n->widget->isDirty();
|
foreach (KitNode *n, nodes) {
|
||||||
|
if (n->widget == w)
|
||||||
emit dataChanged(index(n, 0), index(n, columnCount(QModelIndex())));
|
emit dataChanged(index(n, 0), index(n, columnCount(QModelIndex())));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KitModel::apply()
|
void KitModel::apply()
|
||||||
@@ -277,61 +282,24 @@ void KitModel::apply()
|
|||||||
QList<KitNode *> nodes = m_toRemoveList;
|
QList<KitNode *> nodes = m_toRemoveList;
|
||||||
foreach (KitNode *n, nodes) {
|
foreach (KitNode *n, nodes) {
|
||||||
Q_ASSERT(!n->parent);
|
Q_ASSERT(!n->parent);
|
||||||
KitManager::instance()->deregisterKit(n->kit);
|
n->widget->removeKit();
|
||||||
}
|
}
|
||||||
Q_ASSERT(m_toRemoveList.isEmpty());
|
Q_ASSERT(m_toRemoveList.isEmpty());
|
||||||
|
|
||||||
// Update kits:
|
// Update kits:
|
||||||
foreach (KitNode *n, m_manualRoot->childNodes) {
|
foreach (KitNode *n, m_manualRoot->childNodes) {
|
||||||
Q_ASSERT(n);
|
Q_ASSERT(n);
|
||||||
Q_ASSERT(n->kit);
|
Q_ASSERT(n->widget);
|
||||||
if (n->changed) {
|
if (n->widget->isDirty()) {
|
||||||
KitManager::instance()->blockSignals(true);
|
|
||||||
if (n->widget)
|
|
||||||
n->widget->apply();
|
n->widget->apply();
|
||||||
n->changed = false;
|
|
||||||
|
|
||||||
KitManager::instance()->blockSignals(false);
|
|
||||||
KitManager::instance()->notifyAboutUpdate(n->kit);
|
|
||||||
emit dataChanged(index(n, 0), index(n, columnCount(QModelIndex())));
|
emit dataChanged(index(n, 0), index(n, columnCount(QModelIndex())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new (and already updated) kits
|
|
||||||
QStringList removedSts;
|
|
||||||
nodes = m_toAddList;
|
|
||||||
foreach (KitNode *n, nodes) {
|
|
||||||
if (!KitManager::instance()->registerKit(n->kit))
|
|
||||||
removedSts << n->kit->displayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (KitNode *n, m_toAddList)
|
|
||||||
markForRemoval(n->kit);
|
|
||||||
|
|
||||||
if (removedSts.count() == 1) {
|
|
||||||
QMessageBox::warning(0,
|
|
||||||
tr("Duplicate Kit Detected"),
|
|
||||||
tr("The kit<br> %1<br>"
|
|
||||||
" was already configured. It was not configured again.")
|
|
||||||
.arg(removedSts.at(0)));
|
|
||||||
|
|
||||||
} else if (!removedSts.isEmpty()) {
|
|
||||||
QMessageBox::warning(0,
|
|
||||||
tr("Duplicate Kits Detected"),
|
|
||||||
tr("The following kits were already configured:<br>"
|
|
||||||
" %1<br>"
|
|
||||||
"They were not configured again.")
|
|
||||||
.arg(removedSts.join(QLatin1String(",<br> "))));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set default kit:
|
|
||||||
if (m_defaultNode)
|
|
||||||
KitManager::instance()->setDefaultKit(m_defaultNode->kit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KitModel::markForRemoval(Kit *k)
|
void KitModel::markForRemoval(Kit *k)
|
||||||
{
|
{
|
||||||
KitNode *node = find(k);
|
KitNode *node = findWorkingCopy(k);
|
||||||
if (!node)
|
if (!node)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -347,29 +315,31 @@ void KitModel::markForRemoval(Kit *k)
|
|||||||
beginRemoveRows(index(m_manualRoot), m_manualRoot->childNodes.indexOf(node), m_manualRoot->childNodes.indexOf(node));
|
beginRemoveRows(index(m_manualRoot), m_manualRoot->childNodes.indexOf(node), m_manualRoot->childNodes.indexOf(node));
|
||||||
m_manualRoot->childNodes.removeOne(node);
|
m_manualRoot->childNodes.removeOne(node);
|
||||||
node->parent = 0;
|
node->parent = 0;
|
||||||
if (m_toAddList.contains(node)) {
|
if (node->widget->configures(0))
|
||||||
delete node->kit;
|
|
||||||
node->kit = 0;
|
|
||||||
m_toAddList.removeOne(node);
|
|
||||||
delete node;
|
delete node;
|
||||||
} else {
|
else
|
||||||
m_toRemoveList.append(node);
|
m_toRemoveList.append(node);
|
||||||
}
|
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KitModel::markForAddition(Kit *k)
|
Kit *KitModel::markForAddition(Kit *baseKit)
|
||||||
{
|
{
|
||||||
int pos = m_manualRoot->childNodes.size();
|
int pos = m_manualRoot->childNodes.size();
|
||||||
beginInsertRows(index(m_manualRoot), pos, pos);
|
beginInsertRows(index(m_manualRoot), pos, pos);
|
||||||
|
|
||||||
KitNode *node = createNode(m_manualRoot, k, true);
|
KitNode *node = createNode(m_manualRoot, 0);
|
||||||
m_toAddList.append(node);
|
if (baseKit) {
|
||||||
|
Kit *k = node->widget->workingCopy();
|
||||||
|
k->copyFrom(baseKit);
|
||||||
|
k->setDisplayName(tr("Clone of %1").arg(k->displayName()));
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_defaultNode)
|
if (!m_defaultNode)
|
||||||
setDefaultNode(node);
|
setDefaultNode(node);
|
||||||
|
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
||||||
|
return node->widget->workingCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex KitModel::index(KitNode *node, int column) const
|
QModelIndex KitModel::index(KitNode *node, int column) const
|
||||||
@@ -382,56 +352,48 @@ QModelIndex KitModel::index(KitNode *node, int column) const
|
|||||||
return index(node->parent->childNodes.indexOf(node), column, index(node->parent));
|
return index(node->parent->childNodes.indexOf(node), column, index(node->parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
KitNode *KitModel::find(Kit *k) const
|
KitNode *KitModel::findWorkingCopy(Kit *k) const
|
||||||
{
|
{
|
||||||
foreach (KitNode *n, m_autoRoot->childNodes) {
|
foreach (KitNode *n, m_autoRoot->childNodes) {
|
||||||
if (n->kit == k)
|
if (n->widget->workingCopy() == k)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
foreach (KitNode *n, m_manualRoot->childNodes) {
|
foreach (KitNode *n, m_manualRoot->childNodes) {
|
||||||
if (n->kit == k)
|
if (n->widget->workingCopy() == k)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
KitNode *KitModel::createNode(KitNode *parent, Kit *k, bool changed)
|
KitNode *KitModel::createNode(KitNode *parent, Kit *k)
|
||||||
{
|
{
|
||||||
KitNode *node = new KitNode(parent, k, changed);
|
KitNode *node = new KitNode(parent, k);
|
||||||
if (node->widget) {
|
|
||||||
node->widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
node->widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
m_parentLayout->addWidget(node->widget, 10);
|
m_parentLayout->addWidget(node->widget, 10);
|
||||||
connect(node->widget, SIGNAL(dirty()),
|
connect(node->widget, SIGNAL(dirty()), this, SLOT(setDirty()));
|
||||||
this, SLOT(setDirty()));
|
|
||||||
}
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KitModel::setDefaultNode(KitNode *node)
|
void KitModel::setDefaultNode(KitNode *node)
|
||||||
{
|
{
|
||||||
if (m_defaultNode) {
|
if (m_defaultNode) {
|
||||||
QModelIndex idx = index(m_defaultNode);
|
m_defaultNode->widget->setIsDefaultKit(false);
|
||||||
if (idx.isValid())
|
emit dataChanged(index(m_defaultNode), index(m_defaultNode));
|
||||||
emit dataChanged(idx, idx);
|
|
||||||
}
|
}
|
||||||
m_defaultNode = node;
|
m_defaultNode = node;
|
||||||
if (m_defaultNode) {
|
if (m_defaultNode) {
|
||||||
QModelIndex idx = index(m_defaultNode);
|
m_defaultNode->widget->setIsDefaultKit(true);
|
||||||
if (idx.isValid())
|
emit dataChanged(index(m_defaultNode), index(m_defaultNode));
|
||||||
emit dataChanged(idx, idx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KitModel::addKit(Kit *k)
|
void KitModel::addKit(Kit *k)
|
||||||
{
|
{
|
||||||
QList<KitNode *> nodes = m_toAddList;
|
foreach (KitNode *n, m_manualRoot->childNodes) {
|
||||||
foreach (KitNode *n, nodes) {
|
// Was added by us
|
||||||
if (n->kit == k) {
|
if (n->widget->configures(k))
|
||||||
m_toAddList.removeOne(n);
|
|
||||||
// do not delete n: Still used elsewhere!
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
KitNode *parent = m_manualRoot;
|
KitNode *parent = m_manualRoot;
|
||||||
if (k->isAutoDetected())
|
if (k->isAutoDetected())
|
||||||
@@ -439,7 +401,7 @@ void KitModel::addKit(Kit *k)
|
|||||||
int row = parent->childNodes.count();
|
int row = parent->childNodes.count();
|
||||||
|
|
||||||
beginInsertRows(index(parent), row, row);
|
beginInsertRows(index(parent), row, row);
|
||||||
createNode(parent, k, false);
|
createNode(parent, k);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
||||||
emit kitStateChanged();
|
emit kitStateChanged();
|
||||||
@@ -449,8 +411,10 @@ void KitModel::removeKit(Kit *k)
|
|||||||
{
|
{
|
||||||
QList<KitNode *> nodes = m_toRemoveList;
|
QList<KitNode *> nodes = m_toRemoveList;
|
||||||
foreach (KitNode *n, nodes) {
|
foreach (KitNode *n, nodes) {
|
||||||
if (n->kit == k) {
|
if (n->widget->configures(k)) {
|
||||||
m_toRemoveList.removeOne(n);
|
m_toRemoveList.removeOne(n);
|
||||||
|
if (m_defaultNode == n)
|
||||||
|
m_defaultNode = 0;
|
||||||
delete n;
|
delete n;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -462,7 +426,7 @@ void KitModel::removeKit(Kit *k)
|
|||||||
int row = 0;
|
int row = 0;
|
||||||
KitNode *node = 0;
|
KitNode *node = 0;
|
||||||
foreach (KitNode *current, parent->childNodes) {
|
foreach (KitNode *current, parent->childNodes) {
|
||||||
if (current->kit == k) {
|
if (current->widget->configures(k)) {
|
||||||
node = current;
|
node = current;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -471,27 +435,25 @@ void KitModel::removeKit(Kit *k)
|
|||||||
|
|
||||||
beginRemoveRows(index(parent), row, row);
|
beginRemoveRows(index(parent), row, row);
|
||||||
parent->childNodes.removeAt(row);
|
parent->childNodes.removeAt(row);
|
||||||
delete node;
|
if (m_defaultNode == node)
|
||||||
|
m_defaultNode = 0;
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
delete node;
|
||||||
|
|
||||||
emit kitStateChanged();
|
emit kitStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KitModel::updateKit(Kit *k)
|
|
||||||
{
|
|
||||||
KitNode *n = find(k);
|
|
||||||
// This can happen if Qt Versions and kits are removed simultaneously.
|
|
||||||
if (!n)
|
|
||||||
return;
|
|
||||||
if (n->widget)
|
|
||||||
n->widget->discard();
|
|
||||||
QModelIndex idx = index(n);
|
|
||||||
emit dataChanged(idx, idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
void KitModel::changeDefaultKit()
|
void KitModel::changeDefaultKit()
|
||||||
{
|
{
|
||||||
setDefaultNode(find(KitManager::instance()->defaultKit()));
|
Kit *defaultKit = KitManager::instance()->defaultKit();
|
||||||
|
QList<KitNode *> nodes = m_autoRoot->childNodes;
|
||||||
|
nodes << m_manualRoot->childNodes;
|
||||||
|
foreach (KitNode *n, nodes) {
|
||||||
|
if (n->widget->configures(defaultKit)) {
|
||||||
|
setDefaultNode(n);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ QT_END_NAMESPACE
|
|||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
class Kit;
|
class Kit;
|
||||||
class KitConfigWidget;
|
|
||||||
class KitFactory;
|
class KitFactory;
|
||||||
class KitManager;
|
class KitManager;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
class KitManagerConfigWidget;
|
||||||
|
|
||||||
class KitNode;
|
class KitNode;
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ public:
|
|||||||
void setDefaultKit(const QModelIndex &index);
|
void setDefaultKit(const QModelIndex &index);
|
||||||
bool isDefaultKit(const QModelIndex &index);
|
bool isDefaultKit(const QModelIndex &index);
|
||||||
|
|
||||||
KitConfigWidget *widget(const QModelIndex &);
|
ProjectExplorer::Internal::KitManagerConfigWidget *widget(const QModelIndex &);
|
||||||
|
|
||||||
bool isDirty() const;
|
bool isDirty() const;
|
||||||
bool isDirty(Kit *k) const;
|
bool isDirty(Kit *k) const;
|
||||||
@@ -85,7 +85,7 @@ public:
|
|||||||
void apply();
|
void apply();
|
||||||
|
|
||||||
void markForRemoval(Kit *k);
|
void markForRemoval(Kit *k);
|
||||||
void markForAddition(Kit *k);
|
Kit *markForAddition(Kit *baseKit);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void kitStateChanged();
|
void kitStateChanged();
|
||||||
@@ -93,21 +93,19 @@ signals:
|
|||||||
private slots:
|
private slots:
|
||||||
void addKit(ProjectExplorer::Kit *k);
|
void addKit(ProjectExplorer::Kit *k);
|
||||||
void removeKit(ProjectExplorer::Kit *k);
|
void removeKit(ProjectExplorer::Kit *k);
|
||||||
void updateKit(ProjectExplorer::Kit *k);
|
|
||||||
void changeDefaultKit();
|
void changeDefaultKit();
|
||||||
void setDirty();
|
void setDirty();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QModelIndex index(KitNode *, int column = 0) const;
|
QModelIndex index(KitNode *, int column = 0) const;
|
||||||
KitNode *find(Kit *k) const;
|
KitNode *findWorkingCopy(Kit *k) const;
|
||||||
KitNode *createNode(KitNode *parent, Kit *k, bool changed);
|
KitNode *createNode(KitNode *parent, Kit *k);
|
||||||
void setDefaultNode(KitNode *node);
|
void setDefaultNode(KitNode *node);
|
||||||
|
|
||||||
KitNode *m_root;
|
KitNode *m_root;
|
||||||
KitNode *m_autoRoot;
|
KitNode *m_autoRoot;
|
||||||
KitNode *m_manualRoot;
|
KitNode *m_manualRoot;
|
||||||
|
|
||||||
QList<KitNode *> m_toAddList;
|
|
||||||
QList<KitNode *> m_toRemoveList;
|
QList<KitNode *> m_toRemoveList;
|
||||||
|
|
||||||
QBoxLayout *m_parentLayout;
|
QBoxLayout *m_parentLayout;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
#include "kitmodel.h"
|
#include "kitmodel.h"
|
||||||
#include "kit.h"
|
#include "kit.h"
|
||||||
#include "projectexplorerconstants.h"
|
#include "projectexplorerconstants.h"
|
||||||
#include "kitconfigwidget.h"
|
#include "kitmanagerconfigwidget.h"
|
||||||
#include "kitmanager.h"
|
#include "kitmanager.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -173,18 +173,18 @@ void KitOptionsPage::kitSelectionChanged()
|
|||||||
QModelIndex current = currentIndex();
|
QModelIndex current = currentIndex();
|
||||||
m_currentWidget = current.isValid() ? m_model->widget(current) : 0;
|
m_currentWidget = current.isValid() ? m_model->widget(current) : 0;
|
||||||
|
|
||||||
if (m_currentWidget)
|
if (m_currentWidget) {
|
||||||
m_currentWidget->setVisible(true);
|
m_currentWidget->setVisible(true);
|
||||||
|
m_kitsView->scrollTo(current);
|
||||||
|
}
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KitOptionsPage::addNewKit()
|
void KitOptionsPage::addNewKit()
|
||||||
{
|
{
|
||||||
Kit *k = new Kit;
|
Kit *k = m_model->markForAddition(0);
|
||||||
m_model->markForAddition(k);
|
|
||||||
|
|
||||||
QModelIndex newIdx = m_model->indexOf(k);
|
QModelIndex newIdx = m_model->indexOf(k);
|
||||||
m_kitsView->scrollTo(newIdx);
|
|
||||||
m_selectionModel->select(newIdx,
|
m_selectionModel->select(newIdx,
|
||||||
QItemSelectionModel::Clear
|
QItemSelectionModel::Clear
|
||||||
| QItemSelectionModel::SelectCurrent
|
| QItemSelectionModel::SelectCurrent
|
||||||
@@ -197,10 +197,7 @@ void KitOptionsPage::cloneKit()
|
|||||||
if (!current)
|
if (!current)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Kit *k = current->clone();
|
Kit *k = m_model->markForAddition(current);
|
||||||
|
|
||||||
m_model->markForAddition(k);
|
|
||||||
|
|
||||||
QModelIndex newIdx = m_model->indexOf(k);
|
QModelIndex newIdx = m_model->indexOf(k);
|
||||||
m_kitsView->scrollTo(newIdx);
|
m_kitsView->scrollTo(newIdx);
|
||||||
m_selectionModel->select(newIdx,
|
m_selectionModel->select(newIdx,
|
||||||
@@ -234,7 +231,7 @@ void KitOptionsPage::updateState()
|
|||||||
QModelIndex index = currentIndex();
|
QModelIndex index = currentIndex();
|
||||||
Kit *k = m_model->kit(index);
|
Kit *k = m_model->kit(index);
|
||||||
if (k) {
|
if (k) {
|
||||||
canCopy = k->isValid();
|
canCopy = true;
|
||||||
canDelete = !k->isAutoDetected();
|
canDelete = !k->isAutoDetected();
|
||||||
canMakeDefault = !m_model->isDefaultKit(index);
|
canMakeDefault = !m_model->isDefaultKit(index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ QmakeKitConfigWidget::QmakeKitConfigWidget(ProjectExplorer::Kit *k, QWidget *par
|
|||||||
m_lineEdit->setContentsMargins(0, 0, 0, 0);
|
m_lineEdit->setContentsMargins(0, 0, 0, 0);
|
||||||
layout->addWidget(m_lineEdit);
|
layout->addWidget(m_lineEdit);
|
||||||
|
|
||||||
discard(); // set up everything according to kit
|
refresh(); // set up everything according to kit
|
||||||
connect(m_lineEdit, SIGNAL(textEdited(QString)), this, SIGNAL(dirty()));
|
connect(m_lineEdit, SIGNAL(textEdited(QString)), this, SLOT(mkspecWasChanged(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmakeKitConfigWidget::displayName() const
|
QString QmakeKitConfigWidget::displayName() const
|
||||||
@@ -68,19 +68,14 @@ void QmakeKitConfigWidget::makeReadOnly()
|
|||||||
m_lineEdit->setEnabled(false);
|
m_lineEdit->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeKitConfigWidget::apply()
|
void QmakeKitConfigWidget::refresh()
|
||||||
{
|
|
||||||
QmakeKitInformation::setMkspec(m_kit, Utils::FileName::fromString(m_lineEdit->text()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmakeKitConfigWidget::discard()
|
|
||||||
{
|
{
|
||||||
m_lineEdit->setText(QmakeKitInformation::mkspec(m_kit).toString());
|
m_lineEdit->setText(QmakeKitInformation::mkspec(m_kit).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmakeKitConfigWidget::isDirty() const
|
void QmakeKitConfigWidget::mkspecWasChanged(const QString &text)
|
||||||
{
|
{
|
||||||
return m_lineEdit->text() != QmakeKitInformation::mkspec(m_kit).toString();
|
QmakeKitInformation::setMkspec(m_kit, Utils::FileName::fromString(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -52,9 +52,10 @@ public:
|
|||||||
|
|
||||||
void makeReadOnly();
|
void makeReadOnly();
|
||||||
|
|
||||||
void apply();
|
void refresh();
|
||||||
void discard();
|
|
||||||
bool isDirty() const;
|
private slots:
|
||||||
|
void mkspecWasChanged(const QString &text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int findQtVersion(const int id) const;
|
int findQtVersion(const int id) const;
|
||||||
|
|||||||
@@ -73,13 +73,11 @@ QtKitConfigWidget::QtKitConfigWidget(ProjectExplorer::Kit *k, QWidget *parent) :
|
|||||||
versionIds.append(v->uniqueId());
|
versionIds.append(v->uniqueId());
|
||||||
versionsChanged(versionIds, QList<int>(), QList<int>());
|
versionsChanged(versionIds, QList<int>(), QList<int>());
|
||||||
|
|
||||||
discard();
|
refresh();
|
||||||
connect(m_combo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dirty()));
|
connect(m_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(currentWasChanged(int)));
|
||||||
|
|
||||||
connect(mgr, SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
|
connect(mgr, SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
|
||||||
this, SLOT(versionsChanged(QList<int>,QList<int>,QList<int>)));
|
this, SLOT(versionsChanged(QList<int>,QList<int>,QList<int>)));
|
||||||
connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
|
|
||||||
this, SLOT(kitUpdated(ProjectExplorer::Kit*)));
|
|
||||||
|
|
||||||
connect(m_manageButton, SIGNAL(clicked()), this, SLOT(manageQtVersions()));
|
connect(m_manageButton, SIGNAL(clicked()), this, SLOT(manageQtVersions()));
|
||||||
}
|
}
|
||||||
@@ -94,23 +92,11 @@ void QtKitConfigWidget::makeReadOnly()
|
|||||||
m_combo->setEnabled(false);
|
m_combo->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtKitConfigWidget::apply()
|
void QtKitConfigWidget::refresh()
|
||||||
{
|
|
||||||
int id = m_combo->itemData(m_combo->currentIndex()).toInt();
|
|
||||||
QtKitInformation::setQtVersionId(m_kit, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtKitConfigWidget::discard()
|
|
||||||
{
|
{
|
||||||
m_combo->setCurrentIndex(findQtVersion(QtKitInformation::qtVersionId(m_kit)));
|
m_combo->setCurrentIndex(findQtVersion(QtKitInformation::qtVersionId(m_kit)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtKitConfigWidget::isDirty() const
|
|
||||||
{
|
|
||||||
int id = m_combo->itemData(m_combo->currentIndex()).toInt();
|
|
||||||
return id != QtKitInformation::qtVersionId(m_kit);
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *QtKitConfigWidget::buttonWidget() const
|
QWidget *QtKitConfigWidget::buttonWidget() const
|
||||||
{
|
{
|
||||||
return m_manageButton;
|
return m_manageButton;
|
||||||
@@ -141,27 +127,17 @@ void QtKitConfigWidget::versionsChanged(const QList<int> &added, const QList<int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtKitConfigWidget::kitUpdated(ProjectExplorer::Kit *k)
|
|
||||||
{
|
|
||||||
if (k != m_kit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int id = QtKitInformation::qtVersionId(k);
|
|
||||||
|
|
||||||
for (int i = 0; i < m_combo->count(); ++i) {
|
|
||||||
if (m_combo->itemData(i).toInt() == id) {
|
|
||||||
m_combo->setCurrentIndex(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtKitConfigWidget::manageQtVersions()
|
void QtKitConfigWidget::manageQtVersions()
|
||||||
{
|
{
|
||||||
Core::ICore::showOptionsDialog(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY),
|
Core::ICore::showOptionsDialog(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY),
|
||||||
QLatin1String(QtSupport::Constants::QTVERSION_SETTINGS_PAGE_ID));
|
QLatin1String(QtSupport::Constants::QTVERSION_SETTINGS_PAGE_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtKitConfigWidget::currentWasChanged(int idx)
|
||||||
|
{
|
||||||
|
QtKitInformation::setQtVersionId(m_kit, m_combo->itemData(idx).toInt());
|
||||||
|
}
|
||||||
|
|
||||||
int QtKitConfigWidget::findQtVersion(const int id) const
|
int QtKitConfigWidget::findQtVersion(const int id) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_combo->count(); ++i) {
|
for (int i = 0; i < m_combo->count(); ++i) {
|
||||||
|
|||||||
@@ -53,15 +53,13 @@ public:
|
|||||||
|
|
||||||
void makeReadOnly();
|
void makeReadOnly();
|
||||||
|
|
||||||
void apply();
|
void refresh();
|
||||||
void discard();
|
|
||||||
bool isDirty() const;
|
|
||||||
QWidget *buttonWidget() const;
|
QWidget *buttonWidget() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void versionsChanged(const QList<int> &added, const QList<int> &removed, const QList<int> &changed);
|
void versionsChanged(const QList<int> &added, const QList<int> &removed, const QList<int> &changed);
|
||||||
void kitUpdated(ProjectExplorer::Kit *k);
|
|
||||||
void manageQtVersions();
|
void manageQtVersions();
|
||||||
|
void currentWasChanged(int idx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int findQtVersion(const int id) const;
|
int findQtVersion(const int id) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user