MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / onHeaderCustomContextMenu

Method onHeaderCustomContextMenu

src/downloadlistview.cpp:175–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175void DownloadListView::onHeaderCustomContextMenu(const QPoint& point)
176{
177 QMenu menu;
178
179 // display a list of all headers as checkboxes
180 QAbstractItemModel* model = header()->model();
181 for (int i = 1; i < model->columnCount(); ++i) {
182 QString columnName = model->headerData(i, Qt::Horizontal).toString();
183 QCheckBox* checkBox = new QCheckBox(&menu);
184 checkBox->setText(columnName);
185 checkBox->setChecked(!header()->isSectionHidden(i));
186 QWidgetAction* checkableAction = new QWidgetAction(&menu);
187 checkableAction->setDefaultWidget(checkBox);
188 menu.addAction(checkableAction);
189 }
190
191 menu.exec(header()->viewport()->mapToGlobal(point));
192
193 // view/hide columns depending on check-state
194 int i = 1;
195 for (const QAction* action : menu.actions()) {
196 const QWidgetAction* widgetAction = qobject_cast<const QWidgetAction*>(action);
197 if (widgetAction != nullptr) {
198 const QCheckBox* checkBox =
199 qobject_cast<const QCheckBox*>(widgetAction->defaultWidget());
200 if (checkBox != nullptr) {
201 header()->setSectionHidden(i, !checkBox->isChecked());
202 }
203 }
204 ++i;
205 }
206
207 qobject_cast<DownloadListHeader*>(header())->customResizeSections();
208}
209
210void DownloadListView::resizeEvent(QResizeEvent* event)
211{

Callers

nothing calls this directly

Calls 7

modelMethod · 0.80
customResizeSectionsMethod · 0.80
columnCountMethod · 0.45
toStringMethod · 0.45
headerDataMethod · 0.45
setTextMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected