qml: split off AddressDelegate and handle imported addresses more gracefully
This commit is contained in:
@@ -200,11 +200,13 @@ Pane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
visible: addressdetails.derivationPath
|
||||||
text: qsTr('Derivation path')
|
text: qsTr('Derivation path')
|
||||||
color: Material.accentColor
|
color: Material.accentColor
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
visible: addressdetails.derivationPath
|
||||||
text: addressdetails.derivationPath
|
text: addressdetails.derivationPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,14 +31,7 @@ Pane {
|
|||||||
section.criteria: ViewSection.FullString
|
section.criteria: ViewSection.FullString
|
||||||
section.delegate: sectionDelegate
|
section.delegate: sectionDelegate
|
||||||
|
|
||||||
delegate: ItemDelegate {
|
delegate: AddressDelegate {
|
||||||
id: delegate
|
|
||||||
width: ListView.view.width
|
|
||||||
height: delegateLayout.height
|
|
||||||
highlighted: ListView.isCurrentItem
|
|
||||||
|
|
||||||
font.pixelSize: constants.fontSizeMedium // set default font size for child controls
|
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var page = app.stack.push(Qt.resolvedUrl('AddressDetails.qml'), {'address': model.address})
|
var page = app.stack.push(Qt.resolvedUrl('AddressDetails.qml'), {'address': model.address})
|
||||||
page.addressDetailsChanged.connect(function() {
|
page.addressDetailsChanged.connect(function() {
|
||||||
@@ -46,84 +39,6 @@ Pane {
|
|||||||
listview.model.update_address(model.address)
|
listview.model.update_address(model.address)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: delegateLayout
|
|
||||||
width: parent.width
|
|
||||||
spacing: 0
|
|
||||||
|
|
||||||
GridLayout {
|
|
||||||
columns: 2
|
|
||||||
Layout.topMargin: constants.paddingSmall
|
|
||||||
Layout.leftMargin: constants.paddingLarge
|
|
||||||
Layout.rightMargin: constants.paddingLarge
|
|
||||||
|
|
||||||
Label {
|
|
||||||
id: indexLabel
|
|
||||||
font.bold: true
|
|
||||||
text: '#' + ('00'+model.iaddr).slice(-2)
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
font.family: FixedFont
|
|
||||||
text: model.address
|
|
||||||
elide: Text.ElideMiddle
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: useIndicator
|
|
||||||
Layout.preferredWidth: constants.iconSizeMedium
|
|
||||||
Layout.preferredHeight: constants.iconSizeMedium
|
|
||||||
color: model.held
|
|
||||||
? constants.colorAddressFrozen
|
|
||||||
: model.numtx > 0
|
|
||||||
? model.balance.satsInt == 0
|
|
||||||
? constants.colorAddressUsed
|
|
||||||
: constants.colorAddressUsedWithBalance
|
|
||||||
: model.type == 'receive'
|
|
||||||
? constants.colorAddressExternal
|
|
||||||
: constants.colorAddressInternal
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
Label {
|
|
||||||
id: labelLabel
|
|
||||||
font.pixelSize: model.label != '' ? constants.fontSizeLarge : constants.fontSizeSmall
|
|
||||||
text: model.label != '' ? model.label : qsTr('<no label>')
|
|
||||||
opacity: model.label != '' ? 1.0 : 0.8
|
|
||||||
elide: Text.ElideRight
|
|
||||||
maximumLineCount: 2
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
font.family: FixedFont
|
|
||||||
text: Config.formatSats(model.balance, false)
|
|
||||||
visible: model.balance.satsInt != 0
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
color: Material.accentColor
|
|
||||||
text: Config.baseUnit + ','
|
|
||||||
visible: model.balance.satsInt != 0
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
text: model.numtx
|
|
||||||
visible: model.numtx > 0
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
color: Material.accentColor
|
|
||||||
text: qsTr('tx')
|
|
||||||
visible: model.numtx > 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
Layout.preferredWidth: 1
|
|
||||||
Layout.preferredHeight: constants.paddingSmall
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollIndicator.vertical: ScrollIndicator { }
|
ScrollIndicator.vertical: ScrollIndicator { }
|
||||||
|
|||||||
95
electrum/gui/qml/components/controls/AddressDelegate.qml
Normal file
95
electrum/gui/qml/components/controls/AddressDelegate.qml
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import QtQuick 2.6
|
||||||
|
import QtQuick.Controls 2.0
|
||||||
|
import QtQuick.Layouts 1.0
|
||||||
|
import QtQuick.Controls.Material 2.0
|
||||||
|
|
||||||
|
import org.electrum 1.0
|
||||||
|
|
||||||
|
ItemDelegate {
|
||||||
|
id: delegate
|
||||||
|
width: ListView.view.width
|
||||||
|
height: delegateLayout.height
|
||||||
|
highlighted: ListView.isCurrentItem
|
||||||
|
|
||||||
|
font.pixelSize: constants.fontSizeMedium // set default font size for child controls
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: delegateLayout
|
||||||
|
width: parent.width
|
||||||
|
spacing: 0
|
||||||
|
|
||||||
|
GridLayout {
|
||||||
|
columns: 2
|
||||||
|
Layout.topMargin: constants.paddingSmall
|
||||||
|
Layout.leftMargin: constants.paddingLarge
|
||||||
|
Layout.rightMargin: constants.paddingLarge
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: indexLabel
|
||||||
|
font.bold: true
|
||||||
|
text: model.iaddr < 10
|
||||||
|
? '#' + ('0'+model.iaddr).slice(-2)
|
||||||
|
: '#' + model.iaddr
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
font.family: FixedFont
|
||||||
|
text: model.address
|
||||||
|
elide: Text.ElideMiddle
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: useIndicator
|
||||||
|
Layout.preferredWidth: constants.iconSizeMedium
|
||||||
|
Layout.preferredHeight: constants.iconSizeMedium
|
||||||
|
color: model.held
|
||||||
|
? constants.colorAddressFrozen
|
||||||
|
: model.numtx > 0
|
||||||
|
? model.balance.satsInt == 0
|
||||||
|
? constants.colorAddressUsed
|
||||||
|
: constants.colorAddressUsedWithBalance
|
||||||
|
: model.type == 'change'
|
||||||
|
? constants.colorAddressInternal
|
||||||
|
: constants.colorAddressExternal
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
Label {
|
||||||
|
id: labelLabel
|
||||||
|
font.pixelSize: model.label != '' ? constants.fontSizeLarge : constants.fontSizeSmall
|
||||||
|
text: model.label != '' ? model.label : qsTr('<no label>')
|
||||||
|
opacity: model.label != '' ? 1.0 : 0.8
|
||||||
|
elide: Text.ElideRight
|
||||||
|
maximumLineCount: 2
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
font.family: FixedFont
|
||||||
|
text: Config.formatSats(model.balance, false)
|
||||||
|
visible: model.balance.satsInt != 0
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
color: Material.accentColor
|
||||||
|
text: Config.baseUnit + ','
|
||||||
|
visible: model.balance.satsInt != 0
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
text: model.numtx
|
||||||
|
visible: model.numtx > 0
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
color: Material.accentColor
|
||||||
|
text: qsTr('tx')
|
||||||
|
visible: model.numtx > 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Layout.preferredWidth: 1
|
||||||
|
Layout.preferredHeight: constants.paddingSmall
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -73,7 +73,7 @@ class QEAddressListModel(QAbstractListModel):
|
|||||||
return
|
return
|
||||||
|
|
||||||
r_addresses = self.wallet.get_receiving_addresses()
|
r_addresses = self.wallet.get_receiving_addresses()
|
||||||
c_addresses = self.wallet.get_change_addresses()
|
c_addresses = self.wallet.get_change_addresses() if self.wallet.wallet_type != 'imported' else []
|
||||||
n_addresses = len(r_addresses) + len(c_addresses)
|
n_addresses = len(r_addresses) + len(c_addresses)
|
||||||
|
|
||||||
def insert_row(atype, alist, address, iaddr):
|
def insert_row(atype, alist, address, iaddr):
|
||||||
@@ -84,10 +84,14 @@ class QEAddressListModel(QAbstractListModel):
|
|||||||
|
|
||||||
self.clear()
|
self.clear()
|
||||||
self.beginInsertRows(QModelIndex(), 0, n_addresses - 1)
|
self.beginInsertRows(QModelIndex(), 0, n_addresses - 1)
|
||||||
for i, address in enumerate(r_addresses):
|
if self.wallet.wallet_type != 'imported':
|
||||||
insert_row('receive', self.receive_addresses, address, i)
|
for i, address in enumerate(r_addresses):
|
||||||
for i, address in enumerate(c_addresses):
|
insert_row('receive', self.receive_addresses, address, i)
|
||||||
insert_row('change', self.change_addresses, address, i)
|
for i, address in enumerate(c_addresses):
|
||||||
|
insert_row('change', self.change_addresses, address, i)
|
||||||
|
else:
|
||||||
|
for i, address in enumerate(r_addresses):
|
||||||
|
insert_row('imported', self.receive_addresses, address, i)
|
||||||
self.endInsertRows()
|
self.endInsertRows()
|
||||||
|
|
||||||
self._dirty = False
|
self._dirty = False
|
||||||
|
|||||||
Reference in New Issue
Block a user