diff --git a/src/app/smartlistmodel.cpp b/src/app/smartlistmodel.cpp index 1780ca3d4ec15f1243f2c0fe01185f182b60e054..d61deafa28c3a6c218f8e6b7b57eeeac14297aca 100644 --- a/src/app/smartlistmodel.cpp +++ b/src/app/smartlistmodel.cpp @@ -21,13 +21,10 @@ #include "smartlistmodel.h" #include "lrcinstance.h" -#include "utils.h" #include "api/account.h" -#include "api/contact.h" #include "api/conversation.h" #include "api/conversationmodel.h" -#include "api/contactmodel.h" #include <QDateTime> @@ -37,11 +34,20 @@ SmartListModel::SmartListModel(QObject* parent, : ConversationListModelBase(instance, parent) , listModelType_(listModelType) { - if (listModelType_ == Type::CONFERENCE) { - setConferenceableFilter(); - } else if (listModelType_ == Type::CONVERSATION || listModelType_ == Type::ADDCONVMEMBER) { - fillConversationsList(); - } + connect( + model_, + &ConversationModel::newConversation, + this, + [this] { updateModels(); }, + Qt::DirectConnection); + connect( + model_, + &ConversationModel::conversationRemoved, + this, + [this] { updateModels(); }, + Qt::DirectConnection); + + updateModels(); } int @@ -63,8 +69,9 @@ SmartListModel::rowCount(const QModelIndex& parent) const rowCount += sectionState_[tr("Contacts")] ? contacts.size() : 0; } return rowCount; + } else { + return conversations_.size(); } - return conversations_.size(); } return 0; } @@ -167,6 +174,16 @@ SmartListModel::fillConversationsList() endResetModel(); } +void +SmartListModel::updateModels() +{ + if (listModelType_ == Type::CONFERENCE) { + setConferenceableFilter(); + } else if (listModelType_ == Type::CONVERSATION || listModelType_ == Type::ADDCONVMEMBER) { + fillConversationsList(); + } +} + void SmartListModel::toggleSection(const QString& section) { diff --git a/src/app/smartlistmodel.h b/src/app/smartlistmodel.h index f85e0a0a7f4538f885ea8daa87c632c640490faf..fc2dfc9ac78c7d342ecc77f6ac51142dc5a14499 100644 --- a/src/app/smartlistmodel.h +++ b/src/app/smartlistmodel.h @@ -58,4 +58,6 @@ private: QMap<QString, bool> sectionState_; QMap<ConferenceableItem, ConferenceableValue> conferenceables_; ConversationModel::ConversationQueueProxy conversations_; + + void updateModels(); };