mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-12-16 10:03:40 +00:00
try to implement timeouts support to quotes (ref to #54)
This commit is contained in:
@ -20,11 +20,29 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMap>
|
||||
#include <QNetworkReply>
|
||||
#include <QTimer>
|
||||
|
||||
#define YAHOO_URL "https://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.quotes where symbol=\"$TICKER\"&env=store://datatables.org/alltableswithkeys&format=json"
|
||||
|
||||
|
||||
class QNetworkReply;
|
||||
class QReplyTimeout : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QReplyTimeout(QNetworkReply *reply, const int timeout) : QObject(reply)
|
||||
{
|
||||
QTimer::singleShot(timeout, this, SLOT(timeout()));
|
||||
}
|
||||
|
||||
private slots:
|
||||
void timeout()
|
||||
{
|
||||
QNetworkReply *reply = static_cast<QNetworkReply *>(parent());
|
||||
if (reply->isRunning()) reply->close();
|
||||
}
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class ExtQuotes;
|
||||
|
||||
Reference in New Issue
Block a user