mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
drop pornography with requests
Actually it has been introduced as temporary solution but I totally forgot about it
This commit is contained in:
parent
15abe54290
commit
354fd3cd0c
@ -26,6 +26,7 @@
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QSettings>
|
||||
#include <QUrlQuery>
|
||||
|
||||
#include <qreplytimeout/qreplytimeout.h>
|
||||
|
||||
@ -56,8 +57,8 @@ ExtQuotes::ExtQuotes(QWidget *parent, const QString quotesName,
|
||||
|
||||
// HACK declare as child of nullptr to avoid crash with plasmawindowed
|
||||
// in the destructor
|
||||
manager = new QNetworkAccessManager(nullptr);
|
||||
connect(manager, SIGNAL(finished(QNetworkReply *)), this,
|
||||
m_manager = new QNetworkAccessManager(nullptr);
|
||||
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this,
|
||||
SLOT(quotesReplyReceived(QNetworkReply *)));
|
||||
}
|
||||
|
||||
@ -66,10 +67,10 @@ ExtQuotes::~ExtQuotes()
|
||||
{
|
||||
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
|
||||
|
||||
disconnect(manager, SIGNAL(finished(QNetworkReply *)), this,
|
||||
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this,
|
||||
SLOT(quotesReplyReceived(QNetworkReply *)));
|
||||
|
||||
manager->deleteLater();
|
||||
m_manager->deleteLater();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@ -134,6 +135,16 @@ void ExtQuotes::readConfiguration()
|
||||
setApiVersion(AWEQAPI);
|
||||
writeConfiguration();
|
||||
}
|
||||
|
||||
// init query
|
||||
m_url = QUrl(YAHOO_QUOTES_URL);
|
||||
QUrlQuery params;
|
||||
params.addQueryItem(QString("format"), QString("json"));
|
||||
params.addQueryItem(QString("env"),
|
||||
QString("store://datatables.org/alltableswithkeys"));
|
||||
params.addQueryItem(QString("q"),
|
||||
QString(YAHOO_QUOTES_QUERY).arg(m_ticker));
|
||||
m_url.setQuery(params);
|
||||
}
|
||||
|
||||
|
||||
@ -145,7 +156,7 @@ QVariantHash ExtQuotes::run()
|
||||
if (times == 1) {
|
||||
qCInfo(LOG_LIB) << "Send request";
|
||||
isRunning = true;
|
||||
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url())));
|
||||
QNetworkReply *reply = m_manager->get(QNetworkRequest(m_url));
|
||||
new QReplyTimeout(reply, REQUEST_TIMEOUT);
|
||||
}
|
||||
|
||||
@ -271,12 +282,3 @@ get quotes for the instrument. Refer to <a href=\"http://finance.yahoo.com/\">\
|
||||
ui->checkBox_active->setText(i18n("Active"));
|
||||
ui->label_interval->setText(i18n("Interval"));
|
||||
}
|
||||
|
||||
|
||||
QString ExtQuotes::url() const
|
||||
{
|
||||
QString apiUrl = QString(YAHOO_QUOTES_URL).arg(m_ticker);
|
||||
qCInfo(LOG_LIB) << "API url" << apiUrl;
|
||||
|
||||
return apiUrl;
|
||||
}
|
||||
|
@ -22,11 +22,9 @@
|
||||
|
||||
#include "abstractextitem.h"
|
||||
|
||||
#define YAHOO_QUOTES_URL \
|
||||
"https://query.yahooapis.com/v1/public/yql?q=select * from " \
|
||||
"yahoo.finance.quotes where " \
|
||||
"symbol=\"%1\"&env=store://datatables.org/" \
|
||||
"alltableswithkeys&format=json"
|
||||
#define YAHOO_QUOTES_URL "https://query.yahooapis.com/v1/public/yql"
|
||||
#define YAHOO_QUOTES_QUERY \
|
||||
"select * from yahoo.finance.quotes where symbol='%1'"
|
||||
|
||||
|
||||
namespace Ui
|
||||
@ -61,11 +59,11 @@ private slots:
|
||||
void quotesReplyReceived(QNetworkReply *reply);
|
||||
|
||||
private:
|
||||
QNetworkAccessManager *manager;
|
||||
QNetworkAccessManager *m_manager;
|
||||
QUrl m_url;
|
||||
bool isRunning = false;
|
||||
Ui::ExtQuotes *ui;
|
||||
void translate();
|
||||
QString url() const;
|
||||
// properties
|
||||
QString m_ticker = QString("EURUSD=X");
|
||||
// values
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <QNetworkRequest>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QUrlQuery>
|
||||
|
||||
#include <qreplytimeout/qreplytimeout.h>
|
||||
|
||||
@ -54,8 +55,8 @@ ExtWeather::ExtWeather(QWidget *parent, const QString weatherName,
|
||||
|
||||
// HACK declare as child of nullptr to avoid crash with plasmawindowed
|
||||
// in the destructor
|
||||
manager = new QNetworkAccessManager(nullptr);
|
||||
connect(manager, SIGNAL(finished(QNetworkReply *)), this,
|
||||
m_manager = new QNetworkAccessManager(nullptr);
|
||||
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this,
|
||||
SLOT(weatherReplyReceived(QNetworkReply *)));
|
||||
}
|
||||
|
||||
@ -64,10 +65,10 @@ ExtWeather::~ExtWeather()
|
||||
{
|
||||
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
|
||||
|
||||
disconnect(manager, SIGNAL(finished(QNetworkReply *)), this,
|
||||
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this,
|
||||
SLOT(weatherReplyReceived(QNetworkReply *)));
|
||||
|
||||
manager->deleteLater();
|
||||
m_manager->deleteLater();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@ -94,7 +95,7 @@ QString ExtWeather::weatherFromInt(const int _id) const
|
||||
qCDebug(LOG_LIB) << "Weather ID" << _id;
|
||||
|
||||
QVariantMap map
|
||||
= jsonMap[m_image ? QString("image") : QString("text")].toMap();
|
||||
= m_jsonMap[m_image ? QString("image") : QString("text")].toMap();
|
||||
return map.value(QString::number(_id), map[QString("default")]).toString();
|
||||
}
|
||||
|
||||
@ -193,6 +194,16 @@ void ExtWeather::readConfiguration()
|
||||
setApiVersion(AWEWAPI);
|
||||
writeConfiguration();
|
||||
}
|
||||
|
||||
// init query
|
||||
m_url = QUrl(YAHOO_WEATHER_URL);
|
||||
QUrlQuery params;
|
||||
params.addQueryItem(QString("format"), QString("json"));
|
||||
params.addQueryItem(QString("env"),
|
||||
QString("store://datatables.org/alltableswithkeys"));
|
||||
params.addQueryItem(QString("q"),
|
||||
QString(YAHOO_WEATHER_QUERY).arg(m_city, m_country));
|
||||
m_url.setQuery(params);
|
||||
}
|
||||
|
||||
|
||||
@ -216,9 +227,9 @@ void ExtWeather::readJsonMap()
|
||||
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
||||
return;
|
||||
}
|
||||
jsonMap = jsonDoc.toVariant().toMap();
|
||||
m_jsonMap = jsonDoc.toVariant().toMap();
|
||||
|
||||
qCInfo(LOG_LIB) << "Weather map" << jsonMap;
|
||||
qCInfo(LOG_LIB) << "Weather map" << m_jsonMap;
|
||||
}
|
||||
|
||||
|
||||
@ -230,7 +241,7 @@ QVariantHash ExtWeather::run()
|
||||
if (times == 1) {
|
||||
qCInfo(LOG_LIB) << "Send request";
|
||||
isRunning = true;
|
||||
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url())));
|
||||
QNetworkReply *reply = m_manager->get(QNetworkRequest(m_url));
|
||||
new QReplyTimeout(reply, REQUEST_TIMEOUT);
|
||||
}
|
||||
|
||||
@ -374,13 +385,3 @@ void ExtWeather::translate()
|
||||
ui->checkBox_active->setText(i18n("Active"));
|
||||
ui->label_interval->setText(i18n("Interval"));
|
||||
}
|
||||
|
||||
|
||||
QString ExtWeather::url() const
|
||||
{
|
||||
|
||||
QString apiUrl = QString(YAHOO_WEATHER_URL).arg(m_city).arg(m_country);
|
||||
qCInfo(LOG_LIB) << "API url" << apiUrl;
|
||||
|
||||
return apiUrl;
|
||||
}
|
||||
|
@ -22,10 +22,10 @@
|
||||
|
||||
#include "abstractextitem.h"
|
||||
|
||||
#define YAHOO_WEATHER_URL \
|
||||
"https://query.yahooapis.com/v1/public/yql?format=json&env=store://" \
|
||||
"datatables.org/alltableswithkeys&q=select * from weather.forecast where " \
|
||||
"u='c' and woeid in (select woeid from geo.places(1) where text='%1, %2')"
|
||||
#define YAHOO_WEATHER_URL "https://query.yahooapis.com/v1/public/yql"
|
||||
#define YAHOO_WEATHER_QUERY \
|
||||
"select * from weather.forecast where u='c' and woeid in (select woeid " \
|
||||
"from geo.places(1) where text='%1, %2')"
|
||||
|
||||
|
||||
namespace Ui
|
||||
@ -71,17 +71,17 @@ private slots:
|
||||
void weatherReplyReceived(QNetworkReply *reply);
|
||||
|
||||
private:
|
||||
QNetworkAccessManager *manager;
|
||||
QNetworkAccessManager *m_manager;
|
||||
QUrl m_url;
|
||||
bool isRunning = false;
|
||||
Ui::ExtWeather *ui;
|
||||
void translate();
|
||||
QString url() const;
|
||||
// properties
|
||||
QString m_city = QString("London");
|
||||
QString m_country = QString("uk");
|
||||
bool m_image = false;
|
||||
int m_ts = 0;
|
||||
QVariantMap jsonMap = QVariantMap();
|
||||
QVariantMap m_jsonMap = QVariantMap();
|
||||
// values
|
||||
int times = 0;
|
||||
QVariantHash values;
|
||||
|
Loading…
Reference in New Issue
Block a user