pqHeaderView.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqHeaderView.h
5 
6  Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 ========================================================================*/
32 #ifndef pqHeaderView_h
33 #define pqHeaderView_h
34 
35 #include "pqWidgetsModule.h" // for exports
36 #include <QHeaderView>
37 #include <QPoint> // for QPoint
38 #include <QRect> // for QRect
39 
40 #include <utility> // for std::pair
41 #include <vector> // for std::vector
42 
61 class PQWIDGETS_EXPORT pqHeaderView : public QHeaderView
62 {
63  Q_OBJECT
64  typedef QHeaderView Superclass;
65  Q_PROPERTY(bool showCustomIndicator READ isCustomIndicatorShown WRITE setCustomIndicatorShown);
66 
67 public:
68  pqHeaderView(Qt::Orientation orientation, QWidget* parent = nullptr);
69  ~pqHeaderView() override;
70 
72 
79  void setToggleCheckStateOnSectionClick(bool val) { this->ToggleCheckStateOnSectionClick = val; }
80  bool toggleCheckStateOnSectionClick() const { return this->ToggleCheckStateOnSectionClick; }
82 
84 
92  bool isCustomIndicatorShown() const { return this->CustomIndicatorShown; }
93  void setCustomIndicatorShown(bool val);
95 
97 
104  void addCustomIndicatorIcon(const QIcon& icon, const QString& role);
105  void removeCustomIndicatorIcon(const QString& role);
106  QIcon customIndicatorIcon(const QString& role) const;
108 
115  QRect lastCheckRect() const { return this->CheckRect; }
116 
117 Q_SIGNALS:
118  void customIndicatorClicked(int section, const QPoint& pt, const QString& role);
119 
120 protected:
121  void paintSection(QPainter* painter, const QRect& rect, int logicalIndex) const override;
122  void mousePressEvent(QMouseEvent* event) override;
123  void mouseReleaseEvent(QMouseEvent* event) override;
124 
125 private:
126  Q_DISABLE_COPY(pqHeaderView);
127 
128  void mouseClickEvent(QMouseEvent* event);
129 
130  bool ToggleCheckStateOnSectionClick;
131  QPoint PressPosition;
132  mutable QRect CheckRect;
133 
134  bool CustomIndicatorShown;
135 
136  // we keep as a vector since order of addition of icons is important.
137  std::vector<std::pair<QIcon, QString>> CustomIndicatorIcons;
138  mutable std::vector<std::pair<QRect, QString>> CustomIndicatorRects;
139 };
140 
141 #endif
bool toggleCheckStateOnSectionClick() const
For checkable section, this property controls if clicks on the entire section should be treated as a ...
Definition: pqHeaderView.h:80
pqHeaderView extends QHeaderView to add support for Qt::CheckStateRole.
Definition: pqHeaderView.h:61
void setToggleCheckStateOnSectionClick(bool val)
For checkable section, this property controls if clicks on the entire section should be treated as a ...
Definition: pqHeaderView.h:79
QRect lastCheckRect() const
For testing purposes only.
Definition: pqHeaderView.h:115
#define PQWIDGETS_EXPORT
bool isCustomIndicatorShown() const
This property holds if a custom indicator is shown for sections.
Definition: pqHeaderView.h:92