Skip to content
Snippets Groups Projects
Commit e648bdb9 authored by Stepan Salenikovich's avatar Stepan Salenikovich Committed by Edric Milaret
Browse files

chat: add UnreadTextMessageCount role

This role is added to the Call, ContactMethod, and Person items to
be able to to easily fetch the unread messages and their quantity.

Change-Id: I1308833ad501f0876b20b2301bc96f54fbc5fc71
Tuleap: #203
parent 8b62209e
No related branches found
No related tags found
No related merge requests found
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
#include "media/audio.h" #include "media/audio.h"
#include "media/video.h" #include "media/video.h"
#include "media/text.h" #include "media/text.h"
#include "media/textrecording.h"
#include "media/file.h" #include "media/file.h"
#include "securityevaluationmodel.h" #include "securityevaluationmodel.h"
...@@ -2219,6 +2220,12 @@ QVariant Call::roleData(int role) const ...@@ -2219,6 +2220,12 @@ QVariant Call::roleData(int role) const
return QVariant::fromValue(account()->securityEvaluationModel()->securityLevel()); return QVariant::fromValue(account()->securityEvaluationModel()->securityLevel());
case static_cast<int>(Call::Role::SecurityLevelIcon): //TODO remove case static_cast<int>(Call::Role::SecurityLevelIcon): //TODO remove
return GlobalInstances::pixmapManipulator().securityLevelIcon(account()->securityEvaluationModel()->securityLevel()); return GlobalInstances::pixmapManipulator().securityLevelIcon(account()->securityEvaluationModel()->securityLevel());
case static_cast<int>(Ring::Role::UnreadTextMessageCount):
if (peerContactMethod() && peerContactMethod()->textRecording())
return peerContactMethod()->textRecording()->unreadInstantTextMessagingModel()->rowCount();
else
return 0;
break;
default: default:
break; break;
}; };
......
...@@ -542,6 +542,12 @@ QVariant ContactMethod::roleData(int role) const ...@@ -542,6 +542,12 @@ QVariant ContactMethod::roleData(int role) const
break; break;
case static_cast<int>(Call::Role::LifeCycleState): case static_cast<int>(Call::Role::LifeCycleState):
return QVariant::fromValue(Call::LifeCycleState::FINISHED); return QVariant::fromValue(Call::LifeCycleState::FINISHED);
case static_cast<int>(Ring::Role::UnreadTextMessageCount):
if (auto rec = textRecording())
cat = rec->unreadInstantTextMessagingModel()->rowCount();
else
cat = 0;
break;
} }
return cat; return cat;
} }
......
...@@ -46,6 +46,7 @@ enum class Role ...@@ -46,6 +46,7 @@ enum class Role
FormattedState , FormattedState ,
Length , Length ,
DropState , DropState ,
UnreadTextMessageCount,
UserRole = Qt::UserRole + 100 // this should always be the last role in the list UserRole = Qt::UserRole + 100 // this should always be the last role in the list
}; };
......
...@@ -601,6 +601,16 @@ QVariant Person::roleData(int role) const ...@@ -601,6 +601,16 @@ QVariant Person::roleData(int role) const
return QVariant(QDateTime::fromTime_t( lastUsedTime())); return QVariant(QDateTime::fromTime_t( lastUsedTime()));
case static_cast<int>(Person::Role::Filter): case static_cast<int>(Person::Role::Filter):
return filterString(); return filterString();
case static_cast<int>(Ring::Role::UnreadTextMessageCount):
{
int unread = 0;
for (int i = 0; i < d_ptr->m_Numbers.size(); ++i) {
if (auto rec = d_ptr->m_Numbers.at(i)->textRecording())
unread += rec->unreadInstantTextMessagingModel()->rowCount();
}
return unread;
}
break;
default: default:
break; break;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment