feat(@wallet): all accounts list are ordered by position

fixes #11263
This commit is contained in:
Anthony Laibe 2023-06-28 11:16:30 +02:00 committed by Anthony Laibe
parent 67929c8e03
commit 29d78a99be
4 changed files with 27 additions and 5 deletions

View File

@ -7,6 +7,7 @@ export wallet_account_item
QtObject:
type AccountItem* = ref object of WalletAccountItem
position: int
assets: token_model.Model
currencyBalance: CurrencyAmount
@ -17,8 +18,9 @@ QtObject:
emoji: string,
walletType: string,
assets: token_model.Model,
currencyBalance: CurrencyAmount
) =
currencyBalance: CurrencyAmount,
position: int,
) =
self.QObject.setup
self.WalletAccountItem.setup(name,
address,
@ -29,6 +31,7 @@ QtObject:
keyUid = "",
keycardAccount = false)
self.assets = assets
self.position = position
self.currencyBalance = currencyBalance
proc delete*(self: AccountItem) =
@ -42,9 +45,10 @@ QtObject:
walletType: string = "",
assets: token_model.Model = nil,
currencyBalance: CurrencyAmount = nil,
position: int = 0,
): AccountItem =
new(result, delete)
result.setup(name, address, colorId, emoji, walletType, assets, currencyBalance)
result.setup(name, address, colorId, emoji, walletType, assets, currencyBalance, position)
proc `$`*(self: AccountItem): string =
result = "WalletSection-Send-Item("
@ -70,3 +74,6 @@ QtObject:
QtProperty[QVariant] currencyBalance:
read = getCurrencyBalanceAsQVariant
notify = currencyBalanceChanged
proc position*(self: AccountItem): int =
return self.position

View File

@ -12,6 +12,7 @@ type
Emoji,
Assets,
CurrencyBalance,
Position,
QtObject:
type
@ -54,6 +55,7 @@ QtObject:
ModelRole.Emoji.int: "emoji",
ModelRole.Assets.int: "assets",
ModelRole.CurrencyBalance.int: "currencyBalance",
ModelRole.Position.int: "position",
}.toTable
proc setItems*(self: AccountsModel, items: seq[AccountItem]) =
@ -83,6 +85,8 @@ QtObject:
result = newQVariant(item.walletType())
of ModelRole.Emoji:
result = newQVariant(item.emoji())
of ModelRole.Position:
result = newQVariant(item.position())
of ModelRole.Assets:
result = newQVariant(item.getAssetsAsQVariant())
of ModelRole.CurrencyBalance:

View File

@ -2,6 +2,7 @@ import QtQuick 2.13
import QtGraphicalEffects 1.13
import QtQuick.Layouts 1.13
import QtQuick.Controls 2.14
import SortFilterProxyModel 0.2
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
@ -42,7 +43,12 @@ StatusModal {
hasFloatingButtons: true
advancedHeaderComponent: AccountsModalHeader {
model: RootStore.receiveAccounts
model: SortFilterProxyModel {
sourceModel: RootStore.receiveAccounts
sorters: RoleSorter { roleName: "position"; sortOrder: Qt.AscendingOrder }
}
selectedAccount: RootStore.selectedReceiveAccount
onSelectedIndexChanged: RootStore.switchReceiveAccount(selectedIndex)
}

View File

@ -3,6 +3,7 @@ import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import QtQuick.Dialogs 1.3
import QtGraphicalEffects 1.0
import SortFilterProxyModel 0.2
import utils 1.0
import shared.stores 1.0
@ -150,7 +151,11 @@ StatusDialog {
header: AccountsModalHeader {
anchors.top: parent.top
anchors.topMargin: -height - 18
model: popup.store.senderAccounts
model: SortFilterProxyModel {
sourceModel: popup.store.senderAccounts
sorters: RoleSorter { roleName: "position"; sortOrder: Qt.AscendingOrder }
}
selectedAccount: !!popup.selectedAccount ? popup.selectedAccount: {}
chainShortNames: store.getAllNetworksSupportedPrefix()
onSelectedIndexChanged: store.switchSenderAccount(selectedIndex)