Changeset View
Changeset View
Standalone View
Standalone View
src/provider/qml/qmlpropertysource.cpp
Show All 22 Lines | |||||
23 | class CustomPropertySource : public AbstractDataSource | 23 | class CustomPropertySource : public AbstractDataSource | ||
24 | { | 24 | { | ||
25 | public: | 25 | public: | ||
26 | CustomPropertySource() : AbstractDataSource({}) {} | 26 | CustomPropertySource() : AbstractDataSource({}) {} | ||
27 | 27 | | |||
28 | QVariant data() override { return m_data; } | 28 | QVariant data() override { return m_data; } | ||
29 | QString description() const override { return m_description; } | 29 | QString description() const override { return m_description; } | ||
30 | 30 | | |||
31 | void setSourceName(const QString &name) { setName(name); } | 31 | void setSourceId(const QString &id) { setId(id); } | ||
32 | 32 | | |||
33 | QVariant m_data; | 33 | QVariant m_data; | ||
34 | QString m_description; | 34 | QString m_description; | ||
35 | }; | 35 | }; | ||
36 | 36 | | |||
37 | QmlPropertySource::QmlPropertySource(QObject* parent) | 37 | QmlPropertySource::QmlPropertySource(QObject* parent) | ||
38 | : QmlAbstractDataSource(new CustomPropertySource(), parent) | 38 | : QmlAbstractDataSource(new CustomPropertySource(), parent) | ||
39 | { | 39 | { | ||
40 | } | 40 | } | ||
41 | 41 | | |||
42 | QVariant QmlPropertySource::data() const | 42 | QVariant QmlPropertySource::data() const | ||
43 | { | 43 | { | ||
44 | return source()->data(); | 44 | return source()->data(); | ||
45 | } | 45 | } | ||
46 | 46 | | |||
47 | QString QmlPropertySource::description() const | 47 | QString QmlPropertySource::description() const | ||
48 | { | 48 | { | ||
49 | return source()->description(); | 49 | return source()->description(); | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | QString QmlPropertySource::name() const | 52 | QString QmlPropertySource::id() const | ||
53 | { | 53 | { | ||
54 | return source()->name(); | 54 | return source()->id(); | ||
55 | } | 55 | } | ||
56 | 56 | | |||
57 | void KUserFeedback::QmlPropertySource::setData(const QVariant& data) | 57 | void KUserFeedback::QmlPropertySource::setData(const QVariant& data) | ||
58 | { | 58 | { | ||
59 | if (customSource()->m_data != data) { | 59 | if (customSource()->m_data != data) { | ||
60 | customSource()->m_data = data; | 60 | customSource()->m_data = data; | ||
61 | Q_EMIT dataChanged(data); | 61 | Q_EMIT dataChanged(data); | ||
62 | } | 62 | } | ||
63 | } | 63 | } | ||
64 | 64 | | |||
65 | void KUserFeedback::QmlPropertySource::setDescription(const QString& description) | 65 | void KUserFeedback::QmlPropertySource::setDescription(const QString& description) | ||
66 | { | 66 | { | ||
67 | if (customSource()->m_description != description) { | 67 | if (customSource()->m_description != description) { | ||
68 | customSource()->m_description = description; | 68 | customSource()->m_description = description; | ||
69 | Q_EMIT descriptionChanged(description); | 69 | Q_EMIT descriptionChanged(description); | ||
70 | } | 70 | } | ||
71 | } | 71 | } | ||
72 | 72 | | |||
73 | void KUserFeedback::QmlPropertySource::setName(const QString& name) | 73 | void KUserFeedback::QmlPropertySource::setId(const QString& id) | ||
74 | { | 74 | { | ||
75 | if (name != source()->name()) { | 75 | if (id != source()->id()) { | ||
76 | customSource()->setSourceName(name); | 76 | customSource()->setSourceId(id); | ||
77 | Q_EMIT nameChanged(name); | 77 | Q_EMIT idChanged(id); | ||
78 | } | 78 | } | ||
79 | } | 79 | } | ||
80 | 80 | | |||
81 | CustomPropertySource * KUserFeedback::QmlPropertySource::customSource() | 81 | CustomPropertySource * KUserFeedback::QmlPropertySource::customSource() | ||
82 | { | 82 | { | ||
83 | return dynamic_cast<CustomPropertySource*>(source()); | 83 | return dynamic_cast<CustomPropertySource*>(source()); | ||
84 | } | 84 | } |