Browse Source

compile

pull/140/head
Jonathan "Duke" Leto 5 years ago
parent
commit
f561256b04
  1. 6
      src/mainwindow.cpp
  2. 6
      src/mainwindow.ui
  3. 12
      src/rpc.cpp
  4. 42
      src/settings.cpp
  5. 6
      src/settings.h

6
src/mainwindow.cpp

@ -943,9 +943,9 @@ void MainWindow::setupMarketTab() {
auto s = Settings::getInstance();
auto ticker = s->get_currency_name();
ui->volumeExchange->setText(QString::number((double) s->getVolume("HUSH") ,'f',8) + " HUSH");
ui->volumeExchangeLocal->setText(QString::number((double) s->getVolume(ticker) ,'f',8) + " " + QString::fromStdString(ticker));
ui->volumeExchangeBTC->setText(QString::number((double) s->getVolume("BTC") ,'f',8) + " BTC");
ui->volume->setText(QString::number((double) s->get_volume("HUSH") ,'f',8) + " HUSH");
ui->volumeLocal->setText(QString::number((double) s->get_volume(ticker) ,'f',8) + " " + QString::fromStdString(ticker));
ui->volumeBTC->setText(QString::number((double) s->get_volume("BTC") ,'f',8) + " BTC");
}
void MainWindow::setupTransactionsTab() {

6
src/mainwindow.ui

@ -999,21 +999,21 @@
</widget>
</item>
<item row="14" column="1">
<widget class="QLabel" name="volumeExchange">
<widget class="QLabel" name="volume">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="14" column="2">
<widget class="QLabel" name="volumeExchangeLocal">
<widget class="QLabel" name="volumeLocal">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="14" column="3">
<widget class="QLabel" name="volumeExchangeBTC">
<widget class="QLabel" name="volumeBTC">
<property name="text">
<string>Loading...</string>
</property>

12
src/rpc.cpp

@ -1,4 +1,5 @@
// Copyright 2019 The Hush Developers
// Released under the GPLv3
#include "rpc.h"
#include "addressbook.h"
@ -1145,7 +1146,16 @@ void RPC::refreshPrice() {
// convert ticker to upper case
std::for_each(ticker.begin(), ticker.end(), [](char & c){ c = ::tolower(c); });
qDebug() << "ticker=" << QString::fromStdString(ticker);
s->set_price(ticker, hush[ticker]);
// TODO: update all stats and prevent coredumps!
auto price = hush[ticker];
auto vol = hush[ticker + "_24h_vol"];
auto mcap = hush[ticker + "_market_cap"];
s->set_price(ticker, price);
s->set_volume(ticker, vol);
//s->set_marketcap(ticker, mcap);
//ui->marketcap = QString::number(mcap);
ui->volume = QString::number((double) vol);
refresh(true);
return;
} else {

42
src/settings.cpp

@ -177,10 +177,47 @@ double Settings::get_price(std::string currency) {
void Settings::set_price(std::string curr, double price) {
QString ticker = QString::fromStdString(curr);
qDebug() << "Setting price of " << ticker << "=" << QString::number(price);
// prices[curr] = price;
auto it = prices.insert( std::make_pair(curr, price) );
}
void Settings::set_volume(std::string curr, double volume) {
QString ticker = QString::fromStdString(curr);
qDebug() << "Setting volume of " << ticker << "=" << QString::number(volume);
auto it = volumes.insert( std::make_pair(curr, volume) );
}
double Settings::get_volume(std::string currency) {
std::for_each(currency.begin(), currency.end(), [](char & c){ c = ::tolower(c); });
QString ticker = QString::fromStdString(currency);
auto search = volumes.find(currency);
if (search != volumes.end()) {
qDebug() << "Found volume of " << ticker << " = " << search->second;
return search->second;
} else {
qDebug() << "Could not find volume of" << ticker << "!!!";
return -1.0;
}
}
void Settings::set_marketcap(std::string curr, double marketcap) {
QString ticker = QString::fromStdString(curr);
qDebug() << "Setting marketcap of " << ticker << "=" << QString::number(marketcap);
auto it = marketcaps.insert( std::make_pair(curr, marketcap) );
}
double Settings::get_marketcap(std::string currency) {
std::for_each(currency.begin(), currency.end(), [](char & c){ c = ::tolower(c); });
QString ticker = QString::fromStdString(currency);
auto search = marketcaps.find(currency);
if (search != marketcaps.end()) {
qDebug() << "Found marketcap of " << ticker << " = " << search->second;
return search->second;
} else {
qDebug() << "Could not find marketcap of" << ticker << "!!!";
return -1.0;
}
}
unsigned int Settings::getBTCPrice() {
// in satoshis
return btcPrice;
@ -309,9 +346,6 @@ void Settings::set_currency_name(std::string currency_name) {
QSettings().setValue("options/currency_name", QString::fromStdString(currency_name));
}
double Settings::getVolume(std::string ticker) {
return 0.0;
}
bool Settings::removeFromZcashConf(QString confLocation, QString option) {
if (confLocation.isEmpty())

6
src/settings.h

@ -98,8 +98,9 @@ public:
double get_fiat_price();
unsigned int getBTCPrice();
double get_price(std::string currency);
double get_marketcap(std::string currency);
void set_price(std::string currency, double price);
double getVolume(std::string ticker);
double get_volume(std::string ticker);
void setPeers(int peers);
int getPeers();
@ -163,7 +164,8 @@ private:
double fiat_price = 0.0;
unsigned int btcPrice = 0;
std::map<std::string, double> prices;
std::map<std::string, double> volumes;
std::map<std::string, double> marketcaps;
};
#endif // SETTINGS_H

Loading…
Cancel
Save