initial plasma6 support

This commit is contained in:
2024-03-07 12:09:46 +02:00
parent eecb128865
commit 4d01b87088
176 changed files with 2569 additions and 3795 deletions

View File

@ -18,6 +18,9 @@
#include "quotessource.h"
#include <ksysguard/formatter/Unit.h>
#include <ksysguard/systemstats/SensorInfo.h>
#include "awdebug.h"
#include "extquotes.h"
@ -45,60 +48,58 @@ QVariant QuotesSource::data(const QString &_source)
qCDebug(LOG_ESS) << "Source" << _source;
int ind = index(_source);
auto service = _source;
service.remove("quotes/");
if (!m_values.contains(service)) {
if (!m_values.contains(_source)) {
QVariantHash data = m_extQuotes->itemByTagNumber(ind)->run();
for (auto &key : data.keys())
m_values[key] = data[key];
}
QVariant value = m_values.take(service);
QVariant value = m_values.take(_source);
return value;
}
QVariantMap QuotesSource::initialData(const QString &_source) const
KSysGuard::SensorInfo *QuotesSource::initialData(const QString &_source) const
{
qCDebug(LOG_ESS) << "Source" << _source;
int ind = index(_source);
QVariantMap data;
if (_source.startsWith("quotes/pricechg")) {
data["min"] = 0.0;
data["max"] = 0.0;
data["name"] = QString("Absolute prie changes for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq());
data["type"] = "double";
data["units"] = "";
} else if (_source.startsWith("quotes/price")) {
data["min"] = 0.0;
data["max"] = 0.0;
data["name"] = QString("Price for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq());
data["type"] = "double";
data["units"] = "";
} else if (_source.startsWith("quotes/percpricechg")) {
data["min"] = -100.0;
data["max"] = 100.0;
data["name"] = QString("Price changes for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq());
data["type"] = "double";
data["units"] = "";
} else if (_source.startsWith("quotes/volumechg")) {
data["min"] = 0;
data["max"] = 0;
data["name"] = QString("Absolute volume changes for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq());
data["type"] = "int";
data["units"] = "";
} else if (_source.startsWith("quotes/volume")) {
data["min"] = 0;
data["max"] = 0;
data["name"] = QString("Volume for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq());
data["type"] = "int";
data["units"] = "";
} else if (_source.startsWith("quotes/percvolumechg")) {
data["min"] = -100.0;
data["max"] = 100.0;
data["name"] = QString("Volume changes for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq());
data["type"] = "double";
data["units"] = "";
auto data = new KSysGuard::SensorInfo;
if (_source.startsWith("pricechg")) {
data->min = 0.0;
data->max = 0.0;
data->name = QString("Absolute price changes for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq());
data->variantType = QVariant::Double;
data->unit = KSysGuard::UnitNone;
} else if (_source.startsWith("price")) {
data->min = 0.0;
data->max = 0.0;
data->name = QString("Price for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq());
data->variantType = QVariant::Double;
data->unit = KSysGuard::UnitNone;
} else if (_source.startsWith("percpricechg")) {
data->min = -100.0;
data->max = 100.0;
data->name = QString("Price changes for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq());
data->variantType = QVariant::Double;
data->unit = KSysGuard::UnitPercent;
} else if (_source.startsWith("volumechg")) {
data->min = 0;
data->max = 0;
data->name = QString("Absolute volume changes for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq());
data->variantType = QVariant::Int;
data->unit = KSysGuard::UnitNone;
} else if (_source.startsWith("volume")) {
data->min = 0;
data->max = 0;
data->name = QString("Volume for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq());
data->variantType = QVariant::Int;
data->unit = KSysGuard::UnitNone;
} else if (_source.startsWith("percvolumechg")) {
data->min = -100.0;
data->max = 100.0;
data->name = QString("Volume changes for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq());
data->variantType = QVariant::Double;
data->unit = KSysGuard::UnitPercent;
}
return data;
@ -115,12 +116,12 @@ QStringList QuotesSource::getSources()
{
QStringList sources;
for (auto &item : m_extQuotes->activeItems()) {
sources.append(QString("quotes/%1").arg(item->tag("price")));
sources.append(QString("quotes/%1").arg(item->tag("pricechg")));
sources.append(QString("quotes/%1").arg(item->tag("percpricechg")));
sources.append(QString("quotes/%1").arg(item->tag("volume")));
sources.append(QString("quotes/%1").arg(item->tag("volumechg")));
sources.append(QString("quotes/%1").arg(item->tag("percvolumechg")));
sources.append(item->tag("price"));
sources.append(item->tag("pricechg"));
sources.append(item->tag("percpricechg"));
sources.append(item->tag("volume"));
sources.append(item->tag("volumechg"));
sources.append(item->tag("percvolumechg"));
}
return sources;