From 07319582b99a794c1e1c8880afcfa9b9d420592b Mon Sep 17 00:00:00 2001
From: "moneromooo.monero" <moneromooo.monero@users.noreply.github.com>
Date: Sat, 5 Nov 2016 19:02:39 +0000
Subject: [PATCH] History: display the sum of selected transactions

---
 pages/History.qml | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/pages/History.qml b/pages/History.qml
index bf71791a..a6c216bf 100644
--- a/pages/History.qml
+++ b/pages/History.qml
@@ -41,11 +41,28 @@ Rectangle {
     property var model
 
     color: "#F0EEEE"
+
+    function getSelectedAmount() {
+      var total = 0
+      var count = model.rowCount()
+      for (var i = 0; i < count; ++i) {
+          var idx = model.index(i, 0)
+          var isout = model.data(idx, TransactionHistoryModel.TransactionIsOutRole);
+          var amount = model.data(idx, TransactionHistoryModel.TransactionAmountRole);
+          if (isout)
+              total -= amount
+          else
+              total += amount
+      }
+      return count + qsTr(" selected: ") + total;
+    }
+
     onModelChanged: {
         if (typeof model !== 'undefined') {
             // setup date filter scope according to real transactions
             fromDatePicker.currentDate = model.transactionHistory.firstDateTime
             toDatePicker.currentDate = model.transactionHistory.lastDateTime
+            selectedAmount.text = getSelectedAmount()
         }
     }
 
@@ -65,6 +82,18 @@ Rectangle {
         text: qsTr("Filter transaction history") + translationManager.emptyString
     }
 
+    Label {
+        id: selectedAmount
+        anchors.right: parent.right
+        anchors.top: parent.top
+        anchors.rightMargin: 17
+        anchors.topMargin: 17
+        text: getSelectedAmount()
+        fontSize: 14
+        tipText: qsTr("<b>Total amount of selected payments</b>") + translationManager.emptyString
+    }
+
+
     // Filter by Address input (senseless, removing)
     /*
     Label {
@@ -213,6 +242,7 @@ Rectangle {
                 model.directionFilter = directionFilter
             }
 
+            selectedAmount.text = getSelectedAmount()
 
         }
     }