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
cb598949
Commit
cb598949
authored
Oct 03, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(app): filter/sorter is provided for any instances
parent
62f034db
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
22 deletions
+49
-22
ContactModel.cpp
tests/src/components/contacts/ContactModel.cpp
+11
-0
ContactModel.hpp
tests/src/components/contacts/ContactModel.hpp
+1
-10
ContactsListProxyModel.cpp
tests/src/components/contacts/ContactsListProxyModel.cpp
+26
-2
ContactsListProxyModel.hpp
tests/src/components/contacts/ContactsListProxyModel.hpp
+4
-6
main.cpp
tests/src/main.cpp
+3
-0
Contacts.qml
tests/ui/views/MainWindow/Contacts.qml
+4
-4
No files found.
tests/src/components/contacts/ContactModel.cpp
View file @
cb598949
#include "ContactModel.hpp"
// ===================================================================
ContactModel
::
PresenceLevel
ContactModel
::
getPresenceLevel
()
const
{
if
(
m_presence
==
Online
)
return
Green
;
if
(
m_presence
==
DoNotDisturb
)
return
Red
;
if
(
m_presence
==
Offline
)
return
White
;
return
Orange
;
}
tests/src/components/contacts/ContactModel.hpp
View file @
cb598949
...
...
@@ -100,16 +100,7 @@ private:
return
m_presence
;
}
PresenceLevel
getPresenceLevel
()
const
{
if
(
m_presence
==
Online
)
return
Green
;
if
(
m_presence
==
DoNotDisturb
)
return
Red
;
if
(
m_presence
==
Offline
)
return
White
;
return
Orange
;
}
PresenceLevel
getPresenceLevel
()
const
;
QStringList
getSipAddresses
()
const
{
return
m_sip_addresses
;
...
...
tests/src/components/contacts/ContactsListProxyModel.cpp
View file @
cb598949
#include "ContactsListProxyModel.hpp"
#include <QDebug>
#include "ContactsListProxyModel.hpp"
// ===================================================================
ContactsListModel
*
ContactsListProxyModel
::
m_list
=
nullptr
;
ContactsListProxyModel
::
ContactsListProxyModel
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
)
{
setSourceModel
(
m_list
);
setDynamicSortFilter
(
true
);
sort
(
0
);
}
void
ContactsListProxyModel
::
initContactsListModel
(
ContactsListModel
*
list
)
{
if
(
!
m_list
)
m_list
=
list
;
else
qWarning
()
<<
"Contacts list model already defined."
;
}
bool
ContactsListProxyModel
::
filterAcceptsRow
(
int
source_row
,
const
QModelIndex
&
source_parent
)
const
{
QModelIndex
index
=
sourceModel
()
->
index
(
source_row
,
0
,
source_parent
);
const
ContactModel
*
contact
=
qvariant_cast
<
ContactModel
*>
(
index
.
data
(
ContactsListModel
::
ContactRole
)
);
qDebug
()
<<
"A"
;
return
contact
->
getUsername
().
contains
(
filterRegExp
().
pattern
(),
Qt
::
CaseInsensitive
);
}
bool
ContactsListProxyModel
::
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
{
qDebug
()
<<
"B"
;
return
true
;
}
tests/src/components/contacts/ContactsListProxyModel.hpp
View file @
cb598949
...
...
@@ -11,17 +11,15 @@ class ContactsListProxyModel : public QSortFilterProxyModel {
Q_OBJECT
;
public:
ContactsListProxyModel
(
QObject
*
parent
=
Q_NULLPTR
)
:
QSortFilterProxyModel
(
parent
)
{
setSourceModel
(
&
m_list
);
setDynamicSortFilter
(
true
);
sort
(
0
);
}
ContactsListProxyModel
(
QObject
*
parent
=
Q_NULLPTR
);
static
void
initContactsListModel
(
ContactsListModel
*
list
);
protected:
bool
filterAcceptsRow
(
int
source_row
,
const
QModelIndex
&
source_parent
)
const
;
bool
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
;
private:
ContactsListModel
m_list
;
static
ContactsListModel
*
m_list
;
};
#endif // CONTACTS_LIST_PROXY_MODEL_H
tests/src/main.cpp
View file @
cb598949
...
...
@@ -51,6 +51,9 @@ void registerTypes () {
qmlRegisterUncreatableType
<
ContactModel
>
(
"Linphone"
,
1
,
0
,
"ContactModel"
,
"ContactModel is uncreatable"
);
ContactsListProxyModel
::
initContactsListModel
(
new
ContactsListModel
());
qmlRegisterType
<
ContactsListProxyModel
>
(
"Linphone"
,
1
,
0
,
"ContactsListModel"
);
}
void
addContextProperties
(
QQmlApplicationEngine
&
engine
)
{
...
...
tests/ui/views/MainWindow/Contacts.qml
View file @
cb598949
...
...
@@ -32,9 +32,7 @@ ColumnLayout {
}
placeholderText
:
qsTr
(
'
searchContactPlaceholder
'
)
Component.onCompleted
:
ContactsListModel
.
setFilterRegExp
(
''
)
onTextChanged
:
ContactsListModel
.
setFilterRegExp
(
text
)
onTextChanged
:
contacts
.
setFilterRegExp
(
text
)
}
ExclusiveButtons
{
...
...
@@ -62,7 +60,9 @@ ColumnLayout {
anchors.fill
:
parent
spacing
:
2
model
:
ContactsListModel
model
:
ContactsListModel
{
id
:
contacts
}
delegate
:
Rectangle
{
id
:
contact
...
...
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