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

[*] added timer for request transaction history

[*] added timer for request transaction history
parent d54c4fc1
No related branches found
No related tags found
1 merge request!11Cellframe clone
......@@ -60,7 +60,6 @@ void DapCommandController::getHistory()
void DapCommandController::setNewHistory(const QVariant& aData)
{
qDebug() << "new story" << aData;
emit sendHistory(aData);
}
......
......@@ -3,7 +3,9 @@
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()
......@@ -29,6 +31,8 @@ QHash<int, QByteArray> DapScreenHistoryModel::roleNames() const
void DapScreenHistoryModel::receiveNewData(const QVariant& aData)
{
if(!aData.isValid()) return;
if(m_timeout->isActive()) m_timeout->stop();
beginResetModel();
QList<QVariant> dataList = aData.toList();
m_elementList.clear();
......
......@@ -5,6 +5,7 @@
#include <QImage>
#include <QAbstractListModel>
#include <QDateTime>
#include <QTimer>
#include "DapHistoryType.h"
#define MASK_FOR_MODEL QString("MMMM, dd")
......@@ -46,6 +47,7 @@ public:
private:
QList<DapTransactionItem> m_elementList;
QTimer* m_timeout;
public:
explicit DapScreenHistoryModel(QObject *parent = nullptr);
......@@ -57,6 +59,9 @@ public:
public slots:
void receiveNewData(const QVariant& aData);
signals:
void sendRequestHistory();
};
#endif // DAPSCREENHISTORYMODEL_H
......@@ -59,6 +59,8 @@ 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
......
......@@ -35,8 +35,6 @@ class DapServiceController : public QObject
explicit DapServiceController(QObject *apParent = nullptr);
public:
/// Get an instance of a class.
/// @return Instance of a class.
Q_INVOKABLE static DapServiceController &getInstance();
......@@ -82,7 +80,7 @@ public:
void getWalletInfo(const QString& asWalletName);
void getHistory();
signals:
/// The signal is emitted when the Brand company property changes.
......@@ -119,6 +117,7 @@ private slots:
void processGetHistory(const QVariant& aData);
public slots:
void getHistory();
void getNodeNetwork();
void setNodeStatus(const bool aIsOnline);
......
......@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
dapServiceClient.init();
controller.getNodeLogs(0, 100);
controller.getWallets();
controller.getHistory();
// controller.getHistory();
DapScreenHistoryFilterModel::getInstance()
.setSourceModel(&DapScreenHistoryModel::getInstance());
......
......@@ -31,16 +31,8 @@ void DapChainHistoryHandler::onRequestNewHistory(const QMap<QString, QVariant>&
if(!result.isEmpty())
{
// TODO: error with "\r\n"
QString reg_str;
//#ifdef Q_OS_LINUX
// reg_str = "(\\w{3}\\s\\w{3}\\s\\d+\\s\\d{1,2}:\\d{2}:\\d{2}\\s\\d{4})\\n"
// "\\s(\\w+)\\s(\\d+)\\s(\\w+)\\s\\w+\\s+(\\w+)";
//#endif
//#ifdef Q_OS_WIN
reg_str = "(\\w{3}\\s\\w{3}\\s\\d+\\s\\d{1,2}:\\d{2}:\\d{2}\\s\\d{4})\\s+"
"(\\w+)\\s(\\d+)\\s(\\w+)\\s\\w+\\s+(\\w+)";
//#endif
QString reg_str = "(\\w{3}\\s\\w{3}\\s\\d+\\s\\d{1,2}:\\d{2}:\\d{2}\\s\\d{4})\\s+"
"(\\w+)\\s(\\d+)\\s(\\w+)\\s\\w+\\s+(\\w+)";
QRegExp rx(reg_str);
......@@ -48,7 +40,7 @@ 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(2))) << rx.cap(3) << rx.cap(4) << rx.cap(5) << wallets.at(i).toString();
// qDebug() << "NEW MATCH" << pos << dataItem;
qDebug() << "NEW MATCH" << pos << dataItem;
data << dataItem;
pos += rx.matchedLength();
}
......
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