wayland support

This commit is contained in:
2023-05-15 12:00:46 +03:00
parent 84de9755b5
commit dea9d488df
89 changed files with 423 additions and 646 deletions

View File

@ -34,10 +34,9 @@ AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *_parent, QString _
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
// create directory at $HOME
QString localDir
= QString("%1/awesomewidgets/%2")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation))
.arg(type());
QString localDir = QString("%1/awesomewidgets/%2")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation))
.arg(type());
QDir localDirectory;
if (localDirectory.mkpath(localDir))
qCInfo(LOG_LIB) << "Created directory" << localDir;
@ -47,11 +46,9 @@ AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *_parent, QString _
createButton = ui->buttonBox->addButton(i18n("Create"), QDialogButtonBox::ActionRole);
deleteButton = ui->buttonBox->addButton(i18n("Remove"), QDialogButtonBox::ActionRole);
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton *)), this,
SLOT(editItemButtonPressed(QAbstractButton *)));
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(editItemButtonPressed(QAbstractButton *)));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(ui->listWidget, SIGNAL(itemActivated(QListWidgetItem *)), this,
SLOT(editItemActivated(QListWidgetItem *)));
connect(ui->listWidget, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(editItemActivated(QListWidgetItem *)));
}
@ -118,8 +115,7 @@ void AbstractExtItemAggregator::editItem()
QString AbstractExtItemAggregator::getName()
{
bool ok;
QString name = QInputDialog::getText(this, i18n("Enter file name"), i18n("File name"),
QLineEdit::Normal, "", &ok);
QString name = QInputDialog::getText(this, i18n("Enter file name"), i18n("File name"), QLineEdit::Normal, "", &ok);
if ((!ok) || (name.isEmpty()))
return "";
if (!name.endsWith(".desktop"))
@ -187,8 +183,7 @@ QVariant AbstractExtItemAggregator::configArgs() const
QStringList AbstractExtItemAggregator::directories() const
{
auto dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
QString("awesomewidgets/%1").arg(type()),
auto dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString("awesomewidgets/%1").arg(type()),
QStandardPaths::LocateDirectory);
return dirs;

View File

@ -47,10 +47,9 @@ public:
{
QString fileName = getName();
int number = uniqNumber();
QString dir
= QString("%1/awesomewidgets/%2")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation))
.arg(m_type);
QString dir = QString("%1/awesomewidgets/%2")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation))
.arg(m_type);
if (fileName.isEmpty()) {
qCWarning(LOG_LIB) << "Nothing to create";
return;

View File

@ -33,8 +33,7 @@ public:
: QObject(_parent){};
~AbstractQuotesProvider() override = default;
virtual void initUrl(const QString &_asset) = 0;
[[nodiscard]] virtual QVariantHash parse(const QByteArray &_source,
const QVariantHash &_oldValues) const = 0;
[[nodiscard]] virtual QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const = 0;
[[nodiscard]] QString tag(const QString &_type) const
{
return dynamic_cast<AbstractExtItem *>(parent())->tag(_type);

View File

@ -51,8 +51,8 @@ QString AWFloatFormatter::convert(const QVariant &_value) const
{
qCDebug(LOG_LIB) << "Convert value" << _value;
QString output = QString("%1").arg(_value.toDouble() * multiplier() + summand(), count(),
format(), precision(), fillChar());
QString output
= QString("%1").arg(_value.toDouble() * multiplier() + summand(), count(), format(), precision(), fillChar());
if (forceWidth())
output = output.left(count());
@ -149,8 +149,7 @@ void AWFloatFormatter::setFormat(char _format)
{
qCDebug(LOG_LIB) << "Set format" << _format;
// http://doc.qt.io/qt-5/qstring.html#argument-formats
if ((_format != 'e') && (_format != 'E') && (_format != 'f') && (_format != 'g')
&& (_format != 'G')) {
if ((_format != 'e') && (_format != 'E') && (_format != 'f') && (_format != 'g') && (_format != 'G')) {
qCWarning(LOG_LIB) << "Invalid format" << _format;
_format = 'f';
}

View File

@ -53,9 +53,8 @@ QString AWJsonFormatter::convert(const QVariant &_value) const
qCDebug(LOG_LIB) << "Convert value" << _value;
// check if _value is string and parse first if required
QJsonDocument json = _value.type() == QVariant::String
? QJsonDocument::fromJson(_value.toString().toUtf8())
: QJsonDocument::fromVariant(_value);
QJsonDocument json = _value.type() == QVariant::String ? QJsonDocument::fromJson(_value.toString().toUtf8())
: QJsonDocument::fromVariant(_value);
QVariant converted = json.toVariant();
for (auto &element : m_splittedPath)
converted = getFromJson(converted, element);

View File

@ -59,8 +59,8 @@ QString AWScriptFormatter::convert(const QVariant &_value) const
QJSValue result = fn.call(args);
if (result.isError()) {
qCWarning(LOG_LIB) << "Uncaught exception at line" << result.property("lineNumber").toInt()
<< ":" << result.toString();
qCWarning(LOG_LIB) << "Uncaught exception at line" << result.property("lineNumber").toInt() << ":"
<< result.toString();
return "";
} else {
return result.toString();
@ -199,9 +199,7 @@ void AWScriptFormatter::initProgram()
{
// init JS code
if (appendCode())
m_program = QString("(function(value) { %1%2 })")
.arg(code())
.arg(hasReturn() ? "" : "; return output;");
m_program = QString("(function(value) { %1%2 })").arg(code()).arg(hasReturn() ? "" : "; return output;");
else
m_program = code();

View File

@ -139,9 +139,8 @@ private:
qCInfo(LOG_LIB) << "Found file" << file << "in" << dir;
QString filePath = QString("%1/%2").arg(dir).arg(file);
// check if already exists
if (std::any_of(items.cbegin(), items.cend(), [&filePath](AbstractExtItem *item) {
return (item->fileName() == filePath);
}))
if (std::any_of(items.cbegin(), items.cend(),
[&filePath](AbstractExtItem *item) { return (item->fileName() == filePath); }))
continue;
items.append(new T(this, filePath));
}
@ -149,9 +148,7 @@ private:
// sort items
std::sort(items.begin(), items.end(),
[](const AbstractExtItem *lhs, const AbstractExtItem *rhs) {
return lhs->number() < rhs->number();
});
[](const AbstractExtItem *lhs, const AbstractExtItem *rhs) { return lhs->number() < rhs->number(); });
return items;
};
};

View File

@ -45,8 +45,7 @@ ExtNetworkRequest::ExtNetworkRequest(QWidget *_parent, const QString &_filePath)
// HACK declare as child of nullptr to avoid crash with plasmawindowed
// in the destructor
m_manager = new QNetworkAccessManager(nullptr);
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this,
SLOT(networkReplyReceived(QNetworkReply *)));
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(networkReplyReceived(QNetworkReply *)));
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
}
@ -56,8 +55,7 @@ ExtNetworkRequest::~ExtNetworkRequest()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this,
SLOT(networkReplyReceived(QNetworkReply *)));
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(networkReplyReceived(QNetworkReply *)));
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
m_manager->deleteLater();
@ -171,14 +169,12 @@ void ExtNetworkRequest::writeConfiguration() const
void ExtNetworkRequest::networkReplyReceived(QNetworkReply *_reply)
{
if (_reply->error() != QNetworkReply::NoError) {
qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message"
<< _reply->errorString();
qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" << _reply->errorString();
return;
}
m_isRunning = false;
m_values[tag("response")]
= QTextCodec::codecForMib(106)->toUnicode(_reply->readAll()).trimmed();
m_values[tag("response")] = QTextCodec::codecForMib(106)->toUnicode(_reply->readAll()).trimmed();
emit(dataReceived(m_values));
}

View File

@ -50,8 +50,7 @@ ExtQuotes::ExtQuotes(QWidget *_parent, const QString &_filePath)
// HACK declare as child of nullptr to avoid crash with plasmawindowed
// in the destructor
m_manager = new QNetworkAccessManager(nullptr);
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this,
SLOT(quotesReplyReceived(QNetworkReply *)));
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
}
@ -61,8 +60,7 @@ ExtQuotes::~ExtQuotes()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this,
SLOT(quotesReplyReceived(QNetworkReply *)));
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
m_manager->deleteLater();
@ -176,8 +174,7 @@ void ExtQuotes::writeConfiguration() const
void ExtQuotes::quotesReplyReceived(QNetworkReply *_reply)
{
if (_reply->error() != QNetworkReply::NoError) {
qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message"
<< _reply->errorString();
qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" << _reply->errorString();
return;
}
@ -218,10 +215,9 @@ void ExtQuotes::translate()
ui->label_name->setText(i18n("Name"));
ui->label_comment->setText(i18n("Comment"));
ui->label_number->setText(i18n("Tag"));
ui->label->setText(
i18n("<html><head/><body><p>Use Stooq ticker to get quotes for the instrument. Refer to <a "
"href=\"https://stooq.com/\"><span style=\" text-decoration: underline; "
"color:#0057ae;\">https://stooq.com/</span></a></p></body></html>"));
ui->label->setText(i18n("<html><head/><body><p>Use Stooq ticker to get quotes for the instrument. Refer to <a "
"href=\"https://stooq.com/\"><span style=\" text-decoration: underline; "
"color:#0057ae;\">https://stooq.com/</span></a></p></body></html>"));
ui->label_ticker->setText(i18n("Ticker"));
ui->checkBox_active->setText(i18n("Active"));
ui->label_schedule->setText(i18n("Schedule"));

View File

@ -80,9 +80,8 @@ ExtScript *ExtScript::copy(const QString &_fileName, const int _number)
QString ExtScript::jsonFiltersFile()
{
QString fileName
= QStandardPaths::locate(QStandardPaths::GenericDataLocation,
"awesomewidgets/scripts/awesomewidgets-extscripts-filters.json");
QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
"awesomewidgets/scripts/awesomewidgets-extscripts-filters.json");
qCInfo(LOG_LIB) << "Filters file" << fileName;
return fileName;
@ -272,12 +271,9 @@ int ExtScript::showConfiguration(const QVariant &_args)
ui->lineEdit_socket->setText(socket());
ui->spinBox_interval->setValue(interval());
// filters
ui->checkBox_colorFilter->setCheckState(filters().contains("color") ? Qt::Checked
: Qt::Unchecked);
ui->checkBox_linesFilter->setCheckState(filters().contains("newline") ? Qt::Checked
: Qt::Unchecked);
ui->checkBox_spaceFilter->setCheckState(filters().contains("space") ? Qt::Checked
: Qt::Unchecked);
ui->checkBox_colorFilter->setCheckState(filters().contains("color") ? Qt::Checked : Qt::Unchecked);
ui->checkBox_linesFilter->setCheckState(filters().contains("newline") ? Qt::Checked : Qt::Unchecked);
ui->checkBox_spaceFilter->setCheckState(filters().contains("space") ? Qt::Checked : Qt::Unchecked);
int ret = exec();
if (ret != 1)
@ -329,11 +325,9 @@ void ExtScript::startProcess()
void ExtScript::updateValue()
{
qCInfo(LOG_LIB) << "Cmd returns" << m_process->exitCode();
QString qdebug
= QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardError()).trimmed();
QString qdebug = QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardError()).trimmed();
qCInfo(LOG_LIB) << "Error" << qdebug;
QString qoutput
= QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardOutput()).trimmed();
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardOutput()).trimmed();
qCInfo(LOG_LIB) << "Output" << qoutput;
QString strValue;

View File

@ -215,12 +215,10 @@ void ExtUpgrade::updateValue()
qCInfo(LOG_LIB) << "Cmd returns" << m_process->exitCode();
qCInfo(LOG_LIB) << "Error" << m_process->readAllStandardError();
QString qoutput
= QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardOutput()).trimmed();
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardOutput()).trimmed();
m_values[tag("pkgcount")] = [this](const QString &output) {
return filter().isEmpty()
? output.split('\n', Qt::SkipEmptyParts).count() - null()
: output.split('\n', Qt::SkipEmptyParts).filter(QRegExp(filter())).count();
return filter().isEmpty() ? output.split('\n', Qt::SkipEmptyParts).count() - null()
: output.split('\n', Qt::SkipEmptyParts).filter(QRegExp(filter())).count();
}(qoutput);
emit(dataReceived(m_values));

View File

@ -53,8 +53,7 @@ ExtWeather::ExtWeather(QWidget *_parent, const QString &_filePath)
// HACK declare as child of nullptr to avoid crash with plasmawindowed
// in the destructor
m_manager = new QNetworkAccessManager(nullptr);
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this,
SLOT(weatherReplyReceived(QNetworkReply *)));
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(weatherReplyReceived(QNetworkReply *)));
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
}
@ -64,8 +63,7 @@ ExtWeather::~ExtWeather()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this,
SLOT(weatherReplyReceived(QNetworkReply *)));
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(weatherReplyReceived(QNetworkReply *)));
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
m_manager->deleteLater();
@ -92,9 +90,8 @@ ExtWeather *ExtWeather::copy(const QString &_fileName, const int _number)
QString ExtWeather::jsonMapFile()
{
QString fileName
= QStandardPaths::locate(QStandardPaths::GenericDataLocation,
"awesomewidgets/weather/awesomewidgets-extweather-ids.json");
QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
"awesomewidgets/weather/awesomewidgets-extweather-ids.json");
qCInfo(LOG_LIB) << "Map file" << fileName;
return fileName;
@ -339,8 +336,7 @@ void ExtWeather::sendRequest()
void ExtWeather::weatherReplyReceived(QNetworkReply *_reply)
{
if (_reply->error() != QNetworkReply::NoError) {
qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message"
<< _reply->errorString();
qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" << _reply->errorString();
return;
}

View File

@ -136,8 +136,7 @@ QString GraphicalItem::image(const QVariant &value)
QByteArray byteArray;
QBuffer buffer(&byteArray);
pixmap.save(&buffer, "PNG");
QString url
= QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
QString url = QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
return url;
}
@ -541,8 +540,7 @@ void GraphicalItem::changeColor()
QString outputColor;
if (state == 0) {
QColor color = m_helper->stringToColor(lineEdit->text());
QColor newColor = QColorDialog::getColor(color, this, i18n("Select color"),
QColorDialog::ShowAlphaChannel);
QColor newColor = QColorDialog::getColor(color, this, i18n("Select color"), QColorDialog::ShowAlphaChannel);
if (!newColor.isValid())
return;
qCInfo(LOG_LIB) << "Selected color" << newColor;
@ -557,10 +555,9 @@ void GraphicalItem::changeColor()
} else if (state == 1) {
QString path = lineEdit->text();
QString directory = QFileInfo(path).absolutePath();
outputColor
= QFileDialog::getOpenFileUrl(this, i18n("Select path"), directory,
i18n("Images (*.png *.bpm *.jpg);;All files (*.*)"))
.toString();
outputColor = QFileDialog::getOpenFileUrl(this, i18n("Select path"), directory,
i18n("Images (*.png *.bpm *.jpg);;All files (*.*)"))
.toString();
qCInfo(LOG_LIB) << "Selected path" << outputColor;
}

View File

@ -40,11 +40,11 @@ GraphicalItemHelper::~GraphicalItemHelper()
}
void GraphicalItemHelper::setParameters(const QString &_active, const QString &_inactive,
const int _width, const int _height, const int _count)
void GraphicalItemHelper::setParameters(const QString &_active, const QString &_inactive, const int _width,
const int _height, const int _count)
{
qCDebug(LOG_LIB) << "Use active color" << _active << ", inactive" << _inactive << ", width"
<< _width << ", height" << _height << ", count" << _count;
qCDebug(LOG_LIB) << "Use active color" << _active << ", inactive" << _inactive << ", width" << _width << ", height"
<< _height << ", count" << _count;
// put images to pens if any otherwise set pen colors
// Images resize to content here as well
@ -155,11 +155,10 @@ void GraphicalItemHelper::paintHorizontal(const float _percent)
m_inactivePen.setWidth(m_height);
// inactive
auto width = static_cast<float>(m_width);
m_scene->addLine(_percent * width + 0.5 * m_height, 0.5 * m_height, m_width + 0.5 * m_height,
0.5 * m_height, m_inactivePen);
m_scene->addLine(_percent * width + 0.5 * m_height, 0.5 * m_height, m_width + 0.5 * m_height, 0.5 * m_height,
m_inactivePen);
// active
m_scene->addLine(-0.5 * m_height, 0.5 * m_height, _percent * width - 0.5 * m_height,
0.5 * m_height, m_activePen);
m_scene->addLine(-0.5 * m_height, 0.5 * m_height, _percent * width - 0.5 * m_height, 0.5 * m_height, m_activePen);
}
@ -170,8 +169,8 @@ void GraphicalItemHelper::paintVertical(const float _percent)
m_activePen.setWidth(m_height);
m_inactivePen.setWidth(m_height);
// inactive
m_scene->addLine(0.5 * m_width, -0.5 * m_width, 0.5 * m_width,
(1.0 - _percent) * m_height - 0.5 * m_width, m_inactivePen);
m_scene->addLine(0.5 * m_width, -0.5 * m_width, 0.5 * m_width, (1.0 - _percent) * m_height - 0.5 * m_width,
m_inactivePen);
// active
m_scene->addLine(0.5 * m_width, (1.0 - _percent) * m_height + 0.5 * m_width, 0.5 * m_width,
m_height + 0.5 * m_width, m_activePen);

View File

@ -33,8 +33,7 @@ public:
explicit GraphicalItemHelper(QObject *_parent = nullptr, QGraphicsScene *_scene = nullptr);
~GraphicalItemHelper() override;
// parameters
void setParameters(const QString &_active, const QString &_inactive, int _width, int _height,
int _count);
void setParameters(const QString &_active, const QString &_inactive, int _width, int _height, int _count);
// paint methods
void paintBars(float _value);
void paintCircle(float _percent);

View File

@ -66,8 +66,7 @@ QVariantHash OWMWeatherProvider::parse(const QVariantMap &_json) const
return parseSingleJson(_json);
} else {
QVariantList list = _json["list"].toList();
return parseSingleJson(list.count() <= m_ts ? list.at(m_ts - 1).toMap()
: list.last().toMap());
return parseSingleJson(list.count() <= m_ts ? list.at(m_ts - 1).toMap() : list.last().toMap());
}
}

View File

@ -67,10 +67,8 @@ void QCronScheduler::expired()
{
QDateTime now = QDateTime::currentDateTime();
if (m_schedule.minutes.contains(now.time().minute())
&& m_schedule.hours.contains(now.time().hour())
&& m_schedule.days.contains(now.date().day())
&& m_schedule.months.contains(now.date().month())
if (m_schedule.minutes.contains(now.time().minute()) && m_schedule.hours.contains(now.time().hour())
&& m_schedule.days.contains(now.date().day()) && m_schedule.months.contains(now.date().month())
&& m_schedule.weekdays.contains(now.date().dayOfWeek()))
emit(activated());
}

View File

@ -49,15 +49,13 @@ void StooqQuotesProvider::initUrl(const QString &_asset)
}
QVariantHash StooqQuotesProvider::parse(const QByteArray &_source,
const QVariantHash &_oldValues) const
QVariantHash StooqQuotesProvider::parse(const QByteArray &_source, const QVariantHash &_oldValues) const
{
qCDebug(LOG_LIB) << "Parse csv" << _source;
QVariantHash values;
QStringList sourceValues
= QTextCodec::codecForMib(106)->toUnicode(_source).trimmed().split(',');
QStringList sourceValues = QTextCodec::codecForMib(106)->toUnicode(_source).trimmed().split(',');
if (sourceValues.count() != 2) {
qCWarning(LOG_LIB) << "Parse error" << sourceValues;
return values;

View File

@ -31,8 +31,7 @@ public:
explicit StooqQuotesProvider(QObject *_parent);
~StooqQuotesProvider() override;
void initUrl(const QString &_asset) override;
[[nodiscard]] QVariantHash parse(const QByteArray &_source,
const QVariantHash &_oldValues) const override;
[[nodiscard]] QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const override;
[[nodiscard]] QUrl url() const override;
private:

View File

@ -49,8 +49,7 @@ void YahooQuotesProvider::initUrl(const QString &_asset)
}
QVariantHash YahooQuotesProvider::parse(const QByteArray &_source,
const QVariantHash &_oldValues) const
QVariantHash YahooQuotesProvider::parse(const QByteArray &_source, const QVariantHash &_oldValues) const
{
qCDebug(LOG_LIB) << "Parse json" << _source;

View File

@ -32,8 +32,7 @@ public:
explicit YahooQuotesProvider(QObject *_parent);
~YahooQuotesProvider() override;
void initUrl(const QString &_asset) override;
[[nodiscard]] QVariantHash parse(const QByteArray &_source,
const QVariantHash &_oldValues) const override;
[[nodiscard]] QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const override;
[[nodiscard]] QUrl url() const override;
private:

View File

@ -73,8 +73,7 @@ QUrl YahooWeatherProvider::url() const
}
QVariantHash YahooWeatherProvider::parseCurrent(const QVariantMap &_json,
const QVariantMap &_atmosphere) const
QVariantHash YahooWeatherProvider::parseCurrent(const QVariantMap &_json, const QVariantMap &_atmosphere) const
{
qCDebug(LOG_LIB) << "Parse current weather from" << _json;
@ -99,8 +98,7 @@ QVariantHash YahooWeatherProvider::parseForecast(const QVariantMap &_json) const
QVariantHash values;
QVariantList weatherList = _json["forecast"].toList();
QVariantMap weatherMap
= weatherList.count() < m_ts ? weatherList.last().toMap() : weatherList.at(m_ts).toMap();
QVariantMap weatherMap = weatherList.count() < m_ts ? weatherList.last().toMap() : weatherList.at(m_ts).toMap();
int id = weatherMap["code"].toInt();
values[tag("weatherId")] = id;
values[tag("timestamp")] = weatherMap["date"].toString();

View File

@ -38,8 +38,7 @@ public:
[[nodiscard]] QUrl url() const override;
private:
[[nodiscard]] QVariantHash parseCurrent(const QVariantMap &_json,
const QVariantMap &_atmosphere) const;
[[nodiscard]] QVariantHash parseCurrent(const QVariantMap &_json, const QVariantMap &_atmosphere) const;
[[nodiscard]] QVariantHash parseForecast(const QVariantMap &_json) const;
int m_ts = 0;
QUrl m_url;