Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions electrum/gui/qml/components/AddressDetails.qml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,17 @@ Pane {
color: Material.accentColor
}

Label {
text: addressdetails.numTx
RowLayout{
Label {
text: addressdetails.numTx
}

Label {
visible: addressdetails.numTx
text: '(<a href="#">' + qsTr("show...") + '</a>)'
textFormat: Text.StyledText
onLinkActivated: app.stack.push(Qt.resolvedUrl('AddressHistory.qml'), { address: root.address })
}
}

Label {
Expand Down
57 changes: 57 additions & 0 deletions electrum/gui/qml/components/AddressHistory.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material

import org.electrum 1.0

import "controls"

Pane {
id: root
width: parent.width
height: parent.height
padding: 0

required property string address

ColumnLayout {
anchors.fill: parent
spacing: 10

ColumnLayout {
Layout.fillWidth: true
Layout.margins: 10
Label {
text: qsTr('Transaction history for address:')
color: Material.accentColor
Layout.fillWidth: true
wrapMode: Text.Wrap
}

TextHighlightPane {
Layout.fillWidth: true
Label {
text: address
width: parent.width
font.family: FixedFont
wrapMode: Text.Wrap
}
}
}

Frame {
Layout.fillWidth: true
Layout.fillHeight: true

verticalPadding: bg.lineWidth
horizontalPadding: 0
background: PaneInsetBackground { id: bg; vertical: false }

History {
anchors.fill: parent
forAddress: root.address
}
}
}
}
16 changes: 11 additions & 5 deletions electrum/gui/qml/components/History.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Pane {
vertical: false
}

property string forAddress
property QtObject backingModel: forAddress
? Daemon.currentWallet.historyModelForAddress(forAddress)
: Daemon.currentWallet.historyModel

ElListView {
id: listview
width: parent.width
Expand All @@ -32,7 +37,8 @@ Pane {

header: Item {
width: parent.width
height: headerLayout.height
height: forAddress ? 0 : headerLayout.height
visible: !forAddress
ColumnLayout {
id: headerLayout
anchors.centerIn: parent
Expand Down Expand Up @@ -70,7 +76,7 @@ Pane {

DelegateModel {
id: visualModel
model: Daemon.currentWallet.historyModel
model: backingModel

groups: [
DelegateModelGroup { name: 'today'; includeByDefault: false },
Expand All @@ -86,7 +92,7 @@ Pane {
ScrollIndicator.vertical: ScrollIndicator { }

Label {
visible: Daemon.currentWallet.historyModel.count == 0 && !Daemon.currentWallet.synchronizing
visible: !forAddress && Daemon.currentWallet.historyModel.count == 0 && !Daemon.currentWallet.synchronizing
anchors.centerIn: parent
width: listview.width * 4/5
font.pixelSize: constants.fontSizeXXLarge
Expand Down Expand Up @@ -159,9 +165,9 @@ Pane {

StackView.onVisibleChanged: {
// refresh model if History becomes visible and the model is dirty.
if (StackView.visible) {
if (StackView.visible && backingModel) {
listview.reuseItems = false
Daemon.currentWallet.historyModel.initModel(false)
backingModel.initModel(false)
listview.reuseItems = true
}
}
Expand Down
5 changes: 5 additions & 0 deletions electrum/gui/qml/qewallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ def historyModel(self):
self._historyModel = QETransactionListModel(self.wallet)
return self._historyModel

@pyqtSlot(str, result=QETransactionListModel)
def historyModelForAddress(self, address):
self._hmfa = QETransactionListModel(self.wallet, onchain_domain=[address], include_lightning=False)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be some lifetime issue. When stacking multiple AddressHistory, by clicking on the addresses and then show repeatedly, the previous AddressHistory lose their content when going back again:

Image

Couldn't you pass the model built by AddressDetails to AddressHistory which lives on top, so the AddressDetails own the model? This seems to fix the issue for me.

Like this: (click to expand)
diff --git a/electrum/gui/qml/components/AddressDetails.qml b/electrum/gui/qml/components/AddressDetails.qml
index 8f26a9dca..a376d63ef 100644
--- a/electrum/gui/qml/components/AddressDetails.qml
+++ b/electrum/gui/qml/components/AddressDetails.qml
@@ -108,7 +108,10 @@ Pane {
                         visible: addressdetails.numTx
                         text: '(<a href="#">' + qsTr("show...") + '</a>)'
                         textFormat: Text.StyledText
-                        onLinkActivated: app.stack.push(Qt.resolvedUrl('AddressHistory.qml'), { address: root.address })
+                        onLinkActivated: app.stack.push(Qt.resolvedUrl('AddressHistory.qml'), {
+                            address: root.address,
+                            backingModel: addressdetails.historyModel
+                        })
                     }
                 }
 
diff --git a/electrum/gui/qml/components/AddressHistory.qml b/electrum/gui/qml/components/AddressHistory.qml
index 7f166722e..cd13b6191 100644
--- a/electrum/gui/qml/components/AddressHistory.qml
+++ b/electrum/gui/qml/components/AddressHistory.qml
@@ -14,6 +14,7 @@ Pane {
     padding: 0
 
     required property string address
+    required property QtObject backingModel
 
     ColumnLayout {
         anchors.fill: parent
@@ -51,6 +52,7 @@ Pane {
             History {
                 anchors.fill: parent
                 forAddress: root.address
+                backingModel: root.backingModel
             }
         }
     }
diff --git a/electrum/gui/qml/components/History.qml b/electrum/gui/qml/components/History.qml
index c0e16514f..2336ace1b 100644
--- a/electrum/gui/qml/components/History.qml
+++ b/electrum/gui/qml/components/History.qml
@@ -19,9 +19,7 @@ Pane {
     }
 
     property string forAddress
-    property QtObject backingModel: forAddress
-        ? Daemon.currentWallet.historyModelForAddress(forAddress)
-        : Daemon.currentWallet.historyModel
+    property QtObject backingModel: Daemon.currentWallet.historyModel
 
     ElListView {
         id: listview
diff --git a/electrum/gui/qml/qewallet.py b/electrum/gui/qml/qewallet.py
index 97682d792..eeabf5261 100644
--- a/electrum/gui/qml/qewallet.py
+++ b/electrum/gui/qml/qewallet.py
@@ -304,11 +304,6 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
             self._historyModel = QETransactionListModel(self.wallet)
         return self._historyModel
 
-    @pyqtSlot(str, result=QETransactionListModel)
-    def historyModelForAddress(self, address):
-        self._hmfa = QETransactionListModel(self.wallet, onchain_domain=[address], include_lightning=False)
-        return self._hmfa
-
     addressCoinModelChanged = pyqtSignal()
     @pyqtProperty(QEAddressCoinListModel, notify=addressCoinModelChanged)
     def addressCoinModel(self):

return self._hmfa

addressCoinModelChanged = pyqtSignal()
@pyqtProperty(QEAddressCoinListModel, notify=addressCoinModelChanged)
def addressCoinModel(self):
Expand Down