Utils: Allow BaseTreeView users to hide columns manually

... using a context menu on the header views.

Use the feature in the debugger views where it was previously
un-intuitively available as part of the main context menu of
the view, but not in the header.

Task-number: QTCREATORBUG-24384
Change-Id: I3f030c3dd8ce35dc91bad921e37d2273bfe548b5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2020-11-09 11:08:45 +01:00
parent 1d2b5db02f
commit 2bfd515b03
13 changed files with 38 additions and 33 deletions

View File

@@ -459,26 +459,6 @@ 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
@@ -840,6 +820,7 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(const QStringList &arguments)
breakpointManagerView->setRootIsDecorated(true);
breakpointManagerView->setModel(BreakpointManager::model());
breakpointManagerView->setSpanColumn(BreakpointFunctionColumn);
breakpointManagerView->enableColumnHiding();
auto breakpointManagerWindow = addSearch(breakpointManagerView);
breakpointManagerWindow->setWindowTitle(tr("Breakpoint Preset"));
@@ -854,6 +835,7 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(const QStringList &arguments)
engineManagerView->setIconSize(QSize(10, 10));
engineManagerView->setModel(m_engineManager.model());
engineManagerView->setSelectionMode(QAbstractItemView::SingleSelection);
engineManagerView->enableColumnHiding();
auto engineManagerWindow = addSearch(engineManagerView);
engineManagerWindow->setWindowTitle(tr("Debugger Perspectives"));