@ -37,10 +37,8 @@ bool CoinControlDialog::fSubtractFeeFromAmount = false;
bool CCoinControlWidgetItem : : operator < ( const QTreeWidgetItem & other ) const {
bool CCoinControlWidgetItem : : operator < ( const QTreeWidgetItem & other ) const {
int column = treeWidget ( ) - > sortColumn ( ) ;
int column = treeWidget ( ) - > sortColumn ( ) ;
if ( column = = CoinControlDialog : : COLUMN_AMOUNT_INT64 | | column = = CoinControlDialog : : COLUMN_AMOUNT_INT64 )
if ( column = = CoinControlDialog : : COLUMN_AMOUNT | | column = = CoinControlDialog : : COLUMN_DATE | | column = = CoinControlDialog : : COLUMN_CONFIRMATIONS )
return data ( CoinControlDialog : : COLUMN_AMOUNT_INT64 , Qt : : DisplayRole ) . toULongLong ( ) < other . data ( CoinControlDialog : : COLUMN_AMOUNT_INT64 , Qt : : DisplayRole ) . toULongLong ( ) ;
return data ( column , Qt : : UserRole ) . toLongLong ( ) < other . data ( column , Qt : : UserRole ) . toLongLong ( ) ;
if ( column = = CoinControlDialog : : COLUMN_DATE | | column = = CoinControlDialog : : COLUMN_DATE_INT64 )
return data ( CoinControlDialog : : COLUMN_DATE_INT64 , Qt : : DisplayRole ) . toULongLong ( ) < other . data ( CoinControlDialog : : COLUMN_DATE_INT64 , Qt : : DisplayRole ) . toULongLong ( ) ;
return QTreeWidgetItem : : operator < ( other ) ;
return QTreeWidgetItem : : operator < ( other ) ;
}
}
@ -137,11 +135,9 @@ CoinControlDialog::CoinControlDialog(const PlatformStyle *_platformStyle, QWidge
ui - > treeWidget - > setColumnWidth ( COLUMN_CONFIRMATIONS , 110 ) ;
ui - > treeWidget - > setColumnWidth ( COLUMN_CONFIRMATIONS , 110 ) ;
ui - > treeWidget - > setColumnHidden ( COLUMN_TXHASH , true ) ; // store transaction hash in this column, but don't show it
ui - > treeWidget - > setColumnHidden ( COLUMN_TXHASH , true ) ; // store transaction hash in this column, but don't show it
ui - > treeWidget - > setColumnHidden ( COLUMN_VOUT_INDEX , true ) ; // store vout index in this column, but don't show it
ui - > treeWidget - > setColumnHidden ( COLUMN_VOUT_INDEX , true ) ; // store vout index in this column, but don't show it
ui - > treeWidget - > setColumnHidden ( COLUMN_AMOUNT_INT64 , true ) ; // store amount int64 in this column, but don't show it
ui - > treeWidget - > setColumnHidden ( COLUMN_DATE_INT64 , true ) ; // store date int64 in this column, but don't show it
// default view is sorted by amount desc
// default view is sorted by amount desc
sortView ( COLUMN_AMOUNT_INT64 , Qt : : DescendingOrder ) ;
sortView ( COLUMN_AMOUNT , Qt : : DescendingOrder ) ;
// restore list mode and sortorder as a convenience feature
// restore list mode and sortorder as a convenience feature
QSettings settings ;
QSettings settings ;
@ -173,15 +169,6 @@ void CoinControlDialog::setModel(WalletModel *_model)
}
}
}
}
// helper function str_pad
QString CoinControlDialog : : strPad ( QString s , int nPadLength , QString sPadding )
{
while ( s . length ( ) < nPadLength )
s = sPadding + s ;
return s ;
}
// ok button
// ok button
void CoinControlDialog : : buttonBoxClicked ( QAbstractButton * button )
void CoinControlDialog : : buttonBoxClicked ( QAbstractButton * button )
{
{
@ -347,7 +334,7 @@ void CoinControlDialog::sortView(int column, Qt::SortOrder order)
sortColumn = column ;
sortColumn = column ;
sortOrder = order ;
sortOrder = order ;
ui - > treeWidget - > sortItems ( column , order ) ;
ui - > treeWidget - > sortItems ( column , order ) ;
ui - > treeWidget - > header ( ) - > setSortIndicator ( getMappedColumn ( sortColumn ) , sortOrder ) ;
ui - > treeWidget - > header ( ) - > setSortIndicator ( sortColumn , sortOrder ) ;
}
}
// treeview: clicked on header
// treeview: clicked on header
@ -355,12 +342,10 @@ void CoinControlDialog::headerSectionClicked(int logicalIndex)
{
{
if ( logicalIndex = = COLUMN_CHECKBOX ) // click on most left column -> do nothing
if ( logicalIndex = = COLUMN_CHECKBOX ) // click on most left column -> do nothing
{
{
ui - > treeWidget - > header ( ) - > setSortIndicator ( getMappedColumn ( sortColumn ) , sortOrder ) ;
ui - > treeWidget - > header ( ) - > setSortIndicator ( sortColumn , sortOrder ) ;
}
}
else
else
{
{
logicalIndex = getMappedColumn ( logicalIndex , false ) ;
if ( sortColumn = = logicalIndex )
if ( sortColumn = = logicalIndex )
sortOrder = ( ( sortOrder = = Qt : : AscendingOrder ) ? Qt : : DescendingOrder : Qt : : AscendingOrder ) ;
sortOrder = ( ( sortOrder = = Qt : : AscendingOrder ) ? Qt : : DescendingOrder : Qt : : AscendingOrder ) ;
else
else
@ -730,14 +715,15 @@ void CoinControlDialog::updateView()
// amount
// amount
itemOutput - > setText ( COLUMN_AMOUNT , BitcoinUnits : : format ( nDisplayUnit , out . tx - > vout [ out . i ] . nValue ) ) ;
itemOutput - > setText ( COLUMN_AMOUNT , BitcoinUnits : : format ( nDisplayUnit , out . tx - > vout [ out . i ] . nValue ) ) ;
itemOutput - > setData ( COLUMN_AMOUNT_INT64 , Qt : : Display Role, QVariant ( ( qlonglong ) out . tx - > vout [ out . i ] . nValue ) ) ; // padding so that sorting works correctly
itemOutput - > setData ( COLUMN_AMOUNT , Qt : : User Role, QVariant ( ( qlonglong ) out . tx - > vout [ out . i ] . nValue ) ) ; // padding so that sorting works correctly
// date
// date
itemOutput - > setText ( COLUMN_DATE , GUIUtil : : dateTimeStr ( out . tx - > GetTxTime ( ) ) ) ;
itemOutput - > setText ( COLUMN_DATE , GUIUtil : : dateTimeStr ( out . tx - > GetTxTime ( ) ) ) ;
itemOutput - > setData ( COLUMN_DATE_INT64 , Qt : : Display Role, QVariant ( ( qlonglong ) out . tx - > GetTxTime ( ) ) ) ;
itemOutput - > setData ( COLUMN_DATE , Qt : : User Role, QVariant ( ( qlonglong ) out . tx - > GetTxTime ( ) ) ) ;
// confirmations
// confirmations
itemOutput - > setText ( COLUMN_CONFIRMATIONS , strPad ( QString : : number ( out . nDepth ) , 8 , " " ) ) ;
itemOutput - > setText ( COLUMN_CONFIRMATIONS , QString : : number ( out . nDepth ) ) ;
itemOutput - > setData ( COLUMN_CONFIRMATIONS , Qt : : UserRole , QVariant ( ( qlonglong ) out . nDepth ) ) ;
// transaction hash
// transaction hash
uint256 txhash = out . tx - > GetHash ( ) ;
uint256 txhash = out . tx - > GetHash ( ) ;
@ -765,7 +751,7 @@ void CoinControlDialog::updateView()
{
{
itemWalletAddress - > setText ( COLUMN_CHECKBOX , " ( " + QString : : number ( nChildren ) + " ) " ) ;
itemWalletAddress - > setText ( COLUMN_CHECKBOX , " ( " + QString : : number ( nChildren ) + " ) " ) ;
itemWalletAddress - > setText ( COLUMN_AMOUNT , BitcoinUnits : : format ( nDisplayUnit , nSum ) ) ;
itemWalletAddress - > setText ( COLUMN_AMOUNT , BitcoinUnits : : format ( nDisplayUnit , nSum ) ) ;
itemWalletAddress - > setText ( COLUMN_AMOUNT_INT64 , strPad ( QS tring : : number ( nSum ) , 15 , " " ) ) ;
itemWalletAddress - > setData ( COLUMN_AMOUNT , Qt : : UserRole , QVariant ( ( qlonglong ) nSum ) ) ;
}
}
}
}