mirror of
https://github.com/AskDavis/Casinotest.git
synced 2025-12-31 20:55:58 -08:00
Added active exchanges parser
This commit is contained in:
23
QmlImports.qml
Normal file
23
QmlImports.qml
Normal file
@@ -0,0 +1,23 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Dialogs 1.1
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Window 2.1
|
||||
import QtQuick.Controls.Styles 1.2
|
||||
|
||||
/*
|
||||
QmlImports.qml
|
||||
|
||||
Declaration of QML Imports required by project.
|
||||
|
||||
This is necessary if we want to keep qml files in a folder
|
||||
separate from .pro file because of the way qmlimportscanner works.
|
||||
If these imports are not declared, qmake will not recognize them,
|
||||
and QtQuick will not be packaged with statically built apps and imported
|
||||
at runtime.
|
||||
|
||||
This must be kept in the same directory as your .pro file
|
||||
*/
|
||||
|
||||
QtObject {}
|
||||
14
casinocoin-qt_qml_plugin_import.cpp
Normal file
14
casinocoin-qt_qml_plugin_import.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
// This file is autogenerated by qmake. It imports static plugin classes for
|
||||
// static plugins used by QML imports.
|
||||
#include <QtPlugin>
|
||||
Q_IMPORT_PLUGIN(QtQuick2Plugin)
|
||||
Q_IMPORT_PLUGIN(QtQuickControlsPlugin)
|
||||
Q_IMPORT_PLUGIN(QtQuick2DialogsPlugin)
|
||||
Q_IMPORT_PLUGIN(QtQuickLayoutsPlugin)
|
||||
Q_IMPORT_PLUGIN(QtQuick2WindowPlugin)
|
||||
Q_IMPORT_PLUGIN(QmlFolderListModelPlugin)
|
||||
Q_IMPORT_PLUGIN(QmlSettingsPlugin)
|
||||
Q_IMPORT_PLUGIN(QtQuick2DialogsPrivatePlugin)
|
||||
Q_IMPORT_PLUGIN(QtQuickExtrasPlugin)
|
||||
Q_IMPORT_PLUGIN(QtQmlModelsPlugin)
|
||||
Q_IMPORT_PLUGIN(QtQuick2PrivateWidgetsPlugin)
|
||||
@@ -88,8 +88,8 @@ void CasinoCoinWebAPIParser::ParseCasinos( const QJsonObject& a_rJsonCasinos )
|
||||
|
||||
void CasinoCoinWebAPIParser::ParseExchanges( const QJsonObject& a_rJsonExchanges )
|
||||
{
|
||||
qDebug() << "Coming soon - ParseExchanges";
|
||||
qDebug() << a_rJsonExchanges;
|
||||
qDebug() << "ParseExchanges";
|
||||
emit signalActiveExchangesParsed( new JsonActiveExchangesParser( a_rJsonExchanges ) );
|
||||
}
|
||||
|
||||
void CasinoCoinWebAPIParser::ParseNewsItems( const QJsonObject& a_rJsonNewsItems )
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "jsonactivepromotionsparser.h"
|
||||
#include "jsonsingleactivepromotion.h"
|
||||
#include "jsoncoininfoparser.h"
|
||||
#include "jsonactiveexchangesparser.h"
|
||||
#include "jsonsingleactiveexchange.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
|
||||
@@ -20,7 +22,7 @@ signals:
|
||||
void signalActivePromotionsParsed( JsonActivePromotionsParser* a_pActivePromotions );
|
||||
void signalCoinInfoParsed( JsonCoinInfoParser* a_pCoinInfo );
|
||||
// void signalActiveCasinosParsed( JsonActiveCasinosParser* a_pActivePromotions );
|
||||
// void signalActiveExchangesParsed( JsonActiveExchangesParser* a_pActivePromotions );
|
||||
void signalActiveExchangesParsed( JsonActiveExchangesParser* a_pActiveExchanges );
|
||||
// void signalActiveNewsItemsParsed( JsonActiveNewsItemsParser* a_pActivePromotions );
|
||||
|
||||
public slots:
|
||||
|
||||
54
src/qt/CSCPublicAPI/jsonactiveexchangesparser.cpp
Normal file
54
src/qt/CSCPublicAPI/jsonactiveexchangesparser.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "jsonactiveexchangesparser.h"
|
||||
#include "../qtquick_controls/cpp/qmlimageprovider.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
JsonActiveExchangesParser::JsonActiveExchangesParser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JsonActiveExchangesParser::JsonActiveExchangesParser( const QJsonObject& a_rOther )
|
||||
: QJsonObject( a_rOther )
|
||||
{
|
||||
ResolveExchangesArray();
|
||||
}
|
||||
|
||||
void JsonActiveExchangesParser::ResolveExchangesArray()
|
||||
{
|
||||
if ( find( "Result" ).value().isObject() )
|
||||
{
|
||||
if ( find( "Result" ).value().toObject().find( "ActiveExchanges" ).value().isArray() )
|
||||
{
|
||||
QJsonArray arrayOfExchangeDescriptors( find( "Result" ).value().toObject().find( "ActiveExchanges" ).value().toArray() );
|
||||
foreach( QJsonValue singleExchangeDescriptor, arrayOfExchangeDescriptors )
|
||||
{
|
||||
if ( singleExchangeDescriptor.isObject() )
|
||||
{
|
||||
m_aActiveExchanges.append( JsonSingleActiveExchange( singleExchangeDescriptor.toObject() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QList<JsonSingleActiveExchange>& JsonActiveExchangesParser::GetExchanges() const
|
||||
{
|
||||
return m_aActiveExchanges;
|
||||
}
|
||||
|
||||
QList<JsonSingleActiveExchange>& JsonActiveExchangesParser::GetExchanges()
|
||||
{
|
||||
return m_aActiveExchanges;
|
||||
}
|
||||
|
||||
void JsonActiveExchangesParser::AddImagesToPool( QmlImageProvider* a_pImageProvider )
|
||||
{
|
||||
if ( a_pImageProvider )
|
||||
{
|
||||
foreach( JsonSingleActiveExchange oExchange, m_aActiveExchanges )
|
||||
{
|
||||
a_pImageProvider->AddToImagePool( oExchange.getImageName(), oExchange.getExchangeImage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
31
src/qt/CSCPublicAPI/jsonactiveexchangesparser.h
Normal file
31
src/qt/CSCPublicAPI/jsonactiveexchangesparser.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef JSONACTIVEEXCHANGESPARSER_H
|
||||
#define JSONACTIVEEXCHANGESPARSER_H
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QJsonArray>
|
||||
#include <QList>
|
||||
|
||||
#include "jsonsingleactiveexchange.h"
|
||||
|
||||
class QmlImageProvider;
|
||||
|
||||
class JsonActiveExchangesParser : public QJsonObject
|
||||
{
|
||||
public:
|
||||
JsonActiveExchangesParser();
|
||||
JsonActiveExchangesParser( const QJsonObject& a_rOther );
|
||||
virtual ~JsonActiveExchangesParser(){}
|
||||
|
||||
const QList<JsonSingleActiveExchange>& GetExchanges() const;
|
||||
QList<JsonSingleActiveExchange>& GetExchanges();
|
||||
|
||||
void AddImagesToPool( QmlImageProvider* a_pImageProvider );
|
||||
|
||||
private:
|
||||
void ResolveExchangesArray();
|
||||
|
||||
QList<JsonSingleActiveExchange> m_aActiveExchanges;
|
||||
};
|
||||
|
||||
#endif // JSONACTIVEEXCHANGESPARSER_H
|
||||
42
src/qt/CSCPublicAPI/jsonsingleactiveexchange.cpp
Normal file
42
src/qt/CSCPublicAPI/jsonsingleactiveexchange.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "jsonsingleactiveexchange.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QImage>
|
||||
#include <QDir>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
JsonSingleActiveExchange::JsonSingleActiveExchange()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JsonSingleActiveExchange::JsonSingleActiveExchange( const QJsonObject& a_rOther )
|
||||
: QJsonObject( a_rOther )
|
||||
{
|
||||
m_strImageName = find( "exchange_name" ).value().toString().remove( getRestrictedCharacters() );
|
||||
storeImage();
|
||||
m_strExchangeName = find( "exchange_name" ).value().toString().remove( getRestrictedCharacters() );
|
||||
m_strAccessUrl = find( "access_url" ).value().toString();
|
||||
m_strDescription = find( "description" ).value().toString();
|
||||
m_dblLastBidPriceBTC = find( "last_bid_price_btc" ).value().toDouble();
|
||||
m_dblLastAskPriceBTC = find( "last_ask_price_btc" ).value().toDouble();
|
||||
m_dblLastPriceBTC = find( "last_price_btc" ).value().toDouble();
|
||||
m_dblVolume24H = find( "volume24h" ).value().toDouble();
|
||||
m_strLastUpdateTime = find( "last_update_time" ).value().toString();
|
||||
}
|
||||
|
||||
QRegExp JsonSingleActiveExchange::getRestrictedCharacters()
|
||||
{
|
||||
return QRegExp( "[<,>|\\:()&;#?*% ]" );
|
||||
}
|
||||
|
||||
void JsonSingleActiveExchange::storeImage()
|
||||
{
|
||||
if ( find( "image_mime_type" ).value().toString().split( "/" ).first().contains( "image" ) )
|
||||
{
|
||||
QByteArray binaryData = QByteArray::fromBase64( find( "exchange_image" ).value().toString().toLocal8Bit() );
|
||||
m_oExchangeImage = QImage::fromData( binaryData );
|
||||
}
|
||||
}
|
||||
|
||||
46
src/qt/CSCPublicAPI/jsonsingleactiveexchange.h
Normal file
46
src/qt/CSCPublicAPI/jsonsingleactiveexchange.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef JSONSINGLEACTIVEEXCHANGE_H
|
||||
#define JSONSINGLEACTIVEEXCHANGE_H
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include <QImage>
|
||||
|
||||
class JsonSingleActiveExchange : public QJsonObject
|
||||
{
|
||||
public:
|
||||
JsonSingleActiveExchange();
|
||||
JsonSingleActiveExchange( const QJsonObject& a_rOther );
|
||||
virtual ~JsonSingleActiveExchange(){}
|
||||
|
||||
QString getImageName() const{ return m_strImageName; }
|
||||
QImage getExchangeImage() const { return m_oExchangeImage; }
|
||||
QString getExchangeName() const{ return m_strExchangeName; }
|
||||
QString getAccessUrl() const{ return m_strAccessUrl; }
|
||||
QString getDescription() const{ return m_strDescription; }
|
||||
double getLastBidPriceBTC() const{ return m_dblLastBidPriceBTC; }
|
||||
double getLastAskPriceBTC() const{ return m_dblLastAskPriceBTC; }
|
||||
double getLastPriceBTC() const{ return m_dblLastBidPriceBTC; }
|
||||
double getVolume24H() const{ return m_dblVolume24H; }
|
||||
QString getLastUpdateTime() const{ return m_strLastUpdateTime; }
|
||||
|
||||
private:
|
||||
void storeImage();
|
||||
|
||||
static QRegExp getRestrictedCharacters();
|
||||
|
||||
QString m_strImageName;
|
||||
QImage m_oExchangeImage;
|
||||
QString m_strExchangeName;
|
||||
QString m_strAccessUrl;
|
||||
QString m_strDescription;
|
||||
double m_dblLastBidPriceBTC;
|
||||
double m_dblLastAskPriceBTC;
|
||||
double m_dblLastPriceBTC;
|
||||
double m_dblVolume24H;
|
||||
QString m_strLastUpdateTime;
|
||||
|
||||
};
|
||||
|
||||
#endif // JSONSINGLEACTIVEEXCHANGE_H
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>500</height>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -159,31 +159,6 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>343</width>
|
||||
<height>217</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QFormLayout" name="formCoinDetails">
|
||||
@@ -607,8 +582,6 @@
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
@@ -83,6 +83,14 @@
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="butRedeem">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(166, 27, 31);
|
||||
color: rgb(255, 255, 255);
|
||||
pressed
|
||||
{
|
||||
background-color: rgb(166, 27, 31);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Redeem</string>
|
||||
</property>
|
||||
@@ -91,7 +99,10 @@
|
||||
<normaloff>:/icons/res/icons/prypto.png</normaloff>:/icons/res/icons/prypto.png</iconset>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -730,11 +730,11 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(170, 28, 33);
|
||||
<string notr="true">background-color: rgb(166, 27, 31);
|
||||
color: rgb(255, 255, 255);
|
||||
pressed
|
||||
{
|
||||
background-color: rgb(170, 28, 33);
|
||||
background-color: rgb(166, 27, 31);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QSsl>
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
#include <QListIterator>
|
||||
|
||||
const QString PryptoPage::strAPIEndpoint = "https://prypto.com/merchants/api/";
|
||||
const QString PryptoPage::strMerchantToken = "35616ab118fa557b77fdac78ef09d5632d302609";
|
||||
@@ -18,6 +19,7 @@ PryptoPage::PryptoPage(QWidget *parent) :
|
||||
connect( &networkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(parseAPINetworkResponse(QNetworkReply*)) );
|
||||
connect( this, SIGNAL(apiResponseReady(QByteArray)), this, SLOT(showAPIResult(QByteArray)) );
|
||||
connect( this, SIGNAL(apiNetworkError(QNetworkReply::NetworkError)), this, SLOT(showAPINetworkError(QNetworkReply::NetworkError)) );
|
||||
connect( &networkAccessManager, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError> & )), this, SLOT(sslErrorHandler(QNetworkReply*, const QList<QSslError> & )));
|
||||
}
|
||||
|
||||
void PryptoPage::setWalletModel(WalletModel *model)
|
||||
@@ -82,6 +84,12 @@ void PryptoPage::parseAPINetworkResponse( QNetworkReply *finished )
|
||||
emit apiResponseReady( data );
|
||||
}
|
||||
|
||||
void PryptoPage::sslErrorHandler(QNetworkReply* qnr, const QList<QSslError> & errlist)
|
||||
{
|
||||
qDebug() << "---PryptoPage::sslErrorHandler: ";
|
||||
qnr->ignoreSslErrors();
|
||||
}
|
||||
|
||||
void PryptoPage::showAPINetworkError(QNetworkReply::NetworkError error)
|
||||
{
|
||||
qDebug() << "PryptoPage::showAPINetworkError: " << error;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QProgressDialog>
|
||||
#include <QList>
|
||||
|
||||
class WalletModel;
|
||||
|
||||
@@ -31,6 +32,7 @@ private slots:
|
||||
void parseAPINetworkResponse( QNetworkReply *finished );
|
||||
void showAPIResult(QByteArray data);
|
||||
void showAPINetworkError(QNetworkReply::NetworkError error);
|
||||
void sslErrorHandler(QNetworkReply* qnr, const QList<QSslError> & errlist);
|
||||
|
||||
private:
|
||||
static const QString strAPIEndpoint;
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 26 KiB |
Reference in New Issue
Block a user