itom 2.2.1
K:/git-itom/sources/itom/itomWidgets/checkableComboBox.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2016, Institut fuer Technische Optik (ITO),
00005     Universitaet Stuttgart, Germany
00006 
00007     This file is part of itom and its software development toolkit (SDK).
00008 
00009     itom is free software; you can redistribute it and/or modify it
00010     under the terms of the GNU Library General Public Licence as published by
00011     the Free Software Foundation; either version 2 of the Licence, or (at
00012     your option) any later version.
00013    
00014     In addition, as a special exception, the Institut fuer Technische
00015     Optik (ITO) gives you certain additional rights.
00016     These rights are described in the ITO LGPL Exception version 1.0,
00017     which can be found in the file LGPL_EXCEPTION.txt in this package.
00018 
00019     itom is distributed in the hope that it will be useful, but
00020     WITHOUT ANY WARRANTY; without even the implied warranty of
00021     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00022     General Public Licence for more details.
00023 
00024     You should have received a copy of the GNU Library General Public License
00025     along with itom. If not, see <http://www.gnu.org/licenses/>.
00026 
00027     This file is a port and modified version of the 
00028     Common framework (http://www.commontk.org)
00029 *********************************************************************** */
00030 
00031 #ifndef CHECKABLECOMBOBOX_H
00032 #define CHECKABLECOMBOBOX_H
00033 
00034 // Qt includes
00035 #include <QComboBox>
00036 
00037 #include "commonWidgets.h"
00038 
00039 class CheckableModelHelper;
00040 class CheckableComboBoxPrivate;
00041 
00045 class ITOMWIDGETS_EXPORT CheckableComboBox : public QComboBox
00046 {
00047     Q_OBJECT
00048 
00049     Q_PROPERTY(QVector<int> checkedIndices READ getCheckedIndices WRITE setCheckedIndices);
00050 
00051 public:
00052   CheckableComboBox(QWidget *parent = 0);
00053   virtual ~CheckableComboBox();
00054   
00056   QAbstractItemModel* checkableModel()const;
00057   void setCheckableModel(QAbstractItemModel *model);
00058   
00060   QModelIndexList checkedIndexes()const;
00062   bool allChecked()const;
00064   bool noneChecked()const;
00065 
00067   void setCheckState(const QModelIndex& index, Qt::CheckState check);
00069   Qt::CheckState checkState(const QModelIndex& index)const;
00070 
00073   CheckableModelHelper* checkableModelHelper()const;
00074   
00076   bool eventFilter(QObject *o, QEvent *e);
00077 
00078   void setCheckedIndices(const QVector<int> &indices);
00079   QVector<int> getCheckedIndices() const;
00080 
00081   
00082 Q_SIGNALS:
00083   void checkedIndexesChanged();
00084 
00085 public Q_SLOTS:
00086         void setIndexState(int index, bool state);
00087 
00088 protected Q_SLOTS:
00089   void onDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
00090 
00091 protected:
00093   virtual void paintEvent(QPaintEvent*);
00094 
00095 protected:
00096   QScopedPointer<CheckableComboBoxPrivate> d_ptr;
00097 
00098 private:
00099   Q_DECLARE_PRIVATE(CheckableComboBox);
00100   Q_DISABLE_COPY(CheckableComboBox);
00101 };
00102 
00103 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Friends