Browse Source

[Qt] small cleanup of coincontroldialog

- use a little more Qt-style
- check for NULL pointers first and return in updateView()
- small space and formating changes
0.10
Philip Kaufmann 11 years ago
parent
commit
d34b958406
  1. 23
      src/qt/coincontroldialog.cpp

23
src/qt/coincontroldialog.cpp

@ -434,7 +434,8 @@ void CoinControlDialog::updateLabelLocked()
void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
{ {
if (!model) return; if (!model)
return;
// nPayAmount // nPayAmount
qint64 nPayAmount = 0; qint64 nPayAmount = 0;
@ -640,6 +641,9 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
void CoinControlDialog::updateView() void CoinControlDialog::updateView()
{ {
if (!model || !model->getOptionsModel() || !model->getAddressTableModel())
return;
bool treeMode = ui->radioTreeMode->isChecked(); bool treeMode = ui->radioTreeMode->isChecked();
ui->treeWidget->clear(); ui->treeWidget->clear();
@ -648,9 +652,7 @@ void CoinControlDialog::updateView()
QFlags<Qt::ItemFlag> flgCheckbox = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable; QFlags<Qt::ItemFlag> flgCheckbox = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
QFlags<Qt::ItemFlag> flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsTristate; QFlags<Qt::ItemFlag> flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsTristate;
int nDisplayUnit = BitcoinUnits::BTC; int nDisplayUnit = model->getOptionsModel()->getDisplayUnit();
if (model && model->getOptionsModel())
nDisplayUnit = model->getOptionsModel()->getDisplayUnit();
map<QString, vector<COutput> > mapCoins; map<QString, vector<COutput> > mapCoins;
model->listCoins(mapCoins); model->listCoins(mapCoins);
@ -658,11 +660,10 @@ void CoinControlDialog::updateView()
BOOST_FOREACH(PAIRTYPE(QString, vector<COutput>) coins, mapCoins) BOOST_FOREACH(PAIRTYPE(QString, vector<COutput>) coins, mapCoins)
{ {
QTreeWidgetItem *itemWalletAddress = new QTreeWidgetItem(); QTreeWidgetItem *itemWalletAddress = new QTreeWidgetItem();
itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
QString sWalletAddress = coins.first; QString sWalletAddress = coins.first;
QString sWalletLabel = ""; QString sWalletLabel = model->getAddressTableModel()->labelForAddress(sWalletAddress);
if (model->getAddressTableModel()) if (sWalletLabel.isEmpty())
sWalletLabel = model->getAddressTableModel()->labelForAddress(sWalletAddress);
if (sWalletLabel.length() == 0)
sWalletLabel = tr("(no label)"); sWalletLabel = tr("(no label)");
if (treeMode) if (treeMode)
@ -722,10 +723,8 @@ void CoinControlDialog::updateView()
} }
else if (!treeMode) else if (!treeMode)
{ {
QString sLabel = ""; QString sLabel = model->getAddressTableModel()->labelForAddress(sAddress);
if (model->getAddressTableModel()) if (sLabel.isEmpty())
sLabel = model->getAddressTableModel()->labelForAddress(sAddress);
if (sLabel.length() == 0)
sLabel = tr("(no label)"); sLabel = tr("(no label)");
itemOutput->setText(COLUMN_LABEL, sLabel); itemOutput->setText(COLUMN_LABEL, sLabel);
} }

Loading…
Cancel
Save