#include "ui_coincontroldialog.h"
#include "init.h"
+#include "base58.h"
#include "bitcoinunits.h"
#include "walletmodel.h"
#include "addresstablemodel.h"
#include <QString>
#include <QTreeWidget>
#include <QTreeWidgetItem>
+#include <QKeyEvent>
using namespace std;
QList<qint64> CoinControlDialog::payAmounts;
CCoinControl* CoinControlDialog::coinControl = new CCoinControl();
CoinControlDialog::CoinControlDialog(QWidget *parent) :
- QDialog(parent, DIALOGWINDOWHINTS),
+ QWidget(parent, DIALOGWINDOWHINTS),
ui(new Ui::CoinControlDialog),
model(0)
{
#endif
connect(ui->treeWidget->header(), SIGNAL(sectionClicked(int)), this, SLOT(headerSectionClicked(int)));
- // ok button
- connect(ui->buttonBox, SIGNAL(clicked( QAbstractButton*)), this, SLOT(buttonBoxClicked(QAbstractButton*)));
-
// (un)select all
connect(ui->pushButtonSelectAll, SIGNAL(clicked()), this, SLOT(buttonSelectAllClicked()));
+
+ ui->treeWidget->headerItem()->setText(COLUMN_CHECKBOX, QString());
ui->treeWidget->setColumnWidth(COLUMN_CHECKBOX, 84);
ui->treeWidget->setColumnWidth(COLUMN_AMOUNT, 100);
}
// ok button
-void CoinControlDialog::buttonBoxClicked(QAbstractButton* button)
+void CoinControlDialog::on_buttonBox_accepted()
{
- if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
- done(QDialog::Accepted); // closes the dialog
+ close(); // closes the dialog
}
// (un)select all
else ui->labelLocked->setVisible(false);
}*/
-void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
+void CoinControlDialog::updateLabels(WalletModel *model, QWidget* dialog)
{
if (!model) return;
l2->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAmount)); // Amount
l3->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nPayFee, false, 3)); // Fee
l4->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAfterFee)); // After Fee
- l5->setText(((nBytes > 0) ? "~" : "") + QString::number(nBytes)); // Bytes
+ l5->setText(((nBytes > 0) ? ASYMP_UTF8 : "") + QString::number(nBytes)); // Bytes
l6->setText(sPriorityLabel); // Priority
l7->setText((fLowOutput ? (fDust ? tr("DUST") : tr("yes")) : tr("no"))); // Low Output / Dust
l8->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nChange)); // Change
itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked);
// address
+/*
CTxDestination outputAddress;
QString sAddress = "";
if(ExtractDestination(out.tx->vout[out.i].scriptPubKey, outputAddress))
if (keyid && model->getPubKey(*keyid, pubkey) && !pubkey.IsCompressed())
nInputSize = 180;
}
+*/
+ QString sAddress = "";
+ txnouttype whichType;
+ std::vector<valtype> vSolutions;
+ if (Solver(out.tx->vout[out.i].scriptPubKey, whichType, vSolutions))
+ {
+ CTxDestination address;
+ if (whichType == TX_PUBKEY)
+ {
+ // Pay-to-Pubkey
+ CPubKey pubKey = CPubKey(vSolutions[0]);
+ address = pubKey.GetID();
+ sAddress = CBitcoinAddress(address).ToString().c_str();
+
+ if (!pubKey.IsCompressed())
+ nInputSize = 180;
+ }
+ else if (whichType == TX_PUBKEYHASH)
+ {
+ // Pay-to-PubkeyHash
+ address = CKeyID(uint160(vSolutions[0]));
+ sAddress = CBitcoinAddress(address).ToString().c_str();
+
+ CPubKey pubkey;
+ CKeyID *keyid = boost::get< CKeyID >(&address);
+ if (keyid && model->getPubKey(*keyid, pubkey) && !pubkey.IsCompressed())
+ nInputSize = 180;
+ }
+ else if (whichType == TX_SCRIPTHASH)
+ {
+ // Pay-to-ScriptHash
+ address = CScriptID(uint160(vSolutions[0]));
+ sAddress = CBitcoinAddress(address).ToString().c_str();
+ }
+ else if (whichType == TX_PUBKEY_DROP)
+ {
+ // Pay-to-Pubkey-R
+ CMalleableKeyView view;
+ pwalletMain->CheckOwnership(CPubKey(vSolutions[0]), CPubKey(vSolutions[1]), view);
+ sAddress = CBitcoinAddress(view.GetMalleablePubKey()).ToString().c_str();
+ }
+
+ // if listMode or change => show bitcoin address. In tree mode, address is not shown again for direct wallet address outputs
+ if (!treeMode || (!(sAddress == sWalletAddress)))
+ itemOutput->setText(COLUMN_ADDRESS, sAddress);
+ }
// label
if (!(sAddress == sWalletAddress)) // change
sortView(sortColumn, sortOrder);
ui->treeWidget->setEnabled(true);
}
+
+void CoinControlDialog::keyPressEvent(QKeyEvent *event)
+{
+#ifdef ANDROID
+ if(event->key() == Qt::Key_Back)
+ {
+ close();
+ }
+#else
+ if(event->key() == Qt::Key_Escape)
+ {
+ close();
+ }
+#endif
+}
+
+void CoinControlDialog::closeEvent(QCloseEvent* e)
+{
+ QWidget::closeEvent(e);
+ emit beforeClose();
+}