Skip to content
Snippets Groups Projects
Commit ffcae85d authored by jonymt's avatar jonymt
Browse files

[*] added test converter for currency

parent 074ba8e2
No related branches found
No related tags found
1 merge request!12Bugs 2496
Pipeline #774 passed with stage
in 3 minutes and 6 seconds
......@@ -3,9 +3,7 @@
DapScreenHistoryModel::DapScreenHistoryModel(QObject *parent)
: QAbstractListModel(parent)
{
m_timeout = new QTimer(this);
QObject::connect(m_timeout, &QTimer::timeout, this, &DapScreenHistoryModel::sendRequestHistory);
m_timeout->start(1000);
}
DapScreenHistoryModel& DapScreenHistoryModel::getInstance()
......@@ -52,8 +50,6 @@ void DapScreenHistoryModel::receiveNewData(const QVariant& aData)
return;
}
if(m_timeout->isActive()) m_timeout->stop();
beginResetModel();
QList<QVariant> dataList = aData.toList();
m_elementList.clear();
......@@ -77,16 +73,23 @@ void DapScreenHistoryModel::receiveNewData(const QVariant& aData)
item.TokenName = dataItem.at(3);
item.WalletNumber = dataItem.at(5);
// TODO: Later we should convert currency
item.Currency = "$ 0 USD";
item.Currency = QString::number(dataItem.at(2).toDouble() * 0.98);
switch (item.Status) {
case DapTransactionStatus::stSent: item.Cryptocurrency.prepend("- "); break;
case DapTransactionStatus::stReceived: item.Cryptocurrency.prepend("+ "); break;
case DapTransactionStatus::stSent:
item.Cryptocurrency.prepend("- ");
item.Currency.prepend("- $ ");
break;
case DapTransactionStatus::stReceived:
item.Cryptocurrency.prepend("+ ");
item.Currency.prepend("+ $ ");
break;
default: break;
}
item.Cryptocurrency = toConvertCurrency(item.Cryptocurrency);
item.Cryptocurrency += " " + item.TokenName;
item.Currency.append(" USD");
m_elementList.append(item);
}
......
......@@ -31,7 +31,6 @@ public:
private:
QList<DapTransactionItem> m_elementList;
QTimer* m_timeout;
public:
explicit DapScreenHistoryModel(QObject *parent = nullptr);
......
......@@ -59,8 +59,6 @@ void DapServiceController::init(DapServiceClient *apDapServiceClient)
connect(m_pDapCommandController, SIGNAL(sendHistory(QVariant)), this, SLOT(processGetHistory(QVariant)));
connect(m_pDapCommandController, &DapCommandController::sendHistory, &DapScreenHistoryModel::getInstance(), &DapScreenHistoryModel::receiveNewData);
connect(&DapScreenHistoryModel::getInstance(), &DapScreenHistoryModel::sendRequestHistory, this, &DapServiceController::getHistory);
}
QString DapServiceController::getBrand() const
......
......@@ -124,7 +124,7 @@ public slots:
/// Change status of node
/// @param it is true if a node is online
void setNodeStatus(const bool aIsOnline);
///
void get();
/// Get node logs.
......
......@@ -61,7 +61,7 @@ Item {
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignRight
color: currencyTextInput.readOnly ? "#ACACAF" : "#737880"
font.family: fontExchange.name
font.family: contentFont
font.pixelSize: 12 * pt
text: index === 0 ? currencyName : qsTr("USD")
}
......
......@@ -11,22 +11,18 @@ Item {
width: childrenRect.width
height: childrenRect.height
FontLoader {
id: fontExchange
source: "qrc:/Resources/Fonts/roboto_regular.ttf"
}
ColumnLayout {
DapUiQmlWidgetExchangeOrderTitleForm {
id: orderTitle
orderFont: fontExchange.name
orderFont: "Roboto"
}
Text {
text: qsTr("Balance: ") + balance + " " + currencyName
color: "#ACACAF"
font.family: fontExchange.name
font.family: "Roboto"
font.pixelSize: 12 * pt
}
......@@ -37,7 +33,7 @@ Item {
}
DapUiQmlWidgetExchangeOrderContentForm {
contentFont: fontExchange.name
contentFont: "Roboto"
}
Rectangle {
......@@ -46,7 +42,7 @@ Item {
}
DapUiQmlWidgetExchangeOrderButtonForm {
buttonFont: fontExchange.name
buttonFont: "Roboto"
buttonText: titleOrder
}
}
......
......@@ -52,6 +52,7 @@ int main(int argc, char *argv[])
controller.init(&dapServiceClient);
dapServiceClient.init();
controller.getWallets();
controller.getHistory();
DapScreenHistoryFilterModel::getInstance()
.setSourceModel(&DapScreenHistoryModel::getInstance());
......
......@@ -35,7 +35,6 @@ void DapChainHistoryHandler::onRequestNewHistory(const QMap<QString, QVariant>&
while ((pos = rx.indexIn(result, pos)) != -1)
{
QStringList dataItem = QStringList() << rx.cap(1) << QString::number(DapTransactionStatusConvertor::getStatusByShort(rx.cap(4))) << rx.cap(5) << rx.cap(6) << rx.cap(7) << wallets.at(i).toString();
qDebug() << "NEW MATCH" << pos << dataItem;
data << dataItem;
pos += rx.matchedLength();
}
......
......@@ -13,29 +13,31 @@ DapChainLogHandler::DapChainLogHandler(QObject *parent) : QObject(parent)
QStringList DapChainLogHandler::request()
{
QStringList m_listLogs;
QFile file(LOG_FILE);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
emit onUpdateModel();
}
else
{
QTextStream in(&file);
// QRegExp rx("(\\[|\\]|\\s)([\\w*]{1,1}[\\w\\s\\W]+)([\\n]|\\])" ); !!! DO NOT DELETE!!!
QRegExp rx("(\\[|\\]|\\s)([\\w*]{1,1}[\\w\\s\\W]+)(\\]|$)" );
rx.setMinimal(true);
/// TODO: The application doesn't work because of it. It needs to be changed
// QStringList m_listLogs;
// QFile file(LOG_FILE);
// if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
// {
// emit onUpdateModel();
// }
// else
// {
// QTextStream in(&file);
//// QRegExp rx("(\\[|\\]|\\s)([\\w*]{1,1}[\\w\\s\\W]+)([\\n]|\\])" ); !!! DO NOT DELETE!!!
// QRegExp rx("(\\[|\\]|\\s)([\\w*]{1,1}[\\w\\s\\W]+)(\\]|$)" );
// rx.setMinimal(true);
while (!in.atEnd()) {
QString line = in.readLine();
int pos{0};
while((pos = rx.indexIn(line, pos)) != -1)
{
m_listLogs.append(rx.cap(2));
pos += rx.matchedLength();
}
}
}
return m_listLogs;
// while (!in.atEnd()) {
// QString line = in.readLine();
// int pos{0};
// while((pos = rx.indexIn(line, pos)) != -1)
// {
// m_listLogs.append(rx.cap(2));
// pos += rx.matchedLength();
// }
// }
// }
// return m_listLogs;
return QStringList();
}
......@@ -21,8 +21,7 @@ ICON = icon.ico
win32 {
VERSION = $${VER_MAJ}.$${VER_MIN}.$$VER_PAT
DEFINES += CLI_PATH=\\\"./kelvin-node-cli.exe\\\"
# DEFINES += LOG_FILE=\\\"./opt/kelvin-node/var/log/kelvin-node_logs.txt\\\"
DEFINES += LOG_FILE=\\\"./kelvin-node_logs.txt\\\"
DEFINES += LOG_FILE=\\\"./opt/kelvin-node/var/log/kelvin-node_logs.txt\\\"
}
else {
VERSION = $$VER_MAJ\.$$VER_MIN\-$$VER_PAT
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment