26 #include <initializer_list> 31 #include "ginteractor.h" 35 class _Internal_QComboBox;
52 GChooser(
const std::initializer_list<string>& items, QWidget* parent =
nullptr);
57 GChooser(
const std::vector<string>& items, QWidget* parent =
nullptr);
67 virtual void addItem(
const string& item);
72 virtual void addItems(
const std::initializer_list<string>& items);
77 virtual void addItems(
const std::vector<string>& items);
94 virtual string
getItem(
int index)
const;
115 string
getType()
const override;
141 virtual void setItem(
int index,
const string& item);
158 virtual int size()
const;
164 string getActionEventType()
const override;
169 _Internal_QComboBox* _iqcomboBox;
171 void checkIndex(
const string& member,
int index,
int min = 0,
int max = -1)
const;
173 friend class _Internal_QComboBox;
180 class _Internal_QComboBox :
public QComboBox,
public _Internal_QWidget {
184 _Internal_QComboBox(
GChooser* gchooser, QWidget* parent =
nullptr);
185 void detach()
override;
186 void keyPressEvent(QKeyEvent* event)
override;
187 void keyReleaseEvent(QKeyEvent* event)
override;
188 QSize sizeHint()
const override;
204 #endif // _gchooser_h virtual int getItemCount() const
Returns the number of items in the chooser.
Definition: gchooser.cpp:117
GChooser(QWidget* parent=nullptr)
Creates a chooser that initially contains no items.
Definition: gchooser.cpp:27
string getActionCommand() const override
Returns an action command for this interactor, which is a semi-unique string you can use to identify ...
Definition: gchooser.cpp:96
virtual void setSelectedItem(string item)
Sets the given item in the chooser to be selected.
Definition: gchooser.cpp:165
QWidget* getWidget() const override
Returns a direct pointer to the internal Qt widget being wrapped by this interactor.
Definition: gchooser.cpp:133
virtual void setSelectedIndex(int index)
Sets the item at the given index in the chooser to be selected.
Definition: gchooser.cpp:152
virtual void addItems(const std::initializer_list< string > &items)
Adds each item from the given list to the end of the chooser's list.
Definition: gchooser.cpp:63
virtual void clearItems()
Removes all items from the chooser.
Definition: gchooser.cpp:90
string getType() const override
Returns a string representing the class name of this interactor, such as "GButton" or "GCheckBox"...
Definition: gchooser.cpp:129
This abstract class is the superclass for all graphical interactors.
Definition: ginteractor.h:52
virtual string getSelectedItem() const
Returns the currently selected item in the chooser, or an empty string if no item is currently select...
Definition: gchooser.cpp:125
virtual bool isEditable() const
Returns true if the chooser has an editable area for typing new items.
Definition: gchooser.cpp:137
This interactor subclass represents a selectable drop-down list.
Definition: gchooser.h:42
virtual string getItem(int index) const
Returns the item in the chooser at the given 0-based index.
Definition: gchooser.cpp:112
virtual int size() const
Returns the number of items in the chooser.
Definition: gchooser.cpp:175
virtual void setEditable(bool editable)
Sets whether the chooser has an editable area for typing new items.
Definition: gchooser.cpp:159
_Internal_QWidget* getInternalWidget() const override
Returns a direct pointer to the internal Qt widget being wrapped by this interactor.
Definition: gchooser.cpp:108
virtual void addItem(string item)
Adds a new item consisting of the specified string to the end of the list.
Definition: gchooser.cpp:56
virtual void setItem(int index, string item)
Sets the item at the given index in the chooser to the given value.
Definition: gchooser.cpp:145
virtual bool isEmpty() const
Returns true if the chooser has no items.
Definition: gchooser.cpp:141
virtual int getSelectedIndex() const
Returns which index is selected in the chooser.
Definition: gchooser.cpp:121
~GChooser() override
Frees memory allocated internally by the chooser.
Definition: gchooser.cpp:50
GChooser GComboBox
Definition: gchooser.h:200