@ -31,7 +31,6 @@
# include <QTreeWidget>
# include <QTreeWidget>
QList < CAmount > CoinControlDialog : : payAmounts ;
QList < CAmount > CoinControlDialog : : payAmounts ;
CCoinControl * CoinControlDialog : : coinControl = new CCoinControl ( ) ;
bool CoinControlDialog : : fSubtractFeeFromAmount = false ;
bool CoinControlDialog : : fSubtractFeeFromAmount = false ;
bool CCoinControlWidgetItem : : operator < ( const QTreeWidgetItem & other ) const {
bool CCoinControlWidgetItem : : operator < ( const QTreeWidgetItem & other ) const {
@ -193,7 +192,7 @@ void CoinControlDialog::buttonSelectAllClicked()
ui - > treeWidget - > topLevelItem ( i ) - > setCheckState ( COLUMN_CHECKBOX , state ) ;
ui - > treeWidget - > topLevelItem ( i ) - > setCheckState ( COLUMN_CHECKBOX , state ) ;
ui - > treeWidget - > setEnabled ( true ) ;
ui - > treeWidget - > setEnabled ( true ) ;
if ( state = = Qt : : Unchecked )
if ( state = = Qt : : Unchecked )
coinControl - > UnSelectAll ( ) ; // just to be sure
coinControl ( ) - > UnSelectAll ( ) ; // just to be sure
CoinControlDialog : : updateLabels ( model , this ) ;
CoinControlDialog : : updateLabels ( model , this ) ;
}
}
@ -379,11 +378,11 @@ void CoinControlDialog::viewItemChanged(QTreeWidgetItem* item, int column)
COutPoint outpt ( uint256S ( item - > text ( COLUMN_TXHASH ) . toStdString ( ) ) , item - > text ( COLUMN_VOUT_INDEX ) . toUInt ( ) ) ;
COutPoint outpt ( uint256S ( item - > text ( COLUMN_TXHASH ) . toStdString ( ) ) , item - > text ( COLUMN_VOUT_INDEX ) . toUInt ( ) ) ;
if ( item - > checkState ( COLUMN_CHECKBOX ) = = Qt : : Unchecked )
if ( item - > checkState ( COLUMN_CHECKBOX ) = = Qt : : Unchecked )
coinControl - > UnSelect ( outpt ) ;
coinControl ( ) - > UnSelect ( outpt ) ;
else if ( item - > isDisabled ( ) ) // locked (this happens if "check all" through parent node)
else if ( item - > isDisabled ( ) ) // locked (this happens if "check all" through parent node)
item - > setCheckState ( COLUMN_CHECKBOX , Qt : : Unchecked ) ;
item - > setCheckState ( COLUMN_CHECKBOX , Qt : : Unchecked ) ;
else
else
coinControl - > Select ( outpt ) ;
coinControl ( ) - > Select ( outpt ) ;
// selection changed -> update labels
// selection changed -> update labels
if ( ui - > treeWidget - > isEnabled ( ) ) // do not update on every click for (un)select all
if ( ui - > treeWidget - > isEnabled ( ) ) // do not update on every click for (un)select all
@ -446,7 +445,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
std : : vector < COutPoint > vCoinControl ;
std : : vector < COutPoint > vCoinControl ;
std : : vector < COutput > vOutputs ;
std : : vector < COutput > vOutputs ;
coinControl - > ListSelected ( vCoinControl ) ;
coinControl ( ) - > ListSelected ( vCoinControl ) ;
model - > getOutputs ( vCoinControl , vOutputs ) ;
model - > getOutputs ( vCoinControl , vOutputs ) ;
for ( const COutput & out : vOutputs ) {
for ( const COutput & out : vOutputs ) {
@ -456,7 +455,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
COutPoint outpt ( txhash , out . i ) ;
COutPoint outpt ( txhash , out . i ) ;
if ( model - > isSpent ( outpt ) )
if ( model - > isSpent ( outpt ) )
{
{
coinControl - > UnSelect ( outpt ) ;
coinControl ( ) - > UnSelect ( outpt ) ;
continue ;
continue ;
}
}
@ -509,7 +508,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
nBytes - = 34 ;
nBytes - = 34 ;
// Fee
// Fee
nPayFee = GetMinimumFee ( nBytes , * coinControl , : : mempool , : : feeEstimator , nullptr /* FeeCalculation */ ) ;
nPayFee = GetMinimumFee ( nBytes , * coinControl ( ) , : : mempool , : : feeEstimator , nullptr /* FeeCalculation */ ) ;
if ( nPayAmount > 0 )
if ( nPayAmount > 0 )
{
{
@ -600,6 +599,12 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
label - > setVisible ( nChange < 0 ) ;
label - > setVisible ( nChange < 0 ) ;
}
}
CCoinControl * CoinControlDialog : : coinControl ( )
{
static CCoinControl coin_control ;
return & coin_control ;
}
void CoinControlDialog : : updateView ( )
void CoinControlDialog : : updateView ( )
{
{
if ( ! model | | ! model - > getOptionsModel ( ) | | ! model - > getAddressTableModel ( ) )
if ( ! model | | ! model - > getOptionsModel ( ) | | ! model - > getAddressTableModel ( ) )
@ -703,13 +708,13 @@ void CoinControlDialog::updateView()
if ( model - > isLockedCoin ( txhash , out . i ) )
if ( model - > isLockedCoin ( txhash , out . i ) )
{
{
COutPoint outpt ( txhash , out . i ) ;
COutPoint outpt ( txhash , out . i ) ;
coinControl - > UnSelect ( outpt ) ; // just to be sure
coinControl ( ) - > UnSelect ( outpt ) ; // just to be sure
itemOutput - > setDisabled ( true ) ;
itemOutput - > setDisabled ( true ) ;
itemOutput - > setIcon ( COLUMN_CHECKBOX , platformStyle - > SingleColorIcon ( " :/icons/lock_closed " ) ) ;
itemOutput - > setIcon ( COLUMN_CHECKBOX , platformStyle - > SingleColorIcon ( " :/icons/lock_closed " ) ) ;
}
}
// set checkbox
// set checkbox
if ( coinControl - > IsSelected ( COutPoint ( txhash , out . i ) ) )
if ( coinControl ( ) - > IsSelected ( COutPoint ( txhash , out . i ) ) )
itemOutput - > setCheckState ( COLUMN_CHECKBOX , Qt : : Checked ) ;
itemOutput - > setCheckState ( COLUMN_CHECKBOX , Qt : : Checked ) ;
}
}