| 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 | , m_hasExclusiveGroup(false) | - | ||||||
| 21 | { | - | ||||||
| 22 | menuItemsByID.insert(m_dbusID, this); | - | ||||||
| 23 | } never executed: end of block | 0 | ||||||
| 24 | - | |||||||
| 25 | QDBusPlatformMenuItem::~QDBusPlatformMenuItem() | - | ||||||
| 26 | { | - | ||||||
| 27 | menuItemsByID.remove(m_dbusID); | - | ||||||
| 28 | if (m_subMenu
| 0 | ||||||
| 29 | 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 | ||||||
| 30 | } never executed: end of block | 0 | ||||||
| 31 | - | |||||||
| 32 | void QDBusPlatformMenuItem::setTag(quintptr tag) | - | ||||||
| 33 | { | - | ||||||
| 34 | m_tag = tag; | - | ||||||
| 35 | } never executed: end of block | 0 | ||||||
| 36 | - | |||||||
| 37 | void QDBusPlatformMenuItem::setText(const QString &text) | - | ||||||
| 38 | { | - | ||||||
| 39 | for (bool qt_category_enabled = qLcMenu().isDebugEnabled(); qt_category_enabled
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 | - | |||||||
| 43 | void QDBusPlatformMenuItem::setIcon(const QIcon &icon) | - | ||||||
| 44 | { | - | ||||||
| 45 | m_icon = icon; | - | ||||||
| 46 | } never executed: end of block | 0 | ||||||
| 47 | - | |||||||
| 48 | - | |||||||
| 49 | - | |||||||
| 50 | - | |||||||
| 51 | void QDBusPlatformMenuItem::setMenu(QPlatformMenu *menu) | - | ||||||
| 52 | { | - | ||||||
| 53 | if (m_subMenu
| 0 | ||||||
| 54 | 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 | ||||||
| 55 | m_subMenu = menu; | - | ||||||
| 56 | if (menu
| 0 | ||||||
| 57 | static_cast< never executed: QDBusPlatformMenu *>(menu)->setContainingMenuItem(this);static_cast<QDBusPlatformMenu *>(menu)->setContainingMenuItem(this);never executed: static_cast<QDBusPlatformMenu *>(menu)->setContainingMenuItem(this); | 0 | ||||||
| 58 | } never executed: end of block | 0 | ||||||
| 59 | - | |||||||
| 60 | void QDBusPlatformMenuItem::setEnabled(bool enabled) | - | ||||||
| 61 | { | - | ||||||
| 62 | m_isEnabled = enabled; | - | ||||||
| 63 | } never executed: end of block | 0 | ||||||
| 64 | - | |||||||
| 65 | void QDBusPlatformMenuItem::setVisible(bool isVisible) | - | ||||||
| 66 | { | - | ||||||
| 67 | m_isVisible = isVisible; | - | ||||||
| 68 | } never executed: end of block | 0 | ||||||
| 69 | - | |||||||
| 70 | void QDBusPlatformMenuItem::setIsSeparator(bool isSeparator) | - | ||||||
| 71 | { | - | ||||||
| 72 | m_isSeparator = isSeparator; | - | ||||||
| 73 | } never executed: end of block | 0 | ||||||
| 74 | - | |||||||
| 75 | void QDBusPlatformMenuItem::setRole(QPlatformMenuItem::MenuRole role) | - | ||||||
| 76 | { | - | ||||||
| 77 | m_role = role; | - | ||||||
| 78 | } never executed: end of block | 0 | ||||||
| 79 | - | |||||||
| 80 | void QDBusPlatformMenuItem::setCheckable(bool checkable) | - | ||||||
| 81 | { | - | ||||||
| 82 | m_isCheckable = checkable; | - | ||||||
| 83 | } never executed: end of block | 0 | ||||||
| 84 | - | |||||||
| 85 | void QDBusPlatformMenuItem::setChecked(bool isChecked) | - | ||||||
| 86 | { | - | ||||||
| 87 | m_isChecked = isChecked; | - | ||||||
| 88 | } never executed: end of block | 0 | ||||||
| 89 | - | |||||||
| 90 | void QDBusPlatformMenuItem::setHasExclusiveGroup(bool hasExclusiveGroup) | - | ||||||
| 91 | { | - | ||||||
| 92 | m_hasExclusiveGroup = hasExclusiveGroup; | - | ||||||
| 93 | } never executed: end of block | 0 | ||||||
| 94 | - | |||||||
| 95 | void QDBusPlatformMenuItem::setShortcut(const QKeySequence &shortcut) | - | ||||||
| 96 | { | - | ||||||
| 97 | m_shortcut = shortcut; | - | ||||||
| 98 | } never executed: end of block | 0 | ||||||
| 99 | - | |||||||
| 100 | void QDBusPlatformMenuItem::trigger() | - | ||||||
| 101 | { | - | ||||||
| 102 | activated(); | - | ||||||
| 103 | } never executed: end of block | 0 | ||||||
| 104 | - | |||||||
| 105 | QDBusPlatformMenuItem *QDBusPlatformMenuItem::byId(int id) | - | ||||||
| 106 | { | - | ||||||
| 107 | - | |||||||
| 108 | - | |||||||
| 109 | if (menuItemsByID.contains(id)
| 0 | ||||||
| 110 | return never executed: menuItemsByID[id];return menuItemsByID[id];never executed: return menuItemsByID[id]; | 0 | ||||||
| 111 | return never executed: nullptr;return nullptr;never executed: return nullptr; | 0 | ||||||
| 112 | } | - | ||||||
| 113 | - | |||||||
| 114 | QList<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)
| 0 | ||||||
| 119 | ret << menuItemsByID[id]; never executed: ret << menuItemsByID[id]; | 0 | ||||||
| 120 | } never executed: end of block | 0 | ||||||
| 121 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||
| 122 | } | - | ||||||
| 123 | - | |||||||
| 124 | - | |||||||
| 125 | QDBusPlatformMenu::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 | - | |||||||
| 135 | QDBusPlatformMenu::~QDBusPlatformMenu() | - | ||||||
| 136 | { | - | ||||||
| 137 | if (m_containingMenuItem
| 0 | ||||||
| 138 | m_containingMenuItem->setMenu(nullptr); never executed: m_containingMenuItem->setMenu(nullptr); | 0 | ||||||
| 139 | } never executed: end of block | 0 | ||||||
| 140 | - | |||||||
| 141 | void 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
never executed: QMessageLogger(__FILE__, 188, __PRETTY_FUNCTION__, qLcMenu().categoryName()).debug() << item->dbusID() << item->text(); | 0 | ||||||
| 147 | if (idx < 0
| 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()
| 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 | - | |||||||
| 157 | void 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()
| 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 | - | |||||||
| 173 | void 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 | - | |||||||
| 183 | void QDBusPlatformMenu::syncMenuItem(QPlatformMenuItem *menuItem) | - | ||||||
| 184 | { | - | ||||||
| 185 | QDBusPlatformMenuItem *item = static_cast<QDBusPlatformMenuItem *>(menuItem); | - | ||||||
| 186 | - | |||||||
| 187 | if (item->menu()
| 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
never executed: QMessageLogger(__FILE__, 237, __PRETTY_FUNCTION__, qLcMenu().categoryName()).debug() << updated; | 0 | ||||||
| 196 | propertiesUpdated(updated, removed); | - | ||||||
| 197 | } never executed: end of block | 0 | ||||||
| 198 | - | |||||||
| 199 | void QDBusPlatformMenu::emitUpdated() | - | ||||||
| 200 | { | - | ||||||
| 201 | if (m_containingMenuItem
| 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 | - | |||||||
| 207 | void QDBusPlatformMenu::setTag(quintptr tag) | - | ||||||
| 208 | { | - | ||||||
| 209 | m_tag = tag; | - | ||||||
| 210 | } never executed: end of block | 0 | ||||||
| 211 | - | |||||||
| 212 | void QDBusPlatformMenu::setText(const QString &text) | - | ||||||
| 213 | { | - | ||||||
| 214 | m_text = text; | - | ||||||
| 215 | } never executed: end of block | 0 | ||||||
| 216 | - | |||||||
| 217 | void QDBusPlatformMenu::setIcon(const QIcon &icon) | - | ||||||
| 218 | { | - | ||||||
| 219 | m_icon = icon; | - | ||||||
| 220 | } never executed: end of block | 0 | ||||||
| 221 | - | |||||||
| 222 | void QDBusPlatformMenu::setEnabled(bool enabled) | - | ||||||
| 223 | { | - | ||||||
| 224 | m_isEnabled = enabled; | - | ||||||
| 225 | } never executed: end of block | 0 | ||||||
| 226 | - | |||||||
| 227 | void QDBusPlatformMenu::setVisible(bool isVisible) | - | ||||||
| 228 | { | - | ||||||
| 229 | m_isVisible = isVisible; | - | ||||||
| 230 | } never executed: end of block | 0 | ||||||
| 231 | - | |||||||
| 232 | void QDBusPlatformMenu::setContainingMenuItem(QDBusPlatformMenuItem *item) | - | ||||||
| 233 | { | - | ||||||
| 234 | m_containingMenuItem = item; | - | ||||||
| 235 | } never executed: end of block | 0 | ||||||
| 236 | - | |||||||
| 237 | QPlatformMenuItem *QDBusPlatformMenu::menuItemAt(int position) const | - | ||||||
| 238 | { | - | ||||||
| 239 | return never executed: m_items.value(position);return m_items.value(position);never executed: return m_items.value(position); | 0 | ||||||
| 240 | } | - | ||||||
| 241 | - | |||||||
| 242 | QPlatformMenuItem *QDBusPlatformMenu::menuItemForTag(quintptr tag) const | - | ||||||
| 243 | { | - | ||||||
| 244 | return never executed: m_itemsByTag[tag];return m_itemsByTag[tag];never executed: return m_itemsByTag[tag]; | 0 | ||||||
| 245 | } | - | ||||||
| 246 | - | |||||||
| 247 | const QList<QDBusPlatformMenuItem *> QDBusPlatformMenu::items() const | - | ||||||
| 248 | { | - | ||||||
| 249 | return never executed: m_items;return m_items;never executed: return m_items; | 0 | ||||||
| 250 | } | - | ||||||
| 251 | - | |||||||
| 252 | QPlatformMenuItem *QDBusPlatformMenu::createMenuItem() const | - | ||||||
| 253 | { | - | ||||||
| 254 | QDBusPlatformMenuItem *ret = new QDBusPlatformMenuItem(); | - | ||||||
| 255 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||
| 256 | } | - | ||||||
| 257 | - | |||||||
| 258 | QPlatformMenu *QDBusPlatformMenu::createSubMenu() const | - | ||||||
| 259 | { | - | ||||||
| 260 | return never executed: new QDBusPlatformMenu;return new QDBusPlatformMenu;never executed: return new QDBusPlatformMenu; | 0 | ||||||
| 261 | } | - | ||||||
| 262 | - | |||||||
| 263 | - | |||||||
| Switch to Source code | Preprocessed file |