qdbusplatformmenu.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9