consistent bracing style

This commit is contained in:
Wladimir J. van der Laan 2011-06-07 18:59:01 +02:00
parent 6717457390
commit 8e86dca256
8 changed files with 97 additions and 36 deletions

View File

@ -80,7 +80,8 @@ void AddressBookDialog::on_copyToClipboard_clicked()
QTableView *table = getCurrentTable(); QTableView *table = getCurrentTable();
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
foreach (QModelIndex index, indexes) { foreach (QModelIndex index, indexes)
{
QVariant address = table->model()->data(index); QVariant address = table->model()->data(index);
QApplication::clipboard()->setText(address.toString()); QApplication::clipboard()->setText(address.toString());
} }
@ -148,7 +149,8 @@ void AddressBookDialog::on_buttonBox_accepted()
QTableView *table = getCurrentTable(); QTableView *table = getCurrentTable();
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
foreach (QModelIndex index, indexes) { foreach (QModelIndex index, indexes)
{
QVariant address = table->model()->data(index); QVariant address = table->model()->data(index);
returnValue = address.toString(); returnValue = address.toString();
} }

View File

@ -58,7 +58,9 @@ struct AddressTablePriv
if(idx >= 0 && idx < cachedAddressTable.size()) if(idx >= 0 && idx < cachedAddressTable.size())
{ {
return &cachedAddressTable[idx]; return &cachedAddressTable[idx];
} else { }
else
{
return 0; return 0;
} }
} }
@ -105,13 +107,15 @@ QVariant AddressTableModel::data(const QModelIndex &index, int role) const
case Address: case Address:
return rec->address; return rec->address;
} }
} else if (role == Qt::FontRole) }
else if (role == Qt::FontRole)
{ {
if(index.column() == Address) if(index.column() == Address)
{ {
return GUIUtil::bitcoinAddressFont(); return GUIUtil::bitcoinAddressFont();
} }
} else if (role == TypeRole) }
else if (role == TypeRole)
{ {
switch(rec->type) switch(rec->type)
{ {
@ -178,7 +182,9 @@ QModelIndex AddressTableModel::index(int row, int column, const QModelIndex & pa
if(data) if(data)
{ {
return createIndex(row, column, priv->index(row)); return createIndex(row, column, priv->index(row));
} else { }
else
{
return QModelIndex(); return QModelIndex();
} }
} }
@ -206,11 +212,13 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
return QString(); return QString();
} }
} }
} else if(type == Receive) }
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()); strAddress = PubKeyToAddress(GetKeyFromKeyPool());
} else }
else
{ {
return QString(); return QString();
} }

View File

@ -92,7 +92,8 @@ int main(int argc, char *argv[])
QApplication app(argc, argv); QApplication app(argc, argv);
app.setQuitOnLastWindowClosed(false); app.setQuitOnLastWindowClosed(false);
try { try
{
if(AppInit2(argc, argv)) if(AppInit2(argc, argv))
{ {
BitcoinGUI window; BitcoinGUI window;

View File

@ -345,7 +345,9 @@ void BitcoinGUI::error(const QString &title, const QString &message)
{ {
// Show as "balloon" message if possible // Show as "balloon" message if possible
trayIcon->showMessage(title, message, QSystemTrayIcon::Critical); trayIcon->showMessage(title, message, QSystemTrayIcon::Critical);
} else { }
else
{
// Fall back to old fashioned popup dialog if not // Fall back to old fashioned popup dialog if not
QMessageBox::critical(this, title, QMessageBox::critical(this, title,
message, message,
@ -363,7 +365,9 @@ void BitcoinGUI::changeEvent(QEvent *e)
{ {
hide(); hide();
e->ignore(); e->ignore();
} else { }
else
{
e->accept(); e->accept();
} }
} }

View File

@ -34,7 +34,9 @@ QString ClientModel::getAddress()
if (CWalletDB("r").ReadDefaultKey(vchPubKey)) if (CWalletDB("r").ReadDefaultKey(vchPubKey))
{ {
return QString::fromStdString(PubKeyToAddress(vchPubKey)); return QString::fromStdString(PubKeyToAddress(vchPubKey));
} else { }
else
{
return QString(); return QString();
} }
} }
@ -116,9 +118,13 @@ ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payA
std::string strError = SendMoney(scriptPubKey, payAmount, wtx, true); std::string strError = SendMoney(scriptPubKey, payAmount, wtx, true);
if (strError == "") if (strError == "")
{
return OK; return OK;
}
else if (strError == "ABORTED") else if (strError == "ABORTED")
{
return Aborted; return Aborted;
}
else else
{ {
emit error(tr("Sending..."), QString::fromStdString(strError)); emit error(tr("Sending..."), QString::fromStdString(strError));

View File

@ -81,7 +81,9 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
{ {
addrProxy.ip = addr.ip; addrProxy.ip = addr.ip;
walletdb.WriteSetting("addrProxy", addrProxy); walletdb.WriteSetting("addrProxy", addrProxy);
} else { }
else
{
successful = false; successful = false;
} }
} }
@ -93,7 +95,9 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
{ {
addrProxy.port = htons(nPort); addrProxy.port = htons(nPort);
walletdb.WriteSetting("addrProxy", addrProxy); walletdb.WriteSetting("addrProxy", addrProxy);
} else { }
else
{
successful = false; successful = false;
} }
} }
@ -104,7 +108,9 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
{ {
nTransactionFee = retval; nTransactionFee = retval;
walletdb.WriteSetting("nTransactionFee", nTransactionFee); walletdb.WriteSetting("nTransactionFee", nTransactionFee);
} else { }
else
{
successful = false; /* parse error */ successful = false; /* parse error */
} }
} }

View File

@ -124,12 +124,15 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWalletTx
// Ignore parts sent to self, as this is usually the change // Ignore parts sent to self, as this is usually the change
// from a transaction sent back to our own address. // from a transaction sent back to our own address.
continue; continue;
} else if (!mapValue["to"].empty()) }
else if (!mapValue["to"].empty())
{ {
// Sent to IP // Sent to IP
sub.type = TransactionRecord::SendToIP; sub.type = TransactionRecord::SendToIP;
sub.address = mapValue["to"]; sub.address = mapValue["to"];
} else { }
else
{
// Sent to Bitcoin Address // Sent to Bitcoin Address
sub.type = TransactionRecord::SendToAddress; sub.type = TransactionRecord::SendToAddress;
uint160 hash160; uint160 hash160;
@ -148,7 +151,9 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWalletTx
parts.append(sub); parts.append(sub);
} }
} else { }
else
{
// //
// Mixed debit transaction, can't break down payees // Mixed debit transaction, can't break down payees
// //
@ -192,7 +197,9 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
{ {
status.status = TransactionStatus::OpenUntilBlock; status.status = TransactionStatus::OpenUntilBlock;
status.open_for = nBestHeight - wtx.nLockTime; status.open_for = nBestHeight - wtx.nLockTime;
} else { }
else
{
status.status = TransactionStatus::OpenUntilDate; status.status = TransactionStatus::OpenUntilDate;
status.open_for = wtx.nLockTime; status.open_for = wtx.nLockTime;
} }
@ -202,10 +209,12 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
{ {
status.status = TransactionStatus::Offline; status.status = TransactionStatus::Offline;
} else if (status.depth < 6) }
else if (status.depth < 6)
{ {
status.status = TransactionStatus::Unconfirmed; status.status = TransactionStatus::Unconfirmed;
} else }
else
{ {
status.status = TransactionStatus::HaveConfirmations; status.status = TransactionStatus::HaveConfirmations;
} }
@ -226,10 +235,14 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
// Check if the block was requested by anyone // Check if the block was requested by anyone
if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
status.maturity = TransactionStatus::MaturesWarning; status.maturity = TransactionStatus::MaturesWarning;
} else { }
else
{
status.maturity = TransactionStatus::NotAccepted; status.maturity = TransactionStatus::NotAccepted;
} }
} else { }
else
{
status.maturity = TransactionStatus::Mature; status.maturity = TransactionStatus::Mature;
} }
} }

View File

@ -121,13 +121,15 @@ struct TransactionTablePriv
} }
parent->endInsertRows(); parent->endInsertRows();
} }
} else if(!inWallet && inModel) }
else if(!inWallet && inModel)
{ {
/* Removed */ /* Removed */
parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1); parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
cachedWallet.erase(lower, upper); cachedWallet.erase(lower, upper);
parent->endRemoveRows(); parent->endRemoveRows();
} else if(inWallet && inModel) }
else if(inWallet && inModel)
{ {
/* Updated */ /* Updated */
@ -167,7 +169,9 @@ struct TransactionTablePriv
} }
} }
return rec; return rec;
} else { }
else
{
return 0; return 0;
} }
} }
@ -274,7 +278,9 @@ QVariant TransactionTableModel::formatTxDate(const TransactionRecord *wtx) const
if(wtx->time) if(wtx->time)
{ {
return QVariant(GUIUtil::DateTimeStr(wtx->time)); return QVariant(GUIUtil::DateTimeStr(wtx->time));
} else { }
else
{
return QVariant(); return QVariant();
} }
} }
@ -296,8 +302,10 @@ std::string lookupAddress(const std::string &address)
description += "(" + label + ")"; description += "(" + label + ")";
} }
else else
{
description += address; description += address;
} }
}
return description; return description;
} }
@ -354,7 +362,9 @@ QVariant TransactionTableModel::formatTxDebit(const TransactionRecord *wtx) cons
str = QString("[") + str + QString("]"); str = QString("[") + str + QString("]");
} }
return QVariant(str); return QVariant(str);
} else { }
else
{
return QVariant(); return QVariant();
} }
} }
@ -369,7 +379,9 @@ QVariant TransactionTableModel::formatTxCredit(const TransactionRecord *wtx) con
str = QString("[") + str + QString("]"); str = QString("[") + str + QString("]");
} }
return QVariant(str); return QVariant(str);
} else { }
else
{
return QVariant(); return QVariant();
} }
} }
@ -396,7 +408,8 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
case Credit: case Credit:
return formatTxCredit(rec); return formatTxCredit(rec);
} }
} else if(role == Qt::EditRole) }
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()) switch(index.column())
@ -412,19 +425,24 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
case Credit: case Credit:
return rec->credit; return rec->credit;
} }
} else if (role == Qt::TextAlignmentRole) }
else if (role == Qt::TextAlignmentRole)
{ {
return column_alignments[index.column()]; return column_alignments[index.column()];
} else if (role == Qt::ForegroundRole) }
else if (role == Qt::ForegroundRole)
{ {
/* Non-confirmed transactions are grey */ /* Non-confirmed transactions are grey */
if(rec->status.confirmed) if(rec->status.confirmed)
{ {
return QColor(0, 0, 0); return QColor(0, 0, 0);
} else { }
else
{
return QColor(128, 128, 128); return QColor(128, 128, 128);
} }
} else if (role == TypeRole) }
else if (role == TypeRole)
{ {
/* Role for filtering tabs by type */ /* Role for filtering tabs by type */
switch(rec->type) switch(rec->type)
@ -450,7 +468,8 @@ QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientat
if(role == Qt::DisplayRole) if(role == Qt::DisplayRole)
{ {
return columns[section]; return columns[section];
} else if (role == Qt::TextAlignmentRole) }
else if (role == Qt::TextAlignmentRole)
{ {
return column_alignments[section]; return column_alignments[section];
} }
@ -470,7 +489,9 @@ QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex
if(data) if(data)
{ {
return createIndex(row, column, priv->index(row)); return createIndex(row, column, priv->index(row));
} else { }
else
{
return QModelIndex(); return QModelIndex();
} }
} }