pqSectionVisibilityContextMenu.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqSectionVisibilityContextMenu_h
5 #define pqSectionVisibilityContextMenu_h
6 
7 // In case of QTableView, or any other spreadsheet-like view, the user
8 // should be provided an option to toggle the visibility of
9 // columns/rows. pqSectionVisibilityContextMenu is a context menu
10 // that can be used for the same.
11 
12 #include "pqWidgetsModule.h"
13 #include <QHeaderView>
14 #include <QMenu>
15 #include <QPointer>
16 
18 {
19  Q_OBJECT
20 public:
21  pqSectionVisibilityContextMenu(QWidget* parent = nullptr);
23 
24  // Set the QHeaderView whose section visibility is affected by
25  // this menu. This leads to clearing of any actions
26  // already present in the menu and populating the menu
27  // with the section headings from the header.
28  // This must be set before calling exec().
29  void setHeaderView(QHeaderView* header);
30  QHeaderView* headerView() { return this->HeaderView; }
31 
32 protected Q_SLOTS:
33  void toggleSectionVisibility(QAction* action);
34 
35 protected: // NOLINT(readability-redundant-access-specifiers)
36  QPointer<QHeaderView> HeaderView;
37 };
38 
39 #endif
#define PQWIDGETS_EXPORT