diff options
author | Philip Kaufmann <phil.kaufmann@t-online.de> | 2014-04-01 10:08:35 +0200 |
---|---|---|
committer | Philip Kaufmann <phil.kaufmann@t-online.de> | 2014-04-01 10:11:18 +0200 |
commit | d34b958406869018dec6302ae2ed3aa062ea7516 (patch) | |
tree | 0c2d3e767c117e5ded0844278de3659ab0e3fe61 | |
parent | d8dcfb9034131fec2bbf9791d8c49b546ce29043 (diff) |
[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
-rw-r--r-- | src/qt/coincontroldialog.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 9df8f180b1..dc9d2afe27 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -97,7 +97,7 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) : connect(ui->radioListMode, SIGNAL(toggled(bool)), this, SLOT(radioListMode(bool))); // click on checkbox - connect(ui->treeWidget, SIGNAL(itemChanged( QTreeWidgetItem*, int)), this, SLOT(viewItemChanged( QTreeWidgetItem*, int))); + connect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(viewItemChanged(QTreeWidgetItem*, int))); // click on header #if QT_VERSION < 0x050000 @@ -434,7 +434,8 @@ void CoinControlDialog::updateLabelLocked() void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) { - if (!model) return; + if (!model) + return; // nPayAmount qint64 nPayAmount = 0; @@ -640,17 +641,18 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) void CoinControlDialog::updateView() { + if (!model || !model->getOptionsModel() || !model->getAddressTableModel()) + return; + bool treeMode = ui->radioTreeMode->isChecked(); ui->treeWidget->clear(); ui->treeWidget->setEnabled(false); // performance, otherwise updateLabels would be called for every checked checkbox ui->treeWidget->setAlternatingRowColors(!treeMode); - 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> flgCheckbox = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable; + QFlags<Qt::ItemFlag> flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsTristate; - int nDisplayUnit = BitcoinUnits::BTC; - if (model && model->getOptionsModel()) - nDisplayUnit = model->getOptionsModel()->getDisplayUnit(); + int nDisplayUnit = model->getOptionsModel()->getDisplayUnit(); map<QString, vector<COutput> > mapCoins; model->listCoins(mapCoins); @@ -658,11 +660,10 @@ void CoinControlDialog::updateView() BOOST_FOREACH(PAIRTYPE(QString, vector<COutput>) coins, mapCoins) { QTreeWidgetItem *itemWalletAddress = new QTreeWidgetItem(); + itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); QString sWalletAddress = coins.first; - QString sWalletLabel = ""; - if (model->getAddressTableModel()) - sWalletLabel = model->getAddressTableModel()->labelForAddress(sWalletAddress); - if (sWalletLabel.length() == 0) + QString sWalletLabel = model->getAddressTableModel()->labelForAddress(sWalletAddress); + if (sWalletLabel.isEmpty()) sWalletLabel = tr("(no label)"); if (treeMode) @@ -671,7 +672,7 @@ void CoinControlDialog::updateView() ui->treeWidget->addTopLevelItem(itemWalletAddress); itemWalletAddress->setFlags(flgTristate); - itemWalletAddress->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked); + itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); // label itemWalletAddress->setText(COLUMN_LABEL, sWalletLabel); @@ -722,10 +723,8 @@ void CoinControlDialog::updateView() } else if (!treeMode) { - QString sLabel = ""; - if (model->getAddressTableModel()) - sLabel = model->getAddressTableModel()->labelForAddress(sAddress); - if (sLabel.length() == 0) + QString sLabel = model->getAddressTableModel()->labelForAddress(sAddress); + if (sLabel.isEmpty()) sLabel = tr("(no label)"); itemOutput->setText(COLUMN_LABEL, sLabel); } @@ -766,7 +765,7 @@ void CoinControlDialog::updateView() // set checkbox if (coinControl->IsSelected(txhash, out.i)) - itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Checked); + itemOutput->setCheckState(COLUMN_CHECKBOX, Qt::Checked); } // amount |