parent
d18daccf4a
commit
3afa49a873
|
@ -5,6 +5,7 @@ import message_item, message_reaction_item, message_transaction_parameters_item
|
||||||
type
|
type
|
||||||
ModelRole {.pure.} = enum
|
ModelRole {.pure.} = enum
|
||||||
Id = UserRole + 1
|
Id = UserRole + 1
|
||||||
|
PrevMsgTimestamp
|
||||||
PrevMsgIndex
|
PrevMsgIndex
|
||||||
NextMsgIndex
|
NextMsgIndex
|
||||||
CommunityId
|
CommunityId
|
||||||
|
@ -80,6 +81,7 @@ QtObject:
|
||||||
method roleNames(self: Model): Table[int, string] =
|
method roleNames(self: Model): Table[int, string] =
|
||||||
{
|
{
|
||||||
ModelRole.Id.int:"id",
|
ModelRole.Id.int:"id",
|
||||||
|
ModelRole.PrevMsgTimestamp.int: "prevMsgTimestamp",
|
||||||
ModelRole.PrevMsgIndex.int:"prevMsgIndex",
|
ModelRole.PrevMsgIndex.int:"prevMsgIndex",
|
||||||
ModelRole.NextMsgIndex.int:"nextMsgIndex",
|
ModelRole.NextMsgIndex.int:"nextMsgIndex",
|
||||||
ModelRole.CommunityId.int:"communityId",
|
ModelRole.CommunityId.int:"communityId",
|
||||||
|
@ -126,6 +128,12 @@ QtObject:
|
||||||
case enumRole:
|
case enumRole:
|
||||||
of ModelRole.Id:
|
of ModelRole.Id:
|
||||||
result = newQVariant(item.id)
|
result = newQVariant(item.id)
|
||||||
|
of PrevMsgTimestamp:
|
||||||
|
if (index.row + 1 < self.items.len):
|
||||||
|
let prevItem = self.items[index.row + 1]
|
||||||
|
result = newQVariant(prevItem.timestamp)
|
||||||
|
else:
|
||||||
|
result = newQVariant(0)
|
||||||
of ModelRole.PrevMsgIndex:
|
of ModelRole.PrevMsgIndex:
|
||||||
result = newQVariant(index.row + 1)
|
result = newQVariant(index.row + 1)
|
||||||
of ModelRole.NextMsgIndex:
|
of ModelRole.NextMsgIndex:
|
||||||
|
@ -255,6 +263,9 @@ QtObject:
|
||||||
self.beginInsertRows(parentModelIndex, first, last)
|
self.beginInsertRows(parentModelIndex, first, last)
|
||||||
self.items.add(itemsToAppend)
|
self.items.add(itemsToAppend)
|
||||||
self.endInsertRows()
|
self.endInsertRows()
|
||||||
|
|
||||||
|
if first > 0:
|
||||||
|
self.updateItemAtIndex(first - 1)
|
||||||
self.countChanged()
|
self.countChanged()
|
||||||
|
|
||||||
proc appendItem*(self: Model, item: Item) =
|
proc appendItem*(self: Model, item: Item) =
|
||||||
|
@ -264,9 +275,14 @@ QtObject:
|
||||||
let parentModelIndex = newQModelIndex()
|
let parentModelIndex = newQModelIndex()
|
||||||
defer: parentModelIndex.delete
|
defer: parentModelIndex.delete
|
||||||
|
|
||||||
self.beginInsertRows(parentModelIndex, self.items.len, self.items.len)
|
let position = self.items.len
|
||||||
|
|
||||||
|
self.beginInsertRows(parentModelIndex, position, position)
|
||||||
self.items.add(item)
|
self.items.add(item)
|
||||||
self.endInsertRows()
|
self.endInsertRows()
|
||||||
|
|
||||||
|
if position > 0:
|
||||||
|
self.updateItemAtIndex(position - 1)
|
||||||
self.countChanged()
|
self.countChanged()
|
||||||
|
|
||||||
proc prependItem*(self: Model, item: Item) =
|
proc prependItem*(self: Model, item: Item) =
|
||||||
|
@ -279,6 +295,9 @@ QtObject:
|
||||||
self.beginInsertRows(parentModelIndex, 0, 0)
|
self.beginInsertRows(parentModelIndex, 0, 0)
|
||||||
self.items.insert(item, 0)
|
self.items.insert(item, 0)
|
||||||
self.endInsertRows()
|
self.endInsertRows()
|
||||||
|
|
||||||
|
if self.items.len > 1:
|
||||||
|
self.updateItemAtIndex(1)
|
||||||
self.countChanged()
|
self.countChanged()
|
||||||
|
|
||||||
proc insertItemBasedOnTimestamp*(self: Model, item: Item) =
|
proc insertItemBasedOnTimestamp*(self: Model, item: Item) =
|
||||||
|
@ -296,6 +315,8 @@ QtObject:
|
||||||
|
|
||||||
if position > 0:
|
if position > 0:
|
||||||
self.updateItemAtIndex(position - 1)
|
self.updateItemAtIndex(position - 1)
|
||||||
|
if position + 1 < self.items.len:
|
||||||
|
self.updateItemAtIndex(position + 1)
|
||||||
self.countChanged()
|
self.countChanged()
|
||||||
|
|
||||||
proc removeItem*(self: Model, messageId: string) =
|
proc removeItem*(self: Model, messageId: string) =
|
||||||
|
@ -310,8 +331,14 @@ QtObject:
|
||||||
self.items.delete(ind)
|
self.items.delete(ind)
|
||||||
self.endRemoveRows()
|
self.endRemoveRows()
|
||||||
|
|
||||||
if self.items.len > 0 and ind > 0 and ind < self.items.len:
|
# if self.items.len > 0 and ind > 0 and ind < self.items.len:
|
||||||
self.updateItemAtIndex(ind - 1)
|
# self.updateItemAtIndex(ind - 1)
|
||||||
|
|
||||||
|
if ind > 0 and ind < self.items.len:
|
||||||
|
self.updateItemAtIndex(ind - 1)
|
||||||
|
if ind + 1 < self.items.len:
|
||||||
|
self.updateItemAtIndex(ind + 1)
|
||||||
|
|
||||||
self.countChanged()
|
self.countChanged()
|
||||||
|
|
||||||
proc getItemWithMessageId*(self: Model, messageId: string): Item =
|
proc getItemWithMessageId*(self: Model, messageId: string): Item =
|
||||||
|
|
|
@ -293,6 +293,7 @@ Item {
|
||||||
// recent time is added at index 0.
|
// recent time is added at index 0.
|
||||||
prevMessageIndex: model.prevMsgIndex
|
prevMessageIndex: model.prevMsgIndex
|
||||||
prevMessageAsJsonObj: messageStore.getMessageByIndexAsJson(model.prevMsgIndex)
|
prevMessageAsJsonObj: messageStore.getMessageByIndexAsJson(model.prevMsgIndex)
|
||||||
|
prevMsgTimestamp: model.prevMsgTimestamp
|
||||||
nextMessageIndex: model.nextMsgIndex
|
nextMessageIndex: model.nextMsgIndex
|
||||||
nextMessageAsJsonObj: messageStore.getMessageByIndexAsJson(model.nextMsgIndex)
|
nextMessageAsJsonObj: messageStore.getMessageByIndexAsJson(model.nextMsgIndex)
|
||||||
onOpenStickerPackPopup: {
|
onOpenStickerPackPopup: {
|
||||||
|
|
|
@ -51,6 +51,10 @@ Item {
|
||||||
|
|
||||||
property string message: ""
|
property string message: ""
|
||||||
|
|
||||||
|
property int prevMessageIndex
|
||||||
|
property string prevMsgTimestamp
|
||||||
|
property string messageTimestamp
|
||||||
|
|
||||||
property var transactionParams
|
property var transactionParams
|
||||||
|
|
||||||
signal openStickerPackPopup(string stickerPackId)
|
signal openStickerPackPopup(string stickerPackId)
|
||||||
|
@ -173,9 +177,9 @@ Item {
|
||||||
|
|
||||||
DateGroup {
|
DateGroup {
|
||||||
id: dateGroupLbl
|
id: dateGroupLbl
|
||||||
previousMessageIndex: prevMessageIndex
|
previousMessageIndex: root.prevMessageIndex
|
||||||
previousMessageTimestamp: prevMsgTimestamp
|
previousMessageTimestamp: root.prevMsgTimestamp
|
||||||
messageTimestamp: timestamp
|
messageTimestamp: root.messageTimestamp
|
||||||
isActivityCenterMessage: activityCenterMessage
|
isActivityCenterMessage: activityCenterMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +407,7 @@ Item {
|
||||||
anchors.left: trustStatus.right
|
anchors.left: trustStatus.right
|
||||||
anchors.leftMargin: 4
|
anchors.leftMargin: 4
|
||||||
color: Style.current.secondaryText
|
color: Style.current.secondaryText
|
||||||
timestamp: messageTimestamp
|
timestamp: root.messageTimestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
|
|
|
@ -335,6 +335,10 @@ Loader {
|
||||||
senderTrustStatus: root.senderTrustStatus
|
senderTrustStatus: root.senderTrustStatus
|
||||||
chatLogView: root.chatLogView
|
chatLogView: root.chatLogView
|
||||||
|
|
||||||
|
prevMessageIndex: root.prevMessageIndex
|
||||||
|
prevMsgTimestamp: root.prevMsgTimestamp
|
||||||
|
messageTimestamp: root.messageTimestamp
|
||||||
|
|
||||||
communityId: root.communityId
|
communityId: root.communityId
|
||||||
stickersLoaded: root.stickersLoaded
|
stickersLoaded: root.stickersLoaded
|
||||||
sticker: root.sticker
|
sticker: root.sticker
|
||||||
|
|
Loading…
Reference in New Issue