Commit 8230fb86 authored by Andreas Traczyk's avatar Andreas Traczyk

adapters: handle injecting lrcinstance with zero accounts

Change-Id: I1ec652c60620cf4e7e1caad7fd00ddf1aa40d64d
parent 01cf3f93
......@@ -24,6 +24,9 @@
ConversationListModel::ConversationListModel(LRCInstance* instance, QObject* parent)
: ConversationListModelBase(instance, parent)
{
if (!model_)
return;
connect(
model_,
&ConversationModel::beginInsertRows,
......
......@@ -99,8 +99,6 @@ ConversationsAdapter::ConversationsAdapter(SystemTray* systemTray,
Q_EMIT convSrcModel_->dataChanged(index, index);
});
updateConversationFilterData();
#ifdef Q_OS_LINUX
// notification responses
connect(systemTray_,
......@@ -188,15 +186,8 @@ ConversationsAdapter::onCurrentAccountIdChanged()
{
lrcInstance_->deselectConversation();
convSrcModel_.reset(new ConversationListModel(lrcInstance_));
convModel_->bindSourceModel(convSrcModel_.get());
searchSrcModel_.reset(new SearchResultsListModel(lrcInstance_));
searchModel_->bindSourceModel(searchSrcModel_.get());
connectConversationModel();
updateConversationFilterData();
set_currentTypeFilter(lrcInstance_->getCurrentAccountInfo().profileInfo.type);
}
......@@ -502,6 +493,14 @@ ConversationsAdapter::connectConversationModel(bool updateFilter)
if (updateFilter) {
currentTypeFilter_ = profile::Type::INVALID;
}
convSrcModel_.reset(new ConversationListModel(lrcInstance_));
convModel_->bindSourceModel(convSrcModel_.get());
searchSrcModel_.reset(new SearchResultsListModel(lrcInstance_));
searchModel_->bindSourceModel(searchSrcModel_.get());
updateConversationFilterData();
return true;
}
......
......@@ -210,19 +210,34 @@ LRCInstance::getConversationFromCallId(const QString& callId, const QString& acc
ConversationModel*
LRCInstance::getCurrentConversationModel()
{
return getCurrentAccountInfo().conversationModel.get();
try {
const auto& accInfo = getCurrentAccountInfo();
return accInfo.conversationModel.get();
} catch (...) {
return nullptr;
}
}
NewCallModel*
LRCInstance::getCurrentCallModel()
{
return getCurrentAccountInfo().callModel.get();
try {
const auto& accInfo = getCurrentAccountInfo();
return accInfo.callModel.get();
} catch (...) {
return nullptr;
}
}
ContactModel*
LRCInstance::getCurrentContactModel()
{
return getCurrentAccountInfo().contactModel.get();
try {
const auto& accInfo = getCurrentAccountInfo();
return accInfo.contactModel.get();
} catch (...) {
return nullptr;
}
}
const QString&
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment