1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
|
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2019 Luxoft Sweden AB
// Copyright (C) 2018 Pelagicore AG
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qifabstractfeaturelistmodel.h"
#include "qifabstractfeaturelistmodel_p.h"
#include "qifconfiguration_p.h"
#include "qifservicemanager_p.h"
#include <QtQml/private/qqmlincubator_p.h>
QT_BEGIN_NAMESPACE
QIfHelperFeature::QIfHelperFeature(const QString &interfaceName, QIfAbstractFeatureListModel *model)
: QIfAbstractFeature(interfaceName)
, m_model(model)
{
}
bool QIfHelperFeature::acceptServiceObject(QIfServiceObject *so)
{
return m_model->acceptServiceObject(so);
}
bool QIfHelperFeature::acceptServiceObjectDefaultImpl(QIfServiceObject *so)
{
return QIfAbstractFeature::acceptServiceObject(so);
}
void QIfHelperFeature::connectToServiceObject(QIfServiceObject *so)
{
m_model->connectToServiceObject(so);
}
void QIfHelperFeature::connectToServiceObjectDefaultImpl(QIfServiceObject *so)
{
QIfAbstractFeature::connectToServiceObject(so);
}
void QIfHelperFeature::disconnectFromServiceObject(QIfServiceObject *so)
{
m_model->disconnectFromServiceObject(so);
}
void QIfHelperFeature::disconnectFromServiceObjectDefaultImpl(QIfServiceObject *so)
{
QIfAbstractFeature::disconnectFromServiceObject(so);
}
void QIfHelperFeature::clearServiceObject()
{
m_model->clearServiceObject();
}
QIfAbstractFeaturePrivate *QIfHelperFeature::ifPrivate()
{
Q_D(QIfAbstractFeature);
return d;
}
const QIfAbstractFeaturePrivate *QIfHelperFeature::ifPrivate() const
{
Q_D(const QIfAbstractFeature);
return d;
}
QIfAbstractFeatureListModelPrivate::QIfAbstractFeatureListModelPrivate(const QString &interfaceName, QIfAbstractFeatureListModel *model)
: QAbstractItemModelPrivate()
, m_feature(new QIfHelperFeature(interfaceName, model))
{
}
QIfAbstractFeatureListModelPrivate::~QIfAbstractFeatureListModelPrivate()
{
delete m_feature;
}
void QIfAbstractFeatureListModelPrivate::initialize()
{
}
QIfFeatureInterface *QIfAbstractFeatureListModelPrivate::backend() const
{
return m_feature->ifPrivate()->backend();
}
/*!
\class QIfAbstractFeatureListModel
\inmodule QtInterfaceFramework
\brief The QIfAbstractFeatureListModel is the base class for QtInterfaceFramework Features which should act as a model.
This base class is necessary to avoid virtual inheritance from QAbstractListModel and
QIfAbstractFeature.
For more details on how a Feature works, see QIfAbstractFeature.
For more information about models in QtInterfaceFramework, see \l{Models}.
\section1 Subclassing
Your QIfAbstractFeatureListModel subclass must provide implementations for all virtual
functions from QIfAbstractFeature as well as the virtual functions from QAbstractListModel.
\list
\li For more details on how to integrate with the \l{Dynamic Backend System}, see
\l{Write a Subclass}{QIfAbstractFeature}.
\li For more details on what you need to do to provide the model's required
functionality, see \l{QAbstractListModel - Subclassing}.
\li For a class that implements all the necessary QIfAbstractFeatureListModel functions
to provide pagination functionality, see QIfPagingModel.
\endlist
*/
/*!
\qmltype AbstractFeatureListModel
\nativetype QIfAbstractFeatureListModel
\inqmlmodule QtInterfaceFramework
\brief The QIfAbstractFeatureListModel is the base class for QtInterfaceFramework Features which should act as a model.
This base class is necessary to avoid virtual inheritance from QAbstractListModel and
QIfAbstractFeature.
This element is not directly accessible from QML. It provides the base QML properties for the
feature, like autoDiscovery and isValid.
For more details on how a Feature works, see QIfAbstractFeature.
For more information about models in QtInterfaceFramework, see \l{Models}.
\sa AbstractFeature
*/
/*!
\fn void QIfAbstractFeatureListModel::clearServiceObject()
This method is expected to be implemented by any class subclassing QIfAbstractFeatureListModel.
Called when no service object is available. The implementation is expected to set all
properties to safe defaults and forget all links to the previous service object.
\note You must emit the corresponding change signals for these properties, so that the feature
is informed about the state change. This makes it possible for the implemented class to connect
to a new service object afterwards.
There is no need to disconnect from the service object. If it still exists, it is guaranteed
that \l disconnectFromServiceObject is called first.
\sa acceptServiceObject(), connectToServiceObject(), disconnectFromServiceObject()
*/
/*!
Constructs a QIfAbstractFeatureListModel.
The \a parent argument is passed on to the \l QAbstractListModel base class.
The \a interfaceName argument is used to locate suitable service objects.
*/
QIfAbstractFeatureListModel::QIfAbstractFeatureListModel(const QString &interfaceName, QObject *parent)
: QIfAbstractFeatureListModel(*new QIfAbstractFeatureListModelPrivate(interfaceName, this), parent)
{
}
/*!
\qmlproperty ServiceObject AbstractFeatureListModel::serviceObject
\brief Sets the service object for the feature.
As features only expose the front API facing the developer, a service object implementing the
actual function is required. This is usually retrieved through the auto discovery mechanism.
The setter for this property returns false if the \e {Service Object} is already set to exactly this instance
or the \e {Service Object} doesn't get accepted by the feature.
\sa discoveryMode
*/
/*!
\property QIfAbstractFeatureListModel::serviceObject
\brief Sets the service object for the feature.
As features only expose the front API facing the developer, a service object implementing the
actual function is required. This is usually retrieved through the auto discovery mechanism.
The setter for this property returns false if the \e {Service Object} is already set to exactly this instance
or the \e {Service Object} doesn't get accepted by the feature.
\sa discoveryMode
*/
QIfServiceObject *QIfAbstractFeatureListModel::serviceObject() const
{
Q_D(const QIfAbstractFeatureListModel);
return d->m_feature->serviceObject();
}
/*!
\qmlproperty enumeration AbstractFeatureListModel::discoveryMode
\brief Holds the mode that is used for the autoDiscovery
Available values are:
\value NoAutoDiscovery
No auto discovery is done and the ServiceObject needs to be set manually.
\value AutoDiscovery
Tries to find a production backend with a matching interface and falls back to a simulation backend if not found.
\value LoadOnlyProductionBackends
Only tries to load a production backend with a matching interface.
\value LoadOnlySimulationBackends
Only tries to load a simulation backend with a matching interface.
If needed the auto discovery will be started once the Feature creation is completed.
\note If you change this property after the Feature is instantiated you need to call startAutoDiscovery() to search for
a new Service Object
*/
/*!
\property QIfAbstractFeatureListModel::discoveryMode
\brief Holds the mode that is used for the autoDiscovery
\note If you change this property after the Feature is instantiated you need to call startAutoDiscovery() to search for
a new Service Object
*/
QIfAbstractFeature::DiscoveryMode QIfAbstractFeatureListModel::discoveryMode() const
{
Q_D(const QIfAbstractFeatureListModel);
return d->m_feature->discoveryMode();
}
/*!
\qmlproperty enumeration AbstractFeatureListModel::discoveryResult
\brief The result of the last autoDiscovery attempt
Available values are:
\value NoResult
Indicates that no auto discovery was started because the feature already has a valid
\l ServiceObject assigned or no result could be returned as the backend is loaded
asynchronously.
\value ErrorWhileLoading
An error has happened while searching for a backend with a matching interface.
\value ProductionBackendLoaded
As a result of the auto discovery a production backend was loaded.
\value SimulationBackendLoaded
As a result of the auto discovery a simulation backend was loaded.
*/
/*!
\property QIfAbstractFeatureListModel::discoveryResult
\brief The result of the last autoDiscovery attempt
\sa startAutoDiscovery()
*/
QIfAbstractFeature::DiscoveryResult QIfAbstractFeatureListModel::discoveryResult() const
{
Q_D(const QIfAbstractFeatureListModel);
return d->m_feature->discoveryResult();
}
/*!
\qmlproperty bool AbstractFeatureListModel::isValid
\brief Indicates whether the feature is ready for use.
The property is \c true if the feature is ready to be used, otherwise \c false. Not being
ready usually indicates that no suitable service object could be found, or that automatic
discovery has not been triggered.
The backend still might not have sent all properties yet and is not fully initialized.
Use isInitialized instead to know when the feature holds all correct values.
\sa QIfServiceObject, discoveryMode, isInitialized
*/
/*!
\property QIfAbstractFeatureListModel::isValid
\brief Indicates whether the feature is ready to use.
The property is \c true if the feature is ready to be used, otherwise \c false. Not being
ready usually indicates that no suitable service object could be found, or that automatic
discovery has not been triggered.
The backend still might not have sent all properties yet and is not fully initialized.
Use isInitialized instead to know when the feature holds all correct values.
\sa QIfServiceObject, discoveryMode, isInitialized
*/
bool QIfAbstractFeatureListModel::isValid() const
{
Q_D(const QIfAbstractFeatureListModel);
return d->m_feature->isValid();
}
/*!
\qmlproperty bool AbstractFeatureListModel::isInitialized
\brief Indicates whether the feature has been initialized with all the values from the backend.
The property is \c true once the backend sends the QIfFeatureInterface::initializationDone signal
to indicate that all values have now been initialized with values from the backend.
\sa isValid, QIfFeatureInterface::initializationDone
*/
/*!
\property QIfAbstractFeatureListModel::isInitialized
\brief Indicates whether the feature has been initialized with all the values from the backend.
The property is \c true once the backend sends the QIfFeatureInterface::initializationDone signal
to indicate that all values have now been initialized with values from the backend.
\sa isValid, QIfFeatureInterface::initializationDone
*/
bool QIfAbstractFeatureListModel::isInitialized() const
{
Q_D(const QIfAbstractFeatureListModel);
return d->m_feature->isInitialized();
}
/*!
Returns the last error code.
\sa QIfAbstractFeature::Error
*/
QIfAbstractFeature::Error QIfAbstractFeatureListModel::error() const
{
Q_D(const QIfAbstractFeatureListModel);
return d->m_feature->error();
}
/*!
\qmlproperty string AbstractFeatureListModel::error
Last error message of the feature. Empty if no error.
*/
/*!
\property QIfAbstractFeatureListModel::error
Last error message of the feature. Empty if no error.
*/
QString QIfAbstractFeatureListModel::errorMessage() const
{
Q_D(const QIfAbstractFeatureListModel);
return d->m_feature->errorMessage();
}
/*!
\qmlproperty string AbstractFeatureListModel::configurationId
\brief Holds the id to determine which configuration this feature belongs to.
\since 6.5
Once the id has been set, it is possible to change certain values using the
\l InterfaceFrameworkConfiguration API.
\note Values set in the matching \l InterfaceFrameworkConfiguration can override the initial values
set during the component creation.
\sa InterfaceFrameworkConfiguration
*/
/*!
\property QIfAbstractFeatureListModel::configurationId
\brief Holds the id to determine which configuration this feature belongs to.
\since 6.5
Once the id has been set, it is possible to change certain values using the
\l QIfConfiguration API.
\note Values set in the matching \l QIfConfiguration can override the initial values
set during the component creation.
\sa QIfConfiguration
*/
QString QIfAbstractFeatureListModel::configurationId() const
{
Q_D(const QIfAbstractFeatureListModel);
return d->m_feature->configurationId();
}
/*!
\qmlproperty list<string> AbstractFeatureListModel::preferredBackends
\brief Holds a list of wildcards to load the preferred backend during auto discovery.
\since 6.5
The auto discovery mechanism will automatically search for backends which provide a matching
interface for this feature implementation. See \l startAutoDiscovery() for more information.
In case multiple backends implement the same interface, the list of wildcards can be used
to determine the correct one to load.
The wildcards are applied in order to the found backends. If the wildcard matches some backends
those backends will be loaded, otherwise the next wildcard is used.
For example: Given an AbstractFeature with two backends, backend_mqtt.so and backend_qtro.so,
the property can be set to \c "*_mqtt*" to always select the backend_mqtt.so backend when
available.
*/
/*!
\property QIfAbstractFeatureListModel::preferredBackends
\brief Holds a list of wildcards to load the preferred backend during auto discovery.
\since 6.5
The auto discovery mechanism will automatically search for backends which provide a matching
interface for this feature implementation. See \l startAutoDiscovery() for more information.
In case multiple backends implement the same interface, the list of wildcards can be used
to determine the correct one to load.
The wildcards are applied in order to the found backends. If the wildcard matches some backends
those backends will be loaded, otherwise the next wildcard is used.
For example: Given an AbstractFeature with two backends, backend_mqtt.so and backend_qtro.so,
the property can be set to \c "*_mqtt*" to always select the backend_mqtt.so backend when
available.
*/
QStringList QIfAbstractFeatureListModel::preferredBackends() const
{
Q_D(const QIfAbstractFeatureListModel);
return d->m_feature->preferredBackends();
}
/*!
\qmlproperty bool AbstractFeatureListModel::backendUpdatesEnabled
\brief This property holds whether backend updates are enabled
\since 6.8
By default, this property is \c true.
setBackendUpdatesEnabled() is normally used to disable updates for a short period of time, for instance
to skip expensive updates while the application is currently not visible on the screen.
This is especially useful when backend upates are triggered over an IPC and received by multiple
applications. By disabling updates, the application can avoid unnecessary updates.
A change to this property will cause the connectToServiceObject() and disconnectFromServiceObject()
functions to be called, depending on the new value.
*/
/*!
\property QIfAbstractFeatureListModel::backendUpdatesEnabled
\brief This property holds whether backend updates are enabled
\since 6.8
By default, this property is \c true.
setBackendUpdatesEnabled() is normally used to disable updates for a short period of time, for instance
to skip expensive updates while the application is currently not visible on the screen.
This is especially useful when backend upates are triggered over an IPC and received by multiple
applications. By disabling updates, the application can avoid unnecessary updates.
A change to this property will cause the connectToServiceObject() and disconnectFromServiceObject()
functions to be called, depending on the new value.
*/
bool QIfAbstractFeatureListModel::backendUpdatesEnabled() const
{
Q_D(const QIfAbstractFeatureListModel);
return d->m_feature->backendUpdatesEnabled();
}
/*!
\qmlproperty bool AbstractFeatureListModel::asynchronousBackendLoading
\brief This property holds whether backend loading is asynchronous.
\since 6.8
By default, this property is \c false.
If set to \c true, the backend loading is asynchronous. This means that the feature
will not wait for the backend to complete loading during auto discovery. Instead, the backend
loads in the background and the feature will be updated once the backend is ready.
\note This property defaults to \c true if the AbstractFeatureListModel is
created within an asynchronous \l QQmlIncubator (e.g. \l Loader).
*/
/*!
\property QIfAbstractFeatureListModel::asynchronousBackendLoading
\brief This property holds whether backend loading is asynchronous.
\since 6.8
By default, this property is \c false.
If set to \c true, the backend loading is asynchronous. This means that the feature
will not wait for the backend to complete loading during auto discovery. Instead, the backend
loads in the background and the feature will be updated once the backend is ready.
\note This property defaults to \c true if the QIfAbstractFeatureListModel is
created within an asynchronous \l QQmlIncubator (e.g. \l Loader).
*/
bool QIfAbstractFeatureListModel::asynchronousBackendLoading() const
{
Q_D(const QIfAbstractFeatureListModel);
return d->m_feature->asynchronousBackendLoading();
}
bool QIfAbstractFeatureListModel::setServiceObject(QIfServiceObject *so)
{
Q_D(QIfAbstractFeatureListModel);
return d->m_feature->setServiceObject(so);
}
void QIfAbstractFeatureListModel::setDiscoveryMode(QIfAbstractFeature::DiscoveryMode discoveryMode)
{
Q_D(QIfAbstractFeatureListModel);
d->m_feature->setDiscoveryMode(discoveryMode);
}
void QIfAbstractFeatureListModel::setConfigurationId(const QString &configurationId)
{
Q_D(QIfAbstractFeatureListModel);
d->m_feature->setConfigurationId(configurationId);
}
void QIfAbstractFeatureListModel::setPreferredBackends(const QStringList &preferredBackends)
{
Q_D(QIfAbstractFeatureListModel);
d->m_feature->setPreferredBackends(preferredBackends);
}
void QIfAbstractFeatureListModel::setBackendUpdatesEnabled(bool newBackendUpdatesEnabled)
{
Q_D(QIfAbstractFeatureListModel);
d->m_feature->setBackendUpdatesEnabled(newBackendUpdatesEnabled);
}
void QIfAbstractFeatureListModel::setAsynchronousBackendLoading(bool asynchronousBackendLoading)
{
Q_D(QIfAbstractFeatureListModel);
d->m_feature->setAsynchronousBackendLoading(asynchronousBackendLoading);
}
/*!
\qmlmethod enumeration AbstractFeatureListModel::startAutoDiscovery()
Performs an automatic discovery attempt.
See AbstractFeature::startAutoDiscovery() for more information
*/
/*!
\brief Performs an automatic discovery attempt.
See QIfAbstractFeature::startAutoDiscovery() for more information
*/
QIfAbstractFeature::DiscoveryResult QIfAbstractFeatureListModel::startAutoDiscovery()
{
Q_D(QIfAbstractFeatureListModel);
return d->m_feature->startAutoDiscovery();
}
/*!
\internal
*/
QIfAbstractFeatureListModel::QIfAbstractFeatureListModel(QIfAbstractFeatureListModelPrivate &dd, QObject *parent)
: QAbstractListModel(dd, parent)
{
Q_D(QIfAbstractFeatureListModel);
d->initialize();
connect(d->m_feature, &QIfAbstractFeature::serviceObjectChanged, this, &QIfAbstractFeatureListModel::serviceObjectChanged);
connect(d->m_feature, &QIfAbstractFeature::discoveryModeChanged, this, &QIfAbstractFeatureListModel::discoveryModeChanged);
connect(d->m_feature, &QIfAbstractFeature::discoveryResultChanged, this, &QIfAbstractFeatureListModel::discoveryResultChanged);
connect(d->m_feature, &QIfAbstractFeature::isValidChanged, this, &QIfAbstractFeatureListModel::isValidChanged);
connect(d->m_feature, &QIfAbstractFeature::isInitializedChanged, this, &QIfAbstractFeatureListModel::isInitializedChanged);
connect(d->m_feature, &QIfAbstractFeature::errorChanged, this, &QIfAbstractFeatureListModel::errorChanged);
connect(d->m_feature, &QIfAbstractFeature::configurationIdChanged, this, &QIfAbstractFeatureListModel::configurationIdChanged);
connect(d->m_feature, &QIfAbstractFeature::preferredBackendsChanged, this, &QIfAbstractFeatureListModel::preferredBackendsChanged);
connect(d->m_feature, &QIfAbstractFeature::backendUpdatesEnabledChanged, this, &QIfAbstractFeatureListModel::backendUpdatesEnabledChanged);
connect(d->m_feature, &QIfAbstractFeature::asynchronousBackendLoadingChanged, this, &QIfAbstractFeatureListModel::asynchronousBackendLoadingChanged);
}
/*!
This method is expected to be implemented by any class subclassing QIfAbstractFeature.
The method should return \c true if the given \a serviceObject is accepted and
can be used, otherwise \c false.
If the object is accepted, \l connectToServiceObject is called to actually connect to the
service object.
The default implementation accepts the \a serviceObject if it implements the interface
returned by interfaceName();
\sa connectToServiceObject(), disconnectFromServiceObject(), clearServiceObject()
*/
bool QIfAbstractFeatureListModel::acceptServiceObject(QIfServiceObject *serviceObject)
{
Q_D(QIfAbstractFeatureListModel);
return d->m_feature->acceptServiceObjectDefaultImpl(serviceObject);
}
/*!
This method is expected to be implemented by any class subclassing QIfAbstractFeature.
The implementation should connect to the \a serviceObject, and set up all
properties to reflect the state of the service object.
There is no previous service object connected, as this function call is always preceded by a call to
\l disconnectFromServiceObject or \l clearServiceObject.
It is safe to assume that the \a serviceObject, has always been accepted through the
\l acceptServiceObject method prior to being passed to this method.
The default implementation connects to the signals offered by QIfFeatureInterface and calls
QIfFeatureInterface::initialize() afterwards.
When reimplementing please keep in mind to connect all signals before calling this function. e.g.
/code
void SimpleFeature::connectToServiceObject(QIfServiceObject *serviceObject)
{
SimpleFeatureBackendInterface *backend = backend(serviceObject);
if (!backend)
return;
// connect your signals
connect(backend, &SimpleFeatureBackendInterface::propertyChanged,
this, &SimpleFeature::onPropertyChanged);
// connects the base signals and call initialize()
QIfAbstractFeature::connectToServiceObject(serviceObject);
// Additional initialization functions can be added here
}
/endcode
\sa acceptServiceObject(), disconnectFromServiceObject(), clearServiceObject()
*/
void QIfAbstractFeatureListModel::connectToServiceObject(QIfServiceObject *serviceObject)
{
Q_D(QIfAbstractFeatureListModel);
d->m_feature->connectToServiceObjectDefaultImpl(serviceObject);
}
/*!
This method is expected to be implemented by any class subclassing QIfAbstractFeature.
The implementation should disconnect all connections to the \a serviceObject.
There is no need to reset internal variables to safe defaults. A call to this function is
always followed by a call to \l connectToServiceObject or \l clearServiceObject.
The default implementation disconnects all signals from the serviceObject to this instance.
\sa acceptServiceObject(), connectToServiceObject(), clearServiceObject()
*/
void QIfAbstractFeatureListModel::disconnectFromServiceObject(QIfServiceObject *serviceObject)
{
Q_D(QIfAbstractFeatureListModel);
d->m_feature->disconnectFromServiceObjectDefaultImpl(serviceObject);
if (d->backend())
disconnect(d->backend(), nullptr, this, nullptr);
}
/*!
\internal
*/
void QIfAbstractFeatureListModel::classBegin()
{
Q_D(QIfAbstractFeatureListModel);
d->m_feature->ifPrivate()->m_qmlCreation = true;
// Check if the Feature is created within an Loader which is set to asynchronous
// This is done here to allow overwriting the property in QML
QQmlRefPointer<QQmlContextData> context = QQmlContextData::get(qmlContext(this));
if (context->isValid() && context->incubator() && context->incubator()->isAsynchronous) {
qCDebug(qLcIfServiceManagement) << "Detected asynchronous Loader, setting asynchronousBackendLoading"
<< "for" << this << "to true";
setAsynchronousBackendLoading(true);
}
}
/*!
\internal
*/
void QIfAbstractFeatureListModel::componentComplete()
{
Q_D(QIfAbstractFeatureListModel);
d->m_feature->ifPrivate()->m_qmlCreation = false;
if (!configurationId().isEmpty())
QIfConfigurationManager::instance()->addAbstractFeature(configurationId(), d->m_feature);
startAutoDiscovery();
}
/*!
Returns the interface name this Feature expect to be available from the Service Object and this Feature is implementing.
\sa acceptServiceObject
*/
QString QIfAbstractFeatureListModel::interfaceName() const
{
Q_D(const QIfAbstractFeatureListModel);
return d->m_feature->interfaceName();
}
/*!
Returns the current error code converted from QIfAbstractFeature::Error to QString
\sa error
*/
QString QIfAbstractFeatureListModel::errorText() const
{
Q_D(const QIfAbstractFeatureListModel);
return d->m_feature->errorText();
}
/*!
Sets \a error with the \a message.
Emits errorChanged() signal.
\sa QIfAbstractFeature::Error
*/
void QIfAbstractFeatureListModel::setError(QIfAbstractFeature::Error error, const QString &message)
{
Q_D(QIfAbstractFeatureListModel);
d->m_feature->setError(error, message);
}
/*!
Updates \a error and \a message from the backend.
This slot can be used when implementing a new Feature to report generic errors.
*/
void QIfAbstractFeatureListModel::onErrorChanged(QIfAbstractFeature::Error error, const QString &message)
{
setError(error, message);
}
QT_END_NAMESPACE
#include "moc_qifabstractfeaturelistmodel.cpp"
|