Full support for other units, add configuration option for default unit (used when...
[novacoin.git] / src / qt / transactiontablemodel.cpp
index 52c9b0c..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"
 
@@ -208,7 +211,7 @@ TransactionTableModel::TransactionTableModel(CWallet* wallet, WalletModel *paren
         walletModel(parent),
         priv(new TransactionTablePriv(wallet, this))
 {
-    columns << tr("Status") << tr("Date") << tr("Type") << tr("Address") << tr("Amount");
+    columns << QString() << tr("Date") << tr("Type") << tr("Address") << tr("Amount");
 
     priv->refreshWallet();
 
@@ -278,7 +281,7 @@ QVariant TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) con
         status = tr("Offline (%1 confirmations)").arg(wtx->status.depth);
         break;
     case TransactionStatus::Unconfirmed:
-        status = tr("Unconfirmed (%1/%2 confirmations)").arg(wtx->status.depth).arg(TransactionRecord::NumConfirmations);
+        status = tr("Unconfirmed (%1 of %2 confirmations required)").arg(wtx->status.depth).arg(TransactionRecord::NumConfirmations);
         break;
     case TransactionStatus::HaveConfirmations:
         status = tr("Confirmed (%1 confirmations)").arg(wtx->status.depth);
@@ -320,12 +323,12 @@ QVariant TransactionTableModel::formatTxDate(const TransactionRecord *wtx) const
 }
 
 /* Look up address in address book, if found return
-     address[0:12]... (label)
+     address (label)
    otherwise just return address
  */
 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())
     {
@@ -333,7 +336,7 @@ QString TransactionTableModel::lookupAddress(const std::string &address) const
     }
     else
     {
-        description = label + QString(" (") + QString::fromStdString(address.substr(0,12)) + QString("...)");
+        description = label + QString(" (") + QString::fromStdString(address) + QString(")");
     }
     return description;
 }
@@ -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)
     {