mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-27 19:06:22 +00:00
Fix reply message shortcut:
- move to a better location where the message is supposed to be. - avoid to refresh view when loading chat items.
This commit is contained in:
parent
6f673554e4
commit
d1027f401d
3 changed files with 26 additions and 7 deletions
|
|
@ -858,23 +858,31 @@ int ChatRoomModel::loadTillMessage(ChatMessageModel * message){
|
||||||
});
|
});
|
||||||
// if not find, load more entries and find it in new entries.
|
// if not find, load more entries and find it in new entries.
|
||||||
if( entry == mList.end()){
|
if( entry == mList.end()){
|
||||||
|
mPostModelChangedEvents = false;
|
||||||
|
beginResetModel();
|
||||||
int newEntries = loadMoreEntries();
|
int newEntries = loadMoreEntries();
|
||||||
while( newEntries > 0){// no more new entries
|
while( newEntries > 0){// no more new entries
|
||||||
int entryCount = 0;
|
int entryCount = 0;
|
||||||
entry = mList.begin();
|
entry = mList.begin();
|
||||||
auto chatEventEntry = entry->objectCast<ChatEvent>();
|
auto chatEventEntry = entry->objectCast<ChatEvent>();
|
||||||
while(entryCount < newEntries &&
|
while(entryCount < newEntries &&
|
||||||
(chatEventEntry->mType != ChatRoomModel::EntryType::MessageEntry || chatEventEntry.objectCast<ChatMessageModel>()->getChatMessage() != linphoneMessage)
|
(chatEventEntry->mType != ChatRoomModel::EntryType::MessageEntry || chatEventEntry.objectCast<ChatMessageModel>()->getChatMessage() != linphoneMessage)
|
||||||
){
|
){
|
||||||
++entryCount;
|
++entryCount;
|
||||||
++entry;
|
++entry;
|
||||||
|
if( entry != mList.end())
|
||||||
|
chatEventEntry = entry->objectCast<ChatEvent>();
|
||||||
}
|
}
|
||||||
if( entryCount < newEntries){// We got it
|
if( entryCount < newEntries){// We got it
|
||||||
qDebug() << "Find message at " << entryCount << " after loading new entries";
|
qDebug() << "Find message at " << entryCount << " after loading new entries";
|
||||||
|
mPostModelChangedEvents = true;
|
||||||
|
endResetModel();
|
||||||
return entryCount;
|
return entryCount;
|
||||||
}else
|
}else
|
||||||
newEntries = loadMoreEntries();// continue
|
newEntries = loadMoreEntries();// continue
|
||||||
}
|
}
|
||||||
|
mPostModelChangedEvents = true;
|
||||||
|
endResetModel();
|
||||||
}else{
|
}else{
|
||||||
int entryCount = entry - mList.begin();
|
int entryCount = entry - mList.begin();
|
||||||
qDebug() << "Find message at " << entryCount;
|
qDebug() << "Find message at " << entryCount;
|
||||||
|
|
@ -1029,18 +1037,21 @@ int ChatRoomModel::loadMoreEntries(){
|
||||||
EntrySorterHelper::getLimitedSelection(&entries, prepareEntries, mLastEntriesStep, this);
|
EntrySorterHelper::getLimitedSelection(&entries, prepareEntries, mLastEntriesStep, this);
|
||||||
|
|
||||||
if(entries.size() >0){
|
if(entries.size() >0){
|
||||||
beginInsertRows(QModelIndex(), 0, entries.size()-1);
|
if(mPostModelChangedEvents)
|
||||||
|
beginInsertRows(QModelIndex(), 0, entries.size()-1);
|
||||||
for(auto entry : entries)
|
for(auto entry : entries)
|
||||||
mList.prepend(entry);
|
mList.prepend(entry);
|
||||||
endInsertRows();
|
if(mPostModelChangedEvents)
|
||||||
|
endInsertRows();
|
||||||
//emit layoutChanged();
|
//emit layoutChanged();
|
||||||
updateLastUpdateTime();
|
updateLastUpdateTime();
|
||||||
}
|
}
|
||||||
newEntries = entries.size();
|
newEntries = entries.size();
|
||||||
}while( newEntries>0 && currentRowCount == rowCount());
|
}while( newEntries>0 && currentRowCount == rowCount());
|
||||||
currentRowCount = rowCount() - currentRowCount + 1;
|
currentRowCount = rowCount() - currentRowCount;
|
||||||
setEntriesLoading(false);
|
setEntriesLoading(false);
|
||||||
emit moreEntriesLoaded(currentRowCount);
|
if(mPostModelChangedEvents)
|
||||||
|
emit moreEntriesLoaded(currentRowCount);
|
||||||
return currentRowCount;
|
return currentRowCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -311,6 +311,7 @@ private:
|
||||||
QSharedPointer<ChatMessageModel> mReplyModel;
|
QSharedPointer<ChatMessageModel> mReplyModel;
|
||||||
QSharedPointer<ChatNoticeModel> mUnreadMessageNotice;
|
QSharedPointer<ChatNoticeModel> mUnreadMessageNotice;
|
||||||
int mBindingCalls = 0;
|
int mBindingCalls = 0;
|
||||||
|
bool mPostModelChangedEvents = true;
|
||||||
|
|
||||||
QWeakPointer<ChatRoomModel> mSelf;
|
QWeakPointer<ChatRoomModel> mSelf;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,17 @@ Rectangle {
|
||||||
|
|
||||||
color: ChatStyle.color
|
color: ChatStyle.color
|
||||||
clip: true
|
clip: true
|
||||||
|
Timer{// Let some time to have a better cell sizes
|
||||||
|
id: repositionerDelay
|
||||||
|
property int indexToMove
|
||||||
|
interval: 100
|
||||||
|
onTriggered: chat.positionViewAtIndex(indexToMove, ListView.Center)
|
||||||
|
}
|
||||||
function positionViewAtIndex(index){
|
function positionViewAtIndex(index){
|
||||||
chat.bindToEnd = false
|
chat.bindToEnd = false
|
||||||
chat.positionViewAtIndex(index, ListView.Beginning)
|
chat.positionViewAtIndex(index, ListView.Center)
|
||||||
|
repositionerDelay.indexToMove = index
|
||||||
|
repositionerDelay.restart()
|
||||||
}
|
}
|
||||||
|
|
||||||
function goToMessage(message){
|
function goToMessage(message){
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue