Set invited and left rooms position in model
Invited rooms at the start, left rooms at the end, with the bonus effect of fixing the roomList height problem.
This commit is contained in:
parent
677117983a
commit
424405e3e8
|
@ -197,7 +197,6 @@ class ListModel(QAbstractListModel):
|
|||
if (n <= 0) or (from_ == to) or (qlast == to) or \
|
||||
not (self.rowCount() > qlast >= 0) or \
|
||||
not self.rowCount() >= to >= 0:
|
||||
logging.warning("No need for move or out of range")
|
||||
return
|
||||
|
||||
qidx = QModelIndex()
|
||||
|
|
|
@ -115,6 +115,14 @@ class SignalManager(QObject):
|
|||
)
|
||||
|
||||
model.updateOrAppendWhere("roomId", room_id, item)
|
||||
index = model.indexWhere("roomId", room_id)
|
||||
|
||||
if category == "Invites":
|
||||
model.move(index, 0)
|
||||
|
||||
elif category == "Left":
|
||||
model.move(index, len(model))
|
||||
|
||||
|
||||
|
||||
def onRoomSyncPrevBatchTokenReceived(
|
||||
|
|
|
@ -8,9 +8,9 @@ ListView {
|
|||
|
||||
property int childrenHeight: 36
|
||||
property int sectionHeight: 16 + spacing
|
||||
property int contentHeight: 0
|
||||
property int contentHeight: getContentHeight()
|
||||
|
||||
onCountChanged: {
|
||||
function getContentHeight() {
|
||||
var sections = []
|
||||
|
||||
for (var i = 0; i < model.count; i++) {
|
||||
|
@ -24,6 +24,11 @@ ListView {
|
|||
sectionHeight * sections.length
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: model
|
||||
onChanged: getContentHeight()
|
||||
}
|
||||
|
||||
id: roomList
|
||||
spacing: 8
|
||||
model: Backend.models.rooms.get(forUserId)
|
||||
|
|
Loading…
Reference in New Issue
Block a user