/src/libreoffice/vcl/source/weld/ItemView.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | */ |
9 | | |
10 | | #include <vcl/weld/ItemView.hxx> |
11 | | |
12 | | namespace weld |
13 | | { |
14 | | bool ItemView::signal_item_activated(const TreeIter& rIter) |
15 | 0 | { |
16 | 0 | if (notify_events_disabled()) |
17 | 0 | return true; |
18 | 0 | return m_aItemActivatedHdl.Call(rIter); |
19 | 0 | } |
20 | | |
21 | | void ItemView::signal_selection_changed() |
22 | 0 | { |
23 | 0 | if (notify_events_disabled()) |
24 | 0 | return; |
25 | 0 | m_aSelectionChangeHdl.Call(*this); |
26 | 0 | } |
27 | | |
28 | | OUString ItemView::get_id(int pos) const |
29 | 0 | { |
30 | 0 | if (std::unique_ptr<weld::TreeIter> pIter = get_iterator(pos)) |
31 | 0 | return get_id(*pIter); |
32 | | |
33 | 0 | return OUString(); |
34 | 0 | } |
35 | | |
36 | | void ItemView::set_id(int pos, const OUString& rId) |
37 | 0 | { |
38 | 0 | if (std::unique_ptr<weld::TreeIter> pIter = get_iterator(pos)) |
39 | 0 | return set_id(*pIter, rId); |
40 | 0 | } |
41 | | |
42 | | OUString ItemView::get_selected_id() const |
43 | 0 | { |
44 | 0 | if (std::unique_ptr<weld::TreeIter> pIter = get_selected()) |
45 | 0 | return get_id(*pIter); |
46 | | |
47 | 0 | return OUString(); |
48 | 0 | } |
49 | | |
50 | | int ItemView::get_selected_index() const |
51 | 0 | { |
52 | 0 | if (std::unique_ptr<weld::TreeIter> pIter = get_selected()) |
53 | 0 | return get_iter_index_in_parent(*pIter); |
54 | | |
55 | 0 | return -1; |
56 | 0 | } |
57 | | |
58 | | int ItemView::get_cursor_index() const |
59 | 0 | { |
60 | 0 | if (std::unique_ptr<weld::TreeIter> pIter = get_cursor()) |
61 | 0 | return get_iter_index_in_parent(*pIter); |
62 | | |
63 | 0 | return -1; |
64 | 0 | } |
65 | | |
66 | | void ItemView::set_cursor(const TreeIter& rIter) |
67 | 0 | { |
68 | 0 | disable_notify_events(); |
69 | 0 | do_set_cursor(rIter); |
70 | 0 | enable_notify_events(); |
71 | 0 | } |
72 | | |
73 | | void ItemView::select(int pos) |
74 | 0 | { |
75 | 0 | if (pos == -1 || (pos == 0 && n_children() == 0)) |
76 | 0 | { |
77 | 0 | unselect_all(); |
78 | 0 | return; |
79 | 0 | } |
80 | | |
81 | 0 | if (std::unique_ptr<weld::TreeIter> pIter = get_iterator(pos)) |
82 | 0 | return select(*pIter); |
83 | 0 | } |
84 | | |
85 | | void ItemView::select(const TreeIter& rIter) |
86 | 0 | { |
87 | 0 | disable_notify_events(); |
88 | 0 | do_select(rIter); |
89 | 0 | enable_notify_events(); |
90 | 0 | } |
91 | | |
92 | | void ItemView::unselect(int pos) |
93 | 0 | { |
94 | 0 | if (pos == -1) |
95 | 0 | { |
96 | 0 | select_all(); |
97 | 0 | return; |
98 | 0 | } |
99 | | |
100 | 0 | if (std::unique_ptr<weld::TreeIter> pIter = get_iterator(pos)) |
101 | 0 | return unselect(*pIter); |
102 | 0 | } |
103 | | |
104 | | void ItemView::unselect(const TreeIter& rIter) |
105 | 0 | { |
106 | 0 | disable_notify_events(); |
107 | 0 | do_unselect(rIter); |
108 | 0 | enable_notify_events(); |
109 | 0 | } |
110 | | |
111 | | void ItemView::select_all() |
112 | 0 | { |
113 | 0 | disable_notify_events(); |
114 | 0 | do_select_all(); |
115 | 0 | enable_notify_events(); |
116 | 0 | } |
117 | | |
118 | | void ItemView::unselect_all() |
119 | 0 | { |
120 | 0 | disable_notify_events(); |
121 | 0 | do_unselect_all(); |
122 | 0 | enable_notify_events(); |
123 | 0 | } |
124 | | |
125 | | void ItemView::remove(int pos) |
126 | 0 | { |
127 | 0 | if (std::unique_ptr<weld::TreeIter> pIter = get_iterator(pos)) |
128 | 0 | remove(*pIter); |
129 | 0 | } |
130 | | |
131 | | void ItemView::remove(const TreeIter& rIter) |
132 | 0 | { |
133 | 0 | disable_notify_events(); |
134 | 0 | do_remove(rIter); |
135 | 0 | enable_notify_events(); |
136 | 0 | } |
137 | | |
138 | | void ItemView::clear() |
139 | 0 | { |
140 | 0 | disable_notify_events(); |
141 | 0 | do_clear(); |
142 | 0 | enable_notify_events(); |
143 | 0 | } |
144 | | } |
145 | | |
146 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |