CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkCheckableComboBox.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 #ifndef __ctkCheckableComboBox_h
22 #define __ctkCheckableComboBox_h
23 
24 // Qt includes
25 #include <QComboBox>
26 
27 // CTK includes
28 #include "ctkWidgetsExport.h"
29 
31 class ctkCheckableComboBoxPrivate;
32 
36 class CTK_WIDGETS_EXPORT ctkCheckableComboBox : public QComboBox
37 {
38  Q_OBJECT
39 
40 public:
41  ctkCheckableComboBox(QWidget *parent = 0);
43 
45  Q_INVOKABLE QAbstractItemModel* checkableModel()const;
46  Q_INVOKABLE void setCheckableModel(QAbstractItemModel *model);
47 
49  Q_INVOKABLE QModelIndexList checkedIndexes()const;
51  Q_INVOKABLE bool allChecked()const;
53  Q_INVOKABLE bool noneChecked()const;
54 
56  Q_INVOKABLE void setCheckState(const QModelIndex& index, Qt::CheckState check);
58  Q_INVOKABLE Qt::CheckState checkState(const QModelIndex& index)const;
59 
63 
65  bool eventFilter(QObject *o, QEvent *e);
66 
67 Q_SIGNALS:
69 
70 protected Q_SLOTS:
71  void onDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
72 
73 protected:
75  virtual void paintEvent(QPaintEvent*);
76 
77 protected:
78  QScopedPointer<ctkCheckableComboBoxPrivate> d_ptr;
79 
80 private:
81  Q_DECLARE_PRIVATE(ctkCheckableComboBox);
82  Q_DISABLE_COPY(ctkCheckableComboBox);
83 };
84 
85 #endif
Q_INVOKABLE QModelIndexList checkedIndexes() const
Returns an up-to-date list of all the checked indexes.
Q_INVOKABLE void setCheckState(const QModelIndex &index, Qt::CheckState check)
Utility function to conveniently check the state of an index.
virtual ~ctkCheckableComboBox()
Q_INVOKABLE bool noneChecked() const
Returns true if none of the indexes is checked, false otherwise.
Q_INVOKABLE bool allChecked() const
Returns true if all the indexes are checked, false otherwise.
ctkCheckableComboBox(QWidget *parent=0)
Q_INVOKABLE QAbstractItemModel * checkableModel() const
Use setCheckableModel instead of setModel()
void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
QScopedPointer< ctkCheckableComboBoxPrivate > d_ptr
virtual void paintEvent(QPaintEvent *)
Reimplemented for internal reasons.
Q_INVOKABLE void setCheckableModel(QAbstractItemModel *model)
Q_INVOKABLE ctkCheckableModelHelper * checkableModelHelper() const
bool eventFilter(QObject *o, QEvent *e)
Reimplemented for internal reasons.
Q_INVOKABLE Qt::CheckState checkState(const QModelIndex &index) const
Utility function to return the check state of a model index.