1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the tools applications of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#ifndef QDBUSVIEWER_H
30#define QDBUSVIEWER_H
31
32#include <QtWidgets/QWidget>
33#include <QtDBus/QDBusConnection>
34#include <QtCore/QRegExp>
35
36class ServicesProxyModel;
37
38QT_FORWARD_DECLARE_CLASS(QTableView)
39QT_FORWARD_DECLARE_CLASS(QTreeView)
40QT_FORWARD_DECLARE_CLASS(QTreeWidget)
41QT_FORWARD_DECLARE_CLASS(QStringListModel)
42QT_FORWARD_DECLARE_CLASS(QLineEdit)
43QT_FORWARD_DECLARE_CLASS(QTextBrowser)
44QT_FORWARD_DECLARE_CLASS(QDomDocument)
45QT_FORWARD_DECLARE_CLASS(QDomElement)
46QT_FORWARD_DECLARE_CLASS(QSplitter)
47QT_FORWARD_DECLARE_CLASS(QSettings)
48
49struct BusSignature
50{
51 QString mService, mPath, mInterface, mName;
52 QString mTypeSig;
53};
54
55class QDBusViewer: public QWidget
56{
57 Q_OBJECT
58public:
59 QDBusViewer(const QDBusConnection &connection, QWidget *parent = 0);
60
61 void saveState(QSettings *settings) const;
62 void restoreState(const QSettings *settings);
63
64public slots:
65 void refresh();
66
67private slots:
68 void serviceChanged(const QModelIndex &index);
69 void showContextMenu(const QPoint &);
70 void connectionRequested(const BusSignature &sig);
71 void callMethod(const BusSignature &sig);
72 void getProperty(const BusSignature &sig);
73 void setProperty(const BusSignature &sig);
74 void dumpMessage(const QDBusMessage &msg);
75 void refreshChildren();
76
77 void serviceRegistered(const QString &service);
78 void serviceUnregistered(const QString &service);
79 void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
80
81 void serviceFilterReturnPressed();
82 void activate(const QModelIndex &item);
83
84 void logError(const QString &msg);
85 void anchorClicked(const QUrl &url);
86
87private:
88 void logMessage(const QString &msg);
89 void showEvent(QShowEvent *) override;
90 bool eventFilter(QObject *obj, QEvent *event) override;
91
92 QDBusConnection c;
93 QString currentService;
94 QTreeView *tree;
95 QAction *refreshAction;
96 QTreeWidget *services;
97 QStringListModel *servicesModel;
98 ServicesProxyModel *servicesProxyModel;
99 QLineEdit *serviceFilterLine;
100 QTableView *servicesView;
101 QTextBrowser *log;
102 QSplitter *topSplitter;
103 QSplitter *splitter;
104 QRegExp objectPathRegExp;
105};
106
107#endif
108

source code of qttools/src/qdbus/qdbusviewer/qdbusviewer.h