void AddressBookDialog::setModel(AddressTableModel *model)
{
this->model = model;
- /* Refresh list from core */
+ // Refresh list from core
model->updateList();
- /* Receive filter */
+ // Receive filter
QSortFilterProxyModel *receive_model = new QSortFilterProxyModel(this);
receive_model->setSourceModel(model);
receive_model->setDynamicSortFilter(true);
receive_model->setFilterFixedString(AddressTableModel::Receive);
ui->receiveTableView->setModel(receive_model);
- /* Send filter */
+ // Send filter
QSortFilterProxyModel *send_model = new QSortFilterProxyModel(this);
send_model->setSourceModel(model);
send_model->setDynamicSortFilter(true);
send_model->setFilterFixedString(AddressTableModel::Send);
ui->sendTableView->setModel(send_model);
- /* Set column widths */
+ // Set column widths
ui->receiveTableView->horizontalHeader()->resizeSection(
AddressTableModel::Address, 320);
ui->receiveTableView->horizontalHeader()->setResizeMode(
void AddressBookDialog::on_copyToClipboard_clicked()
{
- /* Copy currently selected address to clipboard
- (or nothing, if nothing selected)
- */
+ // Copy currently selected address to clipboard
+ // (or nothing, if nothing selected)
QTableView *table = getCurrentTable();
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
{
return;
}
- /* Map selected index to source address book model */
+ // Map selected index to source address book model
QAbstractProxyModel *proxy_model = static_cast<QAbstractProxyModel*>(getCurrentTable()->model());
QModelIndex selected = proxy_model->mapToSource(indexes.at(0));
- /* Double click also triggers edit button */
+ // Double click also triggers edit button
EditAddressDialog dlg(
ui->tabWidget->currentIndex() == SendingTab ?
EditAddressDialog::EditSendingAddress :
type(type), label(label), address(address) {}
};
-/* Private implementation */
+// Private implementation
struct AddressTablePriv
{
QList<AddressTableEntry> cachedAddressTable;
rec->label = value.toString();
break;
case Address:
- /* Double-check that we're not overwriting receiving address */
+ // Double-check that we're not overwriting receiving address
if(rec->type == AddressTableEntry::Sending)
{
- /* Remove old entry */
+ // Remove old entry
CWalletDB().EraseName(rec->address.toStdString());
- /* Add new entry with new address */
+ // Add new entry with new address
SetAddressBookName(value.toString().toStdString(), rec->label.toStdString());
rec->address = value.toString();
void AddressTableModel::updateList()
{
- /* Update internal model from Bitcoin core */
+ // Update internal model from Bitcoin core
beginResetModel();
priv->refreshAddressTable();
endResetModel();
if(type == Send)
{
- /* Check for duplicate */
+ // Check for duplicate
CRITICAL_BLOCK(cs_mapAddressBook)
{
if(mapAddressBook.count(strAddress))
}
else if(type == Receive)
{
- /* Generate a new address to associate with given label */
+ // Generate a new address to associate with given label
strAddress = PubKeyToAddress(GetKeyFromKeyPool());
}
else
{
return QString();
}
- /* Add entry and update list */
+ // Add entry and update list
SetAddressBookName(strAddress, strLabel);
updateList();
return QString::fromStdString(strAddress);
AddressTableEntry *rec = priv->index(row);
if(count != 1 || !rec || rec->type == AddressTableEntry::Receiving)
{
- /* Can only remove one row at a time, and cannot remove rows not in model.
- Also refuse to remove receiving addresses.
- */
+ // Can only remove one row at a time, and cannot remove rows not in model.
+ // Also refuse to remove receiving addresses.
return false;
}
CWalletDB().EraseName(rec->address.toStdString());
return true;
bool payFee = false;
- /* Call slot on GUI thread.
- If called from another thread, use a blocking QueuedConnection.
- */
+ // Call slot on GUI thread.
+ // If called from another thread, use a blocking QueuedConnection.
Qt::ConnectionType connectionType = Qt::DirectConnection;
if(QThread::currentThread() != QCoreApplication::instance()->thread())
{
QValidator::State BitcoinAddressValidator::validate(QString &input, int &pos) const
{
- /* Correction */
+ // Correction
for(int idx=0; idx<input.size(); ++idx)
{
switch(input.at(idx).unicode())
}
}
- /* Validation */
+ // Validation
QValidator::State state = QValidator::Acceptable;
for(int idx=0; idx<input.size(); ++idx)
{
(ch >= 'A' && ch<='Z')) &&
ch != 'l' && ch != 'I' && ch != '0' && ch != 'O')
{
- /* Alphanumeric and not a 'forbidden' character */
+ // Alphanumeric and not a 'forbidden' character
}
else
{
void BitcoinGUI::transactionDetails(const QModelIndex& idx)
{
- /* A transaction is doubleclicked */
+ // A transaction is doubleclicked
TransactionDescDialog dlg(idx);
dlg.exec();
}
.data(Qt::EditRole).toULongLong();
if((credit+debit)>0)
{
- /* On incoming transaction, make an info balloon */
+ // On incoming transaction, make an info balloon
QString date = ttm->index(start, TransactionTableModel::Date, parent)
.data().toString();
QString description = ttm->index(start, TransactionTableModel::Description, parent)
QObject(parent), optionsModel(0), addressTableModel(0),
transactionTableModel(0)
{
- /* Until signal notifications is built into the bitcoin core,
- simply update everything after polling using a timer.
- */
+ // Until signal notifications is built into the bitcoin core,
+ // simply update everything after polling using a timer.
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(MODEL_UPDATE_DELAY);
void ClientModel::update()
{
- /* Plainly emit all signals for now. To be precise this should check
- wether the values actually changed first.
- */
+ // Plainly emit all signals for now. To be more efficient this should check
+ // whether the values actually changed first.
emit balanceChanged(getBalance());
emit addressChanged(getAddress());
emit numConnectionsChanged(getNumConnections());
void MonitoredDataMapper::addChangeMonitor(QWidget *widget)
{
- /* Watch user property of widget for changes, and connect
- the signal to our viewModified signal.
- */
+ // Watch user property of widget for changes, and connect
+ // the signal to our viewModified signal.
QMetaProperty prop = widget->metaObject()->userProperty();
int signal = prop.notifySignalIndex();
int method = this->metaObject()->indexOfMethod("viewModified()");
layout->addLayout(fee_hbox);
- layout->addStretch(1); /* Extra space at bottom */
+ layout->addStretch(1); // Extra space at bottom
setLayout(layout);
void MainOptionsPage::setMapper(MonitoredDataMapper *mapper)
{
- /* Map model to widgets */
+ // Map model to widgets
mapper->addMapping(bitcoin_at_startup, OptionsModel::StartAtStartup);
mapper->addMapping(minimize_to_tray, OptionsModel::MinimizeToTray);
mapper->addMapping(map_port_upnp, OptionsModel::MapPortUPnP);
break;
case ProxyIP:
{
- /* Use CAddress to parse IP */
+ // Use CAddress to parse and check IP
CAddress addr(value.toString().toStdString() + ":1");
if (addr.ip != INADDR_NONE)
{
}
else
{
- successful = false; /* parse error */
+ successful = false; // Parse error
}
}
break;
GUIUtil::setupAddressWidget(ui->payTo, this);
GUIUtil::setupAmountWidget(ui->payAmount, this);
- /* Set initial address if provided */
+ // Set initial send-to address if provided
if(!address.isEmpty())
{
ui->payTo->setText(address);
void SendCoinsDialog::on_pasteButton_clicked()
{
- /* Paste text from clipboard into recipient field */
+ // Paste text from clipboard into recipient field
ui->payTo->setText(QApplication::clipboard()->text());
}
#include <QString>
-/* Taken straight from ui.cpp
- TODO: Convert to use QStrings, Qt::Escape and tr()
- */
+// 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;
return true;
}
-/* Decompose CWallet transaction to model transaction records.
+/*
+ * Decompose CWallet transaction to model transaction records.
*/
QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWalletTx &wtx)
{
const QString TransactionTableModel::Received = "r";
const QString TransactionTableModel::Other = "o";
-/* Comparison operator for sort/binary search of model tx list */
+// Comparison operator for sort/binary search of model tx list
struct TxLessThan
{
bool operator()(const TransactionRecord &a, const TransactionRecord &b) const
}
};
-/* Private implementation */
+// Private implementation
struct TransactionTablePriv
{
TransactionTablePriv(TransactionTableModel *parent):
*/
QList<TransactionRecord> cachedWallet;
+ /* Query entire wallet anew from core.
+ */
void refreshWallet()
{
#ifdef WALLET_UPDATE_DEBUG
qDebug() << "refreshWallet";
#endif
- /* Query entire wallet from core.
- */
cachedWallet.clear();
CRITICAL_BLOCK(cs_mapWallet)
{
}
}
- /* Update our model of the wallet incrementally.
+ /* Update our model of the wallet incrementally, to synchronize our model of the wallet
+ with that of the core.
+
Call with list of hashes of transactions that were added, removed or changed.
*/
void updateWallet(const QList<uint256> &updated)
{
- /* Walk through updated transactions, update model as needed.
- */
+ // Walk through updated transactions, update model as needed.
#ifdef WALLET_UPDATE_DEBUG
qDebug() << "updateWallet";
#endif
- /* Sort update list, and iterate through it in reverse, so that model updates
- can be emitted from end to beginning (so that earlier updates will not influence
- the indices of latter ones).
- */
+ // Sort update list, and iterate through it in reverse, so that model updates
+ // can be emitted from end to beginning (so that earlier updates will not influence
+ // the indices of latter ones).
QList<uint256> updated_sorted = updated;
qSort(updated_sorted);
if(inWallet && !inModel)
{
- /* Added -- insert at the right position */
+ // Added -- insert at the right position
QList<TransactionRecord> toInsert =
TransactionRecord::decomposeTransaction(mi->second);
if(!toInsert.isEmpty()) /* only if something to insert */
}
else if(!inWallet && inModel)
{
- /* Removed -- remove entire transaction from table */
+ // Removed -- remove entire transaction from table
parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
cachedWallet.erase(lower, upper);
parent->endRemoveRows();
}
else if(inWallet && inModel)
{
- /* Updated -- nothing to do, status update will take care of this */
+ // Updated -- nothing to do, status update will take care of this
}
}
}
{
TransactionRecord *rec = &cachedWallet[idx];
- /* If a status update is needed (blocks came in since last check),
- update the status of this transaction from the wallet. Otherwise,
- simply re-use the cached status.
- */
+ // If a status update is needed (blocks came in since last check),
+ // update the status of this transaction from the wallet. Otherwise,
+ // simply re-use the cached status.
if(rec->statusUpdateNeeded())
{
CRITICAL_BLOCK(cs_mapWallet)
};
-/* Credit and Debit columns are right-aligned as they contain numbers */
+// Credit and Debit columns are right-aligned as they contain numbers
static int column_alignments[] = {
Qt::AlignLeft|Qt::AlignVCenter,
Qt::AlignLeft|Qt::AlignVCenter,
{
QList<uint256> updated;
- /* Check if there are changes to wallet map */
+ // Check if there are changes to wallet map
TRY_CRITICAL_BLOCK(cs_mapWallet)
{
if(!vWalletUpdated.empty())
{
priv->updateWallet(updated);
- /* Status (number of confirmations) and (possibly) description
- columns changed for all rows.
- */
+ // Status (number of confirmations) and (possibly) description
+ // columns changed for all rows.
emit dataChanged(index(0, Status), index(priv->size()-1, Status));
emit dataChanged(index(0, Description), index(priv->size()-1, Description));
}
}
else if(role == Qt::DisplayRole)
{
- /* Delegate to specific column handlers */
+ // Delegate to specific column handlers
switch(index.column())
{
- //case Status:
- // return formatTxStatus(rec);
case Date:
return formatTxDate(rec);
case Description:
}
else if(role == Qt::EditRole)
{
- /* Edit role is used for sorting so return the real values */
+ // Edit role is used for sorting so return the real values
switch(index.column())
{
case Status: