26 #if defined (HAVE_CONFIG_H)
30 #include <QListWidget>
32 #include <QMouseEvent>
47 int lc = list->count ();
49 list->clearSelection ();
55 if (1 <= idx && idx <= lc)
57 list->item (idx-1)->setSelected (
true);
58 list->scrollToItem (list->item (idx-1));
60 && list->selectionMode () == QAbstractItemView::SingleSelection)
66 list->clearSelection ();
85 new QListWidget (container));
94 :
BaseControl (oct_qobj, interp, go, list), m_blockCallback (false),
95 m_selectionChanged (false)
100 if ((up.get_max () - up.get_min ()) > 1)
101 list->setSelectionMode (QAbstractItemView::ExtendedSelection);
103 list->setSelectionMode (QAbstractItemView::SingleSelection);
104 Matrix value = up.get_value ().matrix_value ();
105 if (value.
numel () > 0)
108 int lc = list->count ();
114 if (1 <= idx && idx <= lc)
116 list->item (idx-1)->setSelected (
true);
117 list->scrollToItem (list->item (idx-1));
118 if (i == 0 && (list->selectionMode ()
119 == QAbstractItemView::SingleSelection))
125 list->viewport ()->installEventFilter (
this);
129 connect (list, SIGNAL (activated (
const QModelIndex &)),
131 connect (list, SIGNAL (
itemPressed (QListWidgetItem*)),
142 QListWidget *list = qWidget<QListWidget> ();
146 case uicontrol::properties::ID_STRING:
154 case uicontrol::properties::ID_MIN:
156 case uicontrol::properties::ID_MAX:
157 if ((up.get_max () - up.get_min ()) > 1)
158 list->setSelectionMode (QAbstractItemView::ExtendedSelection);
160 list->setSelectionMode (QAbstractItemView::SingleSelection);
163 case uicontrol::properties::ID_VALUE:
180 QListWidget *list = qWidget<QListWidget> ();
182 QModelIndexList l = list->selectionModel ()->selectedIndexes ();
186 for (
const auto& idx : l)
187 value(i++) = idx.
row () + 1;
222 case QEvent::KeyRelease:
232 return Object::eventFilter (watched, e);
237 bool override_return =
false;
238 QListWidget *list = qWidget<QListWidget> ();
242 case QEvent::MouseButtonPress:
244 QMouseEvent *
m =
dynamic_cast<QMouseEvent *
> (e);
246 if (
m->button () & Qt::RightButton)
247 override_return =
true;
250 if (! list->indexAt (
m->pos ()).isValid ())
251 override_return =
true;
256 case QEvent::MouseButtonRelease:
258 QMouseEvent *
m =
dynamic_cast<QMouseEvent *
> (e);
260 if (
m->button () & Qt::RightButton)
261 override_return =
true;
263 else if (! list->indexAt (
m->pos ()).isValid ())
265 list->setCurrentRow (list->count () - 1);
266 override_return =
true;
octave_idx_type numel(void) const
Number of elements in the array.
RowVector row(octave_idx_type i) const
bool eventFilter(QObject *watched, QEvent *e)
void itemPressed(QListWidgetItem *)
bool eventFilter(QObject *watched, QEvent *e)
ListBoxControl(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go, QListWidget *list)
void sendSelectionChange()
static ListBoxControl * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
void itemActivated(const QModelIndex &)
void itemSelectionChanged(void)
virtual Container * innerContainer(void)=0
static Object * parentObject(octave::interpreter &interp, const graphics_object &go)
void gh_callback_event(const graphics_handle &h, const std::string &name)
void gh_set_event(const graphics_handle &h, const std::string &name, const octave_value &value)
Vector representing the dimensions (size) of an Array.
Base class for Octave interfaces that use Qt.
QStringList fromStringVector(const string_vector &v)
static void updateSelection(QListWidget *list, const Matrix &value)