qdbusmenutypes.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/platformsupport/dbusmenu/qdbusmenutypes.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuItem &item)-
6{-
7 arg.beginStructure();-
8 arg << item.m_id << item.m_properties;-
9 arg.endStructure();-
10 return
never executed: return arg;
arg;
never executed: return arg;
0
11}-
12-
13const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuItem &item)-
14{-
15 arg.beginStructure();-
16 arg >> item.m_id >> item.m_properties;-
17 arg.endStructure();-
18 return
never executed: return arg;
arg;
never executed: return arg;
0
19}-
20-
21const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuItemKeys &keys)-
22{-
23 arg.beginStructure();-
24 arg << keys.id << keys.properties;-
25 arg.endStructure();-
26 return
never executed: return arg;
arg;
never executed: return arg;
0
27}-
28-
29const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuItemKeys &keys)-
30{-
31 arg.beginStructure();-
32 arg >> keys.id >> keys.properties;-
33 arg.endStructure();-
34 return
never executed: return arg;
arg;
never executed: return arg;
0
35}-
36-
37uint QDBusMenuLayoutItem::populate(int id, int depth, const QStringList &propertyNames, const QDBusPlatformMenu *topLevelMenu)-
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__, 91, __PRETTY_FUNCTION__, qLcMenu().categoryName()).debug() << id << "depth" << depth << propertyNames;
never executed: QMessageLogger(__FILE__, 91, __PRETTY_FUNCTION__, qLcMenu().categoryName()).debug() << id << "depth" << depth << propertyNames;
0
40 m_id = id;-
41 if (id == 0
id == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
42 m_properties.insert(QLatin1String("children-display"), QLatin1String("submenu"));-
43 if (topLevelMenu
topLevelMenuDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
44 populate(topLevelMenu, depth, propertyNames);
never executed: populate(topLevelMenu, depth, propertyNames);
0
45 return
never executed: return 1;
1;
never executed: return 1;
0
46 }-
47-
48 QDBusPlatformMenuItem *item = QDBusPlatformMenuItem::byId(id);-
49 if (item
itemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
50 const QDBusPlatformMenu *menu = static_cast<const QDBusPlatformMenu *>(item->menu());-
51-
52 if (menu
menuDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
53 if (depth != 0
depth != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
54 populate(menu, depth, propertyNames);
never executed: populate(menu, depth, propertyNames);
0
55 return
never executed: return menu->revision();
menu->revision();
never executed: return menu->revision();
0
56 }-
57 }
never executed: end of block
0
58-
59 return
never executed: return 1;
1;
never executed: return 1;
0
60}-
61-
62void QDBusMenuLayoutItem::populate(const QDBusPlatformMenu *menu, int depth, const QStringList &propertyNames)-
63{-
64 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(menu->items())>::type> _container_((menu->items())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QDBusPlatformMenuItem *item = *_container_.i; _container_.control; _container_.control = 0) {-
65 QDBusMenuLayoutItem child;-
66 child.populate(item, depth - 1, propertyNames);-
67 m_children << child;-
68 }
never executed: end of block
0
69}
never executed: end of block
0
70-
71void QDBusMenuLayoutItem::populate(const QDBusPlatformMenuItem *item, int depth, const QStringList &propertyNames)-
72{-
73 m_id = item->dbusID();-
74 QDBusMenuItem proxy(item);-
75 m_properties = proxy.m_properties;-
76-
77 const QDBusPlatformMenu *menu = static_cast<const QDBusPlatformMenu *>(item->menu());-
78 if (depth != 0
depth != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& menu
menuDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
79 populate(menu, depth, propertyNames);
never executed: populate(menu, depth, propertyNames);
0
80}
never executed: end of block
0
81-
82const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuLayoutItem &item)-
83{-
84 arg.beginStructure();-
85 arg << item.m_id << item.m_properties;-
86 arg.beginArray(qMetaTypeId<QDBusVariant>());-
87 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(item.m_children)>::type> _container_((item.m_children)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QDBusMenuLayoutItem& child = *_container_.i; _container_.control; _container_.control = 0)-
88 arg << QDBusVariant(QVariant::fromValue<QDBusMenuLayoutItem>(child));
never executed: arg << QDBusVariant(QVariant::fromValue<QDBusMenuLayoutItem>(child));
0
89 arg.endArray();-
90 arg.endStructure();-
91 return
never executed: return arg;
arg;
never executed: return arg;
0
92}-
93-
94const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuLayoutItem &item)-
95{-
96 arg.beginStructure();-
97 arg >> item.m_id >> item.m_properties;-
98 arg.beginArray();-
99 while (!arg.atEnd()
!arg.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
100 QDBusVariant dbusVariant;-
101 arg >> dbusVariant;-
102 QDBusArgument childArgument = dbusVariant.variant().value<QDBusArgument>();-
103-
104 QDBusMenuLayoutItem child;-
105 childArgument >> child;-
106 item.m_children.append(child);-
107 }
never executed: end of block
0
108 arg.endArray();-
109 arg.endStructure();-
110 return
never executed: return arg;
arg;
never executed: return arg;
0
111}-
112-
113void QDBusMenuItem::registerDBusTypes()-
114{-
115 qDBusRegisterMetaType<QDBusMenuItem>();-
116 qDBusRegisterMetaType<QDBusMenuItemList>();-
117 qDBusRegisterMetaType<QDBusMenuItemKeys>();-
118 qDBusRegisterMetaType<QDBusMenuItemKeysList>();-
119 qDBusRegisterMetaType<QDBusMenuLayoutItem>();-
120 qDBusRegisterMetaType<QDBusMenuLayoutItemList>();-
121 qDBusRegisterMetaType<QDBusMenuEvent>();-
122 qDBusRegisterMetaType<QDBusMenuEventList>();-
123 qDBusRegisterMetaType<QDBusMenuShortcut>();-
124}
never executed: end of block
0
125-
126QDBusMenuItem::QDBusMenuItem(const QDBusPlatformMenuItem *item)-
127 : m_id(item->dbusID())-
128{-
129 if (item->isSeparator()
item->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
130 m_properties.insert(QLatin1String("type"), QLatin1String("separator"));-
131 }
never executed: end of block
else {
0
132 m_properties.insert(QLatin1String("label"), convertMnemonic(item->text()));-
133 if (item->menu()
item->menu()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
134 m_properties.insert(QLatin1String("children-display"), QLatin1String("submenu"));
never executed: m_properties.insert(QLatin1String("children-display"), QLatin1String("submenu"));
0
135 m_properties.insert(QLatin1String("enabled"), item->isEnabled());-
136 if (item->isCheckable()
item->isCheckable()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
137 QString toggleType = item->hasExclusiveGroup()
item->hasExclusiveGroup()Description
TRUEnever evaluated
FALSEnever evaluated
? QLatin1String("radio") : QLatin1String("checkmark");
0
138 m_properties.insert(QLatin1String("toggle-type"), toggleType);-
139 m_properties.insert(QLatin1String("toggle-state"), item->isChecked() ? 1 : 0);-
140 }
never executed: end of block
0
141 const QKeySequence &scut = item->shortcut();-
142 if (!scut.isEmpty()
!scut.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
143 QDBusMenuShortcut shortcut = convertKeySequence(scut);-
144 m_properties.insert(QLatin1String("shortcut"), QVariant::fromValue(shortcut));-
145 }
never executed: end of block
0
146 const QIcon &icon = item->icon();-
147 if (!icon.name().isEmpty()
!icon.name().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
148 m_properties.insert(QLatin1String("icon-name"), icon.name());-
149 }
never executed: end of block
else if (!icon.isNull()
!icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
150 QBuffer buf;-
151 icon.pixmap(16).save(&buf, "PNG");-
152 m_properties.insert(QLatin1String("icon-data"), buf.data());-
153 }
never executed: end of block
0
154 }
never executed: end of block
0
155 m_properties.insert(QLatin1String("visible"), item->isVisible());-
156}
never executed: end of block
0
157-
158QDBusMenuItemList QDBusMenuItem::items(const QList<int> &ids, const QStringList &propertyNames)-
159{-
160 (void)propertyNames;-
161 QDBusMenuItemList ret;-
162 QList<const QDBusPlatformMenuItem *> items = QDBusPlatformMenuItem::byIds(ids);-
163 ret.reserve(items.size());-
164 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(items)>::type> _container_((items)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QDBusPlatformMenuItem *item = *_container_.i; _container_.control; _container_.control = 0)-
165 ret << QDBusMenuItem(item);
never executed: ret << QDBusMenuItem(item);
0
166 return
never executed: return ret;
ret;
never executed: return ret;
0
167}-
168-
169QString QDBusMenuItem::convertMnemonic(const QString &label)-
170{-
171-
172-
173 int idx = label.indexOf(QLatin1Char('&'));-
174 if (idx < 0
idx < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| idx == label.length() - 1
idx == label.length() - 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
175 return
never executed: return label;
label;
never executed: return label;
0
176 QString ret(label);-
177 ret[idx] = QLatin1Char('_');-
178 return
never executed: return ret;
ret;
never executed: return ret;
0
179}-
180-
181QDBusMenuShortcut QDBusMenuItem::convertKeySequence(const QKeySequence &sequence)-
182{-
183 QDBusMenuShortcut shortcut;-
184 for (int i = 0; i < sequence.count()
i < sequence.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
185 QStringList tokens;-
186 int key = sequence[i];-
187 if (key & Qt::MetaModifier
key & Qt::MetaModifierDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
188 tokens << ([]() -> QString { enum { Size = sizeof(u"" "Super")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Super" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}());
never executed: tokens << ([]() -> QString { enum { Size = sizeof(u"" "Super")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Super" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
0
189 if (key & Qt::ControlModifier
key & Qt::ControlModifierDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
190 tokens << ([]() -> QString { enum { Size = sizeof(u"" "Control")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Control" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}());
never executed: tokens << ([]() -> QString { enum { Size = sizeof(u"" "Control")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Control" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
0
191 if (key & Qt::AltModifier
key & Qt::AltModifierDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
192 tokens << ([]() -> QString { enum { Size = sizeof(u"" "Alt")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Alt" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}());
never executed: tokens << ([]() -> QString { enum { Size = sizeof(u"" "Alt")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Alt" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
0
193 if (key & Qt::ShiftModifier
key & Qt::ShiftModifierDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
194 tokens << ([]() -> QString { enum { Size = sizeof(u"" "Shift")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Shift" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}());
never executed: tokens << ([]() -> QString { enum { Size = sizeof(u"" "Shift")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Shift" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
0
195 if (key & Qt::KeypadModifier
key & Qt::KeypadModifierDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
196 tokens << ([]() -> QString { enum { Size = sizeof(u"" "Num")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Num" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}());
never executed: tokens << ([]() -> QString { enum { Size = sizeof(u"" "Num")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Num" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
0
197-
198 QString keyName = QKeySequencePrivate::keyName(key, QKeySequence::PortableText);-
199 if (keyName == QLatin1String("+")
keyName == QLatin1String("+")Description
TRUEnever evaluated
FALSEnever evaluated
)
0
200 tokens << ([]() -> QString { enum { Size = sizeof(u"" "plus")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "plus" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}());
never executed: tokens << ([]() -> QString { enum { Size = sizeof(u"" "plus")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "plus" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
0
201 else if (keyName == QLatin1String("-")
keyName == QLatin1String("-")Description
TRUEnever evaluated
FALSEnever evaluated
)
0
202 tokens << ([]() -> QString { enum { Size = sizeof(u"" "minus")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "minus" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}());
never executed: tokens << ([]() -> QString { enum { Size = sizeof(u"" "minus")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "minus" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
0
203 else-
204 tokens << keyName;
never executed: tokens << keyName;
0
205 shortcut << tokens;-
206 }
never executed: end of block
0
207 return
never executed: return shortcut;
shortcut;
never executed: return shortcut;
0
208}-
209-
210const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuEvent &ev)-
211{-
212 arg.beginStructure();-
213 arg << ev.m_id << ev.m_eventId << ev.m_data << ev.m_timestamp;-
214 arg.endStructure();-
215 return
never executed: return arg;
arg;
never executed: return arg;
0
216}-
217-
218const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuEvent &ev)-
219{-
220 arg.beginStructure();-
221 arg >> ev.m_id >> ev.m_eventId >> ev.m_data >> ev.m_timestamp;-
222 arg.endStructure();-
223 return
never executed: return arg;
arg;
never executed: return arg;
0
224}-
225-
226-
227QDebug operator<<(QDebug d, const QDBusMenuItem &item)-
228{-
229 QDebugStateSaver saver(d);-
230 d.nospace();-
231 d << "QDBusMenuItem(id=" << item.m_id << ", properties=" << item.m_properties << ')';-
232 return
never executed: return d;
d;
never executed: return d;
0
233}-
234-
235QDebug operator<<(QDebug d, const QDBusMenuLayoutItem &item)-
236{-
237 QDebugStateSaver saver(d);-
238 d.nospace();-
239 d << "QDBusMenuLayoutItem(id=" << item.m_id << ", properties=" << item.m_properties << ", " << item.m_children.count() << " children)";-
240 return
never executed: return d;
d;
never executed: return d;
0
241}-
242-
243-
244-
Switch to Source codePreprocessed file

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