mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-22 11:38:57 +00:00
feat(ProfileShowcase): Update ProfileShowcaseModels to support nim models
1. Adapt and unify model rolenames 2. Add support for dirty state 3. Add reset
This commit is contained in:
parent
5a3bca9a51
commit
fbcd90ef3b
@ -31,6 +31,15 @@ QObject {
|
|||||||
*/
|
*/
|
||||||
readonly property alias hiddenModel: hidden
|
readonly property alias hiddenModel: hidden
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns dirty state of the showcase model.
|
||||||
|
*/
|
||||||
|
readonly property alias dirty: writable.dirty
|
||||||
|
|
||||||
|
function revert() {
|
||||||
|
writable.revert()
|
||||||
|
}
|
||||||
|
|
||||||
function currentState() {
|
function currentState() {
|
||||||
return writable.currentState()
|
return writable.currentState()
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,212 @@
|
|||||||
|
import QtQml 2.15
|
||||||
|
|
||||||
|
import StatusQ 0.1
|
||||||
|
import StatusQ.Core.Utils 0.1
|
||||||
|
|
||||||
|
import SortFilterProxyModel 0.2
|
||||||
|
|
||||||
|
QObject {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
// input models
|
||||||
|
property alias communitiesSourceModel: communityRenamingSource.sourceModel
|
||||||
|
property alias communitiesShowcaseModel: communityRenamingShowcase.sourceModel
|
||||||
|
|
||||||
|
// adapted models
|
||||||
|
readonly property alias adaptedCommunitiesSourceModel: communityRenamingSource
|
||||||
|
readonly property alias adaptedCommunitiesShowcaseModel: communityRenamingShowcase
|
||||||
|
|
||||||
|
// input models
|
||||||
|
property alias accountsSourceModel: accountsRenamingSource.sourceModel
|
||||||
|
property alias accountsShowcaseModel: accountsRenamingShowcase.sourceModel
|
||||||
|
|
||||||
|
// adapted models
|
||||||
|
readonly property alias adaptedAccountsSourceModel: accountsRenamingSource
|
||||||
|
readonly property alias adaptedAccountsShowcaseModel: accountsRenamingShowcase
|
||||||
|
|
||||||
|
// input models
|
||||||
|
property alias collectiblesSourceModel: collectiblesRenamingSource.sourceModel
|
||||||
|
property alias collectiblesShowcaseModel: collectiblesRenamingShowcase.sourceModel
|
||||||
|
|
||||||
|
// adapted models
|
||||||
|
readonly property alias adaptedCollectiblesSourceModel: collectiblesRenamingSource
|
||||||
|
readonly property alias adaptedCollectiblesShowcaseModel: collectiblesRenamingShowcase
|
||||||
|
|
||||||
|
|
||||||
|
RolesRenamingModel {
|
||||||
|
id: communityRenamingSource
|
||||||
|
mapping: [
|
||||||
|
RoleRename {
|
||||||
|
from: "id"
|
||||||
|
to: "key"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
RolesRenamingModel {
|
||||||
|
id: communityRenamingShowcase
|
||||||
|
mapping: [
|
||||||
|
RoleRename {
|
||||||
|
from: "id"
|
||||||
|
to: "key"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "order"
|
||||||
|
to: "position"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "showcaseVisibility"
|
||||||
|
to: "visibility"
|
||||||
|
},
|
||||||
|
// Removing model duplicates
|
||||||
|
// TODO: remove this when the lightweigth model is used
|
||||||
|
// https://github.com/status-im/status-desktop/issues/13688
|
||||||
|
RoleRename {
|
||||||
|
from: "name"
|
||||||
|
to: "_name"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "memberRole"
|
||||||
|
to: "_memberRole"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "image"
|
||||||
|
to: "_image"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "color"
|
||||||
|
to: "_color"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "description"
|
||||||
|
to: "_description"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "membersCount"
|
||||||
|
to: "_membersCount"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "loading"
|
||||||
|
to: "_loading"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
RolesRenamingModel {
|
||||||
|
id: accountsRenamingSource
|
||||||
|
mapping: [
|
||||||
|
RoleRename {
|
||||||
|
from: "address"
|
||||||
|
to: "key"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "position"
|
||||||
|
to: "positions"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RolesRenamingModel {
|
||||||
|
id: accountsRenamingShowcase
|
||||||
|
mapping: [
|
||||||
|
RoleRename {
|
||||||
|
from: "address"
|
||||||
|
to: "key"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "order"
|
||||||
|
to: "position"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "showcaseVisibility"
|
||||||
|
to: "visibility"
|
||||||
|
},
|
||||||
|
// Removing model duplicates
|
||||||
|
// TODO: remove this when the lightweigth model is used
|
||||||
|
// https://github.com/status-im/status-desktop/issues/13688
|
||||||
|
RoleRename {
|
||||||
|
from: "name"
|
||||||
|
to: "_name"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "emoji"
|
||||||
|
to: "_emoji"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "colorId"
|
||||||
|
to: "_colorId"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
RolesRenamingModel {
|
||||||
|
id: collectiblesRenamingSource
|
||||||
|
sourceModel: root.collectiblesSourceModel
|
||||||
|
mapping: [
|
||||||
|
RoleRename {
|
||||||
|
from: "uid"
|
||||||
|
to: "key"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
RolesRenamingModel {
|
||||||
|
id: collectiblesRenamingShowcase
|
||||||
|
sourceModel: root.collectiblesShowcaseModel
|
||||||
|
|
||||||
|
mapping: [
|
||||||
|
RoleRename {
|
||||||
|
from: "uid"
|
||||||
|
to: "key"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "order"
|
||||||
|
to: "position"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "showcaseVisibility"
|
||||||
|
to: "visibility"
|
||||||
|
},
|
||||||
|
// Removing model duplicates
|
||||||
|
// TODO: remove this when the lightweigth model is used
|
||||||
|
// https://github.com/status-im/status-desktop/issues/13688
|
||||||
|
RoleRename {
|
||||||
|
from: "chainId"
|
||||||
|
to: "_chainId"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "contractAddress"
|
||||||
|
to: "_contractAddress"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "tokenId"
|
||||||
|
to: "_tokenId"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "name"
|
||||||
|
to: "_name"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "imageUrl"
|
||||||
|
to: "_imageUrl"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "backgroundColor"
|
||||||
|
to: "_backgroundColor"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "collectionName"
|
||||||
|
to: "_collectionName"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "isLoading"
|
||||||
|
to: "_isLoading"
|
||||||
|
},
|
||||||
|
RoleRename {
|
||||||
|
from: "communityId"
|
||||||
|
to: "_communityId"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -10,11 +10,20 @@ import utils 1.0
|
|||||||
QObject {
|
QObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
// GENERAL
|
||||||
|
readonly property bool dirty: communities.dirty || accounts.dirty || collectibles.dirty
|
||||||
|
|
||||||
|
function revert() {
|
||||||
|
communities.revert()
|
||||||
|
accounts.revert()
|
||||||
|
collectibles.revert()
|
||||||
|
}
|
||||||
|
|
||||||
// COMMUNITIES
|
// COMMUNITIES
|
||||||
|
|
||||||
// Input models
|
// Input models
|
||||||
property alias communitiesSourceModel: communities.sourceModel
|
property alias communitiesSourceModel: modelAdapter.communitiesSourceModel
|
||||||
property alias communitiesShowcaseModel: communities.showcaseModel
|
property alias communitiesShowcaseModel: modelAdapter.communitiesShowcaseModel
|
||||||
|
|
||||||
// Output models
|
// Output models
|
||||||
readonly property alias communitiesVisibleModel: communities.visibleModel
|
readonly property alias communitiesVisibleModel: communities.visibleModel
|
||||||
@ -36,8 +45,8 @@ QObject {
|
|||||||
// ACCOUNTS
|
// ACCOUNTS
|
||||||
|
|
||||||
// Input models
|
// Input models
|
||||||
property alias accountsSourceModel: accounts.sourceModel
|
property alias accountsSourceModel: modelAdapter.accountsSourceModel
|
||||||
property alias accountsShowcaseModel: accounts.showcaseModel
|
property alias accountsShowcaseModel: modelAdapter.accountsShowcaseModel
|
||||||
|
|
||||||
// Output models
|
// Output models
|
||||||
readonly property alias accountsVisibleModel: accounts.visibleModel
|
readonly property alias accountsVisibleModel: accounts.visibleModel
|
||||||
@ -66,8 +75,8 @@ QObject {
|
|||||||
// COLLECTIBLES
|
// COLLECTIBLES
|
||||||
|
|
||||||
// Input models
|
// Input models
|
||||||
property alias collectiblesSourceModel: collectiblesFilter.sourceModel
|
property alias collectiblesSourceModel: modelAdapter.collectiblesSourceModel
|
||||||
property alias collectiblesShowcaseModel: collectibles.showcaseModel
|
property alias collectiblesShowcaseModel: modelAdapter.collectiblesShowcaseModel
|
||||||
|
|
||||||
// Output models
|
// Output models
|
||||||
readonly property alias collectiblesVisibleModel: collectibles.visibleModel
|
readonly property alias collectiblesVisibleModel: collectibles.visibleModel
|
||||||
@ -86,25 +95,36 @@ QObject {
|
|||||||
collectibles.changePosition(key, to)
|
collectibles.changePosition(key, to)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProfileShowcaseModelAdapter {
|
||||||
|
id: modelAdapter
|
||||||
|
}
|
||||||
|
|
||||||
ProfileShowcaseDirtyState {
|
ProfileShowcaseDirtyState {
|
||||||
id: communities
|
id: communities
|
||||||
|
|
||||||
|
sourceModel: modelAdapter.adaptedCommunitiesSourceModel
|
||||||
|
showcaseModel: modelAdapter.adaptedCommunitiesShowcaseModel
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileShowcaseDirtyState {
|
ProfileShowcaseDirtyState {
|
||||||
id: accounts
|
id: accounts
|
||||||
|
|
||||||
|
sourceModel: modelAdapter.adaptedAccountsSourceModel
|
||||||
|
showcaseModel: modelAdapter.adaptedAccountsShowcaseModel
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileShowcaseDirtyState {
|
ProfileShowcaseDirtyState {
|
||||||
id: collectibles
|
id: collectibles
|
||||||
|
|
||||||
sourceModel: collectiblesFilter
|
sourceModel: collectiblesFilter
|
||||||
|
showcaseModel: modelAdapter.adaptedCollectiblesShowcaseModel
|
||||||
}
|
}
|
||||||
|
|
||||||
SortFilterProxyModel {
|
SortFilterProxyModel {
|
||||||
id: collectiblesFilter
|
id: collectiblesFilter
|
||||||
|
|
||||||
delayed: true
|
delayed: true
|
||||||
|
sourceModel: modelAdapter.adaptedCollectiblesSourceModel
|
||||||
proxyRoles: FastExpressionRole {
|
proxyRoles: FastExpressionRole {
|
||||||
name: "maxVisibility"
|
name: "maxVisibility"
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
ProfileShowcaseDirtyState 1.0 ProfileShowcaseDirtyState.qml
|
ProfileShowcaseDirtyState 1.0 ProfileShowcaseDirtyState.qml
|
||||||
|
ProfileShowcaseModelAdapter 1.0 ProfileShowcaseModelAdapter.qml
|
||||||
ProfileShowcaseModels 1.0 ProfileShowcaseModels.qml
|
ProfileShowcaseModels 1.0 ProfileShowcaseModels.qml
|
||||||
VisibilityAndPositionDirtyStateModel 1.0 VisibilityAndPositionDirtyStateModel.qml
|
VisibilityAndPositionDirtyStateModel 1.0 VisibilityAndPositionDirtyStateModel.qml
|
||||||
|
Loading…
x
Reference in New Issue
Block a user