Mercurial > octave
annotate libgui/graphics/ListBoxControl.cc @ 23447:db1fdf4384dd
maint: Use convention "static_cast<void *>" for casting of pointers.
* Backend.cc, BaseControl.cc, ButtonControl.cc, ButtonGroup.cc, Canvas.cc,
Container.cc, ContextMenu.cc, Figure.cc, ListBoxControl.cc, Menu.cc,
MouseModeActionGroup.cc, Object.cc, Object.h, Panel.cc, RadioButtonControl.cc,
ToggleButtonControl.cc, ToolBar.cc, ToolBarButton.cc, annotation-dialog.cc,
file-editor-tab.cc, main-window.cc, webinfo.cc, data.cc, ft-text-renderer.cc,
graphics.in.h, zfstream.h, __init_fltk__.cc, __osmesa_print__.cc, gzip.cc,
ov-java.cc, bp-table.cc, oct-time.cc, lo-utils.cc, oct-base64.cc,
url-transfer.cc:
Use convention "static_cast<void *>" for casting of pointers.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 27 Apr 2017 10:04:31 -0700 |
parents | 092078913d54 |
children | c763214a8260 |
rev | line source |
---|---|
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 2011-2017 Michael Goffioul |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
5 This file is part of Octave. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
10 (at your option) any later version. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22737
diff
changeset
|
15 GNU General Public License for more details. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 */ |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
24 # include "config.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 #endif |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #include <QListWidget> |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
28 #include <QEvent> |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
29 #include <QMouseEvent> |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include "Container.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include "ListBoxControl.h" |
18505
fb96b7f55242
rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents:
18501
diff
changeset
|
33 #include "QtHandlesUtils.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 namespace QtHandles |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
38 static void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
39 updateSelection (QListWidget* list, const Matrix& value) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
40 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
41 octave_idx_type n = value.numel (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
42 int lc = list->count (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
44 list->clearSelection (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
46 for (octave_idx_type i = 0; i < n; i++) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
47 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
48 int idx = octave::math::round (value(i)); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
50 if (1 <= idx && idx <= lc) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
51 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
52 list->item (idx-1)->setSelected (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
53 list->scrollToItem (list->item (idx-1)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
54 if (i == 0 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
55 && list->selectionMode () == QAbstractItemView::SingleSelection) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
56 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
57 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
58 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
59 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
60 // Invalid selection. |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
61 list->clearSelection (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 break; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
63 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
64 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
65 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
67 ListBoxControl* |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
68 ListBoxControl::create (const graphics_object& go) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
69 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
70 Object* parent = Object::parentObject (go); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
72 if (parent) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
73 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
74 Container* container = parent->innerContainer (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
76 if (container) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
77 return new ListBoxControl (go, new QListWidget (container)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
78 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
80 return 0; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
81 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
83 ListBoxControl::ListBoxControl (const graphics_object& go, QListWidget* list) |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
84 : BaseControl (go, list), m_blockCallback (false), m_selectionChanged (false) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
85 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
86 uicontrol::properties& up = properties<uicontrol> (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
88 list->addItems (Utils::fromStringVector (up.get_string_vector ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
89 if ((up.get_max () - up.get_min ()) > 1) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
90 list->setSelectionMode (QAbstractItemView::ExtendedSelection); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
91 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
92 list->setSelectionMode (QAbstractItemView::SingleSelection); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
93 Matrix value = up.get_value ().matrix_value (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
94 if (value.numel () > 0) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
95 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
96 octave_idx_type n = value.numel (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
97 int lc = list->count (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
99 for (octave_idx_type i = 0; i < n; i++) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
100 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
101 int idx = octave::math::round (value(i)); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
103 if (1 <= idx && idx <= lc) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
104 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
105 list->item (idx-1)->setSelected (true); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
106 list->scrollToItem (list->item (idx-1)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
107 if (i == 0 && (list->selectionMode () |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
108 == QAbstractItemView::SingleSelection)) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
109 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
110 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
111 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
112 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
114 list->viewport ()->installEventFilter (this); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
116 connect (list, SIGNAL (itemSelectionChanged (void)), |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
117 SLOT (itemSelectionChanged (void))); |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
118 connect (list, SIGNAL (activated (const QModelIndex &)), |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
119 SLOT (itemActivated (const QModelIndex &))); |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
120 connect (list, SIGNAL (itemPressed (QListWidgetItem*)), |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
121 SLOT (itemPressed (QListWidgetItem*))); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
122 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
124 ListBoxControl::~ListBoxControl (void) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22413
diff
changeset
|
125 { } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
127 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
128 ListBoxControl::update (int pId) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
129 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
130 uicontrol::properties& up = properties<uicontrol> (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
131 QListWidget* list = qWidget<QListWidget> (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
133 switch (pId) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
134 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
135 case uicontrol::properties::ID_STRING: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
136 m_blockCallback = true; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
137 list->clear (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
138 list->addItems (Utils::fromStringVector (up.get_string_vector ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
139 updateSelection (list, up.get_value ().matrix_value ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
140 m_blockCallback = false; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
141 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19866
diff
changeset
|
142 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
143 case uicontrol::properties::ID_MIN: |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19866
diff
changeset
|
144 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
145 case uicontrol::properties::ID_MAX: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
146 if ((up.get_max () - up.get_min ()) > 1) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
147 list->setSelectionMode (QAbstractItemView::ExtendedSelection); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
148 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
149 list->setSelectionMode (QAbstractItemView::SingleSelection); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
150 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19866
diff
changeset
|
151 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
152 case uicontrol::properties::ID_VALUE: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
153 m_blockCallback = true; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
154 updateSelection (list, up.get_value ().matrix_value ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
155 m_blockCallback = false; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
156 break; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19866
diff
changeset
|
157 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
158 default: |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
159 BaseControl::update (pId); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
160 break; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
161 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
162 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
163 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
164 void |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
165 ListBoxControl::sendSelectionChange () |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
166 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
167 if (! m_blockCallback) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
168 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
169 QListWidget* list = qWidget<QListWidget> (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
170 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
171 QModelIndexList l = list->selectionModel ()->selectedIndexes (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
172 Matrix value (dim_vector (1, l.size ())); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
173 int i = 0; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
174 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
175 foreach (const QModelIndex& idx, l) |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
176 value(i++) = idx.row () + 1; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
178 gh_manager::post_set (m_handle, "value", octave_value (value), false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
179 gh_manager::post_callback (m_handle, "callback"); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
180 } |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
181 |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
182 m_selectionChanged = false; |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
183 } |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
184 |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
185 void |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
186 ListBoxControl::itemSelectionChanged (void) |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
187 { |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
188 if (! m_blockCallback) |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
189 m_selectionChanged = true; |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
190 } |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
191 |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22726
diff
changeset
|
192 void |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
193 ListBoxControl::itemActivated (const QModelIndex &) |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
194 { |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
195 m_selectionChanged = true; |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
196 } |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22726
diff
changeset
|
197 void |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
198 ListBoxControl::itemPressed (QListWidgetItem*) |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
199 { |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
200 m_selectionChanged = true; |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
201 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
202 |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22726
diff
changeset
|
203 bool |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
204 ListBoxControl::eventFilter (QObject* watched, QEvent* e) |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
205 { |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
206 // listbox change |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
207 if (watched == m_qobject) |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
208 { |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
209 switch (e->type ()) |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
210 { |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
211 case QEvent::KeyRelease: |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
212 if (m_selectionChanged) |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
213 sendSelectionChange (); |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
214 m_selectionChanged = false; |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
215 break; |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22726
diff
changeset
|
216 |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
217 default: |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
218 break; |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22726
diff
changeset
|
219 } |
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22726
diff
changeset
|
220 |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
221 return Object::eventFilter (watched, e); |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
222 } |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
223 // listbox viewport |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
224 else |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
225 { |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
226 bool override_return = false; |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
227 QListWidget* list = qWidget<QListWidget> (); |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
228 |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
229 switch (e->type ()) |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
230 { |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22726
diff
changeset
|
231 case QEvent::MouseButtonPress: |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
232 { |
23447
db1fdf4384dd
maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
233 QMouseEvent* m = dynamic_cast<QMouseEvent *> (e); |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
234 |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
235 if (m->button () & Qt::RightButton) |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
236 override_return = true; |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
237 else |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
238 { |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
239 if (! list->indexAt (m->pos ()).isValid ()) |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22726
diff
changeset
|
240 override_return = true; |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
241 m_selectionChanged = true; |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
242 } |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
243 break; |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
244 } |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
245 case QEvent::MouseButtonRelease: |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
246 { |
23447
db1fdf4384dd
maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
247 QMouseEvent* m = dynamic_cast<QMouseEvent *> (e); |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22726
diff
changeset
|
248 |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
249 if (m->button () & Qt::RightButton) |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
250 override_return = true; |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
251 |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
252 else if (! list->indexAt (m->pos ()).isValid ()) |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
253 { |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
254 list->setCurrentRow (list->count () - 1); |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
255 override_return = true; |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
256 } |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
257 |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
258 if (m_selectionChanged) |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
259 sendSelectionChange (); |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
260 m_selectionChanged = false; |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22726
diff
changeset
|
261 |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
262 break; |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
263 } |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
264 default: |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
265 break; |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22726
diff
changeset
|
266 |
22726
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
267 } |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
268 return BaseControl::eventFilter (watched, e) || override_return; |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
269 } |
dd2f547c21a0
QtHandles: firie listbox callback on click of selected item (Bug #44748)
John Donoghue
parents:
22417
diff
changeset
|
270 } |
22413
8758addcf265
maint: Remove ';' at end of namespace declaration.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
271 } |