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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user