summaryrefslogtreecommitdiff
path: root/src/plugins/debugger/moduleshandler.cpp
diff options
context:
space:
mode:
authorhjk <hjk@theqtcompany.com>2016-09-20 14:01:17 +0200
committerhjk <hjk@qt.io>2016-09-20 13:36:34 +0000
commit6d22c8dafb296fb697201f668fc4893273a9b047 (patch)
treed8e10c3a89e9523581d67d707dc3a9cea9d48ea1 /src/plugins/debugger/moduleshandler.cpp
parent8151a09fdc1c78dd56bd016489dabf3523e700e3 (diff)
downloadqt-creator-6d22c8dafb296fb697201f668fc4893273a9b047.tar.gz
Debugger: Re-enable Moduleshandler context menu also below entries
Change-Id: I2e8cb9289770b46145de0850d15b4124aa5a1536 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/debugger/moduleshandler.cpp')
-rw-r--r--src/plugins/debugger/moduleshandler.cpp89
1 files changed, 52 insertions, 37 deletions
diff --git a/src/plugins/debugger/moduleshandler.cpp b/src/plugins/debugger/moduleshandler.cpp
index 398152b9e4..1262a3a827 100644
--- a/src/plugins/debugger/moduleshandler.cpp
+++ b/src/plugins/debugger/moduleshandler.cpp
@@ -25,6 +25,7 @@
#include "moduleshandler.h"
+#include "debuggeractions.h"
#include "debuggerconstants.h"
#include "debuggercore.h"
#include "debuggerengine.h"
@@ -32,6 +33,7 @@
#include <utils/basetreeview.h>
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
+#include <utils/savedaction.h>
#include <utils/treemodel.h>
#include <QCoreApplication>
@@ -52,12 +54,8 @@ class ModuleItem : public TreeItem
public:
QVariant data(int column, int role) const override;
- bool setData(int column, const QVariant &data, int role) override;
-
- bool contextMenuEvent(const ItemViewEvent &event);
public:
- DebuggerEngine *engine;
Module module;
bool updated;
};
@@ -144,45 +142,61 @@ QVariant ModuleItem::data(int column, int role) const
return QVariant();
}
-bool ModuleItem::setData(int, const QVariant &data, int role)
+//////////////////////////////////////////////////////////////////
+//
+// ModulesModel
+//
+//////////////////////////////////////////////////////////////////
+
+class ModulesModel : public TreeModel<TypedTreeItem<ModuleItem>, ModuleItem>
{
- if (role == BaseTreeView::ItemActivatedRole) {
- engine->gotoLocation(module.modulePath);
- return true;
- }
+ Q_DECLARE_TR_FUNCTIONS(Debuggger::Internal::ModulesHandler)
+
+public:
+ bool setData(const QModelIndex &idx, const QVariant &data, int role) override
+ {
+ if (role == BaseTreeView::ItemViewEventRole) {
+ ItemViewEvent ev = data.value<ItemViewEvent>();
+ if (ev.type() == QEvent::ContextMenu)
+ return contextMenuEvent(ev);
+ }
- if (role == BaseTreeView::ItemViewEventRole) {
- ItemViewEvent ev = data.value<ItemViewEvent>();
- if (ev.type() == QEvent::ContextMenu)
- return contextMenuEvent(ev);
+ return TreeModel::setData(idx, data, role);
}
- return false;
-}
+ bool contextMenuEvent(const ItemViewEvent &ev);
+
+ DebuggerEngine *engine;
+};
-bool ModuleItem::contextMenuEvent(const ItemViewEvent &event)
+bool ModulesModel::contextMenuEvent(const ItemViewEvent &ev)
{
- auto menu = new QMenu;
+ ModuleItem *item = itemForIndexAtLevel<1>(ev.index());
const bool enabled = engine->debuggerActionsEnabled();
const bool canReload = engine->hasCapability(ReloadModuleCapability);
const bool canLoadSymbols = engine->hasCapability(ReloadModuleSymbolsCapability);
const bool canShowSymbols = engine->hasCapability(ShowModuleSymbolsCapability);
- const bool moduleNameValid = !module.moduleName.isEmpty();
+ const bool moduleNameValid = item && !item->module.moduleName.isEmpty();
+ const QString moduleName = item ? item->module.moduleName : QString();
+ const QString modulePath = item ? item->module.modulePath : QString();
+
+ auto menu = new QMenu;
addAction(menu, tr("Update Module List"),
enabled && canReload,
[this] { engine->reloadModules(); });
- addAction(menu, tr("Show Source Files for Module \"%1\"").arg(module.moduleName),
- enabled && canReload,
- [this] { engine->loadSymbols(module.modulePath); });
+ addAction(menu, tr("Show Source Files for Module \"%1\"").arg(moduleName),
+ tr("Show Source Files for Module"),
+ moduleNameValid && enabled && canReload,
+ [this, modulePath] { engine->loadSymbols(modulePath); });
// FIXME: Dependencies only available on Windows, when "depends" is installed.
- addAction(menu, tr("Show Dependencies of \"%1\"").arg(module.moduleName),
+ addAction(menu, tr("Show Dependencies of \"%1\"").arg(moduleName),
tr("Show Dependencies"),
- moduleNameValid && !module.modulePath.isEmpty() && HostOsInfo::isWindowsHost(),
- [this] { QProcess::startDetached("depends", QStringList(module.modulePath)); });
+ moduleNameValid && !moduleName.isEmpty() && HostOsInfo::isWindowsHost(),
+ [this, modulePath] { QProcess::startDetached("depends", { modulePath }); });
addAction(menu, tr("Load Symbols for All Modules"),
enabled && canLoadSymbols,
@@ -192,27 +206,30 @@ bool ModuleItem::contextMenuEvent(const ItemViewEvent &event)
enabled && canLoadSymbols,
[this] { engine->examineModules(); });
- addAction(menu, tr("Load Symbols for Module \"%1\"").arg(module.moduleName),
+ addAction(menu, tr("Load Symbols for Module \"%1\"").arg(moduleName),
tr("Load Symbols for Module"),
- canLoadSymbols,
- [this] { engine->loadSymbols(module.modulePath); });
+ moduleNameValid && canLoadSymbols,
+ [this, modulePath] { engine->loadSymbols(modulePath); });
- addAction(menu, tr("Edit File \"%1\"").arg(module.moduleName),
+ addAction(menu, tr("Edit File \"%1\"").arg(moduleName),
tr("Edit File"),
moduleNameValid,
- [this] { engine->gotoLocation(module.modulePath); });
+ [this, modulePath] { engine->gotoLocation(modulePath); });
- addAction(menu, tr("Show Symbols in File \"%1\"").arg(module.moduleName),
+ addAction(menu, tr("Show Symbols in File \"%1\"").arg(moduleName),
tr("Show Symbols"),
canShowSymbols && moduleNameValid,
- [this] { engine->requestModuleSymbols(module.modulePath); });
+ [this, modulePath] { engine->requestModuleSymbols(modulePath); });
- addAction(menu, tr("Show Sections in File \"%1\"").arg(module.moduleName),
+ addAction(menu, tr("Show Sections in File \"%1\"").arg(moduleName),
tr("Show Sections"),
canShowSymbols && moduleNameValid,
- [this] { engine->requestModuleSections(module.modulePath); });
+ [this, modulePath] { engine->requestModuleSections(modulePath); });
- menu->popup(event.globalPos());
+ menu->addSeparator();
+ menu->addAction(action(SettingsDialog));
+
+ menu->popup(ev.globalPos());
return true;
}
@@ -224,10 +241,9 @@ bool ModuleItem::contextMenuEvent(const ItemViewEvent &event)
ModulesHandler::ModulesHandler(DebuggerEngine *engine)
{
- m_engine = engine;
-
QString pad = " ";
m_model = new ModulesModel;
+ m_model->engine = engine;
m_model->setObjectName("ModulesModel");
m_model->setHeader(QStringList({
tr("Module Name") + pad,
@@ -285,7 +301,6 @@ void ModulesHandler::updateModule(const Module &module)
} else {
item = new ModuleItem;
item->module = module;
- item->engine = m_engine;
m_model->rootItem()->appendChild(item);
}