1
0

qml: clean up Channels/ChannelBackups, implement proper count property on QEFilterProxyModel

This commit is contained in:
Sander van Grieken
2023-01-30 16:26:44 +01:00
parent c868ddedb5
commit bd10fbeaf0
3 changed files with 8 additions and 34 deletions

View File

@@ -2,7 +2,6 @@ import QtQuick 2.6
import QtQuick.Layouts 1.0
import QtQuick.Controls 2.3
import QtQuick.Controls.Material 2.0
import QtQml.Models 2.2
import org.electrum 1.0
@@ -66,7 +65,7 @@ Pane {
ScrollIndicator.vertical: ScrollIndicator { }
Label {
visible: Daemon.currentWallet.channelModel.count == 0
visible: listview.model.count == 0
anchors.centerIn: parent
width: listview.width * 4/5
font.pixelSize: constants.fontSizeXXLarge
@@ -99,20 +98,6 @@ Pane {
}
}
Component {
id: swapDialog
SwapDialog {
onClosed: destroy()
}
}
Component {
id: openChannelDialog
OpenChannelDialog {
onClosed: destroy()
}
}
Component {
id: importChannelBackupDialog
ImportChannelBackupDialog {

View File

@@ -89,7 +89,7 @@ Pane {
ScrollIndicator.vertical: ScrollIndicator { }
Label {
visible: Daemon.currentWallet.channelModel.count == 0
visible: listview.model.count == 0
anchors.centerIn: parent
width: listview.width * 4/5
font.pixelSize: constants.fontSizeXXLarge
@@ -135,14 +135,6 @@ Pane {
}
Connections {
target: Daemon.currentWallet
function onImportChannelBackupFailed(message) {
var dialog = app.messageDialog.createObject(root, { text: message })
dialog.open()
}
}
Component {
id: swapDialog
SwapDialog {
@@ -157,11 +149,4 @@ Pane {
}
}
Component {
id: importChannelBackupDialog
ImportChannelBackupDialog {
onClosed: destroy()
}
}
}

View File

@@ -1,4 +1,4 @@
from PyQt5.QtCore import QSortFilterProxyModel
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QSortFilterProxyModel, QModelIndex
from electrum.logging import get_logger
@@ -11,6 +11,11 @@ class QEFilterProxyModel(QSortFilterProxyModel):
super().__init__(parent)
self.setSourceModel(parent_model)
countChanged = pyqtSignal()
@pyqtProperty(int, notify=countChanged)
def count(self):
return self.rowCount(QModelIndex())
def isCustomFilter(self):
return self._filter_value is not None
@@ -23,5 +28,4 @@ class QEFilterProxyModel(QSortFilterProxyModel):
parent_model = self.sourceModel()
d = parent_model.data(parent_model.index(s_row, 0, s_parent), self.filterRole())
# self._logger.debug(f'DATA in FilterProxy is {repr(d)}')
return True if self._filter_value is None else d == self._filter_value