Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdbusviewer.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#include "qdbusviewer.h"
5#include "qdbusmodel.h"
8#include "logviewer.h"
9
10#include <QtWidgets/QLineEdit>
11#include <QtWidgets/QVBoxLayout>
12#include <QtWidgets/QSplitter>
13#include <QtWidgets/QInputDialog>
14#include <QtWidgets/QMessageBox>
15#include <QtWidgets/QMenu>
16#include <QtWidgets/QTableWidget>
17#include <QtWidgets/QTreeWidget>
18#include <QtWidgets/QHeaderView>
19
20#include <QtDBus/QDBusConnectionInterface>
21#include <QtDBus/QDBusInterface>
22#include <QtDBus/QDBusMetaType>
23#include <QtDBus/QDBusServiceWatcher>
24
25#include <QtGui/QAction>
26#include <QtGui/QClipboard>
27#include <QtGui/QKeyEvent>
28#include <QtGui/QShortcut>
29
30#include <QtCore/QStringListModel>
31#include <QtCore/QMetaProperty>
32#include <QtCore/QSettings>
33
34#include <private/qdbusutil_p.h>
35
36using namespace Qt::StringLiterals;
37
38// Use enum for context menu's QAction::data to avoid collisions
51
53{
54public:
55 inline QDBusViewModel(const QString &service, const QDBusConnection &connection)
56 : QDBusModel(service, connection)
57 {}
58
59 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
60 {
61 if (role == Qt::FontRole && itemType(index) == InterfaceItem) {
62 QFont f;
63 f.setItalic(true);
64 return f;
65 }
66 return QDBusModel::data(index, role);
67 }
68};
69
71{
72public:
73 explicit ServicesModel(QObject *parent = nullptr)
75 {}
76
77 Qt::ItemFlags flags(const QModelIndex &index) const override
78 {
79 return QStringListModel::flags(index) & ~Qt::ItemIsEditable;
80 }
81};
82
83QDBusViewer::QDBusViewer(const QDBusConnection &connection, QWidget *parent)
84 : QWidget(parent), c(connection), objectPathRegExp("\\‍[ObjectPath: (.*)\\‍]"_L1)
85{
86 serviceFilterLine = new QLineEdit(this);
87 serviceFilterLine->setPlaceholderText(tr("Search..."));
88 serviceFilterLine->setClearButtonEnabled(true);
89
90 // Create model for services list
91 servicesModel = new ServicesModel(this);
92 // Wrap service list model in proxy for easy filtering and interactive sorting
93 servicesProxyModel = new ServicesProxyModel(this);
94 servicesProxyModel->setSourceModel(servicesModel);
95 servicesProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
96
97 servicesView = new QTableView(this);
98 servicesView->installEventFilter(this);
99 servicesView->setModel(servicesProxyModel);
100 // Make services grid view behave like a list view with headers
101 servicesView->verticalHeader()->hide();
102 servicesView->horizontalHeader()->setStretchLastSection(true);
103 servicesView->setShowGrid(false);
104 // Sort service list by default
105 servicesView->setSortingEnabled(true);
106 servicesView->sortByColumn(0, Qt::AscendingOrder);
107 servicesView->setContextMenuPolicy(Qt::CustomContextMenu);
108 connect(servicesView, &QWidget::customContextMenuRequested, this, &QDBusViewer::showServicesViewContextMenu);
109
110 connect(serviceFilterLine, &QLineEdit::textChanged, servicesProxyModel, &QSortFilterProxyModel::setFilterFixedString);
111 connect(serviceFilterLine, &QLineEdit::returnPressed, this, &QDBusViewer::serviceFilterReturnPressed);
112
113 tree = new QTreeView;
114 tree->setContextMenuPolicy(Qt::CustomContextMenu);
115 connect(tree, &QWidget::customContextMenuRequested, this, &QDBusViewer::showTreeViewContextMenu);
116 connect(tree, &QAbstractItemView::activated, this, &QDBusViewer::activate);
117
118 refreshChildrenAction = new QAction(tr("&Refresh"), this);
119 refreshChildrenAction->setData(ACTION_DATA_REFRESH_CHILDREN);
120 refreshChildrenAction->setShortcut(QKeySequence::Refresh);
121 connect(refreshChildrenAction, &QAction::triggered, this, &QDBusViewer::refreshChildren);
122
123 QShortcut *refreshShortcut = new QShortcut(QKeySequence::Refresh, this);
124 connect(refreshShortcut, &QShortcut::activated, this, &QDBusViewer::refreshChildren);
125
126 copyServiceNameAction = new QAction(tr("&Copy Service Name"), this);
127 copyServiceNameAction->setData(ACTION_DATA_COPY_SERVICE_NAME);
128 copyServiceNameAction->setShortcut(QKeySequence::Copy);
129
130 copyObjectPathAction = new QAction(tr("&Copy Object Path"), this);
131 copyObjectPathAction->setData(ACTION_DATA_COPY_OBJECT_PATH);
132 copyInterfaceNameAction = new QAction(tr("Copy &Interface Name"), this);
133 copyInterfaceNameAction->setData(ACTION_DATA_COPY_INTERFACE_NAME);
134 // Mutually exclusive actions share the same data tag
135 copyMemberSignalNameAction = new QAction(tr("Copy Signal &Name"), this);
136 copyMemberSignalNameAction->setData(ACTION_DATA_COPY_MEMBER_NAME);
137 copyMemberMethodNameAction = new QAction(tr("Copy Method &Name"), this);
138 copyMemberMethodNameAction->setData(ACTION_DATA_COPY_MEMBER_NAME);
139 copyMemberPropertyNameAction = new QAction(tr("Copy Property &Name"), this);
140 copyMemberPropertyNameAction->setData(ACTION_DATA_COPY_MEMBER_NAME);
141
142 connectAction = new QAction(tr("&Connect"), this);
143 connectAction->setData(ACTION_DATA_CONNECT);
144 callAction = new QAction(tr("&Call"), this);
145 callAction->setData(ACTION_DATA_CALL);
146
147 QVBoxLayout *layout = new QVBoxLayout(this);
148 topSplitter = new QSplitter(Qt::Vertical, this);
149 layout->addWidget(topSplitter);
150
151 log = new LogViewer;
152 connect(log, &QTextBrowser::anchorClicked, this, &QDBusViewer::anchorClicked);
153
154 splitter = new QSplitter(topSplitter);
155 splitter->addWidget(servicesView);
156
157 QWidget *servicesWidget = new QWidget;
158 QVBoxLayout *servicesLayout = new QVBoxLayout(servicesWidget);
159 servicesLayout->setContentsMargins(QMargins());
160 servicesLayout->addWidget(serviceFilterLine);
161 servicesLayout->addWidget(servicesView);
162 splitter->addWidget(servicesWidget);
163 splitter->addWidget(tree);
164
165 topSplitter->addWidget(splitter);
166 topSplitter->addWidget(log);
167
168 connect(servicesView->selectionModel(), &QItemSelectionModel::currentChanged, this, &QDBusViewer::serviceChanged);
169
170 QMetaObject::invokeMethod(this, &QDBusViewer::refresh, Qt::QueuedConnection);
171
172 if (c.isConnected()) {
173 QDBusServiceWatcher *watcher =
174 new QDBusServiceWatcher("*", c, QDBusServiceWatcher::WatchForOwnerChange, this);
175 connect(watcher, &QDBusServiceWatcher::serviceOwnerChanged, this,
176 &QDBusViewer::serviceOwnerChanged);
177 logMessage(tr("Connected to D-Bus."));
178 } else {
179 logError(tr("Cannot connect to D-Bus: %1").arg(c.lastError().message()));
180 }
181
182 objectPathRegExp.setPatternOptions(QRegularExpression::InvertedGreedinessOption);
183}
184
186{
187 return u"topSplitterState"_s;
188}
189
191{
192 return u"splitterState"_s;
193}
194
195void QDBusViewer::saveState(QSettings *settings) const
196{
197 settings->setValue(topSplitterStateKey(), topSplitter->saveState());
198 settings->setValue(splitterStateKey(), splitter->saveState());
199}
200
201void QDBusViewer::restoreState(const QSettings *settings)
202{
203 topSplitter->restoreState(settings->value(topSplitterStateKey()).toByteArray());
204 splitter->restoreState(settings->value(splitterStateKey()).toByteArray());
205}
206
207void QDBusViewer::logMessage(const QString &msg)
208{
209 log->append(msg + '\n'_L1);
210}
211
212void QDBusViewer::showEvent(QShowEvent *)
213{
214 serviceFilterLine->setFocus();
215}
216
217bool QDBusViewer::eventFilter(QObject *obj, QEvent *event)
218{
219 if (obj == servicesView) {
220 if (event->type() == QEvent::KeyPress) {
221 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
222 if (keyEvent->modifiers() == Qt::NoModifier) {
223 if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) {
224 tree->setFocus();
225 }
226 }
227 }
228 }
229 return false;
230}
231
232void QDBusViewer::logError(const QString &msg)
233{
234 log->append(tr("<font color=\"red\">Error: </font>%1<br>").arg(msg.toHtmlEscaped()));
235}
236
237void QDBusViewer::refresh()
238{
239 servicesModel->removeRows(0, servicesModel->rowCount());
240
241 if (c.isConnected()) {
242 const QStringList serviceNames = c.interface()->registeredServiceNames();
243 servicesModel->setStringList(serviceNames);
244 }
245}
246
247void QDBusViewer::activate(const QModelIndex &item)
248{
249 if (!item.isValid())
250 return;
251
252 const QDBusModel *model = static_cast<const QDBusModel *>(item.model());
253
254 BusSignature sig;
255 sig.mService = currentService;
256 sig.mPath = model->dBusPath(item);
257 sig.mInterface = model->dBusInterface(item);
258 sig.mName = model->dBusMethodName(item);
259 sig.mTypeSig = model->dBusTypeSignature(item);
260
261 switch (model->itemType(item)) {
262 case QDBusModel::SignalItem:
263 connectionRequested(sig);
264 break;
265 case QDBusModel::MethodItem:
266 callMethod(sig);
267 break;
268 case QDBusModel::PropertyItem:
269 getProperty(sig);
270 break;
271 default:
272 break;
273 }
274}
275
276void QDBusViewer::getProperty(const BusSignature &sig)
277{
278 QDBusMessage message = QDBusMessage::createMethodCall(
279 sig.mService, sig.mPath, "org.freedesktop.DBus.Properties"_L1, "Get"_L1);
280 QList<QVariant> arguments;
281 arguments << sig.mInterface << sig.mName;
282 message.setArguments(arguments);
283 c.callWithCallback(message, this, SLOT(dumpMessage(QDBusMessage)), SLOT(dumpError(QDBusError)));
284}
285
286void QDBusViewer::setProperty(const BusSignature &sig)
287{
288 QDBusInterface iface(sig.mService, sig.mPath, sig.mInterface, c);
289 const int index = iface.metaObject()->indexOfProperty(sig.mName.toLatin1().constData());
290 QMetaProperty prop = iface.metaObject()->property(index);
291
292 bool ok;
293 QString input = QInputDialog::getText(this, tr("Arguments"),
294 tr("Please enter the value of the property %1 (type %2)").arg(
295 sig.mName, QString::fromLatin1(prop.typeName())),
296 QLineEdit::Normal, QString(), &ok);
297 if (!ok)
298 return;
299
300 QVariant value = input;
301 if (!value.convert(prop.metaType())) {
302 QMessageBox::warning(this, tr("Unable to marshall"),
303 tr("Value conversion failed, unable to set property"));
304 return;
305 }
306
307 QDBusMessage message = QDBusMessage::createMethodCall(
308 sig.mService, sig.mPath, "org.freedesktop.DBus.Properties"_L1, "Set"_L1);
309 QList<QVariant> arguments;
310 arguments << sig.mInterface << sig.mName << QVariant::fromValue(QDBusVariant(value));
311 message.setArguments(arguments);
312 c.callWithCallback(message, this, SLOT(dumpMessage(QDBusMessage)), SLOT(dumpError(QDBusError)));
313}
314
315static QString getDbusSignature(const QMetaMethod& method)
316{
317 // create a D-Bus type signature from QMetaMethod's parameters
318 QString sig;
319 for (const auto &type : method.parameterTypes())
320 sig.append(QString::fromLatin1(QDBusMetaType::typeToSignature(QMetaType::fromName(type))));
321 return sig;
322}
323
324void QDBusViewer::callMethod(const BusSignature &sig)
325{
326 QDBusInterface iface(sig.mService, sig.mPath, sig.mInterface, c);
327 const QMetaObject *mo = iface.metaObject();
328
329 // find the method
330 QMetaMethod method;
331 for (int i = 0; i < mo->methodCount(); ++i) {
332 const QString signature = QString::fromLatin1(mo->method(i).methodSignature());
333 if (signature.startsWith(sig.mName) && signature.at(sig.mName.size()) == '('_L1)
334 if (getDbusSignature(mo->method(i)) == sig.mTypeSig)
335 method = mo->method(i);
336 }
337 if (!method.isValid()) {
338 QMessageBox::warning(this, tr("Unable to find method"),
339 tr("Unable to find method %1 on path %2 in interface %3").arg(
340 sig.mName).arg(sig.mPath).arg(sig.mInterface));
341 return;
342 }
343
344 PropertyDialog dialog;
345 QList<QVariant> args;
346
347 const QList<QByteArray> paramTypes = method.parameterTypes();
348 const QList<QByteArray> paramNames = method.parameterNames();
349 QList<int> types; // remember the low-level D-Bus type
350 for (int i = 0; i < paramTypes.size(); ++i) {
351 const QByteArray paramType = paramTypes.at(i);
352 if (paramType.endsWith('&'))
353 continue; // ignore OUT parameters
354
355 const int type = QMetaType::fromName(paramType).id();
356 dialog.addProperty(QString::fromLatin1(paramNames.value(i)), type);
357 types.append(type);
358 }
359
360 if (!types.isEmpty()) {
361 dialog.setInfo(tr("Please enter parameters for the method \"%1\"").arg(sig.mName));
362
363 if (dialog.exec() != QDialog::Accepted)
364 return;
365
366 args = dialog.values();
367 }
368
369 // Try to convert the values we got as closely as possible to the
370 // dbus signature. This is especially important for those input as strings
371 for (int i = 0; i < args.size(); ++i) {
372 QVariant a = args.at(i);
373 int desttype = types.at(i);
374 if (desttype < int(QMetaType::User) && desttype != qMetaTypeId<QVariantMap>()) {
375 const QMetaType metaType(desttype);
376 if (a.canConvert(metaType))
377 args[i].convert(metaType);
378 }
379 // Special case - convert a value to a QDBusVariant if the
380 // interface wants a variant
381 if (types.at(i) == qMetaTypeId<QDBusVariant>())
382 args[i] = QVariant::fromValue(QDBusVariant(args.at(i)));
383 }
384
385 QDBusMessage message = QDBusMessage::createMethodCall(sig.mService, sig.mPath, sig.mInterface,
386 sig.mName);
387 message.setArguments(args);
388 c.callWithCallback(message, this, SLOT(dumpMessage(QDBusMessage)), SLOT(dumpError(QDBusError)));
389}
390
391void QDBusViewer::showServicesViewContextMenu(const QPoint &point)
392{
393 QModelIndex item = servicesView->indexAt(point);
394 if (!item.isValid())
395 return;
396
397 const QString serviceName = item.data().toString();
398
399 QMenu menu;
400 // servicesView doesn't need a manual refresh action, because the model updates automatically
401 menu.addAction(copyServiceNameAction);
402
403 QAction *selectedAction = menu.exec(servicesView->viewport()->mapToGlobal(point));
404 if (!selectedAction)
405 return;
406
407 switch (selectedAction->data().toInt()) {
408 case ACTION_DATA_COPY_SERVICE_NAME:
409 QGuiApplication::clipboard()->setText(serviceName);
410 break;
411 default:
412 break;
413 }
414}
415
416void QDBusViewer::showTreeViewContextMenu(const QPoint &point)
417{
418 QModelIndex item = tree->indexAt(point);
419 if (!item.isValid())
420 return;
421
422 const QDBusModel *model = static_cast<const QDBusModel *>(item.model());
423
424 auto itemType = model->itemType(item);
425
426 BusSignature sig;
427 sig.mService = currentService;
428 sig.mPath = model->dBusPath(item);
429 sig.mInterface = model->dBusInterface(item);
430 sig.mName = model->dBusMethodName(item);
431 sig.mTypeSig = model->dBusTypeSignature(item);
432
433 QMenu menu;
434 menu.addAction(refreshChildrenAction);
435
436 // Object path is applicable to all types of items
437 menu.addAction(copyObjectPathAction);
438
439 // Interface name is applicable to interfaces and members
440 switch (itemType) {
441 case QDBusModel::InterfaceItem:
442 case QDBusModel::SignalItem:
443 case QDBusModel::MethodItem:
444 case QDBusModel::PropertyItem:
445 menu.addAction(copyInterfaceNameAction);
446 break;
447 default:
448 break;
449 }
450
451 switch (itemType) {
452 case QDBusModel::SignalItem: {
453 menu.addAction(copyMemberSignalNameAction);
454 menu.addAction(connectAction);
455 break; }
456 case QDBusModel::MethodItem: {
457 menu.addAction(copyMemberMethodNameAction);
458 menu.addAction(callAction);
459 break; }
460 case QDBusModel::PropertyItem: {
461 menu.addAction(copyMemberPropertyNameAction);
462 QDBusInterface iface(sig.mService, sig.mPath, sig.mInterface, c);
463 const int index = iface.metaObject()->indexOfProperty(sig.mName.toLatin1().constData());
464 QMetaProperty prop = iface.metaObject()->property(index);
465 QAction *actionSet = new QAction(tr("&Set value"), &menu);
466 actionSet->setData(ACTION_DATA_SET_PROPERTY);
467 actionSet->setEnabled(prop.isWritable());
468 QAction *actionGet = new QAction(tr("&Get value"), &menu);
469 actionGet->setEnabled(prop.isReadable());
470 actionGet->setData(ACTION_DATA_GET_PROPERTY);
471 menu.addAction(actionSet);
472 menu.addAction(actionGet);
473 break; }
474 default:
475 break;
476 }
477
478 QAction *selectedAction = menu.exec(tree->viewport()->mapToGlobal(point));
479 if (!selectedAction)
480 return;
481
482 switch (selectedAction->data().toInt()) {
483 case ACTION_DATA_COPY_OBJECT_PATH:
484 QGuiApplication::clipboard()->setText(sig.mPath);
485 break;
486 case ACTION_DATA_COPY_INTERFACE_NAME:
487 QGuiApplication::clipboard()->setText(sig.mInterface);
488 break;
489 case ACTION_DATA_COPY_MEMBER_NAME:
490 QGuiApplication::clipboard()->setText(sig.mName);
491 break;
492 case ACTION_DATA_CONNECT:
493 connectionRequested(sig);
494 break;
495 case ACTION_DATA_CALL:
496 callMethod(sig);
497 break;
498 case ACTION_DATA_SET_PROPERTY:
499 setProperty(sig);
500 break;
501 case ACTION_DATA_GET_PROPERTY:
502 getProperty(sig);
503 break;
504 default:
505 break;
506 }
507}
508
509void QDBusViewer::connectionRequested(const BusSignature &sig)
510{
511 if (c.connect(sig.mService, QString(), sig.mInterface, sig.mName, this,
512 SLOT(dumpMessage(QDBusMessage)))) {
513 logMessage(tr("Connected to service %1, path %2, interface %3, signal %4").arg(
514 sig.mService, sig.mPath, sig.mInterface, sig.mName));
515 } else {
516 logError(tr("Unable to connect to service %1, path %2, interface %3, signal %4").arg(
517 sig.mService, sig.mPath, sig.mInterface, sig.mName));
518 }
519}
520
521void QDBusViewer::dumpMessage(const QDBusMessage &message)
522{
523 QList<QVariant> args = message.arguments();
524
525 QString messageType;
526 switch (message.type()) {
527 case QDBusMessage::SignalMessage:
528 messageType = tr("signal");
529 break;
530 case QDBusMessage::ErrorMessage:
531 messageType = tr("error message");
532 break;
533 case QDBusMessage::ReplyMessage:
534 messageType = tr("reply");
535 break;
536 default:
537 messageType = tr("message");
538 break;
539 }
540
541 QString out = tr("Received %1 from %2").arg(messageType).arg(message.service());
542
543 if (!message.path().isEmpty())
544 out += tr(", path %1").arg(message.path());
545 if (!message.interface().isEmpty())
546 out += tr(", interface <i>%1</i>").arg(message.interface());
547 if (!message.member().isEmpty())
548 out += tr(", member %1").arg(message.member());
549 out += "<br>"_L1;
550 if (args.isEmpty()) {
551 out += tr("&nbsp;&nbsp;(no arguments)");
552 } else {
553 QStringList argStrings;
554 for (const QVariant &arg : std::as_const(args)) {
555 QString str = QDBusUtil::argumentToString(arg).toHtmlEscaped();
556 // turn object paths into clickable links
557 str.replace(objectPathRegExp, tr("[ObjectPath: <a href=\"qdbus://bus\\1\">\\1</a>]"));
558 // convert new lines from command to proper HTML line breaks
559 str.replace("\n"_L1, "<br/>"_L1);
560 argStrings.append(str);
561 }
562 out += tr("&nbsp;&nbsp;Arguments: %1").arg(argStrings.join(tr(", ")));
563 }
564
565 log->append(out);
566}
567
568void QDBusViewer::dumpError(const QDBusError &error)
569{
570 logError(error.message());
571}
572
573void QDBusViewer::serviceChanged(const QModelIndex &index)
574{
575 delete tree->model();
576
577 currentService.clear();
578 if (!index.isValid())
579 return;
580 currentService = index.data().toString();
581
582 QDBusViewModel *model = new QDBusViewModel(currentService, c);
583 tree->setModel(model);
584 connect(model, &QDBusModel::busError, this, &QDBusViewer::logError);
585}
586
587void QDBusViewer::serviceRegistered(const QString &service)
588{
589 if (service == c.baseService())
590 return;
591
592 servicesModel->insertRows(0, 1);
593 servicesModel->setData(servicesModel->index(0, 0), service);
594}
595
596static QModelIndex findItem(QStringListModel *servicesModel, const QString &name)
597{
598 QModelIndexList hits = servicesModel->match(servicesModel->index(0, 0), Qt::DisplayRole, name);
599 if (hits.isEmpty())
600 return QModelIndex();
601
602 return hits.first();
603}
604
605void QDBusViewer::serviceOwnerChanged(const QString &name, const QString &oldOwner,
606 const QString &newOwner)
607{
608 QModelIndex hit = findItem(servicesModel, name);
609
610 if (!hit.isValid() && oldOwner.isEmpty() && !newOwner.isEmpty())
611 serviceRegistered(name);
612 else if (hit.isValid() && !oldOwner.isEmpty() && newOwner.isEmpty())
613 servicesModel->removeRows(hit.row(), 1);
614 else if (hit.isValid() && !oldOwner.isEmpty() && !newOwner.isEmpty()) {
615 servicesModel->removeRows(hit.row(), 1);
616 serviceRegistered(name);
617 }
618}
619
620void QDBusViewer::serviceFilterReturnPressed()
621{
622 if (servicesProxyModel->rowCount() <= 0)
623 return;
624
625 servicesView->selectRow(0);
626 servicesView->setFocus();
627}
628
629void QDBusViewer::refreshChildren()
630{
631 QDBusModel *model = qobject_cast<QDBusModel *>(tree->model());
632 if (!model)
633 return;
634 model->refresh(tree->currentIndex());
635}
636
637void QDBusViewer::anchorClicked(const QUrl &url)
638{
639 if (url.scheme() != "qdbus"_L1)
640 // not ours
641 return;
642
643 // swallow the click without setting a new document
644 log->setSource(QUrl());
645
646 QDBusModel *model = qobject_cast<QDBusModel *>(tree->model());
647 if (!model)
648 return;
649
650 QModelIndex idx = model->findObject(QDBusObjectPath(url.path()));
651 if (!idx.isValid())
652 return;
653
654 tree->scrollTo(idx);
655 tree->setCurrentIndex(idx);
656}
QDBusViewModel(const QString &service, const QDBusConnection &connection)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns the data stored under the given role for the item referred to by the index.
bool eventFilter(QObject *obj, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
void saveState(QSettings *settings) const
void restoreState(const QSettings *settings)
void showEvent(QShowEvent *) override
This event handler can be reimplemented in a subclass to receive widget show events which are passed ...
ServicesModel(QObject *parent=nullptr)
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the flags for the item with the given index.
static QString topSplitterStateKey()
static QString getDbusSignature(const QMetaMethod &method)
DBusActionData
@ ACTION_DATA_CONNECT
@ ACTION_DATA_COPY_SERVICE_NAME
@ ACTION_DATA_SET_PROPERTY
@ ACTION_DATA_COPY_MEMBER_NAME
@ ACTION_DATA_CALL
@ ACTION_DATA_COPY_OBJECT_PATH
@ ACTION_DATA_GET_PROPERTY
@ ACTION_DATA_COPY_INTERFACE_NAME
@ ACTION_DATA_REFRESH_CHILDREN
static QString splitterStateKey()
static QModelIndex findItem(QStringListModel *servicesModel, const QString &name)