QtUI code cleanup / comment improvements
This commit is contained in:
parent
fb390d3505
commit
b0849613bf
16 changed files with 110 additions and 152 deletions
|
@ -161,13 +161,13 @@ bool AddressTableModel::setData(const QModelIndex & index, const QVariant & valu
|
||||||
rec->label = value.toString();
|
rec->label = value.toString();
|
||||||
break;
|
break;
|
||||||
case Address:
|
case Address:
|
||||||
// Refuse to set invalid address
|
// Refuse to set invalid address, set error status and return false
|
||||||
if(!walletModel->validateAddress(value.toString()))
|
if(!walletModel->validateAddress(value.toString()))
|
||||||
{
|
{
|
||||||
editStatus = INVALID_ADDRESS;
|
editStatus = INVALID_ADDRESS;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Double-check that we're not overwriting receiving address
|
// Double-check that we're not overwriting a receiving address
|
||||||
if(rec->type == AddressTableEntry::Sending)
|
if(rec->type == AddressTableEntry::Sending)
|
||||||
{
|
{
|
||||||
CRITICAL_BLOCK(wallet->cs_mapAddressBook)
|
CRITICAL_BLOCK(wallet->cs_mapAddressBook)
|
||||||
|
@ -234,7 +234,7 @@ QModelIndex AddressTableModel::index(int row, int column, const QModelIndex & pa
|
||||||
|
|
||||||
void AddressTableModel::updateList()
|
void AddressTableModel::updateList()
|
||||||
{
|
{
|
||||||
// Update internal model from Bitcoin core
|
// Update address book model from Bitcoin core
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
priv->refreshAddressTable();
|
priv->refreshAddressTable();
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
@ -247,7 +247,6 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
|
||||||
|
|
||||||
editStatus = OK;
|
editStatus = OK;
|
||||||
|
|
||||||
|
|
||||||
if(type == Send)
|
if(type == Send)
|
||||||
{
|
{
|
||||||
if(!walletModel->validateAddress(address))
|
if(!walletModel->validateAddress(address))
|
||||||
|
@ -255,7 +254,7 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
|
||||||
editStatus = INVALID_ADDRESS;
|
editStatus = INVALID_ADDRESS;
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
// Check for duplicate
|
// Check for duplicate addresses
|
||||||
CRITICAL_BLOCK(wallet->cs_mapAddressBook)
|
CRITICAL_BLOCK(wallet->cs_mapAddressBook)
|
||||||
{
|
{
|
||||||
if(wallet->mapAddressBook.count(strAddress))
|
if(wallet->mapAddressBook.count(strAddress))
|
||||||
|
|
|
@ -135,7 +135,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
// Put this in a block, so that BitcoinGUI is cleaned up properly before
|
// Put this in a block, so that BitcoinGUI is cleaned up properly before
|
||||||
// calling shutdown.
|
// calling Shutdown().
|
||||||
BitcoinGUI window;
|
BitcoinGUI window;
|
||||||
splash.finish(&window);
|
splash.finish(&window);
|
||||||
OptionsModel optionsModel(pwalletMain);
|
OptionsModel optionsModel(pwalletMain);
|
||||||
|
|
|
@ -44,7 +44,7 @@ BitcoinAmountField::BitcoinAmountField(QWidget *parent):
|
||||||
connect(decimals, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged()));
|
connect(decimals, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged()));
|
||||||
connect(unit, SIGNAL(currentIndexChanged(int)), this, SLOT(unitChanged(int)));
|
connect(unit, SIGNAL(currentIndexChanged(int)), this, SLOT(unitChanged(int)));
|
||||||
|
|
||||||
// TODO: set default based on configuration
|
// Set default based on configuration
|
||||||
unitChanged(unit->currentIndex());
|
unitChanged(unit->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,6 @@ void BitcoinAmountField::clear()
|
||||||
{
|
{
|
||||||
amount->clear();
|
amount->clear();
|
||||||
decimals->clear();
|
decimals->clear();
|
||||||
// TODO: set default based on configuration
|
|
||||||
unit->setCurrentIndex(0);
|
unit->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
|
||||||
resize(850, 550);
|
resize(850, 550);
|
||||||
setWindowTitle(tr("Bitcoin Wallet"));
|
setWindowTitle(tr("Bitcoin Wallet"));
|
||||||
setWindowIcon(QIcon(":icons/bitcoin"));
|
setWindowIcon(QIcon(":icons/bitcoin"));
|
||||||
|
// Accept D&D of URIs
|
||||||
|
setAcceptDrops(true);
|
||||||
|
|
||||||
createActions();
|
createActions();
|
||||||
|
|
||||||
|
@ -68,8 +70,8 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
|
||||||
QMenu *help = menuBar()->addMenu("&Help");
|
QMenu *help = menuBar()->addMenu("&Help");
|
||||||
help->addAction(aboutAction);
|
help->addAction(aboutAction);
|
||||||
|
|
||||||
// Toolbar
|
// Toolbars
|
||||||
QToolBar *toolbar = addToolBar("Main toolbar");
|
QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
|
||||||
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||||
toolbar->addAction(overviewAction);
|
toolbar->addAction(overviewAction);
|
||||||
toolbar->addAction(sendCoinsAction);
|
toolbar->addAction(sendCoinsAction);
|
||||||
|
@ -77,19 +79,17 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
|
||||||
toolbar->addAction(historyAction);
|
toolbar->addAction(historyAction);
|
||||||
toolbar->addAction(addressBookAction);
|
toolbar->addAction(addressBookAction);
|
||||||
|
|
||||||
QToolBar *toolbar2 = addToolBar("Transactions toolbar");
|
QToolBar *toolbar2 = addToolBar(tr("Actions toolbar"));
|
||||||
toolbar2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
toolbar2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||||
toolbar2->addAction(exportAction);
|
toolbar2->addAction(exportAction);
|
||||||
|
|
||||||
// Overview page
|
// Create tabs
|
||||||
overviewPage = new OverviewPage();
|
overviewPage = new OverviewPage();
|
||||||
QVBoxLayout *vbox = new QVBoxLayout();
|
|
||||||
|
|
||||||
transactionView = new TransactionView(this);
|
|
||||||
connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));
|
|
||||||
vbox->addWidget(transactionView);
|
|
||||||
|
|
||||||
transactionsPage = new QWidget(this);
|
transactionsPage = new QWidget(this);
|
||||||
|
QVBoxLayout *vbox = new QVBoxLayout();
|
||||||
|
transactionView = new TransactionView(this);
|
||||||
|
vbox->addWidget(transactionView);
|
||||||
transactionsPage->setLayout(vbox);
|
transactionsPage->setLayout(vbox);
|
||||||
|
|
||||||
addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);
|
addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);
|
||||||
|
@ -109,7 +109,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
|
||||||
// Create status bar
|
// Create status bar
|
||||||
statusBar();
|
statusBar();
|
||||||
|
|
||||||
// Status bar "Blocks" notification
|
// Status bar notification icons
|
||||||
QFrame *frameBlocks = new QFrame();
|
QFrame *frameBlocks = new QFrame();
|
||||||
//frameBlocks->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
//frameBlocks->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
||||||
frameBlocks->setContentsMargins(0,0,0,0);
|
frameBlocks->setContentsMargins(0,0,0,0);
|
||||||
|
@ -141,10 +141,11 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
|
||||||
|
|
||||||
syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this);
|
syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this);
|
||||||
|
|
||||||
// Clicking on a transaction simply sends you to transaction history page
|
// Clicking on a transaction on the overview page simply sends you to transaction history page
|
||||||
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
|
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
|
||||||
|
|
||||||
setAcceptDrops(true);
|
// Doubleclicking on a transaction on the transaction history page shows details
|
||||||
|
connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));
|
||||||
|
|
||||||
gotoOverviewPage();
|
gotoOverviewPage();
|
||||||
}
|
}
|
||||||
|
@ -252,7 +253,6 @@ void BitcoinGUI::createTrayIcon()
|
||||||
{
|
{
|
||||||
QMenu *trayIconMenu = new QMenu(this);
|
QMenu *trayIconMenu = new QMenu(this);
|
||||||
trayIconMenu->addAction(openBitcoinAction);
|
trayIconMenu->addAction(openBitcoinAction);
|
||||||
trayIconMenu->addAction(sendCoinsAction);
|
|
||||||
trayIconMenu->addAction(optionsAction);
|
trayIconMenu->addAction(optionsAction);
|
||||||
trayIconMenu->addSeparator();
|
trayIconMenu->addSeparator();
|
||||||
trayIconMenu->addAction(quitAction);
|
trayIconMenu->addAction(quitAction);
|
||||||
|
@ -268,7 +268,7 @@ void BitcoinGUI::createTrayIcon()
|
||||||
|
|
||||||
void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
|
void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
|
||||||
{
|
{
|
||||||
if(reason == QSystemTrayIcon::DoubleClick)
|
if(reason == QSystemTrayIcon::Trigger)
|
||||||
{
|
{
|
||||||
// Doubleclick on system tray icon triggers "open bitcoin"
|
// Doubleclick on system tray icon triggers "open bitcoin"
|
||||||
openBitcoinAction->trigger();
|
openBitcoinAction->trigger();
|
||||||
|
@ -347,31 +347,22 @@ void BitcoinGUI::setNumBlocks(int count)
|
||||||
text = tr("%n day(s) ago","",secs/(60*60*24));
|
text = tr("%n day(s) ago","",secs/(60*60*24));
|
||||||
}
|
}
|
||||||
|
|
||||||
// In the label we want to be less specific
|
// Set icon state: spinning if catching up, tick otherwise
|
||||||
bool spinning = true;
|
|
||||||
if(secs < 30*60)
|
if(secs < 30*60)
|
||||||
{
|
{
|
||||||
tooltip = tr("Up to date") + QString("\n") + tooltip;
|
tooltip = tr("Up to date") + QString("\n") + tooltip;
|
||||||
spinning = false;
|
labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(16,16));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tooltip = tr("Catching up...") + QString("\n") + tooltip;
|
tooltip = tr("Catching up...") + QString("\n") + tooltip;
|
||||||
|
labelBlocksIcon->setMovie(syncIconMovie);
|
||||||
|
syncIconMovie->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
tooltip += QString("\n");
|
tooltip += QString("\n");
|
||||||
tooltip += tr("Last received block was generated %1.").arg(text);
|
tooltip += tr("Last received block was generated %1.").arg(text);
|
||||||
|
|
||||||
if(spinning)
|
|
||||||
{
|
|
||||||
labelBlocksIcon->setMovie(syncIconMovie);
|
|
||||||
syncIconMovie->start();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(16,16));
|
|
||||||
}
|
|
||||||
|
|
||||||
labelBlocksIcon->setToolTip(tooltip);
|
labelBlocksIcon->setToolTip(tooltip);
|
||||||
progressBarLabel->setToolTip(tooltip);
|
progressBarLabel->setToolTip(tooltip);
|
||||||
progressBar->setToolTip(tooltip);
|
progressBar->setToolTip(tooltip);
|
||||||
|
@ -439,12 +430,14 @@ void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee)
|
||||||
|
|
||||||
void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int end)
|
void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int end)
|
||||||
{
|
{
|
||||||
|
if(start == end)
|
||||||
|
return;
|
||||||
TransactionTableModel *ttm = walletModel->getTransactionTableModel();
|
TransactionTableModel *ttm = walletModel->getTransactionTableModel();
|
||||||
qint64 amount = ttm->index(start, TransactionTableModel::Amount, parent)
|
qint64 amount = ttm->index(start, TransactionTableModel::Amount, parent)
|
||||||
.data(Qt::EditRole).toULongLong();
|
.data(Qt::EditRole).toULongLong();
|
||||||
if(!clientModel->inInitialBlockDownload())
|
if(!clientModel->inInitialBlockDownload())
|
||||||
{
|
{
|
||||||
// On incoming transaction, make an info balloon
|
// On new transaction, make an info balloon
|
||||||
// Unless the initial block download is in progress, to prevent balloon-spam
|
// Unless the initial block download is in progress, to prevent balloon-spam
|
||||||
QString date = ttm->index(start, TransactionTableModel::Date, parent)
|
QString date = ttm->index(start, TransactionTableModel::Date, parent)
|
||||||
.data().toString();
|
.data().toString();
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
// Bitcoin unit definitions
|
// Bitcoin unit definitions, encapsulates parsing and formatting
|
||||||
|
// and serves as list model for dropdown selection boxes.
|
||||||
class BitcoinUnits: public QAbstractListModel
|
class BitcoinUnits: public QAbstractListModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -12,7 +12,7 @@ QT_BEGIN_NAMESPACE
|
||||||
class QDateTime;
|
class QDateTime;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
// Interface to Bitcoin network client
|
// Model for Bitcoin network client
|
||||||
class ClientModel : public QObject
|
class ClientModel : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -12,12 +12,12 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
QString GUIUtil::DateTimeStr(qint64 nTime)
|
QString GUIUtil::dateTimeStr(qint64 nTime)
|
||||||
{
|
{
|
||||||
return DateTimeStr(QDateTime::fromTime_t((qint32)nTime));
|
return dateTimeStr(QDateTime::fromTime_t((qint32)nTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GUIUtil::DateTimeStr(const QDateTime &date)
|
QString GUIUtil::dateTimeStr(const QDateTime &date)
|
||||||
{
|
{
|
||||||
return date.date().toString(Qt::SystemLocaleShortDate) + QString(" ") + date.toString("hh:mm");
|
return date.date().toString(Qt::SystemLocaleShortDate) + QString(" ") + date.toString("hh:mm");
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,6 @@ bool GUIUtil::parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out)
|
||||||
}
|
}
|
||||||
else // Amount is non-empty
|
else // Amount is non-empty
|
||||||
{
|
{
|
||||||
// TODO: support <n>X<nexp> (exp = 8-nexp) (https://en.bitcoin.it/wiki/URI_Scheme)
|
|
||||||
// TODO: support <n>E<exp>
|
|
||||||
if(!BitcoinUnits::parse(BitcoinUnits::BTC, amount, &rv.amount))
|
if(!BitcoinUnits::parse(BitcoinUnits::BTC, amount, &rv.amount))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -16,8 +16,8 @@ class GUIUtil
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Create human-readable string from date
|
// Create human-readable string from date
|
||||||
static QString DateTimeStr(qint64 nTime);
|
static QString dateTimeStr(qint64 nTime);
|
||||||
static QString DateTimeStr(const QDateTime &datetime);
|
static QString dateTimeStr(const QDateTime &datetime);
|
||||||
|
|
||||||
// Render bitcoin addresses in monospace font
|
// Render bitcoin addresses in monospace font
|
||||||
static QFont bitcoinAddressFont();
|
static QFont bitcoinAddressFont();
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, amountText);
|
painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, amountText);
|
||||||
|
|
||||||
painter->setPen(option.palette.color(QPalette::Text));
|
painter->setPen(option.palette.color(QPalette::Text));
|
||||||
painter->drawText(amountRect, Qt::AlignLeft|Qt::AlignVCenter, GUIUtil::DateTimeStr(date));
|
painter->drawText(amountRect, Qt::AlignLeft|Qt::AlignVCenter, GUIUtil::dateTimeStr(date));
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,79 +1,55 @@
|
||||||
#include <transactiondesc.h>
|
#include <transactiondesc.h>
|
||||||
|
|
||||||
#include "guiutil.h"
|
#include "guiutil.h"
|
||||||
|
#include "bitcoinunits.h"
|
||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
#include "qtui.h"
|
#include "qtui.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QTextDocument> // For Qt::escape
|
||||||
// Taken straight from ui.cpp
|
|
||||||
// TODO: Convert to use QStrings, Qt::Escape and tr()
|
|
||||||
// or: refactor and put describeAsHTML() into bitcoin core but that is unneccesary with better
|
|
||||||
// UI<->core API, no need to put display logic in core.
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static string HtmlEscape(const char* psz, bool fMultiLine=false)
|
QString TransactionDesc::HtmlEscape(const QString& str, bool fMultiLine)
|
||||||
{
|
{
|
||||||
int len = 0;
|
QString escaped = Qt::escape(str);
|
||||||
for (const char* p = psz; *p; p++)
|
if(fMultiLine)
|
||||||
{
|
{
|
||||||
if (*p == '<') len += 4;
|
escaped = escaped.replace("\n", "<br>\n");
|
||||||
else if (*p == '>') len += 4;
|
|
||||||
else if (*p == '&') len += 5;
|
|
||||||
else if (*p == '"') len += 6;
|
|
||||||
else if (*p == ' ' && p > psz && p[-1] == ' ' && p[1] == ' ') len += 6;
|
|
||||||
else if (*p == '\n' && fMultiLine) len += 5;
|
|
||||||
else
|
|
||||||
len++;
|
|
||||||
}
|
}
|
||||||
string str;
|
return escaped;
|
||||||
str.reserve(len);
|
|
||||||
for (const char* p = psz; *p; p++)
|
|
||||||
{
|
|
||||||
if (*p == '<') str += "<";
|
|
||||||
else if (*p == '>') str += ">";
|
|
||||||
else if (*p == '&') str += "&";
|
|
||||||
else if (*p == '"') str += """;
|
|
||||||
else if (*p == ' ' && p > psz && p[-1] == ' ' && p[1] == ' ') str += " ";
|
|
||||||
else if (*p == '\n' && fMultiLine) str += "<br>\n";
|
|
||||||
else
|
|
||||||
str += *p;
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static string HtmlEscape(const string& str, bool fMultiLine=false)
|
QString TransactionDesc::HtmlEscape(const std::string& str, bool fMultiLine)
|
||||||
{
|
{
|
||||||
return HtmlEscape(str.c_str(), fMultiLine);
|
return HtmlEscape(QString::fromStdString(str), fMultiLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
static string FormatTxStatus(const CWalletTx& wtx)
|
QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx)
|
||||||
{
|
{
|
||||||
// Status
|
|
||||||
if (!wtx.IsFinal())
|
if (!wtx.IsFinal())
|
||||||
{
|
{
|
||||||
if (wtx.nLockTime < 500000000)
|
if (wtx.nLockTime < LOCKTIME_THRESHOLD)
|
||||||
return strprintf(_("Open for %d blocks"), nBestHeight - wtx.nLockTime);
|
return tr("Open for %1 blocks").arg(nBestHeight - wtx.nLockTime);
|
||||||
else
|
else
|
||||||
return strprintf(_("Open until %s"), GUIUtil::DateTimeStr(wtx.nLockTime).toStdString().c_str());
|
return tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx.nLockTime));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int nDepth = wtx.GetDepthInMainChain();
|
int nDepth = wtx.GetDepthInMainChain();
|
||||||
if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
|
if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
|
||||||
return strprintf(_("%d/offline?"), nDepth);
|
return tr("%1/offline?").arg(nDepth);
|
||||||
else if (nDepth < 6)
|
else if (nDepth < 6)
|
||||||
return strprintf(_("%d/unconfirmed"), nDepth);
|
return tr("%1/unconfirmed").arg(nDepth);
|
||||||
else
|
else
|
||||||
return strprintf(_("%d confirmations"), nDepth);
|
return tr("%1 confirmations").arg(nDepth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
{
|
{
|
||||||
string strHTML;
|
QString strHTML;
|
||||||
CRITICAL_BLOCK(wallet->cs_mapAddressBook)
|
CRITICAL_BLOCK(wallet->cs_mapAddressBook)
|
||||||
{
|
{
|
||||||
strHTML.reserve(4000);
|
strHTML.reserve(4000);
|
||||||
|
@ -84,36 +60,33 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
int64 nDebit = wtx.GetDebit();
|
int64 nDebit = wtx.GetDebit();
|
||||||
int64 nNet = nCredit - nDebit;
|
int64 nNet = nCredit - nDebit;
|
||||||
|
|
||||||
|
strHTML += tr("<b>Status:</b> ") + FormatTxStatus(wtx);
|
||||||
|
|
||||||
strHTML += _("<b>Status:</b> ") + FormatTxStatus(wtx);
|
|
||||||
int nRequests = wtx.GetRequestCount();
|
int nRequests = wtx.GetRequestCount();
|
||||||
if (nRequests != -1)
|
if (nRequests != -1)
|
||||||
{
|
{
|
||||||
if (nRequests == 0)
|
if (nRequests == 0)
|
||||||
strHTML += _(", has not been successfully broadcast yet");
|
strHTML += tr(", has not been successfully broadcast yet");
|
||||||
else if (nRequests == 1)
|
else if (nRequests == 1)
|
||||||
strHTML += strprintf(_(", broadcast through %d node"), nRequests);
|
strHTML += tr(", broadcast through %1 node").arg(nRequests);
|
||||||
else
|
else
|
||||||
strHTML += strprintf(_(", broadcast through %d nodes"), nRequests);
|
strHTML += tr(", broadcast through %1 nodes").arg(nRequests);
|
||||||
}
|
}
|
||||||
strHTML += "<br>";
|
strHTML += "<br>";
|
||||||
|
|
||||||
strHTML += _("<b>Date:</b> ") + (nTime ? GUIUtil::DateTimeStr(nTime).toStdString() : "") + "<br>";
|
strHTML += tr("<b>Date:</b> ") + (nTime ? GUIUtil::dateTimeStr(nTime) : QString("")) + "<br>";
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// From
|
// From
|
||||||
//
|
//
|
||||||
if (wtx.IsCoinBase())
|
if (wtx.IsCoinBase())
|
||||||
{
|
{
|
||||||
strHTML += _("<b>Source:</b> Generated<br>");
|
strHTML += tr("<b>Source:</b> Generated<br>");
|
||||||
}
|
}
|
||||||
else if (!wtx.mapValue["from"].empty())
|
else if (!wtx.mapValue["from"].empty())
|
||||||
{
|
{
|
||||||
// Online transaction
|
// Online transaction
|
||||||
if (!wtx.mapValue["from"].empty())
|
if (!wtx.mapValue["from"].empty())
|
||||||
strHTML += _("<b>From:</b> ") + HtmlEscape(wtx.mapValue["from"]) + "<br>";
|
strHTML += tr("<b>From:</b> ") + HtmlEscape(wtx.mapValue["from"]) + "<br>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -130,13 +103,13 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
{
|
{
|
||||||
if (wallet->mapAddressBook.count(address))
|
if (wallet->mapAddressBook.count(address))
|
||||||
{
|
{
|
||||||
strHTML += string() + _("<b>From:</b> ") + _("unknown") + "<br>";
|
strHTML += tr("<b>From:</b> ") + tr("unknown") + "<br>";
|
||||||
strHTML += _("<b>To:</b> ");
|
strHTML += tr("<b>To:</b> ");
|
||||||
strHTML += HtmlEscape(address.ToString());
|
strHTML += HtmlEscape(address.ToString());
|
||||||
if (!wallet->mapAddressBook[address].empty())
|
if (!wallet->mapAddressBook[address].empty())
|
||||||
strHTML += _(" (yours, label: ") + HtmlEscape(wallet->mapAddressBook[address]) + ")";
|
strHTML += tr(" (yours, label: ") + HtmlEscape(wallet->mapAddressBook[address]) + ")";
|
||||||
else
|
else
|
||||||
strHTML += _(" (yours)");
|
strHTML += tr(" (yours)");
|
||||||
strHTML += "<br>";
|
strHTML += "<br>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +119,6 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// To
|
// To
|
||||||
//
|
//
|
||||||
|
@ -155,13 +127,12 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
{
|
{
|
||||||
// Online transaction
|
// Online transaction
|
||||||
strAddress = wtx.mapValue["to"];
|
strAddress = wtx.mapValue["to"];
|
||||||
strHTML += _("<b>To:</b> ");
|
strHTML += tr("<b>To:</b> ");
|
||||||
if (wallet->mapAddressBook.count(strAddress) && !wallet->mapAddressBook[strAddress].empty())
|
if (wallet->mapAddressBook.count(strAddress) && !wallet->mapAddressBook[strAddress].empty())
|
||||||
strHTML += HtmlEscape(wallet->mapAddressBook[strAddress]) + " ";
|
strHTML += HtmlEscape(wallet->mapAddressBook[strAddress]) + " ";
|
||||||
strHTML += HtmlEscape(strAddress) + "<br>";
|
strHTML += HtmlEscape(strAddress) + "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Amount
|
// Amount
|
||||||
//
|
//
|
||||||
|
@ -173,11 +144,13 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
int64 nUnmatured = 0;
|
int64 nUnmatured = 0;
|
||||||
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||||
nUnmatured += wallet->GetCredit(txout);
|
nUnmatured += wallet->GetCredit(txout);
|
||||||
strHTML += _("<b>Credit:</b> ");
|
strHTML += tr("<b>Credit:</b> ");
|
||||||
if (wtx.IsInMainChain())
|
if (wtx.IsInMainChain())
|
||||||
strHTML += strprintf(_("(%s matures in %d more blocks)"), FormatMoney(nUnmatured).c_str(), wtx.GetBlocksToMaturity());
|
strHTML += tr("(%1 matures in %2 more blocks)")
|
||||||
|
.arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nUnmatured))
|
||||||
|
.arg(wtx.GetBlocksToMaturity());
|
||||||
else
|
else
|
||||||
strHTML += _("(not accepted)");
|
strHTML += tr("(not accepted)");
|
||||||
strHTML += "<br>";
|
strHTML += "<br>";
|
||||||
}
|
}
|
||||||
else if (nNet > 0)
|
else if (nNet > 0)
|
||||||
|
@ -185,7 +158,7 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
//
|
//
|
||||||
// Credit
|
// Credit
|
||||||
//
|
//
|
||||||
strHTML += _("<b>Credit:</b> ") + FormatMoney(nNet) + "<br>";
|
strHTML += tr("<b>Credit:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nNet) + "<br>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -213,7 +186,7 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
CBitcoinAddress address;
|
CBitcoinAddress address;
|
||||||
if (ExtractAddress(txout.scriptPubKey, 0, address))
|
if (ExtractAddress(txout.scriptPubKey, 0, address))
|
||||||
{
|
{
|
||||||
strHTML += _("<b>To:</b> ");
|
strHTML += tr("<b>To:</b> ");
|
||||||
if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty())
|
if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty())
|
||||||
strHTML += HtmlEscape(wallet->mapAddressBook[address]) + " ";
|
strHTML += HtmlEscape(wallet->mapAddressBook[address]) + " ";
|
||||||
strHTML += HtmlEscape(address.ToString());
|
strHTML += HtmlEscape(address.ToString());
|
||||||
|
@ -221,7 +194,7 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strHTML += _("<b>Debit:</b> ") + FormatMoney(-txout.nValue) + "<br>";
|
strHTML += tr("<b>Debit:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -txout.nValue) + "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fAllToMe)
|
if (fAllToMe)
|
||||||
|
@ -229,13 +202,13 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
// Payment to self
|
// Payment to self
|
||||||
int64 nChange = wtx.GetChange();
|
int64 nChange = wtx.GetChange();
|
||||||
int64 nValue = nCredit - nChange;
|
int64 nValue = nCredit - nChange;
|
||||||
strHTML += _("<b>Debit:</b> ") + FormatMoney(-nValue) + "<br>";
|
strHTML += tr("<b>Debit:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -nValue) + "<br>";
|
||||||
strHTML += _("<b>Credit:</b> ") + FormatMoney(nValue) + "<br>";
|
strHTML += tr("<b>Credit:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nValue) + "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 nTxFee = nDebit - wtx.GetValueOut();
|
int64 nTxFee = nDebit - wtx.GetValueOut();
|
||||||
if (nTxFee > 0)
|
if (nTxFee > 0)
|
||||||
strHTML += _("<b>Transaction fee:</b> ") + FormatMoney(-nTxFee) + "<br>";
|
strHTML += tr("<b>Transaction fee:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,-nTxFee) + "<br>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -244,27 +217,25 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
//
|
//
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
|
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
|
||||||
if (wallet->IsMine(txin))
|
if (wallet->IsMine(txin))
|
||||||
strHTML += _("<b>Debit:</b> ") + FormatMoney(-wallet->GetDebit(txin)) + "<br>";
|
strHTML += tr("<b>Debit:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,-wallet->GetDebit(txin)) + "<br>";
|
||||||
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||||
if (wallet->IsMine(txout))
|
if (wallet->IsMine(txout))
|
||||||
strHTML += _("<b>Credit:</b> ") + FormatMoney(wallet->GetCredit(txout)) + "<br>";
|
strHTML += tr("<b>Credit:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,wallet->GetCredit(txout)) + "<br>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strHTML += _("<b>Net amount:</b> ") + FormatMoney(nNet, true) + "<br>";
|
strHTML += tr("<b>Net amount:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,nNet, true) + "<br>";
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Message
|
// Message
|
||||||
//
|
//
|
||||||
if (!wtx.mapValue["message"].empty())
|
if (!wtx.mapValue["message"].empty())
|
||||||
strHTML += string() + "<br><b>" + _("Message:") + "</b><br>" + HtmlEscape(wtx.mapValue["message"], true) + "<br>";
|
strHTML += QString("<br><b>") + tr("Message:") + "</b><br>" + HtmlEscape(wtx.mapValue["message"], true) + "<br>";
|
||||||
if (!wtx.mapValue["comment"].empty())
|
if (!wtx.mapValue["comment"].empty())
|
||||||
strHTML += string() + "<br><b>" + _("Comment:") + "</b><br>" + HtmlEscape(wtx.mapValue["comment"], true) + "<br>";
|
strHTML += QString("<br><b>") + tr("Comment:") + "</b><br>" + HtmlEscape(wtx.mapValue["comment"], true) + "<br>";
|
||||||
|
|
||||||
if (wtx.IsCoinBase())
|
if (wtx.IsCoinBase())
|
||||||
strHTML += string() + "<br>" + _("Generated coins must wait 120 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, it will change to \"not accepted\" and not be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.") + "<br>";
|
strHTML += QString("<br>") + tr("Generated coins must wait 120 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, it will change to \"not accepted\" and not be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.") + "<br>";
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Debug view
|
// Debug view
|
||||||
|
@ -274,10 +245,10 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
strHTML += "<hr><br>Debug information<br><br>";
|
strHTML += "<hr><br>Debug information<br><br>";
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
|
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
|
||||||
if(wallet->IsMine(txin))
|
if(wallet->IsMine(txin))
|
||||||
strHTML += "<b>Debit:</b> " + FormatMoney(-wallet->GetDebit(txin)) + "<br>";
|
strHTML += "<b>Debit:</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,-wallet->GetDebit(txin)) + "<br>";
|
||||||
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||||
if(wallet->IsMine(txout))
|
if(wallet->IsMine(txout))
|
||||||
strHTML += "<b>Credit:</b> " + FormatMoney(wallet->GetCredit(txout)) + "<br>";
|
strHTML += "<b>Credit:</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,wallet->GetCredit(txout)) + "<br>";
|
||||||
|
|
||||||
strHTML += "<br><b>Transaction:</b><br>";
|
strHTML += "<br><b>Transaction:</b><br>";
|
||||||
strHTML += HtmlEscape(wtx.ToString(), true);
|
strHTML += HtmlEscape(wtx.ToString(), true);
|
||||||
|
@ -304,9 +275,9 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
{
|
{
|
||||||
if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty())
|
if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty())
|
||||||
strHTML += HtmlEscape(wallet->mapAddressBook[address]) + " ";
|
strHTML += HtmlEscape(wallet->mapAddressBook[address]) + " ";
|
||||||
strHTML += address.ToString();
|
strHTML += QString::fromStdString(address.ToString());
|
||||||
}
|
}
|
||||||
strHTML = strHTML + " Amount=" + FormatMoney(vout.nValue);
|
strHTML = strHTML + " Amount=" + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,vout.nValue);
|
||||||
strHTML = strHTML + " IsMine=" + (wallet->IsMine(vout) ? "true" : "false") + "</li>";
|
strHTML = strHTML + " IsMine=" + (wallet->IsMine(vout) ? "true" : "false") + "</li>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,8 +286,6 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
strHTML += "</ul>";
|
strHTML += "</ul>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
strHTML += "</font></html>";
|
strHTML += "</font></html>";
|
||||||
}
|
}
|
||||||
return strHTML;
|
return strHTML;
|
||||||
|
|
|
@ -1,16 +1,24 @@
|
||||||
#ifndef TRANSACTIONDESC_H
|
#ifndef TRANSACTIONDESC_H
|
||||||
#define TRANSACTIONDESC_H
|
#define TRANSACTIONDESC_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QObject>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class CWallet;
|
class CWallet;
|
||||||
class CWalletTx;
|
class CWalletTx;
|
||||||
|
|
||||||
class TransactionDesc
|
class TransactionDesc: public QObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/* Provide human-readable extended HTML description of a transaction */
|
// Provide human-readable extended HTML description of a transaction
|
||||||
static std::string toHTML(CWallet *wallet, CWalletTx &wtx);
|
static QString toHTML(CWallet *wallet, CWalletTx &wtx);
|
||||||
|
private:
|
||||||
|
TransactionDesc() {}
|
||||||
|
|
||||||
|
static QString HtmlEscape(const QString& str, bool fMultiLine=false);
|
||||||
|
static QString HtmlEscape(const std::string &str, bool fMultiLine=false);
|
||||||
|
static QString FormatTxStatus(const CWalletTx& wtx);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRANSACTIONDESC_H
|
#endif // TRANSACTIONDESC_H
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QtAlgorithms>
|
#include <QtAlgorithms>
|
||||||
|
|
||||||
// Credit and Debit columns are right-aligned as they contain numbers
|
// Amount column is right-aligned it contains numbers
|
||||||
static int column_alignments[] = {
|
static int column_alignments[] = {
|
||||||
Qt::AlignLeft|Qt::AlignVCenter,
|
Qt::AlignLeft|Qt::AlignVCenter,
|
||||||
Qt::AlignLeft|Qt::AlignVCenter,
|
Qt::AlignLeft|Qt::AlignVCenter,
|
||||||
|
@ -100,10 +100,10 @@ struct TransactionTablePriv
|
||||||
for(int update_idx = updated_sorted.size()-1; update_idx >= 0; --update_idx)
|
for(int update_idx = updated_sorted.size()-1; update_idx >= 0; --update_idx)
|
||||||
{
|
{
|
||||||
const uint256 &hash = updated_sorted.at(update_idx);
|
const uint256 &hash = updated_sorted.at(update_idx);
|
||||||
/* Find transaction in wallet */
|
// Find transaction in wallet
|
||||||
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(hash);
|
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(hash);
|
||||||
bool inWallet = mi != wallet->mapWallet.end();
|
bool inWallet = mi != wallet->mapWallet.end();
|
||||||
/* Find bounds of this transaction in model */
|
// Find bounds of this transaction in model
|
||||||
QList<TransactionRecord>::iterator lower = qLowerBound(
|
QList<TransactionRecord>::iterator lower = qLowerBound(
|
||||||
cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
|
cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
|
||||||
QList<TransactionRecord>::iterator upper = qUpperBound(
|
QList<TransactionRecord>::iterator upper = qUpperBound(
|
||||||
|
@ -196,7 +196,7 @@ struct TransactionTablePriv
|
||||||
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
|
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
|
||||||
if(mi != wallet->mapWallet.end())
|
if(mi != wallet->mapWallet.end())
|
||||||
{
|
{
|
||||||
return QString::fromStdString(TransactionDesc::toHTML(wallet, mi->second));
|
return TransactionDesc::toHTML(wallet, mi->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QString("");
|
return QString("");
|
||||||
|
@ -274,7 +274,7 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons
|
||||||
status = tr("Open for %n block(s)","",wtx->status.open_for);
|
status = tr("Open for %n block(s)","",wtx->status.open_for);
|
||||||
break;
|
break;
|
||||||
case TransactionStatus::OpenUntilDate:
|
case TransactionStatus::OpenUntilDate:
|
||||||
status = tr("Open until %1").arg(GUIUtil::DateTimeStr(wtx->status.open_for));
|
status = tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx->status.open_for));
|
||||||
break;
|
break;
|
||||||
case TransactionStatus::Offline:
|
case TransactionStatus::Offline:
|
||||||
status = tr("Offline (%1 confirmations)").arg(wtx->status.depth);
|
status = tr("Offline (%1 confirmations)").arg(wtx->status.depth);
|
||||||
|
@ -313,7 +313,7 @@ QString TransactionTableModel::formatTxDate(const TransactionRecord *wtx) const
|
||||||
{
|
{
|
||||||
if(wtx->time)
|
if(wtx->time)
|
||||||
{
|
{
|
||||||
return GUIUtil::DateTimeStr(wtx->time);
|
return GUIUtil::dateTimeStr(wtx->time);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -606,11 +606,6 @@ QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientat
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags TransactionTableModel::flags(const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
return QAbstractTableModel::flags(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex &parent) const
|
QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
|
|
|
@ -51,7 +51,6 @@ public:
|
||||||
int columnCount(const QModelIndex &parent) const;
|
int columnCount(const QModelIndex &parent) const;
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
|
||||||
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
|
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
|
||||||
private:
|
private:
|
||||||
CWallet* wallet;
|
CWallet* wallet;
|
||||||
|
|
|
@ -24,6 +24,7 @@ public:
|
||||||
|
|
||||||
void setModel(WalletModel *model);
|
void setModel(WalletModel *model);
|
||||||
|
|
||||||
|
// Date ranges for filter
|
||||||
enum DateEnum
|
enum DateEnum
|
||||||
{
|
{
|
||||||
All,
|
All,
|
||||||
|
|
|
@ -83,8 +83,6 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipie
|
||||||
// Pre-check input data for validity
|
// Pre-check input data for validity
|
||||||
foreach(const SendCoinsRecipient &rcp, recipients)
|
foreach(const SendCoinsRecipient &rcp, recipients)
|
||||||
{
|
{
|
||||||
uint160 hash160 = 0;
|
|
||||||
|
|
||||||
if(!validateAddress(rcp.address))
|
if(!validateAddress(rcp.address))
|
||||||
{
|
{
|
||||||
return InvalidAddress;
|
return InvalidAddress;
|
||||||
|
|
|
@ -15,7 +15,7 @@ struct SendCoinsRecipient
|
||||||
qint64 amount;
|
qint64 amount;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Interface to a Bitcoin wallet
|
// Interface to Bitcoin wallet from Qt view code
|
||||||
class WalletModel : public QObject
|
class WalletModel : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -47,9 +47,7 @@ public:
|
||||||
// Check address for validity
|
// Check address for validity
|
||||||
bool validateAddress(const QString &address);
|
bool validateAddress(const QString &address);
|
||||||
|
|
||||||
// Return status record for SendCoins
|
// Return status record for SendCoins, contains error id + information
|
||||||
// fee is used in case status is "AmountWithFeeExceedsBalance"
|
|
||||||
// hex is filled with the transaction hash if status is "OK"
|
|
||||||
struct SendCoinsReturn
|
struct SendCoinsReturn
|
||||||
{
|
{
|
||||||
SendCoinsReturn(StatusCode status,
|
SendCoinsReturn(StatusCode status,
|
||||||
|
@ -57,11 +55,11 @@ public:
|
||||||
QString hex=QString()):
|
QString hex=QString()):
|
||||||
status(status), fee(fee), hex(hex) {}
|
status(status), fee(fee), hex(hex) {}
|
||||||
StatusCode status;
|
StatusCode status;
|
||||||
qint64 fee;
|
qint64 fee; // is used in case status is "AmountWithFeeExceedsBalance"
|
||||||
QString hex;
|
QString hex; // is filled with the transaction hash if status is "OK"
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send coins to list of recipients
|
// Send coins to a list of recipients
|
||||||
SendCoinsReturn sendCoins(const QList<SendCoinsRecipient> &recipients);
|
SendCoinsReturn sendCoins(const QList<SendCoinsRecipient> &recipients);
|
||||||
private:
|
private:
|
||||||
CWallet *wallet;
|
CWallet *wallet;
|
||||||
|
|
Loading…
Reference in a new issue