KUserFeedback

propertyratiosource.h
1/*
2 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#ifndef KUSERFEEDBACK_PROPERTYRATIOSOURCE_H
8#define KUSERFEEDBACK_PROPERTYRATIOSOURCE_H
9
10#include "kuserfeedbackcore_export.h"
11#include "abstractdatasource.h"
12
13namespace KUserFeedback {
14
15class PropertyRatioSourcePrivate;
16
17/*! Records the time ratio a given QObject property has a specific value.
18 *
19 * An example use-case would be the usage ratio of a applications
20 * views/modes selected by a QTabWidget or QRadioButton.
21 *
22 * The default telemetry mode for this source is Provider::DetailedUsageStatistics.
23 */
24class KUSERFEEDBACKCORE_EXPORT PropertyRatioSource : public AbstractDataSource
25{
26public:
27 /*! Create a new property ratio data source.
28 * @param obj the QObject of which a property should be monitored.
29 * @param propertyName The name of the property to monitor.
30 * This property must have a change notification signal. The value must have
31 * comparison operators registered.
32 * @param sampleName This is the name of the database field this data source is
33 * associated with.
34 */
35 explicit PropertyRatioSource(QObject *obj, const char* propertyName, const QString &sampleName);
36
37 /*! Returns the monitored object. */
38 QObject* object() const;
39 /*! Sets the monitoried object. */
40 void setObject(QObject *object);
41
42 /*! Returns the property name. */
43 QString propertyName() const;
44 /*! Sets the property name that should be monitored. */
45 void setPropertyName(const QString &name);
46
47 /*! Map property value @p value to @p str for sending to the server.
48 * This is useful to map internal identifiers to portable and persistable values,
49 * such as turning pointers or indexes into meaningful descriptions.
50 * @param value The property value to map.
51 * @param str The string the property value @p value should be mapped to.
52 */
53 void addValueMapping(const QVariant &value, const QString &str);
54
55 QString name() const override;
56 /*! Set human readable name.
57 * @see AbstractDataSource::name()
58 */
59 void setName(const QString &name);
60
61 QString description() const override;
62
63 /*! Set human-readable and translated description of the data provided by this source.
64 * @note This must be set before adding this source, sources without description are
65 * discarded.
66 * @param desc The description.
67 */
68 void setDescription(const QString &desc);
69
70 QVariant data() override;
71
72 void loadImpl(QSettings *settings) override;
73 void storeImpl(QSettings *settings) override;
74 void resetImpl(QSettings *settings) override;
75
76 using AbstractDataSource::setId;
77private:
78 Q_DECLARE_PRIVATE(PropertyRatioSource)
79};
80
81}
82
83#endif // KUSERFEEDBACK_PROPERTYRATIOSOURCE_H
Base class for data sources for telemetry data.
Records the time ratio a given QObject property has a specific value.
Classes for integrating telemetry collection, survey targeting, and contribution encouragenemt and co...
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:56 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.