/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 | | OUString ItemView::get_id(int pos) const |
15 | 0 | { |
16 | 0 | if (std::unique_ptr<weld::TreeIter> pIter = get_iterator(pos)) |
17 | 0 | return get_id(*pIter); |
18 | | |
19 | 0 | return OUString(); |
20 | 0 | } |
21 | | |
22 | | void ItemView::set_id(int pos, const OUString& rId) |
23 | 0 | { |
24 | 0 | if (std::unique_ptr<weld::TreeIter> pIter = get_iterator(pos)) |
25 | 0 | return set_id(*pIter, rId); |
26 | 0 | } |
27 | | |
28 | | int ItemView::get_cursor_index() const |
29 | 0 | { |
30 | 0 | if (std::unique_ptr<weld::TreeIter> pIter = get_cursor()) |
31 | 0 | return get_iter_index_in_parent(*pIter); |
32 | | |
33 | 0 | return -1; |
34 | 0 | } |
35 | | |
36 | | void ItemView::set_cursor(const TreeIter& rIter) |
37 | 0 | { |
38 | 0 | disable_notify_events(); |
39 | 0 | do_set_cursor(rIter); |
40 | 0 | enable_notify_events(); |
41 | 0 | } |
42 | | |
43 | | void ItemView::select(int pos) |
44 | 0 | { |
45 | 0 | if (pos == -1 || (pos == 0 && n_children() == 0)) |
46 | 0 | { |
47 | 0 | unselect_all(); |
48 | 0 | return; |
49 | 0 | } |
50 | | |
51 | 0 | if (std::unique_ptr<weld::TreeIter> pIter = get_iterator(pos)) |
52 | 0 | return select(*pIter); |
53 | 0 | } |
54 | | |
55 | | void ItemView::select(const TreeIter& rIter) |
56 | 0 | { |
57 | 0 | disable_notify_events(); |
58 | 0 | do_select(rIter); |
59 | 0 | enable_notify_events(); |
60 | 0 | } |
61 | | |
62 | | void ItemView::unselect(int pos) |
63 | 0 | { |
64 | 0 | if (pos == -1) |
65 | 0 | { |
66 | 0 | select_all(); |
67 | 0 | return; |
68 | 0 | } |
69 | | |
70 | 0 | if (std::unique_ptr<weld::TreeIter> pIter = get_iterator(pos)) |
71 | 0 | return unselect(*pIter); |
72 | 0 | } |
73 | | |
74 | | void ItemView::unselect(const TreeIter& rIter) |
75 | 0 | { |
76 | 0 | disable_notify_events(); |
77 | 0 | do_unselect(rIter); |
78 | 0 | enable_notify_events(); |
79 | 0 | } |
80 | | |
81 | | void ItemView::select_all() |
82 | 0 | { |
83 | 0 | disable_notify_events(); |
84 | 0 | do_select_all(); |
85 | 0 | enable_notify_events(); |
86 | 0 | } |
87 | | |
88 | | void ItemView::unselect_all() |
89 | 0 | { |
90 | 0 | disable_notify_events(); |
91 | 0 | do_unselect_all(); |
92 | 0 | enable_notify_events(); |
93 | 0 | } |
94 | | |
95 | | void ItemView::remove(int pos) |
96 | 0 | { |
97 | 0 | if (std::unique_ptr<weld::TreeIter> pIter = get_iterator(pos)) |
98 | 0 | remove(*pIter); |
99 | 0 | } |
100 | | |
101 | | void ItemView::remove(const TreeIter& rIter) |
102 | 0 | { |
103 | 0 | disable_notify_events(); |
104 | 0 | do_remove(rIter); |
105 | 0 | enable_notify_events(); |
106 | 0 | } |
107 | | |
108 | | void ItemView::clear() |
109 | 0 | { |
110 | 0 | disable_notify_events(); |
111 | 0 | do_clear(); |
112 | 0 | enable_notify_events(); |
113 | 0 | } |
114 | | } |
115 | | |
116 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |