mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
Having the KCMs that are mobile specific here makes more sense than in the settings application. Historically plasma-settings had a faster release cycle than Plasma, but the application is now moving to the Plasma release schedule and so it makes sense do this now.
89 lines
2.1 KiB
C++
89 lines
2.1 KiB
C++
/*
|
|
* SPDX-FileCopyrightText: 2015 David Edmundson <david@davidedmundson.co.uk>
|
|
*
|
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
*
|
|
*/
|
|
|
|
#ifndef STATISTICSPROVIDER_H
|
|
#define STATISTICSPROVIDER_H
|
|
|
|
#include <QObject>
|
|
#include <QPointF>
|
|
#include <QQmlParserStatus>
|
|
|
|
struct HistoryReply {
|
|
public:
|
|
uint time = 0;
|
|
double value = 0.0;
|
|
uint charging = 0;
|
|
};
|
|
|
|
Q_DECLARE_METATYPE(HistoryReply)
|
|
|
|
class StatisticsProvider : public QObject, public QQmlParserStatus
|
|
{
|
|
Q_OBJECT
|
|
Q_INTERFACES(QQmlParserStatus)
|
|
|
|
Q_PROPERTY(QString device MEMBER m_device WRITE setDevice NOTIFY deviceChanged)
|
|
Q_PROPERTY(uint duration MEMBER m_duration WRITE setDuration NOTIFY durationChanged)
|
|
Q_PROPERTY(HistoryType type MEMBER m_type WRITE setType NOTIFY typeChanged)
|
|
|
|
Q_PROPERTY(QVariantList points READ asPoints NOTIFY dataChanged)
|
|
Q_PROPERTY(int count READ count NOTIFY dataChanged)
|
|
Q_PROPERTY(int firstDataPointTime READ firstDataPointTime NOTIFY dataChanged)
|
|
Q_PROPERTY(int lastDataPointTime READ lastDataPointTime NOTIFY dataChanged)
|
|
Q_PROPERTY(int largestValue READ largestValue NOTIFY dataChanged)
|
|
|
|
public:
|
|
enum HistoryType {
|
|
RateType,
|
|
ChargeType,
|
|
};
|
|
Q_ENUM(HistoryType)
|
|
|
|
enum HistoryRoles {
|
|
TimeRole = Qt::UserRole + 1,
|
|
ValueRole,
|
|
ChargingRole,
|
|
};
|
|
|
|
explicit StatisticsProvider(QObject *parent = nullptr);
|
|
|
|
void setDevice(const QString &device);
|
|
void setDuration(uint duration);
|
|
void setType(HistoryType type);
|
|
|
|
void load();
|
|
|
|
void classBegin() override;
|
|
void componentComplete() override;
|
|
|
|
QVariantList asPoints() const;
|
|
int count() const;
|
|
|
|
int firstDataPointTime() const;
|
|
int lastDataPointTime() const;
|
|
int largestValue() const;
|
|
|
|
Q_SIGNALS:
|
|
void deviceChanged();
|
|
void typeChanged();
|
|
void durationChanged();
|
|
|
|
void dataChanged();
|
|
|
|
public Q_SLOTS:
|
|
void refresh();
|
|
|
|
private:
|
|
QString m_device;
|
|
HistoryType m_type;
|
|
uint m_duration; // in seconds
|
|
|
|
QList<HistoryReply> m_values;
|
|
bool m_isComplete = false;
|
|
};
|
|
|
|
#endif // STATISTICSPROVIDER_H
|