Commit 36227d5c authored by hjk's avatar hjk

ProjectExplorer: Introduce per-kit debugger configuration page

Change-Id: I65c76f3ff43e1479075926c7e3fa460cca74d8fe
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent c90df2b3
......@@ -786,10 +786,8 @@ void AndroidConfigurations::updateAutomaticKitList()
ToolChainKitInformation::setToolChain(newKit, tc);
QtSupport::QtKitInformation::setQtVersion(newKit, qt);
DeviceKitInformation::setDevice(newKit, device);
Debugger::DebuggerKitInformation::DebuggerItem item;
item.engineType = Debugger::GdbEngineType;
item.binary = tc->suggestedDebugger();
Debugger::DebuggerKitInformation::setDebuggerItem(newKit, item);
Debugger::DebuggerKitInformation::setDebuggerItem(newKit,
Debugger::GdbEngineType, tc->suggestedDebugger());
AndroidGdbServerKitInformation::setGdbSever(newKit, tc->suggestedGdbServer());
newKit->makeSticky();
newKits << newKit;
......
......@@ -121,7 +121,7 @@ bool DebuggerKitChooser::kitMatches(const ProjectExplorer::Kit *k) const
QString DebuggerKitChooser::kitToolTip(Kit *k) const
{
return DebuggerKitInformation::userOutput(DebuggerKitInformation::debuggerItem(k));
return DebuggerKitInformation::debuggerItem(k).userOutput();
}
///////////////////////////////////////////////////////////////////////
......
......@@ -30,29 +30,91 @@
#ifndef DEBUGGER_DEBUGGERKITCONFIGWIDGET_H
#define DEBUGGER_DEBUGGERKITCONFIGWIDGET_H
#include <projectexplorer/kitconfigwidget.h>
#include "debuggerkitinformation.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <projectexplorer/kitconfigwidget.h>
#include <projectexplorer/abi.h>
#include <utils/detailswidget.h>
#include <utils/fileutils.h>
#include <utils/pathchooser.h>
#include <utils/persistentsettings.h>
#include <QDialog>
#include <QStandardItemModel>
#include <QTreeView>
QT_BEGIN_NAMESPACE
class QLabel;
class QComboBox;
class QLabel;
class QPushButton;
QT_END_NAMESPACE
namespace ProjectExplorer { class Kit; }
namespace Utils {
class PathChooser;
class FileName;
}
namespace Debugger {
namespace Internal {
class DebuggerItemConfigWidget;
// -----------------------------------------------------------------------
// DebuggerKitConfigWidget:
// DebuggerItemManager
// -----------------------------------------------------------------------
class DebuggerItemManager : public QStandardItemModel
{
Q_OBJECT
public:
DebuggerItemManager(QObject *parent);
~DebuggerItemManager();
QList<DebuggerItem *> debuggers() const { return m_debuggers; }
QList<DebuggerItem *> findDebuggers(const ProjectExplorer::Abi &abi) const;
DebuggerItem *currentDebugger() const { return m_currentDebugger; }
static DebuggerItem *debuggerFromId(const QVariant &id);
QModelIndex currentIndex() const;
void setCurrentIndex(const QModelIndex &index);
bool isLoaded() const;
void updateCurrentItem();
// Returns id.
QVariant defaultDebugger(ProjectExplorer::ToolChain *tc);
// Adds item unless present. Return id of a matching item.
QVariant maybeAddDebugger(const DebuggerItem &item, bool makeCurrent = true);
static void restoreDebuggers();
public slots:
void saveDebuggers();
void autoDetectDebuggers();
void addDebugger();
void cloneDebugger();
void removeDebugger();
signals:
void debuggerAdded(DebuggerItem *item);
void debuggerRemoved(DebuggerItem *item);
void debuggerUpdated(DebuggerItem *item);
private:
friend class DebuggerOptionsPage;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
void autoDetectCdbDebugger();
QMap<QString, Utils::FileName> m_abiToDebugger;
Utils::PersistentSettingsWriter *m_writer;
QList<DebuggerItem *> m_debuggers;
DebuggerItem *m_currentDebugger;
QStandardItem *m_autoRoot;
QStandardItem *m_manualRoot;
QStringList added;
QStringList removed;
QHash<DebuggerItem *, QStandardItem *> m_itemFromDebugger;
QHash<QStandardItem *, DebuggerItem *> m_debuggerFromItem;
};
// -----------------------------------------------------------------------
// DebuggerKitConfigWidget
// -----------------------------------------------------------------------
class DebuggerKitConfigWidget : public ProjectExplorer::KitConfigWidget
......@@ -64,48 +126,63 @@ public:
QString displayName() const;
QString toolTip() const;
void makeReadOnly();
void refresh();
QWidget *buttonWidget() const;
QWidget *mainWidget() const;
private slots:
void autoDetectDebugger();
void showDialog();
void manageDebuggers();
void currentDebuggerChanged(int idx);
void onDebuggerAdded(DebuggerItem *);
void onDebuggerUpdated(DebuggerItem *);
void onDebuggerRemoved(DebuggerItem *);
private:
QWidget *m_main;
QLabel *m_label;
QPushButton *m_autoDetectButton;
QPushButton *m_editButton;
int indexOf(const DebuggerItem *debugger);
QVariant currentId() const;
void updateComboBox(const QVariant &id);
bool m_isReadOnly;
QComboBox *m_comboBox;
QPushButton *m_manageButton;
};
class DebuggerKitConfigDialog : public QDialog
// --------------------------------------------------------------------------
// DebuggerOptionsPage
// --------------------------------------------------------------------------
class DebuggerOptionsPage : public Core::IOptionsPage
{
Q_OBJECT
public:
explicit DebuggerKitConfigDialog(QWidget *parent = 0);
DebuggerOptionsPage();
void setDebuggerItem(const DebuggerKitInformation::DebuggerItem &item);
DebuggerKitInformation::DebuggerItem item() const
{ return DebuggerKitInformation::DebuggerItem(engineType(), fileName()); }
QWidget *createPage(QWidget *parent);
void apply();
void finish();
bool matches(const QString &) const;
private slots:
void refreshLabel();
void debuggerSelectionChanged();
void debuggerModelChanged();
void updateState();
void cloneDebugger();
void addDebugger();
void removeDebugger();
private:
DebuggerEngineType engineType() const;
void setEngineType(DebuggerEngineType et);
Utils::FileName fileName() const;
void setFileName(const Utils::FileName &fn);
QComboBox *m_comboBox;
QLabel *m_label;
Utils::PathChooser *m_chooser;
QWidget *m_configWidget;
QString m_searchKeywords;
DebuggerItemManager *m_manager;
DebuggerItemConfigWidget *m_itemConfigWidget;
QTreeView *m_debuggerView;
Utils::DetailsWidget *m_container;
QPushButton *m_addButton;
QPushButton *m_cloneButton;
QPushButton *m_delButton;
};
} // namespace Internal
......
......@@ -33,34 +33,47 @@
#include "debugger_global.h"
#include "debuggerconstants.h"
#include <projectexplorer/abi.h>
#include <projectexplorer/kitinformation.h>
namespace Debugger {
class DEBUGGER_EXPORT DebuggerKitInformation : public ProjectExplorer::KitInformation
class DEBUGGER_EXPORT DebuggerItem
{
Q_OBJECT
public:
DebuggerItem();
bool looksLike(const DebuggerItem &rhs) const;
bool canClone() const { return true; }
bool isValid() const { return true; }
QString engineTypeName() const;
QString userOutput() const;
QVariantMap toMap() const;
void fromMap(const QVariantMap &data);
void reinitializeFromFile();
public:
class DEBUGGER_EXPORT DebuggerItem {
public:
DebuggerItem();
DebuggerItem(DebuggerEngineType engineType, const Utils::FileName &fn);
bool equals(const DebuggerItem &rhs) const { return engineType == rhs.engineType && binary == rhs.binary; }
QVariant id;
QString displayName;
DebuggerEngineType engineType;
Utils::FileName command;
bool isAutoDetected;
QList<ProjectExplorer::Abi> abis;
};
DebuggerEngineType engineType;
Utils::FileName binary;
};
class DEBUGGER_EXPORT DebuggerKitInformation : public ProjectExplorer::KitInformation
{
Q_OBJECT
public:
DebuggerKitInformation();
Core::Id dataId() const;
unsigned int priority() const; // the higher the closer to the top.
static DebuggerItem autoDetectItem(const ProjectExplorer::Kit *k);
QVariant defaultValue(ProjectExplorer::Kit *k) const
{ return DebuggerKitInformation::itemToVariant(DebuggerKitInformation::autoDetectItem(k)); }
QVariant defaultValue(ProjectExplorer::Kit *k) const;
QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const
{ return DebuggerKitInformation::validateDebugger(k); }
......@@ -73,34 +86,26 @@ public:
ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const;
ItemList toUserOutput(const ProjectExplorer::Kit *k) const;
static QString userOutput(const DebuggerItem &item);
static DebuggerItem debuggerItem(const ProjectExplorer::Kit *k);
static void setDebuggerItem(ProjectExplorer::Kit *k, const DebuggerItem &item);
static void setDebuggerItem(ProjectExplorer::Kit *k,
DebuggerEngineType type, const Utils::FileName &command);
static Utils::FileName debuggerCommand(const ProjectExplorer::Kit *k)
{ return debuggerItem(k).binary; }
{ return debuggerItem(k).command; }
static void setDebuggerCommand(ProjectExplorer::Kit *k, const Utils::FileName &command);
static DebuggerEngineType engineType(const ProjectExplorer::Kit *k)
{ return debuggerItem(k).engineType; }
static void setEngineType(ProjectExplorer::Kit *k, DebuggerEngineType type);
static QString debuggerEngineName(DebuggerEngineType t);
static void makeSticky(ProjectExplorer::Kit *k);
private:
static DebuggerItem variantToItem(const QVariant &v);
static QVariant itemToVariant(const DebuggerItem &i);
};
inline bool operator==(const DebuggerKitInformation::DebuggerItem &i1, const DebuggerKitInformation::DebuggerItem &i2)
{ return i1.equals(i2); }
inline bool operator!=(const DebuggerKitInformation::DebuggerItem &i1, const DebuggerKitInformation::DebuggerItem &i2)
{ return !i1.equals(i2); }
inline bool operator==(const DebuggerItem &i1, const DebuggerItem &i2)
{ return i1.looksLike(i2); }
inline bool operator!=(const DebuggerItem &i1, const DebuggerItem &i2)
{ return !i1.looksLike(i2); }
} // namespace Debugger
......
......@@ -33,6 +33,7 @@
#include "debuggeractions.h"
#include "debuggerinternalconstants.h"
#include "debuggercore.h"
#include "debuggerkitconfigwidget.h"
#include "debuggerdialogs.h"
#include "debuggerengine.h"
#include "debuggermainwindow.h"
......@@ -1626,7 +1627,7 @@ void DebuggerPluginPrivate::attachCore()
DebuggerStartParameters sp;
QString display = dlg.useLocalCoreFile() ? dlg.localCoreFile() : dlg.remoteCoreFile();
QTC_ASSERT(fillParameters(&sp, dlg.kit()), return);
DebuggerKitInformation::DebuggerItem info = DebuggerKitInformation::debuggerItem(dlg.kit());
DebuggerItem info = DebuggerKitInformation::debuggerItem(dlg.kit());
sp.masterEngineType = info.engineType;
sp.executable = dlg.localExecutableFile();
sp.coreFile = dlg.localCoreFile();
......@@ -3182,6 +3183,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
foreach (IOptionsPage *op, engineOptionPages)
m_plugin->addAutoReleasedObject(op);
m_plugin->addAutoReleasedObject(new LocalsAndExpressionsOptionsPage);
m_plugin->addAutoReleasedObject(new DebuggerOptionsPage);
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
SLOT(onModeChanged(Core::IMode*)));
......@@ -3436,6 +3438,8 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
mstart->addSeparator(globalcontext, Constants::G_GENERAL);
mstart->addSeparator(globalcontext, Constants::G_SPECIAL);
DebuggerItemManager::restoreDebuggers();
KitManager::registerKitInformation(new DebuggerKitInformation);
return theDebuggerCore->initialize(arguments, errorMessage);
......
......@@ -179,6 +179,7 @@ const char PROJECTEXPLORER_SETTINGS_TR_CATEGORY[] = QT_TRANSLATE_NOOP("ProjectEx
const char PROJECTEXPLORER_SETTINGS_CATEGORY_ICON[] = ":/core/images/category_buildrun.png";
const char PROJECTEXPLORER_SETTINGS_ID[] = "A.ProjectExplorer.ProjectExplorer";
const char TOOLCHAIN_SETTINGS_PAGE_ID[] = "M.ProjectExplorer.ToolChainOptions";
const char DEBUGGER_SETTINGS_PAGE_ID[] = "N.ProjectExplorer.DebuggerOptions";
const char KITS_SETTINGS_PAGE_ID[] = "D.ProjectExplorer.KitsOptions";
// Device settings page
......
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