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