From 41ec1ca0ec6df26c3b716fe401e55d8925fda31d Mon Sep 17 00:00:00 2001 From: Evgenii Tagiltsev <tagiltsev.ebgenii@gmail.com> Date: Thu, 22 Aug 2019 14:01:05 +0200 Subject: [PATCH] [*] checked filters, corrected design --- .../DapScreenHistoryFilterModel.cpp | 18 ++++++++--- .../DapScreenHistoryFilterModel.h | 6 ++-- KelvinDashboardGUI/DapScreenHistoryModel.cpp | 10 ++++++ KelvinDashboardGUI/DapScreenHistoryModel.h | 1 + KelvinDashboardGUI/DapUiQmlScreenHistory.qml | 31 ++++++------------- 5 files changed, 37 insertions(+), 29 deletions(-) diff --git a/KelvinDashboardGUI/DapScreenHistoryFilterModel.cpp b/KelvinDashboardGUI/DapScreenHistoryFilterModel.cpp index e52aef219..8f6d334e8 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 606cc0c45..8c38e0f49 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 2b7d2fdb8..24656d6ef 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 f29de672a..4314fe2fb 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 31d49d645..353f06b06 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; -// } -// } -- GitLab