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
758dd1c0
Commit
758dd1c0
authored
Dec 20, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unstable (refactoring)
parent
e69d7fcd
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
55 additions
and
62 deletions
+55
-62
CMakeLists.txt
tests/CMakeLists.txt
+12
-12
App.cpp
tests/src/app/App.cpp
+16
-23
ContactsListModel.cpp
tests/src/components/contacts/ContactsListModel.cpp
+2
-0
ContactsListModel.hpp
tests/src/components/contacts/ContactsListModel.hpp
+14
-1
ContactsListProxyModel.cpp
tests/src/components/contacts/ContactsListProxyModel.cpp
+2
-11
ContactsListProxyModel.hpp
tests/src/components/contacts/ContactsListProxyModel.hpp
+6
-12
TimelineModel.cpp
tests/src/components/timeline/TimelineModel.cpp
+2
-2
TimelineModel.hpp
tests/src/components/timeline/TimelineModel.hpp
+1
-1
No files found.
tests/CMakeLists.txt
View file @
758dd1c0
# ====================================================================
# ====================================================================
==========
# CMakeLists.txt
# CMakeLists.txt
# ====================================================================
# ====================================================================
==========
cmake_minimum_required
(
VERSION 3.1
)
cmake_minimum_required
(
VERSION 3.1
)
project
(
linphone
)
project
(
linphone
)
...
@@ -31,9 +31,9 @@ set(CUSTOM_FLAGS "\
...
@@ -31,9 +31,9 @@ set(CUSTOM_FLAGS "\
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
${
CUSTOM_FLAGS
}
"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
${
CUSTOM_FLAGS
}
"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
-DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
-DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG"
)
# --------------------------------------------------------------------
# --------------------------------------------------------------------
----------
# Define packages, libs, sources, headers, resources and languages
# Define packages, libs, sources, headers, resources and languages
.
# --------------------------------------------------------------------
# --------------------------------------------------------------------
----------
set
(
QT5_PACKAGES Core Gui Quick Widgets QuickControls2 LinguistTools
)
set
(
QT5_PACKAGES Core Gui Quick Widgets QuickControls2 LinguistTools
)
...
@@ -108,7 +108,7 @@ set(LANGUAGES_DIRECTORY assets/languages)
...
@@ -108,7 +108,7 @@ set(LANGUAGES_DIRECTORY assets/languages)
set
(
I18N_FILENAME i18n.qrc
)
set
(
I18N_FILENAME i18n.qrc
)
set
(
LANGUAGES en fr
)
set
(
LANGUAGES en fr
)
# --------------------------------------------------------------------
# --------------------------------------------------------------------
----------
function
(
PREPEND list prefix
)
function
(
PREPEND list prefix
)
set
(
new_list
""
)
set
(
new_list
""
)
...
@@ -125,9 +125,9 @@ PREPEND(SOURCES "${CMAKE_SOURCE_DIR}/")
...
@@ -125,9 +125,9 @@ PREPEND(SOURCES "${CMAKE_SOURCE_DIR}/")
PREPEND
(
HEADERS
"
${
CMAKE_SOURCE_DIR
}
/"
)
PREPEND
(
HEADERS
"
${
CMAKE_SOURCE_DIR
}
/"
)
PREPEND
(
QRC_RESOURCES
"
${
CMAKE_SOURCE_DIR
}
/"
)
PREPEND
(
QRC_RESOURCES
"
${
CMAKE_SOURCE_DIR
}
/"
)
# --------------------------------------------------------------------
# --------------------------------------------------------------------
----------
# Compute QML files list.
# Compute QML files list.
# --------------------------------------------------------------------
# --------------------------------------------------------------------
----------
set
(
QML_SOURCES
)
set
(
QML_SOURCES
)
file
(
STRINGS
${
QRC_RESOURCES
}
QRC_RESOURCES_CONTENT
)
file
(
STRINGS
${
QRC_RESOURCES
}
QRC_RESOURCES_CONTENT
)
...
@@ -149,18 +149,18 @@ add_custom_target(
...
@@ -149,18 +149,18 @@ add_custom_target(
COMMAND
"
${
CMAKE_SOURCE_DIR
}
/tools/check_qml_syntax"
COMMAND
"
${
CMAKE_SOURCE_DIR
}
/tools/check_qml_syntax"
)
)
# --------------------------------------------------------------------
# --------------------------------------------------------------------
----------
# Init git hooks.
# Init git hooks.
# --------------------------------------------------------------------
# --------------------------------------------------------------------
----------
execute_process
(
COMMAND
${
CMAKE_COMMAND
}
-E copy
execute_process
(
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
CMAKE_SOURCE_DIR
}
/tools/private/pre-commit"
"
${
CMAKE_SOURCE_DIR
}
/tools/private/pre-commit"
"
${
CMAKE_SOURCE_DIR
}
/../.git/hooks/pre-commit"
"
${
CMAKE_SOURCE_DIR
}
/../.git/hooks/pre-commit"
)
)
# --------------------------------------------------------------------
# --------------------------------------------------------------------
----------
# Build.
# Build.
# --------------------------------------------------------------------
# --------------------------------------------------------------------
----------
find_package
(
Qt5 COMPONENTS
${
QT5_PACKAGES
}
)
find_package
(
Qt5 COMPONENTS
${
QT5_PACKAGES
}
)
...
...
tests/src/app/App.cpp
View file @
758dd1c0
...
@@ -63,8 +63,9 @@ App::App (int &argc, char **argv) : QApplication(argc, argv) {
...
@@ -63,8 +63,9 @@ App::App (int &argc, char **argv) : QApplication(argc, argv) {
void
App
::
initContentApp
()
{
void
App
::
initContentApp
()
{
qInfo
()
<<
"Initializing core manager..."
;
qInfo
()
<<
"Initializing core manager..."
;
// Init core.
// Init core
& contacts
.
CoreManager
::
init
();
CoreManager
::
init
();
ContactsListModel
::
init
();
// Register types and load context properties.
// Register types and load context properties.
registerTypes
();
registerTypes
();
...
@@ -86,13 +87,18 @@ void App::initContentApp () {
...
@@ -86,13 +87,18 @@ void App::initContentApp () {
void
App
::
registerTypes
()
{
void
App
::
registerTypes
()
{
qInfo
()
<<
"Registering types..."
;
qInfo
()
<<
"Registering types..."
;
// Register meta types.
qmlRegisterUncreatableType
<
ContactModel
>
(
"Linphone"
,
1
,
0
,
"ContactModel"
,
"ContactModel is uncreatable"
);
qmlRegisterUncreatableType
<
VcardModel
>
(
"Linphone"
,
1
,
0
,
"VcardModel"
,
"VcardModel is uncreatable"
);
qmlRegisterUncreatableType
<
Presence
>
(
qmlRegisterUncreatableType
<
Presence
>
(
"Linphone"
,
1
,
0
,
"Presence"
,
"Presence is uncreatable"
"Linphone"
,
1
,
0
,
"Presence"
,
"Presence is uncreatable"
);
);
qRegisterMetaType
<
ChatModel
::
EntryType
>
(
"ChatModel::EntryType"
);
qRegisterMetaType
<
ChatModel
::
EntryType
>
(
"ChatModel::EntryType"
);
// Register Application/Core.
qmlRegisterSingletonType
<
App
>
(
qmlRegisterSingletonType
<
App
>
(
"Linphone"
,
1
,
0
,
"App"
,
"Linphone"
,
1
,
0
,
"App"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
...
@@ -107,28 +113,10 @@ void App::registerTypes () {
...
@@ -107,28 +113,10 @@ void App::registerTypes () {
}
}
);
);
// Register models.
qmlRegisterType
<
Camera
>
(
"Linphone"
,
1
,
0
,
"Camera"
);
qmlRegisterUncreatableType
<
ContactModel
>
(
"Linphone"
,
1
,
0
,
"ContactModel"
,
"ContactModel is uncreatable"
);
qmlRegisterUncreatableType
<
VcardModel
>
(
"Linphone"
,
1
,
0
,
"VcardModel"
,
"VcardModel is uncreatable"
);
ContactsListProxyModel
::
initContactsListModel
(
new
ContactsListModel
());
qmlRegisterType
<
ContactsListProxyModel
>
(
"Linphone"
,
1
,
0
,
"ContactsListProxyModel"
);
qmlRegisterType
<
ChatModel
>
(
"Linphone"
,
1
,
0
,
"ChatModel"
);
qmlRegisterType
<
ChatProxyModel
>
(
"Linphone"
,
1
,
0
,
"ChatProxyModel"
);
// Register singletons.
qmlRegisterSingletonType
<
ContactsListModel
>
(
qmlRegisterSingletonType
<
ContactsListModel
>
(
"Linphone"
,
1
,
0
,
"ContactsListModel"
,
"Linphone"
,
1
,
0
,
"ContactsListModel"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
ContactsList
ProxyModel
::
getContactsListModel
();
return
ContactsList
Model
::
getInstance
();
}
}
);
);
...
@@ -142,9 +130,14 @@ void App::registerTypes () {
...
@@ -142,9 +130,14 @@ void App::registerTypes () {
qmlRegisterSingletonType
<
TimelineModel
>
(
qmlRegisterSingletonType
<
TimelineModel
>
(
"Linphone"
,
1
,
0
,
"TimelineModel"
,
"Linphone"
,
1
,
0
,
"TimelineModel"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
new
TimelineModel
(
ContactsListProxyModel
::
getContactsListModel
()
);
return
new
TimelineModel
();
}
}
);
);
qmlRegisterType
<
Camera
>
(
"Linphone"
,
1
,
0
,
"Camera"
);
qmlRegisterType
<
ContactsListProxyModel
>
(
"Linphone"
,
1
,
0
,
"ContactsListProxyModel"
);
qmlRegisterType
<
ChatModel
>
(
"Linphone"
,
1
,
0
,
"ChatModel"
);
qmlRegisterType
<
ChatProxyModel
>
(
"Linphone"
,
1
,
0
,
"ChatProxyModel"
);
}
}
void
App
::
addContextProperties
()
{
void
App
::
addContextProperties
()
{
...
...
tests/src/components/contacts/ContactsListModel.cpp
View file @
758dd1c0
...
@@ -10,6 +10,8 @@ using namespace std;
...
@@ -10,6 +10,8 @@ using namespace std;
// =============================================================================
// =============================================================================
ContactsListModel
*
ContactsListModel
::
m_instance
=
nullptr
;
ContactsListModel
::
ContactsListModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{
ContactsListModel
::
ContactsListModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{
m_linphone_friends
=
CoreManager
::
getInstance
()
->
getCore
()
->
getFriendsLists
().
front
();
m_linphone_friends
=
CoreManager
::
getInstance
()
->
getCore
()
->
getFriendsLists
().
front
();
...
...
tests/src/components/contacts/ContactsListModel.hpp
View file @
758dd1c0
...
@@ -14,7 +14,6 @@ class ContactsListModel : public QAbstractListModel {
...
@@ -14,7 +14,6 @@ class ContactsListModel : public QAbstractListModel {
friend
class
ContactsListProxyModel
;
friend
class
ContactsListProxyModel
;
public:
public:
ContactsListModel
(
QObject
*
parent
=
Q_NULLPTR
);
~
ContactsListModel
()
=
default
;
~
ContactsListModel
()
=
default
;
int
rowCount
(
const
QModelIndex
&
index
=
QModelIndex
())
const
override
;
int
rowCount
(
const
QModelIndex
&
index
=
QModelIndex
())
const
override
;
...
@@ -25,6 +24,16 @@ public:
...
@@ -25,6 +24,16 @@ public:
bool
removeRow
(
int
row
,
const
QModelIndex
&
parent
=
QModelIndex
());
bool
removeRow
(
int
row
,
const
QModelIndex
&
parent
=
QModelIndex
());
bool
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
=
QModelIndex
())
override
;
bool
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
=
QModelIndex
())
override
;
static
void
init
()
{
if
(
!
ContactsListModel
::
m_instance
)
{
m_instance
=
new
ContactsListModel
();
}
}
static
ContactsListModel
*
getInstance
()
{
return
m_instance
;
}
public
slots
:
public
slots
:
ContactModel
*
mapSipAddressToContact
(
const
QString
&
sipAddress
)
const
;
ContactModel
*
mapSipAddressToContact
(
const
QString
&
sipAddress
)
const
;
...
@@ -32,8 +41,12 @@ public slots:
...
@@ -32,8 +41,12 @@ public slots:
void
removeContact
(
ContactModel
*
contact
);
void
removeContact
(
ContactModel
*
contact
);
private:
private:
ContactsListModel
(
QObject
*
parent
=
Q_NULLPTR
);
QList
<
ContactModel
*>
m_list
;
QList
<
ContactModel
*>
m_list
;
std
::
shared_ptr
<
linphone
::
FriendList
>
m_linphone_friends
;
std
::
shared_ptr
<
linphone
::
FriendList
>
m_linphone_friends
;
static
ContactsListModel
*
m_instance
;
};
};
#endif // CONTACTS_LIST_MODEL_H_
#endif // CONTACTS_LIST_MODEL_H_
tests/src/components/contacts/ContactsListProxyModel.cpp
View file @
758dd1c0
#include <QDebug>
#include <QDebug>
#include "../../utils.hpp"
#include "../../utils.hpp"
#include "ContactsListModel.hpp"
#include "ContactsListProxyModel.hpp"
#include "ContactsListProxyModel.hpp"
...
@@ -17,8 +18,6 @@ using namespace std;
...
@@ -17,8 +18,6 @@ using namespace std;
// =============================================================================
// =============================================================================
ContactsListModel
*
ContactsListProxyModel
::
m_list
=
nullptr
;
// Notes:
// Notes:
//
//
// - First `^` is necessary to search two words with one separator
// - First `^` is necessary to search two words with one separator
...
@@ -33,8 +32,7 @@ const QRegExp ContactsListProxyModel::m_search_separators("^[^_.-;@ ][_.-;@ ]");
...
@@ -33,8 +32,7 @@ const QRegExp ContactsListProxyModel::m_search_separators("^[^_.-;@ ][_.-;@ ]");
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
ContactsListProxyModel
::
ContactsListProxyModel
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
)
{
ContactsListProxyModel
::
ContactsListProxyModel
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
)
{
if
(
m_list
==
nullptr
)
m_list
=
ContactsListModel
::
getInstance
();
qFatal
(
"Contacts list model is undefined."
);
setSourceModel
(
m_list
);
setSourceModel
(
m_list
);
setFilterCaseSensitivity
(
Qt
::
CaseInsensitive
);
setFilterCaseSensitivity
(
Qt
::
CaseInsensitive
);
...
@@ -46,13 +44,6 @@ ContactsListProxyModel::ContactsListProxyModel (QObject *parent) : QSortFilterPr
...
@@ -46,13 +44,6 @@ ContactsListProxyModel::ContactsListProxyModel (QObject *parent) : QSortFilterPr
sort
(
0
);
sort
(
0
);
}
}
void
ContactsListProxyModel
::
initContactsListModel
(
ContactsListModel
*
list
)
{
if
(
!
m_list
)
m_list
=
list
;
else
qWarning
()
<<
"Contacts list model is already defined."
;
}
bool
ContactsListProxyModel
::
filterAcceptsRow
(
bool
ContactsListProxyModel
::
filterAcceptsRow
(
int
source_row
,
int
source_row
,
const
QModelIndex
&
source_parent
const
QModelIndex
&
source_parent
...
...
tests/src/components/contacts/ContactsListProxyModel.hpp
View file @
758dd1c0
...
@@ -3,10 +3,12 @@
...
@@ -3,10 +3,12 @@
#include <QSortFilterProxyModel>
#include <QSortFilterProxyModel>
#include "
ContactsLis
tModel.hpp"
#include "
../contact/Contac
tModel.hpp"
// =============================================================================
// =============================================================================
class
ContactsListModel
;
class
ContactsListProxyModel
:
public
QSortFilterProxyModel
{
class
ContactsListProxyModel
:
public
QSortFilterProxyModel
{
Q_OBJECT
;
Q_OBJECT
;
...
@@ -20,11 +22,6 @@ public:
...
@@ -20,11 +22,6 @@ public:
ContactsListProxyModel
(
QObject
*
parent
=
Q_NULLPTR
);
ContactsListProxyModel
(
QObject
*
parent
=
Q_NULLPTR
);
~
ContactsListProxyModel
()
=
default
;
~
ContactsListProxyModel
()
=
default
;
static
void
initContactsListModel
(
ContactsListModel
*
list
);
static
ContactsListModel
*
getContactsListModel
()
{
return
m_list
;
}
public
slots
:
public
slots
:
void
setFilter
(
const
QString
&
pattern
)
{
void
setFilter
(
const
QString
&
pattern
)
{
setFilterFixedString
(
pattern
);
setFilterFixedString
(
pattern
);
...
@@ -45,17 +42,14 @@ private:
...
@@ -45,17 +42,14 @@ private:
void
setConnectedFilter
(
bool
use_connected_filter
);
void
setConnectedFilter
(
bool
use_connected_filter
);
ContactsListModel
*
m_list
;
bool
m_use_connected_filter
=
false
;
// It's just a cache to save values computed by `filterAcceptsRow`
// It's just a cache to save values computed by `filterAcceptsRow`
// and reused by `lessThan`.
// and reused by `lessThan`.
mutable
QHash
<
const
ContactModel
*
,
unsigned
int
>
m_weights
;
mutable
QHash
<
const
ContactModel
*
,
unsigned
int
>
m_weights
;
bool
m_use_connected_filter
=
false
;
static
const
QRegExp
m_search_separators
;
static
const
QRegExp
m_search_separators
;
// The contacts list is shared between `ContactsListProxyModel`
// it's necessary to initialize it with `initContactsListModel`.
static
ContactsListModel
*
m_list
;
};
};
#endif // CONTACTS_LIST_PROXY_MODEL_H_
#endif // CONTACTS_LIST_PROXY_MODEL_H_
tests/src/components/timeline/TimelineModel.cpp
View file @
758dd1c0
...
@@ -14,13 +14,13 @@ using namespace std;
...
@@ -14,13 +14,13 @@ using namespace std;
// ===================================================================
// ===================================================================
TimelineModel
::
TimelineModel
(
const
ContactsListModel
*
contacts_lis
t
)
{
TimelineModel
::
TimelineModel
(
QObject
*
parent
)
:
QAbstractListModel
(
paren
t
)
{
init_entries
();
init_entries
();
// Invalidate model if a contact is removed.
// Invalidate model if a contact is removed.
// Better than compare each sip address.
// Better than compare each sip address.
connect
(
connect
(
contacts_list
,
&
ContactsListModel
::
rowsRemoved
,
this
,
ContactsListModel
::
getInstance
()
,
&
ContactsListModel
::
rowsRemoved
,
this
,
[
this
](
const
QModelIndex
&
,
int
,
int
)
{
[
this
](
const
QModelIndex
&
,
int
,
int
)
{
beginResetModel
();
beginResetModel
();
// Nothing.
// Nothing.
...
...
tests/src/components/timeline/TimelineModel.hpp
View file @
758dd1c0
...
@@ -11,7 +11,7 @@ class TimelineModel : public QAbstractListModel {
...
@@ -11,7 +11,7 @@ class TimelineModel : public QAbstractListModel {
Q_OBJECT
;
Q_OBJECT
;
public:
public:
TimelineModel
(
const
ContactsListModel
*
contacts_list
);
TimelineModel
(
QObject
*
parent
=
Q_NULLPTR
);
int
rowCount
(
const
QModelIndex
&
)
const
override
;
int
rowCount
(
const
QModelIndex
&
)
const
override
;
QHash
<
int
,
QByteArray
>
roleNames
()
const
override
;
QHash
<
int
,
QByteArray
>
roleNames
()
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