Commit 93e5942d authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Debugger: GdbChooserWidget: Fix memory leak, add tooltip.

Add a tooltip for disabled toolchains in the selector dialog.
parent 4f235452
......@@ -48,7 +48,6 @@
#include <QtGui/QIcon>
#include <QtGui/QGroupBox>
#include <QtGui/QCheckBox>
#include <QtCore/QDebug>
#include <QtCore/QSet>
#include <QtCore/QDir>
......@@ -274,7 +273,7 @@ void GdbBinaryModel::append(const QString &binary, const QList<int> &toolChains)
GdbChooserWidget::GdbChooserWidget(QWidget *parent) :
QWidget(parent),
m_treeView(new QTreeView),
m_model(new GdbBinaryModel),
m_model(new GdbBinaryModel(m_treeView)),
m_addButton(new QToolButton),
m_deleteButton(new QToolButton),
m_dirty(false)
......@@ -373,7 +372,8 @@ void GdbChooserWidget::slotDoubleClicked(const QModelIndex &current)
BinaryToolChainDialog dialog(this);
dialog.setPath(oldBinary);
dialog.setToolChainChoices(toolChainChoices.toList());
const BinaryToolChainMap map = gdbBinaries();
dialog.setToolChainChoices(toolChainChoices.toList(), &map);
dialog.setToolChains(oldToolChains);
if (dialog.exec() != QDialog::Accepted)
return;
......@@ -477,11 +477,29 @@ QCheckBox *ToolChainSelectorWidget::createToolChainCheckBox(int tc)
return cb;
}
void ToolChainSelectorWidget::setEnabledToolChains(const QList<int> &enabled)
static inline QString msgDisabledToolChainToolTip(const QString &binary, int toolChain)
{
foreach(QCheckBox *cb, m_checkBoxes)
if (!enabled.contains(toolChainOfCheckBox(cb)))
return ToolChainSelectorWidget::tr(
"<html><head/><body><p>Another gdb binary (<i>%1</i>) is currently configured "
"to handle the toolchain <i>%2</i>.</p></body></html>").
arg(QFileInfo(binary).fileName(), toolChainName(toolChain));
}
void ToolChainSelectorWidget::setEnabledToolChains(const QList<int> &enabled,
const BinaryToolChainMap *binaryToolChainMap)
{
foreach(QCheckBox *cb, m_checkBoxes) {
const int toolChain = toolChainOfCheckBox(cb);
if (enabled.contains(toolChain)) {
cb->setToolTip(QString());
} else {
// Toolchain is handled by a different binary, hint to user.
cb->setEnabled(false);
const QString binary = binaryToolChainMap ? binaryToolChainMap->key(toolChain) : QString();
if (!binary.isEmpty())
cb->setToolTip(msgDisabledToolChainToolTip(binary, toolChain));
}
}
}
void ToolChainSelectorWidget::setCheckedToolChains(const QList<int> &checked)
......@@ -555,9 +573,10 @@ BinaryToolChainDialog::BinaryToolChainDialog(QWidget *parent) :
m_pathChooser->setFocus();
}
void BinaryToolChainDialog::setToolChainChoices(const QList<int> &tcs)
void BinaryToolChainDialog::setToolChainChoices(const QList<int> &tcs,
const BinaryToolChainMap *binaryToolChainMap)
{
m_toolChainSelector->setEnabledToolChains(tcs);
m_toolChainSelector->setEnabledToolChains(tcs, binaryToolChainMap);
}
void BinaryToolChainDialog::setToolChains(const QList<int> &tcs)
......
......@@ -97,9 +97,13 @@ private:
class ToolChainSelectorWidget : public QWidget {
Q_OBJECT
public:
typedef GdbChooserWidget::BinaryToolChainMap BinaryToolChainMap;
explicit ToolChainSelectorWidget(QWidget *parent = 0);
void setEnabledToolChains(const QList<int> &);
void setEnabledToolChains(const QList<int> &enabled,
// Optionally used for generating a tooltip for the disabled check boxes
const BinaryToolChainMap *binaryToolChainMap = 0);
void setCheckedToolChains(const QList<int> &);
QList<int> checkedToolChains() const;
......@@ -125,9 +129,13 @@ private:
class BinaryToolChainDialog : public QDialog {
Q_OBJECT
public:
typedef GdbChooserWidget::BinaryToolChainMap BinaryToolChainMap;
explicit BinaryToolChainDialog(QWidget *parent);
void setToolChainChoices(const QList<int> &);
void setToolChainChoices(const QList<int> &,
// Optionally used for generating a tooltip for the disabled check boxes
const BinaryToolChainMap *binaryToolChainMap = 0);
void setToolChains(const QList<int> &);
QList<int> toolChains() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment