bitcoin/bitcoin — pull request #5587 by SoCoCpp (2015-01-01 03:10:57+00:00)
Title: Addition of a balance column in transaction history table

I created a running balance column in the transaction table, like you would see on most financial ledgers. This came into complications with the table's column re-size fixer system. I updated that as well to support multiple columns to the right of the column you want to stretch.

Balance column details:

This was accomplished by adding a balance variable to the TransactionRecord class, but the main code which fills those variables is in (/src/qt/transactiontablemodel.cpp) TransactionTablePriv::updateWalletBalances() which is called in reaction to TransactionTablePriv::refreshWallet() and new/deleted transactions detected in TransactionTablePriv::updateWallet().

TransactionTablePriv::updateWalletBalances() builds a list of pointers to the transactions in the TransactionTablePriv::cachedWallet list, sorts them by time as they are already ordered by hash, then iterates them calculating the balance at the time that transaction came in the list.

Many changes were made to support adding the GUI column and all the features that go with that. This includes filtering support, Bitcoin units support, CSV export support, and column sorting support.

Column size fixer details:

The (src/qt/guiutil.cpp) TableViewLastColumnResizingFixer was created expecting the RecentRequestsTableModel::Message to be the main stretching column and only the RecentRequestsTableModel::Amount column to be to the right of it as well as being the right most column.

I updated this to allow you to specify the stretch column index. It handles the special cases of re-sizing the stretch column, the last column, and the second last column. Aside from restoring the same functionality with support for the additional column (and future column additions), it also restores the ability to re-size the last column from the right side. This isn't an intuitive way to do it, but there seems no benefit from preventing doing so. I think preventing this was just a side effect of the previous code.

This column size fixer is used on the transaction table (src/qt/transactionview.cpp) and the received coins table (src/qt/receivecoinsdialog.cpp).

I put together a quick video comparing the column re-sizing Qt default behavior, the original Bitcoin column size fixer, what happens to the original fixer when the new balance column is added, and how it works with the balance column and the updated column fixer.

http://youtu.be/7N-c9p-YNCQ