Image Component Library (ICL)
ComboHandle.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLQt/src/ICLQt/ComboHandle.h **
10 ** Module : ICLQt **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLQt/GUIHandle.h>
35 #include <string>
36 
38 class QComboBox;
41 namespace icl{
42  namespace qt{
43 
45  class ComboHandle : public GUIHandle<QComboBox>{
46  public:
49 
51  ComboHandle(QComboBox *cb, GUIWidget *w):GUIHandle<QComboBox>(cb,w){}
52 
54  ICLQt_API void add(const std::string &item);
55 
57  ICLQt_API void remove(const std::string &item);
58 
60  ICLQt_API void remove(int idx);
61 
63  ICLQt_API void clear();
64 
66  ICLQt_API std::string getItem(int idx) const;
67 
69  ICLQt_API int getIndex(const std::string &item) const;
70 
72  ICLQt_API int getSelectedIndex() const;
73 
75  ICLQt_API std::string getSelectedItem() const;
76 
78  ICLQt_API int getItemCount() const;
79 
81  ICLQt_API void setSelectedIndex(int idx);
82 
84  ICLQt_API void setSelectedItem(const std::string &item);
85 
87  inline operator int() const { return getSelectedIndex(); }
88 
90  inline operator std::string() const { return getSelectedItem(); }
91 
92  private:
94  QComboBox *cbx() { return **this; }
95 
97  const QComboBox *cbx() const{ return **this; }
98  };
99 
100  } // namespace qt
101 }
102 
103 
undocument this line if you encounter any issues!
Definition: Any.h:37
ICLQt_API int getSelectedIndex() const
returns the currently selected index
ICLQt_API std::string getItem(int idx) const
returns the item at given index
Handle class for combo components.
Definition: ComboHandle.h:45
ICLQt_API int getItemCount() const
returns the count of elements
QComboBox * cbx()
utility function (internally used)
Definition: ComboHandle.h:94
Abstract base class for Handle classes.
Definition: GUIHandle.h:40
ICLQt_API void setSelectedIndex(int idx)
sets the current index
ComboHandle()
create an empty handle
Definition: ComboHandle.h:48
ICLQt_API std::string getSelectedItem() const
returns the currently selected item
Abstract class for GUI components.
Definition: GUIWidget.h:52
ICLQt_API void setSelectedItem(const std::string &item)
sets the current item
#define ICLQt_API
Definition: CompatMacros.h:178
const QComboBox * cbx() const
utility function (internally used)
Definition: ComboHandle.h:97
ICLQt_API void clear()
void remove all items
virtual void cb()
envokes all registered callbacks
Definition: GUIHandleBase.h:102
ICLQt_API void remove(const std::string &item)
remove an item
ICLQt_API int getIndex(const std::string &item) const
returns the index of a given item
ComboHandle(QComboBox *cb, GUIWidget *w)
create a new ComboHandle wrapping a given QComboBox
Definition: ComboHandle.h:51
ICLQt_API void add(const std::string &item)
add an item