diff --git a/KelvinDashboardGUI/DapScreenHistoryFilterModel.cpp b/KelvinDashboardGUI/DapScreenHistoryFilterModel.cpp index e52aef2192b52e746091630e6fc181441f5a5c04..8f6d334e8d283170e2c0ea76267b17956b64ad6e 100644 --- a/KelvinDashboardGUI/DapScreenHistoryFilterModel.cpp +++ b/KelvinDashboardGUI/DapScreenHistoryFilterModel.cpp @@ -1,7 +1,8 @@ #include "DapScreenHistoryFilterModel.h" DapScreenHistoryFilterModel::DapScreenHistoryFilterModel(QObject *parent) : - QSortFilterProxyModel(parent) + QSortFilterProxyModel(parent), + m_status(-1) { sort(0, Qt::DescendingOrder); } @@ -19,7 +20,7 @@ void DapScreenHistoryFilterModel::setFilterWallet(const QString& aWalletNumber) setFilterKeyColumn(0); } -void DapScreenHistoryFilterModel::setFilterDate(const QDateTime& aDateLeft, const QDateTime& aDateRight) +void DapScreenHistoryFilterModel::setFilterDate(const QDate& aDateLeft, const QDate& aDateRight) { if(m_dateLeft == aDateLeft || m_dateRight == aDateRight) return; m_dateLeft = aDateLeft; @@ -46,7 +47,14 @@ bool DapScreenHistoryFilterModel::filterAcceptsRow(int source_row, const QModelI QModelIndex index = sourceModel()->index(source_row, 0, source_parent); QDateTime time = index.data(DapScreenHistoryModel::DateRole).toDateTime(); - return (index.data(DapScreenHistoryModel::DisplayNumberWalletRole).toString() == m_walletNumber) || - (index.data(DapScreenHistoryModel::DisplayStatusRole).toInt() == m_status) || - (time >= m_dateLeft && time <= m_dateRight); + bool result = true; + bool filterByWalletNumber = !m_walletNumber.isEmpty(); + bool filterByDate = m_dateLeft.isValid() && m_dateRight.isValid(); + bool filterByStatus = m_status > -1; + + if(filterByDate) result &= (time.date() >= m_dateLeft && time.date() <= m_dateRight); + if(filterByStatus) result &= (index.data(DapScreenHistoryModel::StatusRole).toInt() == m_status); + if(filterByWalletNumber) result &= (index.data(DapScreenHistoryModel::DisplayNumberWalletRole).toString() == m_walletNumber); + + return result; } diff --git a/KelvinDashboardGUI/DapScreenHistoryFilterModel.h b/KelvinDashboardGUI/DapScreenHistoryFilterModel.h index 606cc0c45211bae23b63dcfcc5cc0209242805fe..8c38e0f492f9c25ab0fc0e825c85df7a72c6475f 100644 --- a/KelvinDashboardGUI/DapScreenHistoryFilterModel.h +++ b/KelvinDashboardGUI/DapScreenHistoryFilterModel.h @@ -11,8 +11,8 @@ class DapScreenHistoryFilterModel : public QSortFilterProxyModel private: QString m_walletNumber; - QDateTime m_dateLeft; - QDateTime m_dateRight; + QDate m_dateLeft; + QDate m_dateRight; int m_status; protected: @@ -25,7 +25,7 @@ public: public slots: void setFilterWallet(const QString& aWalletNumber); - void setFilterDate(const QDateTime& aDateLeft, const QDateTime& aDateRight); + void setFilterDate(const QDate& aDateLeft, const QDate& aDateRight); void setFilterStatus(const DapTransactionStatus aStatus); }; diff --git a/KelvinDashboardGUI/DapScreenHistoryModel.cpp b/KelvinDashboardGUI/DapScreenHistoryModel.cpp index 2b7d2fdb8044d77e79cb9212b8f0fc26a293b0c4..24656d6ef26e797c8a34d3729ebba18a6978e6fe 100644 --- a/KelvinDashboardGUI/DapScreenHistoryModel.cpp +++ b/KelvinDashboardGUI/DapScreenHistoryModel.cpp @@ -52,6 +52,15 @@ void DapScreenHistoryModel::receiveNewData(const QVariant& aData) item.TokenName = dataItem.at(3); item.WalletNumber = dataItem.at(5); item.Currency = "$ 0 USD"; // TODO: + + switch (item.Status) { + case DapTransactionStatus::stSent: item.Cryptocurrency.prepend("- "); break; + case DapTransactionStatus::stReceived: item.Cryptocurrency.prepend("+ "); break; + default: break; + } + + item.Cryptocurrency += " " + item.TokenName; + m_elementList.append(item); } @@ -84,6 +93,7 @@ QVariant DapScreenHistoryModel::data(const QModelIndex &index, int role) const case DisplayCurrency: return m_elementList.at(index.row()).Currency; case DateRole: return m_elementList.at(index.row()).Date; case StatusColorRole: return DapTransactionStatusConvertor::getStatusColor(m_elementList.at(index.row()).Status); + case StatusRole: return m_elementList.at(index.row()).Status; default: return QVariant(); } } diff --git a/KelvinDashboardGUI/DapScreenHistoryModel.h b/KelvinDashboardGUI/DapScreenHistoryModel.h index f29de672a15c39b7956ddb9a90e0fad07db375f8..4314fe2fb74fb20b37ad317ac7e24fac096b1cc0 100644 --- a/KelvinDashboardGUI/DapScreenHistoryModel.h +++ b/KelvinDashboardGUI/DapScreenHistoryModel.h @@ -38,6 +38,7 @@ public: DisplayNameTokenRole, DisplayNumberWalletRole, DisplayStatusRole, + StatusRole, StatusColorRole, DisplayCryptocurrency, DisplayCurrency diff --git a/KelvinDashboardGUI/DapUiQmlScreenHistory.qml b/KelvinDashboardGUI/DapUiQmlScreenHistory.qml index 31d49d645dd8236d7fbbeb2c139749fc15e63420..353f06b06c8e382ddd6805539dbe504e47b9d613 100644 --- a/KelvinDashboardGUI/DapUiQmlScreenHistory.qml +++ b/KelvinDashboardGUI/DapUiQmlScreenHistory.qml @@ -78,6 +78,7 @@ Page { // Token name Rectangle { + id: dapTokenNameContainer width: 246 * pt Layout.maximumWidth: width height: dapTokenName.contentHeight @@ -86,7 +87,6 @@ Page { Text { id: dapTokenName anchors.fill: parent - textFormat: Qt.RichText text: tokenName color: "#4F5357" font.family: "Regular" @@ -214,21 +214,13 @@ Page { // Spacing Rectangle { + id: dapEndItem width: 20 * pt height: parent.height } } } - // Underline - Rectangle { - width: parent.width -// width: 1056 * pt -// anchors.right: parent.right -// anchors.left: dapNumberWallet.left - height: 1 - color: "#C2CAD1" - } // Number wallet tip Rectangle { @@ -244,17 +236,14 @@ Page { font.pixelSize: 14 * pt } } + + // Underline + Rectangle { + x: dapTokenNameContainer.x + width: 1056 * pt + height: 1 + color: "#C2CAD1" + } } } } - - - -// onTextChanged: { -// switch(text) { -// case DapTransactionModel.Error: color = "#00081B"; break; -// case DapTransactionModel.Received: color = "#454E63"; break; -// case DapTransactionModel.Sent: color = "#959CA6"; break; -// case DapTransactionModel.Pending: color = "#E3E3E3"; break; -// } -// }