Fix GUI data updates

This commit is contained in:
Julien Wadel 2021-08-25 11:14:51 +02:00
parent 9ec17ff5f1
commit 643cc54d6c
21 changed files with 32 additions and 16 deletions

View file

@ -498,6 +498,7 @@ void CallsListModel::addCall (const shared_ptr<linphone::Call> &call) {
beginInsertRows(QModelIndex(), row, row);
mList << callModel;
endInsertRows();
emit layoutChanged();
}
void CallsListModel::removeCall (const shared_ptr<linphone::Call> &call) {

View file

@ -27,7 +27,7 @@
// =============================================================================
ChatCallModel::ChatCallModel ( std::shared_ptr<linphone::CallLog> callLog, const bool& isStart, QObject * parent) : QObject(parent), ChatEvent(ChatRoomModel::EntryType::CallEntry) {
ChatCallModel::ChatCallModel ( std::shared_ptr<linphone::CallLog> callLog, const bool& isStart, QObject * parent) : ChatEvent(ChatRoomModel::EntryType::CallEntry, parent) {
App::getInstance()->getEngine()->setObjectOwnership(this, QQmlEngine::CppOwnership);// Avoid QML to destroy it when passing by Q_INVOKABLE
mCallLog = callLog;
if(isStart){

View file

@ -27,7 +27,7 @@
// =============================================================================
class ChatCallModel : public QObject, public ChatEvent {
class ChatCallModel : public ChatEvent {
Q_OBJECT
public:
@ -64,7 +64,6 @@ private:
std::shared_ptr<linphone::CallLog> mCallLog;
std::weak_ptr<ChatCallModel> mSelf; // Used to pass to functions that need a shared_ptr
};
Q_DECLARE_METATYPE(std::shared_ptr<ChatCallModel>)
Q_DECLARE_METATYPE(ChatCallModel*)
#endif

View file

@ -26,7 +26,7 @@
// =============================================================================
ChatEvent::ChatEvent (ChatRoomModel::EntryType type){
ChatEvent::ChatEvent (ChatRoomModel::EntryType type, QObject * parent) : QObject(parent){
mType = type;
}
ChatEvent::~ChatEvent(){

View file

@ -26,9 +26,10 @@
// =============================================================================
class ChatEvent{
class ChatEvent : public QObject{
Q_OBJECT
public:
ChatEvent (ChatRoomModel::EntryType type);
ChatEvent (ChatRoomModel::EntryType type, QObject * parent = nullptr);
virtual ~ChatEvent();
ChatRoomModel::EntryType mType;
QDateTime mTimestamp;

View file

@ -294,7 +294,7 @@ QString ChatMessageModel::AppDataManager::toString(){
}
return pairs.join(';');
}
ChatMessageModel::ChatMessageModel ( std::shared_ptr<linphone::ChatMessage> chatMessage, QObject * parent) : QObject(parent), ChatEvent(ChatRoomModel::EntryType::MessageEntry) {
ChatMessageModel::ChatMessageModel ( std::shared_ptr<linphone::ChatMessage> chatMessage, QObject * parent) : ChatEvent(ChatRoomModel::EntryType::MessageEntry, parent) {
App::getInstance()->getEngine()->setObjectOwnership(this, QQmlEngine::CppOwnership);// Avoid QML to destroy it
mParticipantImdnStateListModel = std::make_shared<ParticipantImdnStateListModel>(chatMessage);
mChatMessageListener = std::make_shared<ChatMessageListener>(this, parent);

View file

@ -118,7 +118,7 @@ signals:
void ephemeralMessageDeleted(const std::shared_ptr<linphone::ChatMessage> & message);
};
class ChatMessageModel : public QObject, public ChatEvent {
class ChatMessageModel : public ChatEvent {
Q_OBJECT
public:
static std::shared_ptr<ChatMessageModel> create(std::shared_ptr<linphone::ChatMessage> chatMessage, QObject * parent = nullptr);// Call it instead constructor
@ -220,7 +220,7 @@ private:
std::shared_ptr<ParticipantImdnStateListModel> mParticipantImdnStateListModel;
std::shared_ptr<ChatMessageListener> mChatMessageListener;
};
Q_DECLARE_METATYPE(ChatMessageModel*)
Q_DECLARE_METATYPE(std::shared_ptr<ChatMessageModel>)
Q_DECLARE_METATYPE(ChatMessageListener*)
#endif

View file

@ -28,7 +28,7 @@
// =============================================================================
ChatNoticeModel::ChatNoticeModel ( std::shared_ptr<linphone::EventLog> eventLog, QObject * parent) : QObject(parent), ChatEvent(ChatRoomModel::EntryType::NoticeEntry) {
ChatNoticeModel::ChatNoticeModel ( std::shared_ptr<linphone::EventLog> eventLog, QObject * parent) : ChatEvent(ChatRoomModel::EntryType::NoticeEntry, parent) {
App::getInstance()->getEngine()->setObjectOwnership(this, QQmlEngine::CppOwnership);// Avoid QML to destroy it when passing by Q_INVOKABLE
mEventLog = eventLog;
mTimestamp = QDateTime::fromMSecsSinceEpoch(eventLog->getCreationTime() * 1000);

View file

@ -27,7 +27,7 @@
// =============================================================================
class ChatNoticeModel : public QObject, public ChatEvent {
class ChatNoticeModel : public ChatEvent {
Q_OBJECT
public:

View file

@ -835,6 +835,7 @@ void ChatRoomModel::loadMoreEntries(){
for(auto entry : entries)
mEntries.prepend(entry);
endInsertRows();
emit layoutChanged();
updateLastUpdateTime();
}
}
@ -869,6 +870,7 @@ void ChatRoomModel::insertCall (const std::shared_ptr<linphone::CallLog> &callLo
endInsertRows();
}
}
emit layoutChanged();
updateLastUpdateTime();
}
}
@ -894,6 +896,7 @@ void ChatRoomModel::insertCalls (const QList<std::shared_ptr<linphone::CallLog>
entries << mEntries;
mEntries = entries;
endInsertRows();
emit layoutChanged();
}
}
}
@ -907,6 +910,7 @@ void ChatRoomModel::insertMessageAtEnd (const std::shared_ptr<linphone::ChatMess
beginInsertRows(QModelIndex(), row, row);
mEntries << model;
endInsertRows();
emit layoutChanged();
}
}
}
@ -925,6 +929,7 @@ void ChatRoomModel::insertMessages (const QList<std::shared_ptr<linphone::ChatMe
entries << mEntries;
mEntries = entries;
endInsertRows();
emit layoutChanged();
}
}
}
@ -937,6 +942,7 @@ void ChatRoomModel::insertNotice (const std::shared_ptr<linphone::EventLog> &eve
beginInsertRows(QModelIndex(), row, row);
mEntries << model;
endInsertRows();
emit layoutChanged();
}
}
}
@ -956,6 +962,7 @@ void ChatRoomModel::insertNotices (const QList<std::shared_ptr<linphone::EventLo
entries << mEntries;
mEntries = entries;
endInsertRows();
emit layoutChanged();
}
}
}

View file

@ -82,6 +82,7 @@ bool ConferenceHelperModel::ConferenceAddModel::addToConference (const shared_pt
beginInsertRows(QModelIndex(), row, row);
addToConferencePrivate(linphoneAddress->clone());
endInsertRows();
emit layoutChanged();
mConferenceHelperModel->invalidate();
@ -105,6 +106,7 @@ bool ConferenceHelperModel::ConferenceAddModel::addToConference (const QString &
addToConferencePrivate(address);
endInsertRows();
emit layoutChanged();
mConferenceHelperModel->invalidate();

View file

@ -152,6 +152,7 @@ ContactsImporterModel *ContactsImporterListModel::createContactsImporter(QVarian
beginInsertRows(QModelIndex(), row, row);
addContactsImporter(contactsImporter);
endInsertRows();
emit layoutChanged();
emit contactsImporterAdded(contactsImporter);
}

View file

@ -162,6 +162,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcardModel) {
beginInsertRows(QModelIndex(), row, row);
addContact(contact);
endInsertRows();
emit layoutChanged();
emit contactAdded(contact);

View file

@ -225,6 +225,7 @@ void HistoryModel::insertCall (const shared_ptr<linphone::CallLog> &callLog) {
beginInsertRows(QModelIndex(), row, row);
it = mEntries.insert(it, entry);
endInsertRows();
emit layoutChanged();
return it;
};

View file

@ -126,7 +126,7 @@ void LdapListModel::add(){
ldap->init();
mServers << ldap;
endInsertRows();
resetInternalData();
emit layoutChanged();
}
void LdapListModel::remove (LdapModel *ldap) {

View file

@ -76,7 +76,7 @@ void ColorListModel::add(std::shared_ptr<ColorModel> color){
mList << color;
endInsertRows();
resetInternalData();
emit layoutChanged();
}
bool ColorListModel::removeRow (int row, const QModelIndex &parent){

View file

@ -84,7 +84,7 @@ void ImageListModel::add(std::shared_ptr<ImageModel> image){
mList << image;
endInsertRows();
resetInternalData();
emit layoutChanged();
}
bool ImageListModel::removeRow (int row, const QModelIndex &parent){

View file

@ -77,7 +77,7 @@ void ParticipantImdnStateListModel::add(std::shared_ptr<ParticipantImdnStateMode
mList << imdn;
endInsertRows();
emit countChanged();
//resetInternalData();
emit layoutChanged();
}
bool ParticipantImdnStateListModel::removeRow (int row, const QModelIndex &parent){

View file

@ -222,6 +222,7 @@ void ParticipantListModel::updateParticipants () {
}
}
if( changed){
emit layoutChanged();
emit participantsChanged();
emit countChanged();
}
@ -236,6 +237,7 @@ void ParticipantListModel::add (std::shared_ptr<ParticipantModel> participant){
beginInsertRows(QModelIndex(), row, row);
mParticipants << participant;
endInsertRows();
emit layoutChanged();
emit participantsChanged();
emit countChanged();
}

View file

@ -529,6 +529,7 @@ void SipAddressesModel::addOrUpdateSipAddress (const QString &sipAddress, T data
mRefs << &mPeerAddressToSipAddressEntry[sipAddress];
endInsertRows();
emit layoutChanged();
}
// -----------------------------------------------------------------------------

View file

@ -288,7 +288,7 @@ void TimelineListModel::add (std::shared_ptr<TimelineModel> timeline){
beginInsertRows(QModelIndex(), row, row);
mTimelines << timeline;
endInsertRows();
resetInternalData();
emit layoutChanged();
emit countChanged();
}