Browse Source

Merge pull request #3991

d34b958 [Qt] small cleanup of coincontroldialog (Philip Kaufmann)
0.10
Wladimir J. van der Laan 11 years ago
parent
commit
8d5abd480b
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 33
      src/qt/coincontroldialog.cpp

33
src/qt/coincontroldialog.cpp

@ -97,7 +97,7 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) :
connect(ui->radioListMode, SIGNAL(toggled(bool)), this, SLOT(radioListMode(bool))); connect(ui->radioListMode, SIGNAL(toggled(bool)), this, SLOT(radioListMode(bool)));
// click on checkbox // 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 // click on header
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
@ -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,17 +641,18 @@ 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();
ui->treeWidget->setEnabled(false); // performance, otherwise updateLabels would be called for every checked checkbox ui->treeWidget->setEnabled(false); // performance, otherwise updateLabels would be called for every checked checkbox
ui->treeWidget->setAlternatingRowColors(!treeMode); ui->treeWidget->setAlternatingRowColors(!treeMode);
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)
@ -671,7 +672,7 @@ void CoinControlDialog::updateView()
ui->treeWidget->addTopLevelItem(itemWalletAddress); ui->treeWidget->addTopLevelItem(itemWalletAddress);
itemWalletAddress->setFlags(flgTristate); itemWalletAddress->setFlags(flgTristate);
itemWalletAddress->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked); itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
// label // label
itemWalletAddress->setText(COLUMN_LABEL, sWalletLabel); itemWalletAddress->setText(COLUMN_LABEL, sWalletLabel);
@ -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);
} }
@ -766,7 +765,7 @@ void CoinControlDialog::updateView()
// set checkbox // set checkbox
if (coinControl->IsSelected(txhash, out.i)) if (coinControl->IsSelected(txhash, out.i))
itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Checked); itemOutput->setCheckState(COLUMN_CHECKBOX, Qt::Checked);
} }
// amount // amount

Loading…
Cancel
Save