ctkCheckableComboBox.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.commontk.org/LICENSE
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkCheckableComboBox_h
  15. #define __ctkCheckableComboBox_h
  16. // Qt includes
  17. #include <QComboBox>
  18. // CTK includes
  19. #include "ctkWidgetsExport.h"
  20. class ctkCheckableModelHelper;
  21. class ctkCheckableComboBoxPrivate;
  22. /// Description
  23. /// ctkCheckableComboBox is a QComboBox that allow its items to be checkable
  24. class CTK_WIDGETS_EXPORT ctkCheckableComboBox : public QComboBox
  25. {
  26. Q_OBJECT
  27. public:
  28. ctkCheckableComboBox(QWidget *parent = 0);
  29. virtual ~ctkCheckableComboBox();
  30. /// Use setCheckableModel instead of setModel()
  31. QAbstractItemModel* checkableModel()const;
  32. void setCheckableModel(QAbstractItemModel *model);
  33. ctkCheckableModelHelper* checkableModelHelper()const;
  34. QModelIndexList checkedIndexes()const;
  35. bool allChecked()const;
  36. bool noneChecked()const;
  37. bool eventFilter(QObject *o, QEvent *e);
  38. signals:
  39. void checkedIndexesChanged();
  40. protected slots:
  41. void onDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
  42. protected:
  43. /// Reimplemented for internal reasons
  44. virtual void paintEvent(QPaintEvent*);
  45. protected:
  46. QScopedPointer<ctkCheckableComboBoxPrivate> d_ptr;
  47. private:
  48. Q_DECLARE_PRIVATE(ctkCheckableComboBox);
  49. Q_DISABLE_COPY(ctkCheckableComboBox);
  50. };
  51. #endif