CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkCheckableHeaderView.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Library: CTK
4
5 Copyright (c) Kitware Inc.
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0.txt
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18
19=========================================================================*/
20/*=========================================================================
21
22 Program: ParaView
23 Module: pqCheckableHeaderView.h
24
25 Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
26 All rights reserved.
27
28 ParaView is a free software; you can redistribute it and/or modify it
29 under the terms of the ParaView license version 1.2.
30
31 See http://www.paraview.org/paraview/project/license.html for the full ParaView license.
32 A copy of this license can be obtained by contacting
33 Kitware Inc.
34 28 Corporate Drive
35 Clifton Park, NY 12065
36 USA
37
38THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
41A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
42CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
43EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
44PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
45PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
46LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
47NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
48SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49
50=========================================================================*/
51
52#ifndef _ctkCheckableHeaderView_h
53#define _ctkCheckableHeaderView_h
54
55// Qt includes
56#include <QHeaderView>
57
58// CTK includes
59#include "ctkWidgetsExport.h"
60
61class ctkCheckableHeaderViewPrivate;
63
74class CTK_WIDGETS_EXPORT ctkCheckableHeaderView : public QHeaderView
75{
76 Q_OBJECT;
77public:
78 ctkCheckableHeaderView(Qt::Orientation orient, QWidget *parent=0);
80
88 virtual void setModel(QAbstractItemModel *model);
89
91 virtual void setRootIndex(const QModelIndex &index);
92
99 virtual bool eventFilter(QObject *object, QEvent *e);
100
101
106 Qt::CheckState checkState(int section)const;
107
112 bool checkState(int section,Qt::CheckState& checkState )const;
113
115
116public Q_SLOTS:
120 void setCheckState(int section, Qt::CheckState checkState);
121
122private Q_SLOTS:
123 void onHeaderDataChanged(Qt::Orientation orient, int first, int last);
124 void onHeaderSectionInserted();
125 inline void updateHeaderPixmaps();
126
127protected:
128 virtual void updateHeaderPixmaps(int first, int last);
129 virtual void initStyleSectionOption(QStyleOptionHeader *option, int section, QRect rect)const;
130 virtual void mousePressEvent(QMouseEvent *e);
131 virtual void mouseReleaseEvent(QMouseEvent *e);
132 bool isPointInCheckBox(int section, QPoint pos)const;
133
134protected:
135 QScopedPointer<ctkCheckableHeaderViewPrivate> d_ptr;
136
137private:
138 Q_DECLARE_PRIVATE(ctkCheckableHeaderView);
139 Q_DISABLE_COPY(ctkCheckableHeaderView);
140};
141
142//-----------------------------------------------------------------------------
143void ctkCheckableHeaderView::updateHeaderPixmaps()
144{
145 this->updateHeaderPixmaps(0, this->count()-1);
146}
147
148#endif
ctkCheckableModelHelper * checkableModelHelper() const
bool isPointInCheckBox(int section, QPoint pos) const
virtual void setModel(QAbstractItemModel *model)
virtual void updateHeaderPixmaps(int first, int last)
virtual void initStyleSectionOption(QStyleOptionHeader *option, int section, QRect rect) const
QScopedPointer< ctkCheckableHeaderViewPrivate > d_ptr
virtual void setRootIndex(const QModelIndex &index)
Reimplemented for internal reasons.
virtual bool eventFilter(QObject *object, QEvent *e)
virtual ~ctkCheckableHeaderView()
void setCheckState(int section, Qt::CheckState checkState)
Qt::CheckState checkState(int section) const
bool checkState(int section, Qt::CheckState &checkState) const
virtual void mousePressEvent(QMouseEvent *e)
virtual void mouseReleaseEvent(QMouseEvent *e)
ctkCheckableHeaderView(Qt::Orientation orient, QWidget *parent=0)