Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | - | |||||||
5 | const QLoggingCategory &qLcMenu() { static const QLoggingCategory category("qt.qpa.menu"); return executed 1 time by 1 test: category;return category; Executed by:
executed 1 time by 1 test: }return category; Executed by:
| 1 | ||||||
6 | - | |||||||
7 | static int nextDBusID = 1; | - | ||||||
8 | QHash<int, QDBusPlatformMenuItem *> menuItemsByID; | - | ||||||
9 | - | |||||||
10 | QDBusPlatformMenuItem::QDBusPlatformMenuItem(quintptr tag) | - | ||||||
11 | : m_tag(tag ? tag : reinterpret_cast<quintptr>(this)) | - | ||||||
12 | , m_subMenu(nullptr) | - | ||||||
13 | , m_role(NoRole) | - | ||||||
14 | , m_isEnabled(true) | - | ||||||
15 | , m_isVisible(true) | - | ||||||
16 | , m_isSeparator(false) | - | ||||||
17 | , m_isCheckable(false) | - | ||||||
18 | , m_isChecked(false) | - | ||||||
19 | , m_dbusID(nextDBusID++) | - | ||||||
20 | { | - | ||||||
21 | menuItemsByID.insert(m_dbusID, this); | - | ||||||
22 | } never executed: end of block | 0 | ||||||
23 | - | |||||||
24 | QDBusPlatformMenuItem::~QDBusPlatformMenuItem() | - | ||||||
25 | { | - | ||||||
26 | menuItemsByID.remove(m_dbusID); | - | ||||||
27 | if (m_subMenu
| 0 | ||||||
28 | static_cast< never executed: QDBusPlatformMenu *>(m_subMenu)->setContainingMenuItem(nullptr);static_cast<QDBusPlatformMenu *>(m_subMenu)->setContainingMenuItem(nullptr); never executed: static_cast<QDBusPlatformMenu *>(m_subMenu)->setContainingMenuItem(nullptr); | 0 | ||||||
29 | } never executed: end of block | 0 | ||||||
30 | - | |||||||
31 | void QDBusPlatformMenuItem::setTag(quintptr tag) | - | ||||||
32 | { | - | ||||||
33 | m_tag = tag; | - | ||||||
34 | } never executed: end of block | 0 | ||||||
35 | - | |||||||
36 | void QDBusPlatformMenuItem::setText(const QString &text) | - | ||||||
37 | { | - | ||||||
38 | for (bool qt_category_enabled = qLcMenu().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 74, __PRETTY_FUNCTION__, qLcMenu().categoryName()).debug() << m_dbusID << text; | 0 | ||||||
39 | m_text = text; | - | ||||||
40 | } never executed: end of block | 0 | ||||||
41 | - | |||||||
42 | void QDBusPlatformMenuItem::setIcon(const QIcon &icon) | - | ||||||
43 | { | - | ||||||
44 | m_icon = icon; | - | ||||||
45 | } never executed: end of block | 0 | ||||||
46 | - | |||||||
47 | - | |||||||
48 | - | |||||||
49 | - | |||||||
50 | void QDBusPlatformMenuItem::setMenu(QPlatformMenu *menu) | - | ||||||
51 | { | - | ||||||
52 | if (m_subMenu
| 0 | ||||||
53 | static_cast< never executed: QDBusPlatformMenu *>(m_subMenu)->setContainingMenuItem(nullptr);static_cast<QDBusPlatformMenu *>(m_subMenu)->setContainingMenuItem(nullptr); never executed: static_cast<QDBusPlatformMenu *>(m_subMenu)->setContainingMenuItem(nullptr); | 0 | ||||||
54 | m_subMenu = menu; | - | ||||||
55 | if (menu
| 0 | ||||||
56 | static_cast< never executed: QDBusPlatformMenu *>(menu)->setContainingMenuItem(this);static_cast<QDBusPlatformMenu *>(menu)->setContainingMenuItem(this); never executed: static_cast<QDBusPlatformMenu *>(menu)->setContainingMenuItem(this); | 0 | ||||||
57 | } never executed: end of block | 0 | ||||||
58 | - | |||||||
59 | void QDBusPlatformMenuItem::setEnabled(bool enabled) | - | ||||||
60 | { | - | ||||||
61 | m_isEnabled = enabled; | - | ||||||
62 | } never executed: end of block | 0 | ||||||
63 | - | |||||||
64 | void QDBusPlatformMenuItem::setVisible(bool isVisible) | - | ||||||
65 | { | - | ||||||
66 | m_isVisible = isVisible; | - | ||||||
67 | } never executed: end of block | 0 | ||||||
68 | - | |||||||
69 | void QDBusPlatformMenuItem::setIsSeparator(bool isSeparator) | - | ||||||
70 | { | - | ||||||
71 | m_isSeparator = isSeparator; | - | ||||||
72 | } never executed: end of block | 0 | ||||||
73 | - | |||||||
74 | void QDBusPlatformMenuItem::setRole(QPlatformMenuItem::MenuRole role) | - | ||||||
75 | { | - | ||||||
76 | m_role = role; | - | ||||||
77 | } never executed: end of block | 0 | ||||||
78 | - | |||||||
79 | void QDBusPlatformMenuItem::setCheckable(bool checkable) | - | ||||||
80 | { | - | ||||||
81 | m_isCheckable = checkable; | - | ||||||
82 | } never executed: end of block | 0 | ||||||
83 | - | |||||||
84 | void QDBusPlatformMenuItem::setChecked(bool isChecked) | - | ||||||
85 | { | - | ||||||
86 | m_isChecked = isChecked; | - | ||||||
87 | } never executed: end of block | 0 | ||||||
88 | - | |||||||
89 | void QDBusPlatformMenuItem::setShortcut(const QKeySequence &shortcut) | - | ||||||
90 | { | - | ||||||
91 | m_shortcut = shortcut; | - | ||||||
92 | } never executed: end of block | 0 | ||||||
93 | - | |||||||
94 | void QDBusPlatformMenuItem::trigger() | - | ||||||
95 | { | - | ||||||
96 | activated(); | - | ||||||
97 | } never executed: end of block | 0 | ||||||
98 | - | |||||||
99 | QDBusPlatformMenuItem *QDBusPlatformMenuItem::byId(int id) | - | ||||||
100 | { | - | ||||||
101 | - | |||||||
102 | - | |||||||
103 | if (menuItemsByID.contains(id)
| 0 | ||||||
104 | return never executed: menuItemsByID[id];return menuItemsByID[id]; never executed: return menuItemsByID[id]; | 0 | ||||||
105 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||
106 | } | - | ||||||
107 | - | |||||||
108 | QList<const QDBusPlatformMenuItem *> QDBusPlatformMenuItem::byIds(const QList<int> &ids) | - | ||||||
109 | { | - | ||||||
110 | QList<const QDBusPlatformMenuItem *> ret; | - | ||||||
111 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(ids)>::type> _container_((ids)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (int id = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||
112 | if (menuItemsByID.contains(id)
| 0 | ||||||
113 | ret << menuItemsByID[id]; never executed: ret << menuItemsByID[id]; | 0 | ||||||
114 | } never executed: end of block | 0 | ||||||
115 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||
116 | } | - | ||||||
117 | - | |||||||
118 | - | |||||||
119 | QDBusPlatformMenu::QDBusPlatformMenu(quintptr tag) | - | ||||||
120 | : m_tag(tag ? tag : reinterpret_cast<quintptr>(this)) | - | ||||||
121 | , m_isEnabled(true) | - | ||||||
122 | , m_isVisible(true) | - | ||||||
123 | , m_isSeparator(false) | - | ||||||
124 | , m_revision(1) | - | ||||||
125 | , m_containingMenuItem(nullptr) | - | ||||||
126 | { | - | ||||||
127 | } never executed: end of block | 0 | ||||||
128 | - | |||||||
129 | QDBusPlatformMenu::~QDBusPlatformMenu() | - | ||||||
130 | { | - | ||||||
131 | if (m_containingMenuItem
| 0 | ||||||
132 | m_containingMenuItem->setMenu(nullptr); never executed: m_containingMenuItem->setMenu(nullptr); | 0 | ||||||
133 | } never executed: end of block | 0 | ||||||
134 | - | |||||||
135 | void QDBusPlatformMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before) | - | ||||||
136 | { | - | ||||||
137 | QDBusPlatformMenuItem *item = static_cast<QDBusPlatformMenuItem *>(menuItem); | - | ||||||
138 | QDBusPlatformMenuItem *beforeItem = static_cast<QDBusPlatformMenuItem *>(before); | - | ||||||
139 | int idx = m_items.indexOf(beforeItem); | - | ||||||
140 | for (bool qt_category_enabled = qLcMenu().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 176, __PRETTY_FUNCTION__, qLcMenu().categoryName()).debug() << item->dbusID() << item->text(); | 0 | ||||||
141 | if (idx < 0
| 0 | ||||||
142 | m_items.append(item); never executed: m_items.append(item); | 0 | ||||||
143 | else | - | ||||||
144 | m_items.insert(idx, item); never executed: m_items.insert(idx, item); | 0 | ||||||
145 | m_itemsByTag.insert(item->tag(), item); | - | ||||||
146 | if (item->menu()
| 0 | ||||||
147 | syncSubMenu(static_cast<const QDBusPlatformMenu *>(item->menu())); never executed: syncSubMenu(static_cast<const QDBusPlatformMenu *>(item->menu())); | 0 | ||||||
148 | emitUpdated(); | - | ||||||
149 | } never executed: end of block | 0 | ||||||
150 | - | |||||||
151 | void QDBusPlatformMenu::removeMenuItem(QPlatformMenuItem *menuItem) | - | ||||||
152 | { | - | ||||||
153 | QDBusPlatformMenuItem *item = static_cast<QDBusPlatformMenuItem *>(menuItem); | - | ||||||
154 | m_items.removeAll(item); | - | ||||||
155 | m_itemsByTag.remove(menuItem->tag()); | - | ||||||
156 | if (item->menu()
| 0 | ||||||
157 | - | |||||||
158 | const QDBusPlatformMenu *menu = static_cast<const QDBusPlatformMenu *>(item->menu()); | - | ||||||
159 | disconnect(menu, &QDBusPlatformMenu::propertiesUpdated, | - | ||||||
160 | this, &QDBusPlatformMenu::propertiesUpdated); | - | ||||||
161 | disconnect(menu, &QDBusPlatformMenu::updated, | - | ||||||
162 | this, &QDBusPlatformMenu::updated); | - | ||||||
163 | } never executed: end of block | 0 | ||||||
164 | emitUpdated(); | - | ||||||
165 | } never executed: end of block | 0 | ||||||
166 | - | |||||||
167 | void QDBusPlatformMenu::syncSubMenu(const QDBusPlatformMenu *menu) | - | ||||||
168 | { | - | ||||||
169 | - | |||||||
170 | - | |||||||
171 | connect(menu, &QDBusPlatformMenu::propertiesUpdated, | - | ||||||
172 | this, &QDBusPlatformMenu::propertiesUpdated, Qt::UniqueConnection); | - | ||||||
173 | connect(menu, &QDBusPlatformMenu::updated, | - | ||||||
174 | this, &QDBusPlatformMenu::updated, Qt::UniqueConnection); | - | ||||||
175 | } never executed: end of block | 0 | ||||||
176 | - | |||||||
177 | void QDBusPlatformMenu::syncMenuItem(QPlatformMenuItem *menuItem) | - | ||||||
178 | { | - | ||||||
179 | QDBusPlatformMenuItem *item = static_cast<QDBusPlatformMenuItem *>(menuItem); | - | ||||||
180 | - | |||||||
181 | if (item->menu()
| 0 | ||||||
182 | syncSubMenu(static_cast<const QDBusPlatformMenu *>(item->menu())); never executed: syncSubMenu(static_cast<const QDBusPlatformMenu *>(item->menu())); | 0 | ||||||
183 | - | |||||||
184 | - | |||||||
185 | - | |||||||
186 | QDBusMenuItemList updated; | - | ||||||
187 | QDBusMenuItemKeysList removed; | - | ||||||
188 | updated << QDBusMenuItem(item); | - | ||||||
189 | for (bool qt_category_enabled = qLcMenu().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 225, __PRETTY_FUNCTION__, qLcMenu().categoryName()).debug() << updated; | 0 | ||||||
190 | propertiesUpdated(updated, removed); | - | ||||||
191 | } never executed: end of block | 0 | ||||||
192 | - | |||||||
193 | void QDBusPlatformMenu::emitUpdated() | - | ||||||
194 | { | - | ||||||
195 | if (m_containingMenuItem
| 0 | ||||||
196 | updated(++m_revision, m_containingMenuItem->dbusID()); never executed: updated(++m_revision, m_containingMenuItem->dbusID()); | 0 | ||||||
197 | else | - | ||||||
198 | updated(++m_revision, 0); never executed: updated(++m_revision, 0); | 0 | ||||||
199 | } | - | ||||||
200 | - | |||||||
201 | void QDBusPlatformMenu::setTag(quintptr tag) | - | ||||||
202 | { | - | ||||||
203 | m_tag = tag; | - | ||||||
204 | } never executed: end of block | 0 | ||||||
205 | - | |||||||
206 | void QDBusPlatformMenu::setText(const QString &text) | - | ||||||
207 | { | - | ||||||
208 | m_text = text; | - | ||||||
209 | } never executed: end of block | 0 | ||||||
210 | - | |||||||
211 | void QDBusPlatformMenu::setIcon(const QIcon &icon) | - | ||||||
212 | { | - | ||||||
213 | m_icon = icon; | - | ||||||
214 | } never executed: end of block | 0 | ||||||
215 | - | |||||||
216 | void QDBusPlatformMenu::setEnabled(bool enabled) | - | ||||||
217 | { | - | ||||||
218 | m_isEnabled = enabled; | - | ||||||
219 | } never executed: end of block | 0 | ||||||
220 | - | |||||||
221 | void QDBusPlatformMenu::setVisible(bool isVisible) | - | ||||||
222 | { | - | ||||||
223 | m_isVisible = isVisible; | - | ||||||
224 | } never executed: end of block | 0 | ||||||
225 | - | |||||||
226 | void QDBusPlatformMenu::setContainingMenuItem(QDBusPlatformMenuItem *item) | - | ||||||
227 | { | - | ||||||
228 | m_containingMenuItem = item; | - | ||||||
229 | } never executed: end of block | 0 | ||||||
230 | - | |||||||
231 | QPlatformMenuItem *QDBusPlatformMenu::menuItemAt(int position) const | - | ||||||
232 | { | - | ||||||
233 | return never executed: m_items.value(position);return m_items.value(position); never executed: return m_items.value(position); | 0 | ||||||
234 | } | - | ||||||
235 | - | |||||||
236 | QPlatformMenuItem *QDBusPlatformMenu::menuItemForTag(quintptr tag) const | - | ||||||
237 | { | - | ||||||
238 | return never executed: m_itemsByTag[tag];return m_itemsByTag[tag]; never executed: return m_itemsByTag[tag]; | 0 | ||||||
239 | } | - | ||||||
240 | - | |||||||
241 | const QList<QDBusPlatformMenuItem *> QDBusPlatformMenu::items() const | - | ||||||
242 | { | - | ||||||
243 | return never executed: m_items;return m_items; never executed: return m_items; | 0 | ||||||
244 | } | - | ||||||
245 | - | |||||||
246 | QPlatformMenuItem *QDBusPlatformMenu::createMenuItem() const | - | ||||||
247 | { | - | ||||||
248 | QDBusPlatformMenuItem *ret = new QDBusPlatformMenuItem(); | - | ||||||
249 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||
250 | } | - | ||||||
251 | - | |||||||
252 | QPlatformMenu *QDBusPlatformMenu::createSubMenu() const | - | ||||||
253 | { | - | ||||||
254 | return never executed: new QDBusPlatformMenu;return new QDBusPlatformMenu; never executed: return new QDBusPlatformMenu; | 0 | ||||||
255 | } | - | ||||||
256 | - | |||||||
257 | - | |||||||
Switch to Source code | Preprocessed file |