Explorar o código

Add utility functions to ctkCheckableComboBox

Add ctkCheckableComboBox::checkState() and
ctkCheckableComboBox::setCheckState()
Julien Finet %!s(int64=14) %!d(string=hai) anos
pai
achega
4196f13b31
Modificáronse 2 ficheiros con 27 adicións e 2 borrados
  1. 14 0
      Libs/Widgets/ctkCheckableComboBox.cpp
  2. 13 2
      Libs/Widgets/ctkCheckableComboBox.h

+ 14 - 0
Libs/Widgets/ctkCheckableComboBox.cpp

@@ -185,6 +185,20 @@ bool ctkCheckableComboBox::noneChecked()const
 }
 
 //-----------------------------------------------------------------------------
+void ctkCheckableComboBox::setCheckState(const QModelIndex& index, Qt::CheckState check)
+{
+  Q_D(ctkCheckableComboBox);
+  return d->CheckableModelHelper->setCheckState(index, check);
+}
+
+//-----------------------------------------------------------------------------
+Qt::CheckState ctkCheckableComboBox::checkState(const QModelIndex& index)const
+{
+  Q_D(const ctkCheckableComboBox);
+  return d->CheckableModelHelper->checkState(index);
+}
+
+//-----------------------------------------------------------------------------
 void ctkCheckableComboBox::onDataChanged(const QModelIndex& start, const QModelIndex& end)
 {
   Q_D(ctkCheckableComboBox);

+ 13 - 2
Libs/Widgets/ctkCheckableComboBox.h

@@ -44,12 +44,23 @@ public:
   QAbstractItemModel* checkableModel()const;
   void setCheckableModel(QAbstractItemModel *model);
   
-  ctkCheckableModelHelper* checkableModelHelper()const;
-  
+  /// Returns an up-to-date list of all the checked indexes.
   QModelIndexList checkedIndexes()const;
+  /// Returns true if all the indexes are checked, false otherwise 
   bool allChecked()const;
+  /// Returns true if none of the indexes is checked, false otherwise
   bool noneChecked()const;
 
+  /// Utility function to conveniently check the state of an index
+  void setCheckState(const QModelIndex& index, Qt::CheckState check);
+  /// Utility function to return the check state of a model index
+  Qt::CheckState checkState(const QModelIndex& index)const;
+
+  /// Returns a pointer to the checkable model helper to give a direct access
+  /// to the check manager.
+  ctkCheckableModelHelper* checkableModelHelper()const;
+  
+  /// Reimplemented for internal reasons
   bool eventFilter(QObject *o, QEvent *e);
   
 signals: