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
7495b4aa
Commit
7495b4aa
authored
Nov 23, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(components/timeline): force render when a contact is removed
parent
dac94d02
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
27 deletions
+54
-27
CMakeLists.txt
tests/CMakeLists.txt
+2
-0
App.cpp
tests/src/app/App.cpp
+1
-1
ContactsListModel.cpp
tests/src/components/contacts/ContactsListModel.cpp
+2
-0
ContactsListModel.hpp
tests/src/components/contacts/ContactsListModel.hpp
+1
-1
TimelineModel.cpp
tests/src/components/timeline/TimelineModel.cpp
+39
-23
TimelineModel.hpp
tests/src/components/timeline/TimelineModel.hpp
+4
-2
utils.hpp
tests/src/utils.hpp
+5
-0
No files found.
tests/CMakeLists.txt
View file @
7495b4aa
...
...
@@ -42,6 +42,7 @@ set(SOURCES
src/components/settings/AccountSettingsModel.cpp
src/components/settings/SettingsModel.cpp
src/components/smart-search-bar/SmartSearchBarModel.cpp
src/components/smart-search-bar/SmartSearchBarProxyModel.cpp
src/components/timeline/TimelineModel.cpp
src/main.cpp
)
...
...
@@ -60,6 +61,7 @@ set(HEADERS
src/components/settings/AccountSettingsModel.hpp
src/components/settings/SettingsModel.hpp
src/components/smart-search-bar/SmartSearchBarModel.hpp
src/components/smart-search-bar/SmartSearchBarProxyModel.hpp
src/components/timeline/TimelineModel.hpp
src/utils.hpp
)
...
...
tests/src/app/App.cpp
View file @
7495b4aa
...
...
@@ -108,7 +108,7 @@ void App::registerTypes () {
qmlRegisterSingletonType
<
TimelineModel
>
(
"Linphone"
,
1
,
0
,
"TimelineModel"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
new
TimelineModel
();
return
new
TimelineModel
(
ContactsListProxyModel
::
getContactsListModel
()
);
}
);
}
...
...
tests/src/components/contacts/ContactsListModel.cpp
View file @
7495b4aa
...
...
@@ -59,7 +59,9 @@ bool ContactsListModel::removeRows (int row, int count, const QModelIndex &paren
ContactModel
*
contact
=
m_list
[
row
];
m_list
.
removeAt
(
row
);
m_friend_to_contact
.
remove
(
contact
->
m_linphone_friend
.
get
());
// m_linphone_friends->removeFriend(contact->m_linphone_friend);
contact
->
deleteLater
();
}
...
...
tests/src/components/contacts/ContactsListModel.hpp
View file @
7495b4aa
...
...
@@ -34,7 +34,7 @@ public slots:
private:
QList
<
ContactModel
*>
m_list
;
QHash
<
const
linphone
::
Friend
*
,
ContactModel
*
>
m_friend_to_contact
;
QHash
<
const
linphone
::
Friend
*
,
ContactModel
*
>
m_friend_to_contact
;
std
::
shared_ptr
<
linphone
::
FriendList
>
m_linphone_friends
;
};
...
...
tests/src/components/timeline/TimelineModel.cpp
View file @
7495b4aa
...
...
@@ -12,7 +12,45 @@ using namespace std;
// ===================================================================
TimelineModel
::
TimelineModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{
TimelineModel
::
TimelineModel
(
const
ContactsListModel
*
contacts_list
)
{
init_entries
();
// Invalidate model if a contact is removed.
connect
(
contacts_list
,
&
ContactsListModel
::
rowsRemoved
,
this
,
[
this
](
const
QModelIndex
&
,
int
,
int
)
{
beginResetModel
();
// Nothing.
endResetModel
();
}
);
}
int
TimelineModel
::
rowCount
(
const
QModelIndex
&
)
const
{
return
m_entries
.
count
();
}
QHash
<
int
,
QByteArray
>
TimelineModel
::
roleNames
()
const
{
QHash
<
int
,
QByteArray
>
roles
;
roles
[
Qt
::
DisplayRole
]
=
"$timelineEntry"
;
return
roles
;
}
QVariant
TimelineModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
int
row
=
index
.
row
();
if
(
row
<
0
||
row
>=
m_entries
.
count
())
return
QVariant
();
if
(
role
==
Qt
::
DisplayRole
)
return
m_entries
[
row
];
return
QVariant
();
}
// -------------------------------------------------------------------
void
TimelineModel
::
init_entries
()
{
// Returns an iterator entry position to insert a new entry.
auto
search_entry
=
[
this
](
const
QVariantMap
&
map
,
...
...
@@ -89,25 +127,3 @@ TimelineModel::TimelineModel (QObject *parent): QAbstractListModel(parent) {
}
}
}
int
TimelineModel
::
rowCount
(
const
QModelIndex
&
)
const
{
return
m_entries
.
count
();
}
QHash
<
int
,
QByteArray
>
TimelineModel
::
roleNames
()
const
{
QHash
<
int
,
QByteArray
>
roles
;
roles
[
Qt
::
DisplayRole
]
=
"$timelineEntry"
;
return
roles
;
}
QVariant
TimelineModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
int
row
=
index
.
row
();
if
(
row
<
0
||
row
>=
m_entries
.
count
())
return
QVariant
();
if
(
role
==
Qt
::
DisplayRole
)
return
m_entries
[
row
];
return
QVariant
();
}
tests/src/components/timeline/TimelineModel.hpp
View file @
7495b4aa
#ifndef TIMELINE_MODEL_H_
#define TIMELINE_MODEL_H_
#include
<QAbstractListModel>
#include
"../contacts/ContactsListModel.hpp"
// ===================================================================
...
...
@@ -9,13 +9,15 @@ class TimelineModel : public QAbstractListModel {
Q_OBJECT
;
public:
TimelineModel
(
QObject
*
parent
=
Q_NULLPTR
);
TimelineModel
(
const
ContactsListModel
*
contacts_list
);
int
rowCount
(
const
QModelIndex
&
)
const
;
QHash
<
int
,
QByteArray
>
roleNames
()
const
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
private:
void
init_entries
();
// A timeline enty is a object that contains:
// - A QDateTime `timestamp`.
// - A `sipAddresses` value, if it exists only one address, it's
...
...
tests/src/utils.hpp
View file @
7495b4aa
#ifndef UTILS_H_
#define UTILS_H_
#include <QString>
namespace
Utils
{
...
...
@@ -5,3 +8,5 @@ namespace Utils {
return
QString
::
fromLocal8Bit
(
string
.
c_str
(),
string
.
size
());
}
}
#endif // UTILS_H_
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