Fetch ZEC Price for display purposes

This commit is contained in:
Aditya Kulkarni
2018-10-18 11:15:49 -07:00
parent 6f79abcc14
commit 1b2335c0d4
9 changed files with 108 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
#include "balancestablemodel.h"
#include "settings.h"
#include "utils.h"
BalancesTableModel::BalancesTableModel(QObject *parent)
@@ -68,12 +69,22 @@ QVariant BalancesTableModel::data(const QModelIndex &index, int role) const
return b;
}
if (role == Qt::DisplayRole || role == Qt::ToolTipRole) {
if (role == Qt::DisplayRole) {
switch (index.column()) {
case 0: return std::get<0>(modeldata->at(index.row()));
case 1: return QVariant(std::get<1>(modeldata->at(index.row())) % " " % Utils::getTokenName());
}
}
if(role == Qt::ToolTipRole) {
switch (index.column()) {
case 0: return std::get<0>(modeldata->at(index.row()));
case 1: {
auto bal = std::get<1>(modeldata->at(index.row())).toDouble();
return "$ " + QString::number(bal * Settings::getInstance()->getZECPrice(), 'f', 2); // Use 'f' notation to get 2 decimal places
}
}
}
return QVariant();
}