26 #if defined (HAVE_CONFIG_H)
30 #include <QListWidget>
32 #include <QMouseEvent>
46 int lc = list->count ();
48 list->clearSelection ();
54 if (1 <= idx && idx <= lc)
56 list->item (idx-1)->setSelected (
true);
57 list->scrollToItem (list->item (idx-1));
59 && list->selectionMode () == QAbstractItemView::SingleSelection)
65 list->clearSelection ();
73 octave::interpreter& interp,
74 const graphics_object& go)
84 new QListWidget (container));
91 octave::interpreter& interp,
92 const graphics_object& go, QListWidget *list)
93 :
BaseControl (oct_qobj, interp, go, list), m_blockCallback (false),
94 m_selectionChanged (false)
99 if ((up.get_max () - up.get_min ()) > 1)
100 list->setSelectionMode (QAbstractItemView::ExtendedSelection);
102 list->setSelectionMode (QAbstractItemView::SingleSelection);
103 Matrix value = up.get_value ().matrix_value ();
104 if (value.
numel () > 0)
107 int lc = list->count ();
113 if (1 <= idx && idx <= lc)
115 list->item (idx-1)->setSelected (
true);
116 list->scrollToItem (list->item (idx-1));
117 if (i == 0 && (list->selectionMode ()
118 == QAbstractItemView::SingleSelection))
124 list->viewport ()->installEventFilter (
this);
126 connect (list, &QListWidget::itemSelectionChanged,
128 connect (list, &QListWidget::activated,
130 connect (list, &QListWidget::itemPressed,
141 QListWidget *list = qWidget<QListWidget> ();
145 case uicontrol::properties::ID_STRING:
153 case uicontrol::properties::ID_MIN:
154 case uicontrol::properties::ID_MAX:
155 if ((up.get_max () - up.get_min ()) > 1)
156 list->setSelectionMode (QAbstractItemView::ExtendedSelection);
158 list->setSelectionMode (QAbstractItemView::SingleSelection);
161 case uicontrol::properties::ID_LISTBOXTOP:
165 list->scrollToItem (list->item (idx-1),
166 QAbstractItemView::PositionAtTop);
170 case uicontrol::properties::ID_VALUE:
187 QListWidget *list = qWidget<QListWidget> ();
189 QModelIndexList l = list->selectionModel ()->selectedIndexes ();
193 for (
const auto& idx : l)
194 value(i++) = idx.
row () + 1;
229 case QEvent::KeyRelease:
239 return Object::eventFilter (watched, e);
244 bool override_return =
false;
245 QListWidget *list = qWidget<QListWidget> ();
249 case QEvent::MouseButtonPress:
251 QMouseEvent *
m =
dynamic_cast<QMouseEvent *
> (e);
253 if (
m->button () & Qt::RightButton)
254 override_return =
true;
257 if (! list->indexAt (
m->pos ()).isValid ())
258 override_return =
true;
263 case QEvent::MouseButtonRelease:
265 QMouseEvent *
m =
dynamic_cast<QMouseEvent *
> (e);
267 if (
m->button () & Qt::RightButton)
268 override_return =
true;
270 else if (! list->indexAt (
m->pos ()).isValid ())
272 list->setCurrentRow (list->count () - 1);
273 override_return =
true;
static void updateSelection(QListWidget *list, const Matrix &value)
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel(void) const
Number of elements in the array.
bool eventFilter(QObject *watched, QEvent *e)
void itemSelectionChanged(void)
ListBoxControl(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go, QListWidget *list)
void itemPressed(QListWidgetItem *)
void itemActivated(const QModelIndex &)
static ListBoxControl * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
bool eventFilter(QObject *watched, QEvent *e)
void sendSelectionChange()
OCTAVE_API RowVector row(octave_idx_type i) const
void gh_callback_event(const graphics_handle &h, const std::string &name)
static Object * parentObject(octave::interpreter &interp, const graphics_object &go)
void gh_set_event(const graphics_handle &h, const std::string &name, const octave_value &value)
virtual Container * innerContainer(void)=0
Vector representing the dimensions (size) of an Array.
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
QStringList fromStringVector(const string_vector &v)
T::properties & properties(graphics_object obj)