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
a9d43492
Commit
a9d43492
authored
Nov 30, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(ui/modules/Linphone): load more entries dynamically
parent
a1fc6a63
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
9 deletions
+31
-9
ChatProxyModel.cpp
tests/src/components/chat/ChatProxyModel.cpp
+9
-1
ChatProxyModel.hpp
tests/src/components/chat/ChatProxyModel.hpp
+2
-1
Chat.qml
tests/ui/modules/Linphone/Chat/Chat.qml
+20
-7
No files found.
tests/src/components/chat/ChatProxyModel.cpp
View file @
a9d43492
#include "ChatProxyModel.hpp"
// ===================================================================
ChatModelFilter
::
ChatModelFilter
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
)
{
setSourceModel
(
&
m_chat_model
);
}
...
...
@@ -30,7 +32,13 @@ ChatProxyModel::ChatProxyModel (QObject *parent) : QSortFilterProxyModel(parent)
}
void
ChatProxyModel
::
loadMoreEntries
()
{
// TODO.
int
count
=
rowCount
();
m_n_max_displayed_entries
+=
ENTRIES_CHUNK_SIZE
;
invalidateFilter
();
if
(
count
<
rowCount
())
emit
moreEntriesLoaded
();
}
void
ChatProxyModel
::
removeEntry
(
int
id
)
{
...
...
tests/src/components/chat/ChatProxyModel.hpp
View file @
a9d43492
...
...
@@ -9,7 +9,7 @@
// Fetch the L last filtered chat entries.
// ===================================================================
// Cannot be used as a nested class by Qt and `Q_OBJECT
Y
` macro
// Cannot be used as a nested class by Qt and `Q_OBJECT` macro
// must be used in header c++ file.
class
ChatModelFilter
:
public
QSortFilterProxyModel
{
friend
class
ChatProxyModel
;
...
...
@@ -42,6 +42,7 @@ class ChatProxyModel : public QSortFilterProxyModel {
signals:
void
sipAddressChanged
(
const
QString
&
sipAddress
);
void
moreEntriesLoaded
();
public:
ChatProxyModel
(
QObject
*
parent
=
Q_NULLPTR
);
...
...
tests/ui/modules/Linphone/Chat/Chat.qml
View file @
a9d43492
...
...
@@ -14,6 +14,10 @@ ColumnLayout {
// Can be a model or a proxy chat model.
property
alias
proxyModel
:
chat
.
model
// Set the offset position to load more entries.
// Not a style property.
property
int
_loadMoreEntriesAtPosition
:
1
// -----------------------------------------------------------------
spacing
:
0
...
...
@@ -21,16 +25,16 @@ ColumnLayout {
ScrollableListView
{
id
:
chat
property
bool
_tryToLoadMoreEntries
:
fals
e
property
bool
_tryToLoadMoreEntries
:
tru
e
function
_loadMoreEntries
()
{
if
(
chat
.
contentY
>
500
||
_tryToLoadMoreEntries
)
{
return
if
(
chat
.
visibleArea
.
yPosition
*
chat
.
height
<=
_loadMoreEntriesAtPosition
&&
!
_tryToLoadMoreEntries
)
{
_tryToLoadMoreEntries
=
true
proxyModel
.
loadMoreEntries
()
}
_tryToLoadMoreEntries
=
true
proxyModel
.
loadMoreEntries
()
}
Layout.fillHeight
:
true
...
...
@@ -178,6 +182,15 @@ ColumnLayout {
}
onContentYChanged
:
_loadMoreEntries
()
Component.onCompleted
:
{
positionViewAtEnd
()
_tryToLoadMoreEntries
=
false
proxyModel
.
moreEntriesLoaded
.
connect
(
function
()
{
_tryToLoadMoreEntries
=
false
})
}
}
// -----------------------------------------------------------------
...
...
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