chore(communities/portal): extend curated communites model
This commit is contained in:
parent
76f79cda4d
commit
a543f46de5
|
@ -7,6 +7,7 @@ type
|
|||
description: string
|
||||
available: bool
|
||||
icon: string
|
||||
banner: string
|
||||
color: string
|
||||
tags: string
|
||||
members: int
|
||||
|
@ -17,6 +18,7 @@ proc initCuratedCommunityItem*(
|
|||
description: string,
|
||||
available: bool,
|
||||
icon: string,
|
||||
banner: string,
|
||||
color: string,
|
||||
tags: string,
|
||||
members: int
|
||||
|
@ -26,6 +28,7 @@ proc initCuratedCommunityItem*(
|
|||
result.description = description
|
||||
result.available = available
|
||||
result.icon = icon
|
||||
result.banner = banner
|
||||
result.color = color
|
||||
result.tags = tags
|
||||
result.members = members
|
||||
|
@ -56,6 +59,9 @@ proc isAvailable*(self: CuratedCommunityItem): bool =
|
|||
proc getIcon*(self: CuratedCommunityItem): string =
|
||||
return self.icon
|
||||
|
||||
proc getBanner*(self: CuratedCommunityItem): string =
|
||||
return self.banner
|
||||
|
||||
proc getMembers*(self: CuratedCommunityItem): int =
|
||||
return self.members
|
||||
|
||||
|
|
|
@ -8,10 +8,12 @@ type
|
|||
Name
|
||||
Description
|
||||
Icon
|
||||
Banner
|
||||
Featured
|
||||
Members
|
||||
Popularity
|
||||
Color
|
||||
Tags
|
||||
|
||||
QtObject:
|
||||
type CuratedCommunityModel* = ref object of QAbstractListModel
|
||||
|
@ -52,10 +54,12 @@ QtObject:
|
|||
ModelRole.Available.int:"available",
|
||||
ModelRole.Description.int:"description",
|
||||
ModelRole.Icon.int:"icon",
|
||||
ModelRole.Banner.int:"banner",
|
||||
ModelRole.Featured.int:"featured",
|
||||
ModelRole.Members.int:"members",
|
||||
ModelRole.Color.int:"color",
|
||||
ModelRole.Popularity.int:"popularity"
|
||||
ModelRole.Popularity.int:"popularity",
|
||||
ModelRole.Tags.int:"tags"
|
||||
}.toTable
|
||||
|
||||
method data(self: CuratedCommunityModel, index: QModelIndex, role: int): QVariant =
|
||||
|
@ -76,6 +80,8 @@ QtObject:
|
|||
result = newQVariant(item.isAvailable())
|
||||
of ModelRole.Icon:
|
||||
result = newQVariant(item.getIcon())
|
||||
of ModelRole.Banner:
|
||||
result = newQVariant(item.getBanner())
|
||||
of ModelRole.Members:
|
||||
result = newQVariant(item.getMembers())
|
||||
of ModelRole.Color:
|
||||
|
@ -83,6 +89,8 @@ QtObject:
|
|||
of ModelRole.Popularity:
|
||||
# TODO: replace this with a real value
|
||||
result = newQVariant(index.row)
|
||||
of ModelRole.Tags:
|
||||
result = newQVariant(item.getTags())
|
||||
of ModelRole.Featured:
|
||||
# TODO: replace this with a real value
|
||||
var featured = false
|
||||
|
@ -121,10 +129,12 @@ QtObject:
|
|||
ModelRole.Available.int,
|
||||
ModelRole.Description.int,
|
||||
ModelRole.Icon.int,
|
||||
ModelRole.Banner.int,
|
||||
ModelRole.Featured.int,
|
||||
ModelRole.Members.int,
|
||||
ModelRole.Color.int,
|
||||
ModelRole.Popularity.int])
|
||||
ModelRole.Popularity.int,
|
||||
ModelRole.Tags.int])
|
||||
else:
|
||||
let parentModelIndex = newQModelIndex()
|
||||
defer: parentModelIndex.delete
|
||||
|
@ -132,4 +142,3 @@ QtObject:
|
|||
self.items.add(item)
|
||||
self.endInsertRows()
|
||||
self.countChanged()
|
||||
|
|
@ -143,6 +143,7 @@ method getCuratedCommunityItem(self: Module, c: CuratedCommunity): CuratedCommun
|
|||
c.community.description,
|
||||
c.available,
|
||||
c.community.images.thumbnail,
|
||||
c.community.images.banner,
|
||||
c.community.color,
|
||||
c.community.tags,
|
||||
len(c.community.members))
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -63,10 +63,11 @@ StatusScrollView {
|
|||
}
|
||||
|
||||
locale: root.locale
|
||||
communityId: model.communityId
|
||||
communityId: model.id
|
||||
loaded: model.available
|
||||
logo: model.icon
|
||||
banner: model.banner
|
||||
communityColor: model.color
|
||||
name: model.name
|
||||
description: model.description
|
||||
members: model.members
|
||||
|
|
Loading…
Reference in New Issue