Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
ff733ab3
Commit
ff733ab3
authored
Jan 11, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(src/components/chat/ChatModel): mark messages as read when it is necessary
parent
ec2b3545
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
ChatModel.cpp
tests/src/components/chat/ChatModel.cpp
+14
-3
ChatModel.hpp
tests/src/components/chat/ChatModel.hpp
+1
-1
No files found.
tests/src/components/chat/ChatModel.cpp
View file @
ff733ab3
...
...
@@ -14,13 +14,13 @@ using namespace std;
// =============================================================================
class
ChatModel
::
MessageHandlers
:
public
linphone
::
ChatMessageListener
{
friend
class
ChatModel
;
public:
MessageHandlers
(
ChatModel
*
chat_model
)
:
m_chat_model
(
chat_model
)
{}
~
MessageHandlers
()
=
default
;
private:
void
onFileTransferRecv
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
,
const
shared_ptr
<
linphone
::
Content
>
&
content
,
...
...
@@ -48,6 +48,9 @@ private:
}
void
onMsgStateChanged
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
,
linphone
::
ChatMessageState
state
)
override
{
if
(
!
m_chat_model
)
return
;
ChatModel
&
chat
=
*
m_chat_model
;
auto
it
=
find_if
(
chat
.
m_entries
.
begin
(),
chat
.
m_entries
.
end
(),
[
&
message
](
const
ChatEntryData
&
pair
)
{
...
...
@@ -62,6 +65,7 @@ private:
emit
chat
.
dataChanged
(
chat
.
index
(
row
,
0
),
chat
.
index
(
row
,
0
));
}
private:
ChatModel
*
m_chat_model
;
};
...
...
@@ -82,12 +86,18 @@ ChatModel::ChatModel (QObject *parent) : QAbstractListModel(parent) {
const
shared_ptr
<
linphone
::
ChatRoom
>
&
room
,
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
if
(
m_chat_room
==
room
)
if
(
m_chat_room
==
room
)
{
insertMessageAtEnd
(
message
);
m_chat_room
->
markAsRead
();
}
}
);
}
ChatModel
::~
ChatModel
()
{
m_message_handlers
->
m_chat_model
=
nullptr
;
}
QHash
<
int
,
QByteArray
>
ChatModel
::
roleNames
()
const
{
QHash
<
int
,
QByteArray
>
roles
;
roles
[
Roles
::
ChatEntry
]
=
"$chatEntry"
;
...
...
@@ -162,6 +172,7 @@ void ChatModel::setSipAddress (const QString &sip_address) {
string
std_sip_address
=
::
Utils
::
qStringToLinphoneString
(
sip_address
);
m_chat_room
=
core
->
getChatRoomFromUri
(
std_sip_address
);
m_chat_room
->
markAsRead
();
// Get messages.
for
(
auto
&
message
:
m_chat_room
->
getHistory
(
0
))
{
...
...
tests/src/components/chat/ChatModel.hpp
View file @
ff733ab3
...
...
@@ -50,7 +50,7 @@ public:
Q_ENUM
(
MessageStatus
);
ChatModel
(
QObject
*
parent
=
Q_NULLPTR
);
~
ChatModel
()
=
default
;
~
ChatModel
();
int
rowCount
(
const
QModelIndex
&
index
=
QModelIndex
())
const
override
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment