forked from qt-creator/qt-creator
Debugger: Add ability to hide view columns
Not perfect, e.g. one would probably expect the items to appear in the context menu of the header views, too, not just on the main background of the view, but better than nothing. Task-number: QTCREATORBUG-23342 Change-Id: Ifdc44dcfd390112faa7b15bb8a51d809e42d7b29 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -1680,8 +1680,7 @@ bool BreakHandler::contextMenuEvent(const ItemViewEvent &ev)
|
||||
menu->addSeparator();
|
||||
|
||||
menu->addAction(action(UseToolTipsInBreakpointsView));
|
||||
menu->addAction(action(UseAddressInBreakpointsView));
|
||||
menu->addSeparator();
|
||||
Internal::addHideColumnActions(menu, ev.view());
|
||||
menu->addAction(action(SettingsDialog));
|
||||
|
||||
menu->popup(ev.globalPos());
|
||||
@@ -2669,8 +2668,7 @@ bool BreakpointManager::contextMenuEvent(const ItemViewEvent &ev)
|
||||
menu->addSeparator();
|
||||
|
||||
menu->addAction(action(UseToolTipsInBreakpointsView));
|
||||
menu->addAction(action(UseAddressInBreakpointsView));
|
||||
menu->addSeparator();
|
||||
Internal::addHideColumnActions(menu, ev.view());
|
||||
menu->addAction(action(SettingsDialog));
|
||||
|
||||
menu->popup(ev.globalPos());
|
||||
|
@@ -228,8 +228,6 @@ QWidget *CommonOptionsPage::widget()
|
||||
m_group.insert(action(AlwaysAdjustColumnWidths), nullptr);
|
||||
m_group.insert(action(UseToolTipsInBreakpointsView), nullptr);
|
||||
m_group.insert(action(UseToolTipsInStackView), nullptr);
|
||||
m_group.insert(action(UseAddressInBreakpointsView), nullptr);
|
||||
m_group.insert(action(UseAddressInStackView), nullptr);
|
||||
m_group.insert(action(MaximalStackDepth), spinBoxMaximalStackDepth);
|
||||
m_group.insert(action(ShowStdNamespace), nullptr);
|
||||
m_group.insert(action(ShowQtNamespace), nullptr);
|
||||
|
@@ -541,24 +541,6 @@ DebuggerSettings::DebuggerSettings()
|
||||
item->setDefaultValue(true);
|
||||
insertItem(UseToolTipsInStackView, item);
|
||||
|
||||
item = new SavedAction;
|
||||
item->setSettingsKey(debugModeGroup, "UseAddressInBreakpointsView");
|
||||
item->setText(tr("Show Address Data in Breakpoints View when Debugging"));
|
||||
item->setToolTip(tr("<p>Checking this will show a column with address "
|
||||
"information in the breakpoint view during debugging."));
|
||||
item->setCheckable(true);
|
||||
item->setDefaultValue(false);
|
||||
insertItem(UseAddressInBreakpointsView, item);
|
||||
|
||||
item = new SavedAction;
|
||||
item->setSettingsKey(debugModeGroup, "UseAddressInStackView");
|
||||
item->setText(tr("Show Address Data in Stack View when Debugging"));
|
||||
item->setToolTip(tr("<p>Checking this will show a column with address "
|
||||
"information in the stack view during debugging."));
|
||||
item->setCheckable(true);
|
||||
item->setDefaultValue(false);
|
||||
insertItem(UseAddressInStackView, item);
|
||||
|
||||
item = new SavedAction;
|
||||
item->setSettingsKey(debugModeGroup, "SkipKnownFrames");
|
||||
item->setText(tr("Skip Known Frames"));
|
||||
|
@@ -101,8 +101,6 @@ enum DebuggerActionCode
|
||||
UseToolTipsInLocalsView,
|
||||
UseToolTipsInBreakpointsView,
|
||||
UseToolTipsInStackView,
|
||||
UseAddressInBreakpointsView,
|
||||
UseAddressInStackView,
|
||||
|
||||
RegisterForPostMortem,
|
||||
AlwaysAdjustColumnWidths,
|
||||
|
@@ -77,6 +77,9 @@ QAction *addAction(QMenu *menu, const QString &d1, const QString &d2, bool on,
|
||||
QAction *addCheckableAction(QMenu *menu, const QString &display, bool on, bool checked,
|
||||
const std::function<void()> &onTriggered);
|
||||
|
||||
void addHideColumnActions(QMenu *menu, QWidget *widget);
|
||||
|
||||
|
||||
// Qt's various build paths for unpatched versions
|
||||
QStringList qtBuildPaths();
|
||||
|
||||
|
@@ -731,8 +731,6 @@ void DebuggerEnginePrivate::setupViews()
|
||||
m_breakView->setWindowIcon(Icons::BREAKPOINTS.icon());
|
||||
m_breakView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_breakView->setSpanColumn(BreakpointFunctionColumn);
|
||||
connect(action(UseAddressInBreakpointsView), &QAction::toggled,
|
||||
this, [this](bool on) { m_breakView->setColumnHidden(BreakpointAddressColumn, !on); });
|
||||
m_breakView->setSettings(settings, "Debugger.BreakWindow");
|
||||
m_breakView->setModel(m_breakHandler.model());
|
||||
m_breakView->setRootIsDecorated(true);
|
||||
|
@@ -460,6 +460,26 @@ QAction *addCheckableAction(QMenu *menu, const QString &display, bool on, bool c
|
||||
return act;
|
||||
}
|
||||
|
||||
void addHideColumnActions(QMenu *menu, QWidget *widget)
|
||||
{
|
||||
QTreeView *view = qobject_cast<QTreeView *>(widget);
|
||||
QTC_ASSERT(view, return);
|
||||
QAbstractItemModel *model = view->model();
|
||||
QTC_ASSERT(model, return);
|
||||
const int columns = model->columnCount();
|
||||
menu->addSeparator();
|
||||
for (int i = 0; i < columns; ++i) {
|
||||
QString columnName = model->headerData(i, Qt::Horizontal).toString();
|
||||
QAction *act = menu->addAction(DebuggerPlugin::tr("Show %1 Column").arg(columnName));
|
||||
act->setCheckable(true);
|
||||
act->setChecked(!view->isColumnHidden(i));
|
||||
QObject::connect(act, &QAction::toggled, menu, [view, i](bool on) {
|
||||
view->setColumnHidden(i, !on);
|
||||
});
|
||||
}
|
||||
menu->addSeparator();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DebugMode
|
||||
|
@@ -223,7 +223,7 @@ bool ModulesModel::contextMenuEvent(const ItemViewEvent &ev)
|
||||
canShowSymbols && moduleNameValid,
|
||||
[this, modulePath] { engine->requestModuleSections(modulePath); });
|
||||
|
||||
menu->addSeparator();
|
||||
Internal::addHideColumnActions(menu, ev.view());
|
||||
menu->addAction(action(SettingsDialog));
|
||||
|
||||
menu->popup(ev.globalPos());
|
||||
|
@@ -772,7 +772,7 @@ bool PeripheralRegisterHandler::contextMenuEvent(const ItemViewEvent &ev)
|
||||
menu->addMenu(fmtMenu);
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
Internal::addHideColumnActions(menu, ev.view());
|
||||
menu->addAction(action(SettingsDialog));
|
||||
menu->popup(ev.globalPos());
|
||||
return true;
|
||||
|
@@ -756,7 +756,7 @@ bool RegisterHandler::contextMenuEvent(const ItemViewEvent &ev)
|
||||
addFormatAction(tr("Octal"), OctalFormat);
|
||||
addFormatAction(tr("Binary"), BinaryFormat);
|
||||
|
||||
menu->addSeparator();
|
||||
Internal::addHideColumnActions(menu, ev.view());
|
||||
menu->addAction(action(SettingsDialog));
|
||||
menu->popup(ev.globalPos());
|
||||
return true;
|
||||
|
@@ -137,7 +137,7 @@ bool SourceFilesHandler::setData(const QModelIndex &idx, const QVariant &data, i
|
||||
addAction(tr("Open File \"%1\"").arg(name), true,
|
||||
[this, name] { m_engine->gotoLocation(name); });
|
||||
|
||||
menu->addSeparator();
|
||||
Internal::addHideColumnActions(menu, ev.view());
|
||||
menu->addAction(action(SettingsDialog));
|
||||
menu->popup(ev.globalPos());
|
||||
return true;
|
||||
|
@@ -444,12 +444,9 @@ bool StackHandler::contextMenuEvent(const ItemViewEvent &ev)
|
||||
[this] { m_engine->loadSymbolsForStack(); });
|
||||
}
|
||||
|
||||
if (m_engine->hasCapability(MemoryAddressCapability))
|
||||
menu->addAction(action(UseAddressInStackView));
|
||||
|
||||
menu->addSeparator();
|
||||
menu->addAction(action(UseToolTipsInStackView));
|
||||
menu->addSeparator();
|
||||
Internal::addHideColumnActions(menu, ev.view());
|
||||
menu->addAction(action(SettingsDialog));
|
||||
menu->popup(ev.globalPos());
|
||||
return true;
|
||||
|
@@ -40,10 +40,7 @@ namespace Internal {
|
||||
StackTreeView::StackTreeView(QWidget *parent)
|
||||
: BaseTreeView(parent)
|
||||
{
|
||||
connect(action(UseAddressInStackView), &QAction::toggled,
|
||||
this, &StackTreeView::showAddressColumn);
|
||||
setSpanColumn(StackFunctionNameColumn);
|
||||
showAddressColumn(false);
|
||||
}
|
||||
|
||||
void StackTreeView::setModel(QAbstractItemModel *model)
|
||||
@@ -58,9 +55,6 @@ void StackTreeView::setModel(QAbstractItemModel *model)
|
||||
if (!m_contentsAdjusted)
|
||||
adjustForContents();
|
||||
});
|
||||
|
||||
// Resize for the current contents if any are available.
|
||||
showAddressColumn(action(UseAddressInStackView)->isChecked());
|
||||
}
|
||||
|
||||
void StackTreeView::showAddressColumn(bool on)
|
||||
|
@@ -258,6 +258,7 @@ bool ThreadsHandler::setData(const QModelIndex &idx, const QVariant &data, int r
|
||||
|
||||
if (ev.as<QContextMenuEvent>()) {
|
||||
auto menu = new QMenu;
|
||||
Internal::addHideColumnActions(menu, ev.view());
|
||||
menu->addAction(action(SettingsDialog));
|
||||
menu->popup(ev.globalPos());
|
||||
return true;
|
||||
|
@@ -1741,7 +1741,7 @@ bool WatchModel::contextMenuEvent(const ItemViewEvent &ev)
|
||||
menu->addAction(action(UseDynamicType));
|
||||
menu->addAction(action(SettingsDialog));
|
||||
|
||||
menu->addSeparator();
|
||||
Internal::addHideColumnActions(menu, ev.view());
|
||||
menu->addAction(action(SettingsDialog));
|
||||
connect(menu, &QMenu::aboutToHide, menu, &QObject::deleteLater);
|
||||
menu->popup(ev.globalPos());
|
||||
|
Reference in New Issue
Block a user