Debian Codegraph @

src/imports/publishsubscribe/qdeclarativevaluespacesubscriber.cpp

raw symbols SCIP
1 /****************************************************************************
2 **
3 ** Copyright (C) 2018 The Qt Company Ltd and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtSystems module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
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 Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39
40 #include "qdeclarativevaluespacesubscriber_p.h"
41
42 QT_BEGIN_NAMESPACE
43
44 /*!
45 \qmltype ValueSpaceSubscriber
46 \instantiates QDeclarativeValueSpaceSubscriber
47 \inqmlmodule QtPublishSubscribe
48 \ingroup qml-publishsubscribe
49
50 \brief The QValueSpaceSubscriber class allows applications to read and subscribe to Value Space.
51
52 Each \l ValueSpaceSubscriber element represents a single value or path in the Value Space. The
53 path is set using the \e path property.
54
55 Note that unlike the C++ class QValueSpaceSubscriber, the QML element has no default path. A path
56 must be set before the subscriber will connect to the Value Space and begin receiving notifications.
57
58 \code
59 ValueSpaceSubscriber {
60 id: nowPlaying
61 path: "/applications/mediaplayer/now-playing"
62 }
63 \endcode
64
65 The value is accessed using the \e value property:
66
67 \code
68 Text {
69 text: nowPlaying.value
70 }
71 \endcode
72 */
73
74 QDeclarativeValueSpaceSubscriber::QDeclarativeValueSpaceSubscriber()
75 : d_ptr(0)
76 {
77 }
78
79 QDeclarativeValueSpaceSubscriber::~QDeclarativeValueSpaceSubscriber()
80 {
81 }
82
83 /*!
84 \qmlproperty string ValueSpaceSubscriber::path
85
86 This property holds the base path of the subscriber, and it should be set before connecting to
87 any Value Space layers and receiving notifications.
88 */
89 void QDeclarativeValueSpaceSubscriber::setPath(QString path)
90 {
91 if (!d_ptr) {
92 d_ptr = new QValueSpaceSubscriber(path, this);
93 connect(d_ptr, SIGNAL(contentsChanged()), this, SIGNAL(contentsChanged()));
94 } else {
95 d_ptr->setPath(path);
96 emit pathChanged();
97 }
98 }
99
100 QString QDeclarativeValueSpaceSubscriber::path() const
101 {
102 if (d_ptr)
103 return d_ptr->path();
104 else
105 return QString();
106 }
107
108 /*!
109 \qmlproperty QVariant ValueSpaceSubscriber::value
110
111 This property holds the value of the key at the set path in the Value Space.
112 Read-only.
113 */
114 QVariant QDeclarativeValueSpaceSubscriber::value(const QString &subPath, const QVariant &def) const
115 {
116 if (d_ptr)
117 return d_ptr->value(subPath, def);
118 else
119 return QVariant();
120 }
121
122 /*!
123 \qmlproperty QStringList ValueSpaceSubscriber::subPaths
124
125 This property holds a list of known sub-paths of the currently set path.
126 */
127 QStringList QDeclarativeValueSpaceSubscriber::subPaths() const
128 {
129 if (d_ptr)
130 return d_ptr->subPaths();
131 else
132 return QStringList();
133 }
134
135 /*!
136 \qmlproperty bool ValueSpaceSubscriber::connected
137
138 This property holds whether the subscriber is currently connected to the
139 backing store of the Value Space.
140 */
141 bool QDeclarativeValueSpaceSubscriber::isConnected() const
142 {
143 if (d_ptr)
144 return d_ptr->isConnected();
145 else
146 return false;
147 }
148
149 QT_END_NAMESPACE