parent
e130953634
commit
d4c4fe1f41
|
@ -141,10 +141,18 @@ QtObject:
|
|||
of ModelRole.PendingRequestsToJoinModel:
|
||||
result = newQVariant(item.pendingRequestsToJoin)
|
||||
|
||||
proc isItemExist(self: SectionModel, id: string): bool =
|
||||
for it in self.items:
|
||||
if(it.id == id):
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
proc addItem*(self: SectionModel, item: SectionItem) =
|
||||
let parentModelIndex = newQModelIndex()
|
||||
defer: parentModelIndex.delete
|
||||
|
||||
if not self.isItemExist(item.id):
|
||||
self.beginInsertRows(parentModelIndex, self.items.len, self.items.len)
|
||||
self.items.add(item)
|
||||
self.endInsertRows()
|
||||
|
@ -155,6 +163,7 @@ QtObject:
|
|||
let parentModelIndex = newQModelIndex()
|
||||
defer: parentModelIndex.delete
|
||||
|
||||
if not self.isItemExist(item.id):
|
||||
self.beginInsertRows(parentModelIndex, index, index)
|
||||
self.items.insert(item, index)
|
||||
self.endInsertRows()
|
||||
|
|
Loading…
Reference in New Issue