Commit a053724c authored by Tobias Hunger's avatar Tobias Hunger Committed by hjk

Debugger: Refresh list of debuggers in kits options page on changes

Task-number: QTCREATORBUG-13991
Change-Id: I06ff6daea88e14b4193e4f1a71d768b528d80bf9
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent 9c5a56a3
......@@ -69,14 +69,11 @@ namespace Internal {
// -----------------------------------------------------------------------
DebuggerKitConfigWidget::DebuggerKitConfigWidget(Kit *workingCopy, const KitInformation *ki)
: KitConfigWidget(workingCopy, ki)
: KitConfigWidget(workingCopy, ki),
m_ignoreChanges(false)
{
m_comboBox = new QComboBox;
m_comboBox->setEnabled(true);
m_comboBox->setToolTip(toolTip());
m_comboBox->addItem(tr("None"), QString());
foreach (const DebuggerItem &item, DebuggerItemManager::debuggers())
m_comboBox->addItem(item.displayName(), item.id());
refresh();
connect(m_comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
......@@ -112,8 +109,16 @@ void DebuggerKitConfigWidget::makeReadOnly()
void DebuggerKitConfigWidget::refresh()
{
m_ignoreChanges = true;
m_comboBox->clear();
m_comboBox->setToolTip(toolTip());
m_comboBox->addItem(tr("None"), QString());
foreach (const DebuggerItem &item, DebuggerItemManager::debuggers())
m_comboBox->addItem(item.displayName(), item.id());
const DebuggerItem *item = DebuggerKitInformation::debugger(m_kit);
updateComboBox(item ? item->id() : QVariant());
m_ignoreChanges = false;
}
QWidget *DebuggerKitConfigWidget::buttonWidget() const
......@@ -134,6 +139,9 @@ void DebuggerKitConfigWidget::manageDebuggers()
void DebuggerKitConfigWidget::currentDebuggerChanged(int)
{
if (m_ignoreChanges)
return;
int currentIndex = m_comboBox->currentIndex();
QVariant id = m_comboBox->itemData(currentIndex);
m_kit->setValue(DebuggerKitInformation::id(), id);
......
......@@ -79,6 +79,7 @@ private:
void updateComboBox(const QVariant &id);
bool m_isReadOnly;
bool m_ignoreChanges;
QComboBox *m_comboBox;
QPushButton *m_manageButton;
};
......
......@@ -126,31 +126,19 @@ void SysRootInformationConfigWidget::pathWasChanged()
// --------------------------------------------------------------------------
ToolChainInformationConfigWidget::ToolChainInformationConfigWidget(Kit *k, const KitInformation *ki) :
KitConfigWidget(k, ki)
KitConfigWidget(k, ki),
m_ignoreChanges(false)
{
m_comboBox = new QComboBox;
m_comboBox->setEnabled(false);
m_comboBox->setToolTip(toolTip());
foreach (ToolChain *tc, ToolChainManager::toolChains())
toolChainAdded(tc);
updateComboBox();
refresh();
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentToolChainChanged(int)));
m_manageButton = new QPushButton(KitConfigWidget::msgManage());
m_manageButton->setContentsMargins(0, 0, 0, 0);
connect(m_manageButton, SIGNAL(clicked()), this, SLOT(manageToolChains()));
QObject *tcm = ToolChainManager::instance();
connect(tcm, SIGNAL(toolChainAdded(ProjectExplorer::ToolChain*)),
this, SLOT(toolChainAdded(ProjectExplorer::ToolChain*)));
connect(tcm, SIGNAL(toolChainRemoved(ProjectExplorer::ToolChain*)),
this, SLOT(toolChainRemoved(ProjectExplorer::ToolChain*)));
connect(tcm, SIGNAL(toolChainUpdated(ProjectExplorer::ToolChain*)),
this, SLOT(toolChainUpdated(ProjectExplorer::ToolChain*)));
}
ToolChainInformationConfigWidget::~ToolChainInformationConfigWidget()
......@@ -173,7 +161,13 @@ QString ToolChainInformationConfigWidget::toolTip() const
void ToolChainInformationConfigWidget::refresh()
{
m_ignoreChanges = true;
m_comboBox->clear();
foreach (ToolChain *tc, ToolChainManager::toolChains())
m_comboBox->addItem(tc->displayName(), tc->id());
m_comboBox->setCurrentIndex(indexOf(ToolChainKitInformation::toolChain(m_kit)));
m_ignoreChanges = false;
}
void ToolChainInformationConfigWidget::makeReadOnly()
......@@ -191,28 +185,6 @@ QWidget *ToolChainInformationConfigWidget::buttonWidget() const
return m_manageButton;
}
void ToolChainInformationConfigWidget::toolChainAdded(ToolChain *tc)
{
m_comboBox->addItem(tc->displayName(), tc->id());
updateComboBox();
}
void ToolChainInformationConfigWidget::toolChainRemoved(ToolChain *tc)
{
const int pos = indexOf(tc);
if (pos < 0)
return;
m_comboBox->removeItem(pos);
updateComboBox();
}
void ToolChainInformationConfigWidget::toolChainUpdated(ToolChain *tc)
{
const int pos = indexOf(tc);
if (pos < 0)
return;
m_comboBox->setItemText(pos, tc->displayName());
}
void ToolChainInformationConfigWidget::manageToolChains()
{
ICore::showOptionsDialog(Constants::TOOLCHAIN_SETTINGS_PAGE_ID, buttonWidget());
......@@ -220,6 +192,9 @@ void ToolChainInformationConfigWidget::manageToolChains()
void ToolChainInformationConfigWidget::currentToolChainChanged(int idx)
{
if (m_ignoreChanges)
return;
const QString id = m_comboBox->itemData(idx).toString();
ToolChainKitInformation::setToolChain(m_kit, ToolChainManager::findToolChain(id));
}
......
......@@ -100,9 +100,6 @@ public:
QString toolTip() const;
private slots:
void toolChainAdded(ProjectExplorer::ToolChain *tc);
void toolChainRemoved(ProjectExplorer::ToolChain *tc);
void toolChainUpdated(ProjectExplorer::ToolChain *tc);
void manageToolChains();
void currentToolChainChanged(int idx);
......@@ -112,6 +109,7 @@ private:
QComboBox *m_comboBox;
QPushButton *m_manageButton;
bool m_ignoreChanges;
};
// --------------------------------------------------------------------------
......
......@@ -366,6 +366,13 @@ void KitManagerConfigWidget::kitWasUpdated(Kit *k)
updateVisibility();
}
void KitManagerConfigWidget::showEvent(QShowEvent *event)
{
Q_UNUSED(event);
foreach (KitConfigWidget *widget, m_widgets)
widget->refresh();
}
QLabel *KitManagerConfigWidget::createLabel(const QString &name, const QString &toolTip)
{
QLabel *label = new QLabel(name);
......
......@@ -93,6 +93,7 @@ private:
ButtonColumn
};
void showEvent(QShowEvent *event);
QLabel *createLabel(const QString &name, const QString &toolTip);
void paintEvent(QPaintEvent *ev);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment