Full support for other units, add configuration option for default unit (used when...
[novacoin.git] / src / qt / transactiontablemodel.cpp
index 2477a1e..99f2d58 100644 (file)
@@ -4,6 +4,9 @@
 #include "guiconstants.h"
 #include "transactiondesc.h"
 #include "walletmodel.h"
+#include "optionsmodel.h"
+#include "addresstablemodel.h"
+#include "bitcoinunits.h"
 
 #include "headers.h"
 
@@ -325,7 +328,7 @@ QVariant TransactionTableModel::formatTxDate(const TransactionRecord *wtx) const
  */
 QString TransactionTableModel::lookupAddress(const std::string &address) const
 {
-    QString label = walletModel->labelForAddress(QString::fromStdString(address));
+    QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(address));
     QString description;
     if(label.isEmpty())
     {
@@ -396,7 +399,7 @@ QVariant TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx)
 
 QVariant TransactionTableModel::formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed) const
 {
-    QString str = QString::fromStdString(FormatMoney(wtx->credit + wtx->debit));
+    QString str = BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->credit + wtx->debit);
     if(showUnconfirmed)
     {
         if(!wtx->status.confirmed || wtx->status.maturity != TransactionStatus::Mature)
@@ -513,11 +516,11 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
         /* Non-confirmed transactions are grey */
         if(!rec->status.confirmed)
         {
-            return QColor(128, 128, 128);
+            return COLOR_UNCONFIRMED;
         }
         if(index.column() == Amount && (rec->credit+rec->debit) < 0)
         {
-            return QColor(255, 0, 0);
+            return COLOR_NEGATIVE;
         }
     }
     else if (role == TypeRole)
@@ -538,7 +541,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
     }
     else if (role == LabelRole)
     {
-        return walletModel->labelForAddress(QString::fromStdString(rec->address));
+        return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address));
     }
     else if (role == AbsoluteAmountRole)
     {