remove commented code, use // for one-line comments and comments inside functions

This commit is contained in:
Wladimir J. van der Laan 2011-06-18 11:53:25 +02:00
parent aa52972660
commit 0f3981bea9
13 changed files with 66 additions and 74 deletions

View file

@ -36,10 +36,10 @@ AddressBookDialog::~AddressBookDialog()
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);
@ -47,7 +47,7 @@ void AddressBookDialog::setModel(AddressTableModel *model)
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);
@ -55,7 +55,7 @@ void AddressBookDialog::setModel(AddressTableModel *model)
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(
@ -86,9 +86,8 @@ QTableView *AddressBookDialog::getCurrentTable()
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);
@ -106,11 +105,11 @@ void AddressBookDialog::on_editButton_clicked()
{
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 :

View file

@ -23,7 +23,7 @@ struct AddressTableEntry
type(type), label(label), address(address) {}
};
/* Private implementation */
// Private implementation
struct AddressTablePriv
{
QList<AddressTableEntry> cachedAddressTable;
@ -144,12 +144,12 @@ bool AddressTableModel::setData(const QModelIndex & index, const QVariant & valu
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();
@ -191,7 +191,7 @@ QModelIndex AddressTableModel::index(int row, int column, const QModelIndex & pa
void AddressTableModel::updateList()
{
/* Update internal model from Bitcoin core */
// Update internal model from Bitcoin core
beginResetModel();
priv->refreshAddressTable();
endResetModel();
@ -204,7 +204,7 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
if(type == Send)
{
/* Check for duplicate */
// Check for duplicate
CRITICAL_BLOCK(cs_mapAddressBook)
{
if(mapAddressBook.count(strAddress))
@ -215,14 +215,14 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
}
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);
@ -234,9 +234,8 @@ bool AddressTableModel::removeRows(int row, int count, const QModelIndex & paren
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());

View file

@ -57,9 +57,8 @@ bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindo
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())
{

View file

@ -22,7 +22,7 @@ BitcoinAddressValidator::BitcoinAddressValidator(QObject *parent) :
QValidator::State BitcoinAddressValidator::validate(QString &input, int &pos) const
{
/* Correction */
// Correction
for(int idx=0; idx<input.size(); ++idx)
{
switch(input.at(idx).unicode())
@ -40,7 +40,7 @@ QValidator::State BitcoinAddressValidator::validate(QString &input, int &pos) co
}
}
/* Validation */
// Validation
QValidator::State state = QValidator::Acceptable;
for(int idx=0; idx<input.size(); ++idx)
{
@ -51,7 +51,7 @@ QValidator::State BitcoinAddressValidator::validate(QString &input, int &pos) co
(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
{

View file

@ -429,7 +429,7 @@ void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee)
void BitcoinGUI::transactionDetails(const QModelIndex& idx)
{
/* A transaction is doubleclicked */
// A transaction is doubleclicked
TransactionDescDialog dlg(idx);
dlg.exec();
}
@ -443,7 +443,7 @@ void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int
.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)

View file

@ -11,9 +11,8 @@ ClientModel::ClientModel(QObject *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);
@ -63,9 +62,8 @@ int ClientModel::getNumTransactions()
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());

View file

@ -26,9 +26,8 @@ void MonitoredDataMapper::addMapping(QWidget *widget, int section, const QByteAr
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()");

View file

@ -207,7 +207,7 @@ MainOptionsPage::MainOptionsPage(QWidget *parent):
layout->addLayout(fee_hbox);
layout->addStretch(1); /* Extra space at bottom */
layout->addStretch(1); // Extra space at bottom
setLayout(layout);
@ -221,7 +221,7 @@ MainOptionsPage::MainOptionsPage(QWidget *parent):
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);

View file

@ -75,7 +75,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
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)
{
@ -111,7 +111,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
}
else
{
successful = false; /* parse error */
successful = false; // Parse error
}
}
break;

View file

@ -25,7 +25,7 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent, const QString &address) :
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);
@ -94,7 +94,7 @@ void SendCoinsDialog::on_sendButton_clicked()
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());
}

View file

@ -6,9 +6,10 @@
#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;

View file

@ -26,7 +26,8 @@ bool TransactionRecord::showTransaction(const CWalletTx &wtx)
return true;
}
/* Decompose CWallet transaction to model transaction records.
/*
* Decompose CWallet transaction to model transaction records.
*/
QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWalletTx &wtx)
{

View file

@ -17,7 +17,7 @@ const QString TransactionTableModel::Sent = "s";
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
@ -34,7 +34,7 @@ struct TxLessThan
}
};
/* Private implementation */
// Private implementation
struct TransactionTablePriv
{
TransactionTablePriv(TransactionTableModel *parent):
@ -50,13 +50,13 @@ struct TransactionTablePriv
*/
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)
{
@ -67,20 +67,20 @@ struct TransactionTablePriv
}
}
/* 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);
@ -113,7 +113,7 @@ struct TransactionTablePriv
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 */
@ -130,14 +130,14 @@ struct TransactionTablePriv
}
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
}
}
}
@ -154,10 +154,9 @@ struct TransactionTablePriv
{
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)
@ -193,7 +192,7 @@ struct TransactionTablePriv
};
/* 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,
@ -225,7 +224,7 @@ void TransactionTableModel::update()
{
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())
@ -242,9 +241,8 @@ void TransactionTableModel::update()
{
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));
}
@ -442,11 +440,9 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
}
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:
@ -459,7 +455,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
}
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: