refactor(@desktop/wallet): remove unused 'collectible' module
This commit is contained in:
parent
ecd799c209
commit
4907f52b46
|
@ -1,21 +0,0 @@
|
||||||
import io_interface
|
|
||||||
import ../../../../../../app_service/service/collectible/service as collectible_service
|
|
||||||
|
|
||||||
type
|
|
||||||
Controller* = ref object of RootObj
|
|
||||||
delegate: io_interface.AccessInterface
|
|
||||||
collectibleService: collectible_service.Service
|
|
||||||
|
|
||||||
proc newController*(
|
|
||||||
delegate: io_interface.AccessInterface,
|
|
||||||
collectibleService: collectible_service.Service
|
|
||||||
): Controller =
|
|
||||||
result = Controller()
|
|
||||||
result.delegate = delegate
|
|
||||||
result.collectibleService = collectibleService
|
|
||||||
|
|
||||||
proc delete*(self: Controller) =
|
|
||||||
discard
|
|
||||||
|
|
||||||
proc init*(self: Controller) =
|
|
||||||
discard
|
|
|
@ -1,18 +0,0 @@
|
||||||
type
|
|
||||||
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
|
||||||
## Abstract class for any input/interaction with this module.
|
|
||||||
|
|
||||||
method delete*(self: AccessInterface) {.base.} =
|
|
||||||
raise newException(ValueError, "No implementation available")
|
|
||||||
|
|
||||||
method load*(self: AccessInterface) {.base.} =
|
|
||||||
raise newException(ValueError, "No implementation available")
|
|
||||||
|
|
||||||
method isLoaded*(self: AccessInterface): bool {.base.} =
|
|
||||||
raise newException(ValueError, "No implementation available")
|
|
||||||
|
|
||||||
# View Delegate Interface
|
|
||||||
# Delegate for the view must be declared here due to use of QtObject and multi
|
|
||||||
# inheritance, which is not well supported in Nim.
|
|
||||||
method viewDidLoad*(self: AccessInterface) {.base.} =
|
|
||||||
raise newException(ValueError, "No implementation available")
|
|
|
@ -1,16 +0,0 @@
|
||||||
import strformat
|
|
||||||
|
|
||||||
type
|
|
||||||
Item* = object
|
|
||||||
name: string
|
|
||||||
|
|
||||||
proc initItem*(name: string): Item =
|
|
||||||
result.name = name
|
|
||||||
|
|
||||||
proc `$`*(self: Item): string =
|
|
||||||
result = fmt"""Collectible(
|
|
||||||
name: {self.name}
|
|
||||||
]"""
|
|
||||||
|
|
||||||
proc getName*(self: Item): string =
|
|
||||||
return self.name
|
|
|
@ -1,64 +0,0 @@
|
||||||
import NimQml, Tables, strutils, strformat
|
|
||||||
|
|
||||||
import ./item
|
|
||||||
|
|
||||||
type
|
|
||||||
ModelRole {.pure.} = enum
|
|
||||||
Name = UserRole + 1,
|
|
||||||
|
|
||||||
QtObject:
|
|
||||||
type
|
|
||||||
Model* = ref object of QAbstractListModel
|
|
||||||
items: seq[Item]
|
|
||||||
|
|
||||||
proc delete(self: Model) =
|
|
||||||
self.items = @[]
|
|
||||||
self.QAbstractListModel.delete
|
|
||||||
|
|
||||||
proc setup(self: Model) =
|
|
||||||
self.QAbstractListModel.setup
|
|
||||||
|
|
||||||
proc newModel*(): Model =
|
|
||||||
new(result, delete)
|
|
||||||
result.setup
|
|
||||||
|
|
||||||
proc `$`*(self: Model): string =
|
|
||||||
for i in 0 ..< self.items.len:
|
|
||||||
result &= fmt"""[{i}]:({$self.items[i]})"""
|
|
||||||
|
|
||||||
proc countChanged(self: Model) {.signal.}
|
|
||||||
|
|
||||||
proc getCount(self: Model): int {.slot.} =
|
|
||||||
self.items.len
|
|
||||||
|
|
||||||
QtProperty[int] count:
|
|
||||||
read = getCount
|
|
||||||
notify = countChanged
|
|
||||||
|
|
||||||
method rowCount(self: Model, index: QModelIndex = nil): int =
|
|
||||||
return self.items.len
|
|
||||||
|
|
||||||
method roleNames(self: Model): Table[int, string] =
|
|
||||||
{
|
|
||||||
ModelRole.Name.int:"name",
|
|
||||||
}.toTable
|
|
||||||
|
|
||||||
method data(self: Model, index: QModelIndex, role: int): QVariant =
|
|
||||||
if (not index.isValid):
|
|
||||||
return
|
|
||||||
|
|
||||||
if (index.row < 0 or index.row >= self.items.len):
|
|
||||||
return
|
|
||||||
|
|
||||||
let item = self.items[index.row]
|
|
||||||
let enumRole = role.ModelRole
|
|
||||||
|
|
||||||
case enumRole:
|
|
||||||
of ModelRole.Name:
|
|
||||||
result = newQVariant(item.getName())
|
|
||||||
|
|
||||||
proc setItems*(self: Model, items: seq[Item]) =
|
|
||||||
self.beginResetModel()
|
|
||||||
self.items = items
|
|
||||||
self.endResetModel()
|
|
||||||
self.countChanged()
|
|
|
@ -1,37 +0,0 @@
|
||||||
import sequtils, sugar
|
|
||||||
|
|
||||||
import ./io_interface, ./view, ./controller, ./item
|
|
||||||
import ../io_interface as delegate_interface
|
|
||||||
import ../../../../../../app_service/service/collectible/service as collectible_service
|
|
||||||
|
|
||||||
export io_interface
|
|
||||||
|
|
||||||
type
|
|
||||||
Module* = ref object of io_interface.AccessInterface
|
|
||||||
delegate: delegate_interface.AccessInterface
|
|
||||||
view: View
|
|
||||||
controller: Controller
|
|
||||||
moduleLoaded: bool
|
|
||||||
|
|
||||||
proc newModule*(delegate: delegate_interface.AccessInterface, collectibleService: collectible_service.Service):
|
|
||||||
Module =
|
|
||||||
result = Module()
|
|
||||||
result.delegate = delegate
|
|
||||||
result.view = newView(result)
|
|
||||||
result.controller = controller.newController(result, collectibleService)
|
|
||||||
result.moduleLoaded = false
|
|
||||||
|
|
||||||
method delete*(self: Module) =
|
|
||||||
self.view.delete
|
|
||||||
self.controller.delete
|
|
||||||
|
|
||||||
method load*(self: Module) =
|
|
||||||
self.controller.init()
|
|
||||||
self.view.load()
|
|
||||||
|
|
||||||
method isLoaded*(self: Module): bool =
|
|
||||||
return self.moduleLoaded
|
|
||||||
|
|
||||||
method viewDidLoad*(self: Module) =
|
|
||||||
self.moduleLoaded = true
|
|
||||||
self.delegate.collectibleModuleDidLoad()
|
|
|
@ -1,39 +0,0 @@
|
||||||
import NimQml
|
|
||||||
|
|
||||||
import ./model
|
|
||||||
import ./item
|
|
||||||
import ./io_interface
|
|
||||||
|
|
||||||
QtObject:
|
|
||||||
type
|
|
||||||
View* = ref object of QObject
|
|
||||||
delegate: io_interface.AccessInterface
|
|
||||||
model: Model
|
|
||||||
modelVariant: QVariant
|
|
||||||
|
|
||||||
proc delete*(self: View) =
|
|
||||||
self.model.delete
|
|
||||||
self.modelVariant.delete
|
|
||||||
self.QObject.delete
|
|
||||||
|
|
||||||
proc newView*(delegate: io_interface.AccessInterface): View =
|
|
||||||
new(result, delete)
|
|
||||||
result.QObject.setup
|
|
||||||
result.delegate = delegate
|
|
||||||
result.model = newModel()
|
|
||||||
result.modelVariant = newQVariant(result.model)
|
|
||||||
|
|
||||||
proc load*(self: View) =
|
|
||||||
self.delegate.viewDidLoad()
|
|
||||||
|
|
||||||
proc modelChanged*(self: View) {.signal.}
|
|
||||||
|
|
||||||
proc getModel(self: View): QVariant {.slot.} =
|
|
||||||
return self.modelVariant
|
|
||||||
|
|
||||||
QtProperty[QVariant] model:
|
|
||||||
read = getModel
|
|
||||||
notify = modelChanged
|
|
||||||
|
|
||||||
proc setItems*(self: View, items: seq[Item]) =
|
|
||||||
self.model.setItems(items)
|
|
|
@ -15,9 +15,6 @@ method switchAccount*(self: AccessInterface, accountIndex: int) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
# Methods called by submodules of this module
|
# Methods called by submodules of this module
|
||||||
method collectibleModuleDidLoad*(self: AccessInterface) {.base.} =
|
|
||||||
raise newException(ValueError, "No implementation available")
|
|
||||||
|
|
||||||
method collectiblesModuleDidLoad*(self: AccessInterface) {.base.} =
|
method collectiblesModuleDidLoad*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import ../../../../core/eventemitter
|
||||||
import ../../../../../app_service/service/collectible/service as collectible_service
|
import ../../../../../app_service/service/collectible/service as collectible_service
|
||||||
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
|
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
|
||||||
|
|
||||||
import ./collectible/module as collectible_module
|
|
||||||
import ./collections/module as collections_module
|
import ./collections/module as collections_module
|
||||||
import ./collectibles/module as collectibles_module
|
import ./collectibles/module as collectibles_module
|
||||||
import ./current_collectible/module as current_collectible_module
|
import ./current_collectible/module as current_collectible_module
|
||||||
|
@ -19,7 +18,6 @@ type
|
||||||
|
|
||||||
collectiblesModule: collectibles_module.AccessInterface
|
collectiblesModule: collectibles_module.AccessInterface
|
||||||
collectionsModule: collections_module.AccessInterface
|
collectionsModule: collections_module.AccessInterface
|
||||||
collectibleModule: collectible_module.AccessInterface
|
|
||||||
currentCollectibleModule: current_collectible_module.AccessInterface
|
currentCollectibleModule: current_collectible_module.AccessInterface
|
||||||
|
|
||||||
proc newModule*(
|
proc newModule*(
|
||||||
|
@ -35,20 +33,17 @@ proc newModule*(
|
||||||
|
|
||||||
result.collectiblesModule = collectibles_module.newModule(result, collectibleService)
|
result.collectiblesModule = collectibles_module.newModule(result, collectibleService)
|
||||||
result.collectionsModule = collectionsModule.newModule(result, events, collectibleService)
|
result.collectionsModule = collectionsModule.newModule(result, events, collectibleService)
|
||||||
result.collectibleModule = collectibleModule.newModule(result, collectibleService)
|
|
||||||
result.currentCollectibleModule = currentCollectibleModule.newModule(result, result.collectionsModule, result.collectiblesModule)
|
result.currentCollectibleModule = currentCollectibleModule.newModule(result, result.collectionsModule, result.collectiblesModule)
|
||||||
|
|
||||||
method delete*(self: Module) =
|
method delete*(self: Module) =
|
||||||
self.collectiblesModule.delete
|
self.collectiblesModule.delete
|
||||||
self.collectionsModule.delete
|
self.collectionsModule.delete
|
||||||
self.collectibleModule.delete
|
|
||||||
self.currentCollectibleModule.delete
|
self.currentCollectibleModule.delete
|
||||||
|
|
||||||
method load*(self: Module) =
|
method load*(self: Module) =
|
||||||
self.controller.init
|
self.controller.init
|
||||||
self.collectiblesModule.load
|
self.collectiblesModule.load
|
||||||
self.collectionsModule.load
|
self.collectionsModule.load
|
||||||
self.collectibleModule.load
|
|
||||||
self.currentCollectibleModule.load
|
self.currentCollectibleModule.load
|
||||||
|
|
||||||
method isLoaded*(self: Module): bool =
|
method isLoaded*(self: Module): bool =
|
||||||
|
@ -61,18 +56,12 @@ proc checkIfModuleDidLoad(self: Module) =
|
||||||
if(not self.collectionsModule.isLoaded()):
|
if(not self.collectionsModule.isLoaded()):
|
||||||
return
|
return
|
||||||
|
|
||||||
if(not self.collectibleModule.isLoaded()):
|
|
||||||
return
|
|
||||||
|
|
||||||
if(not self.currentCollectibleModule.isLoaded()):
|
if(not self.currentCollectibleModule.isLoaded()):
|
||||||
return
|
return
|
||||||
|
|
||||||
self.moduleLoaded = true
|
self.moduleLoaded = true
|
||||||
self.delegate.collectiblesModuleDidLoad()
|
self.delegate.collectiblesModuleDidLoad()
|
||||||
|
|
||||||
method collectibleModuleDidLoad*(self: Module) =
|
|
||||||
self.checkIfModuleDidLoad()
|
|
||||||
|
|
||||||
method collectiblesModuleDidLoad*(self: Module) =
|
method collectiblesModuleDidLoad*(self: Module) =
|
||||||
self.checkIfModuleDidLoad()
|
self.checkIfModuleDidLoad()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue