File indexing completed on 2024-12-15 03:45:05
0001 /* 0002 SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #include "usagetimesource.h" 0008 #include "abstractdatasource_p.h" 0009 #include "provider_p.h" 0010 0011 #include <QVariant> 0012 0013 using namespace KUserFeedback; 0014 0015 namespace KUserFeedback { 0016 class UsageTimeSourcePrivate : public AbstractDataSourcePrivate 0017 { 0018 public: 0019 UsageTimeSourcePrivate() : provider(nullptr) {} 0020 ProviderPrivate *provider; 0021 }; 0022 } 0023 0024 UsageTimeSource::UsageTimeSource() : 0025 AbstractDataSource(QStringLiteral("usageTime"), Provider::BasicUsageStatistics, new UsageTimeSourcePrivate) 0026 { 0027 } 0028 0029 QString UsageTimeSource::description() const 0030 { 0031 return tr("The total amount of time the application has been used."); 0032 } 0033 0034 QVariant UsageTimeSource::data() 0035 { 0036 Q_D(UsageTimeSource); 0037 Q_ASSERT(d->provider); 0038 0039 QVariantMap m; 0040 m.insert(QStringLiteral("value"), d->provider->currentApplicationTime()); 0041 return m; 0042 } 0043 0044 QString UsageTimeSource::name() const 0045 { 0046 return tr("Usage time"); 0047 } 0048 0049 void UsageTimeSource::setProvider(ProviderPrivate* p) 0050 { 0051 Q_D(UsageTimeSource); 0052 d->provider = p; 0053 }