chore(communities/portal): extend curated communites model

This commit is contained in:
Patryk Osmaczko 2022-10-18 10:50:58 +02:00 committed by osmaczko
parent 76f79cda4d
commit a543f46de5
5 changed files with 42 additions and 16 deletions

View File

@ -7,6 +7,7 @@ type
description: string description: string
available: bool available: bool
icon: string icon: string
banner: string
color: string color: string
tags: string tags: string
members: int members: int
@ -17,6 +18,7 @@ proc initCuratedCommunityItem*(
description: string, description: string,
available: bool, available: bool,
icon: string, icon: string,
banner: string,
color: string, color: string,
tags: string, tags: string,
members: int members: int
@ -26,6 +28,7 @@ proc initCuratedCommunityItem*(
result.description = description result.description = description
result.available = available result.available = available
result.icon = icon result.icon = icon
result.banner = banner
result.color = color result.color = color
result.tags = tags result.tags = tags
result.members = members result.members = members
@ -56,6 +59,9 @@ proc isAvailable*(self: CuratedCommunityItem): bool =
proc getIcon*(self: CuratedCommunityItem): string = proc getIcon*(self: CuratedCommunityItem): string =
return self.icon return self.icon
proc getBanner*(self: CuratedCommunityItem): string =
return self.banner
proc getMembers*(self: CuratedCommunityItem): int = proc getMembers*(self: CuratedCommunityItem): int =
return self.members return self.members

View File

@ -8,10 +8,12 @@ type
Name Name
Description Description
Icon Icon
Banner
Featured Featured
Members Members
Popularity Popularity
Color Color
Tags
QtObject: QtObject:
type CuratedCommunityModel* = ref object of QAbstractListModel type CuratedCommunityModel* = ref object of QAbstractListModel
@ -52,10 +54,12 @@ QtObject:
ModelRole.Available.int:"available", ModelRole.Available.int:"available",
ModelRole.Description.int:"description", ModelRole.Description.int:"description",
ModelRole.Icon.int:"icon", ModelRole.Icon.int:"icon",
ModelRole.Banner.int:"banner",
ModelRole.Featured.int:"featured", ModelRole.Featured.int:"featured",
ModelRole.Members.int:"members", ModelRole.Members.int:"members",
ModelRole.Color.int:"color", ModelRole.Color.int:"color",
ModelRole.Popularity.int:"popularity" ModelRole.Popularity.int:"popularity",
ModelRole.Tags.int:"tags"
}.toTable }.toTable
method data(self: CuratedCommunityModel, index: QModelIndex, role: int): QVariant = method data(self: CuratedCommunityModel, index: QModelIndex, role: int): QVariant =
@ -76,6 +80,8 @@ QtObject:
result = newQVariant(item.isAvailable()) result = newQVariant(item.isAvailable())
of ModelRole.Icon: of ModelRole.Icon:
result = newQVariant(item.getIcon()) result = newQVariant(item.getIcon())
of ModelRole.Banner:
result = newQVariant(item.getBanner())
of ModelRole.Members: of ModelRole.Members:
result = newQVariant(item.getMembers()) result = newQVariant(item.getMembers())
of ModelRole.Color: of ModelRole.Color:
@ -83,6 +89,8 @@ QtObject:
of ModelRole.Popularity: of ModelRole.Popularity:
# TODO: replace this with a real value # TODO: replace this with a real value
result = newQVariant(index.row) result = newQVariant(index.row)
of ModelRole.Tags:
result = newQVariant(item.getTags())
of ModelRole.Featured: of ModelRole.Featured:
# TODO: replace this with a real value # TODO: replace this with a real value
var featured = false var featured = false
@ -121,10 +129,12 @@ QtObject:
ModelRole.Available.int, ModelRole.Available.int,
ModelRole.Description.int, ModelRole.Description.int,
ModelRole.Icon.int, ModelRole.Icon.int,
ModelRole.Banner.int,
ModelRole.Featured.int, ModelRole.Featured.int,
ModelRole.Members.int, ModelRole.Members.int,
ModelRole.Color.int, ModelRole.Color.int,
ModelRole.Popularity.int]) ModelRole.Popularity.int,
ModelRole.Tags.int])
else: else:
let parentModelIndex = newQModelIndex() let parentModelIndex = newQModelIndex()
defer: parentModelIndex.delete defer: parentModelIndex.delete
@ -132,4 +142,3 @@ QtObject:
self.items.add(item) self.items.add(item)
self.endInsertRows() self.endInsertRows()
self.countChanged() self.countChanged()

View File

@ -143,6 +143,7 @@ method getCuratedCommunityItem(self: Module, c: CuratedCommunity): CuratedCommun
c.community.description, c.community.description,
c.available, c.available,
c.community.images.thumbnail, c.community.images.thumbnail,
c.community.images.banner,
c.community.color, c.community.color,
c.community.tags, c.community.tags,
len(c.community.members)) len(c.community.members))

File diff suppressed because one or more lines are too long

View File

@ -63,10 +63,11 @@ StatusScrollView {
} }
locale: root.locale locale: root.locale
communityId: model.communityId communityId: model.id
loaded: model.available loaded: model.available
logo: model.icon logo: model.icon
banner: model.banner banner: model.banner
communityColor: model.color
name: model.name name: model.name
description: model.description description: model.description
members: model.members members: model.members