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
55a4e008
Commit
55a4e008
authored
Nov 29, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unstable
parent
2a19553f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
119 additions
and
31 deletions
+119
-31
CMakeLists.txt
tests/CMakeLists.txt
+2
-0
fr.ts
tests/assets/languages/fr.ts
+2
-2
ChatModelFilter.cpp
tests/src/components/chat/ChatModelFilter.cpp
+19
-0
ChatModelFilter.hpp
tests/src/components/chat/ChatModelFilter.hpp
+35
-0
ChatProxyModel.cpp
tests/src/components/chat/ChatProxyModel.cpp
+25
-13
ChatProxyModel.hpp
tests/src/components/chat/ChatProxyModel.hpp
+22
-16
Chat.qml
tests/ui/modules/Linphone/Chat/Chat.qml
+14
-0
No files found.
tests/CMakeLists.txt
View file @
55a4e008
...
...
@@ -35,6 +35,7 @@ set(SOURCES
src/app/DefaultTranslator.cpp
src/app/Logger.cpp
src/components/chat/ChatModel.cpp
src/components/chat/ChatModelFilter.cpp
src/components/chat/ChatProxyModel.cpp
src/components/contacts/ContactModel.cpp
src/components/contacts/ContactsListModel.cpp
...
...
@@ -55,6 +56,7 @@ set(HEADERS
src/app/DefaultTranslator.hpp
src/app/Logger.hpp
src/components/chat/ChatModel.hpp
src/components/chat/ChatModelFilter.hpp
src/components/chat/ChatProxyModel.hpp
src/components/contacts/ContactModel.hpp
src/components/contacts/ContactsListModel.hpp
...
...
tests/assets/languages/fr.ts
View file @
55a4e008
...
...
@@ -139,7 +139,7 @@
<
/message
>
<
message
>
<
source
>
removeAllEntriesTitle
<
/source
>
<
translation
>
Suppression
de
l
'
historique</translation>
<
translation
>
Suppression
de
l
&
apos
;
historique
<
/translation
>
<
/message
>
<
/context
>
<
context
>
...
...
@@ -184,7 +184,7 @@
<
/message
>
<
message
>
<
source
>
endedCall
<
/source
>
<translation>Fin d
'
appel
<
/translation
>
<
translation
>
Fin
d
&
apos
;
appel
<
/translation
>
<
/message
>
<
message
>
<
source
>
missedIncomingCall
<
/source
>
...
...
tests/src/components/chat/ChatModelFilter.cpp
0 → 100644
View file @
55a4e008
#include "ChatProxyModel.hpp"
// ===================================================================
ChatModelFilter
::
ChatModelFilter
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
)
{
setSourceModel
(
&
m_chat_model
);
}
bool
ChatModelFilter
::
filterAcceptsRow
(
int
source_row
,
const
QModelIndex
&
source_parent
)
const
{
if
(
m_entry_type_filter
==
ChatModel
::
EntryType
::
GenericEntry
)
return
true
;
QModelIndex
index
=
sourceModel
()
->
index
(
source_row
,
0
,
QModelIndex
());
const
QVariantMap
&
data
=
qvariant_cast
<
QVariantMap
>
(
index
.
data
()
);
return
data
[
"type"
].
toInt
()
==
m_entry_type_filter
;
}
tests/src/components/chat/ChatModelFilter.hpp
0 → 100644
View file @
55a4e008
#ifndef CHAT_MODEL_FILTER_H_
#define CHAT_MODEL_FILTER_H_
#include <QSortFilterProxyModel>
#include "ChatModel.hpp"
#include <QtDebug>
// ===================================================================
// Fetch K filtered chat entries.
// ===================================================================
class
ChatModelFilter
:
public
QSortFilterProxyModel
{
friend
class
ChatProxyModel
;
Q_OBJECT
;
public:
ChatModelFilter
(
QObject
*
parent
=
Q_NULLPTR
);
protected:
bool
filterAcceptsRow
(
int
source_row
,
const
QModelIndex
&
source_parent
)
const
;
private:
void
setEntryTypeFilter
(
ChatModel
::
EntryType
type
)
{
m_entry_type_filter
=
type
;
invalidateFilter
();
}
ChatModel
m_chat_model
;
ChatModel
::
EntryType
m_entry_type_filter
=
ChatModel
::
EntryType
::
GenericEntry
;
};
#endif // CHAT_MODEL_FILTER_H_
tests/src/components/chat/ChatProxyModel.cpp
View file @
55a4e008
...
...
@@ -2,25 +2,37 @@
// ===================================================================
const
unsigned
int
ChatProxyModel
::
ENTRIES_CHUNK_SIZE
=
25
;
ChatProxyModel
::
ChatProxyModel
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
)
{
m_chat_model
.
setParent
(
this
);
setSourceModel
(
&
m_chat_model
);
setSourceModel
(
&
m_chat_model_filter
);
}
void
ChatProxyModel
::
removeEntry
(
int
id
)
{
m_chat_model
.
removeEntry
(
mapToSource
(
index
(
id
,
0
)).
row
()
);
int
ChatProxyModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
int
size
=
QSortFilterProxyModel
::
rowCount
(
parent
);
return
size
<
m_n_max_displayed_entries
?
size
:
m_n_max_displayed_entries
;
}
bool
ChatProxyModel
::
filterAcceptsRow
(
int
source_row
,
const
QModelIndex
&
source_parent
)
const
{
if
(
m_entry_type_filter
==
ChatModel
::
EntryType
::
GenericEntry
)
return
true
;
QVariant
ChatProxyModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
QAbstractItemModel
*
model
=
sourceModel
();
QModelIndex
index
=
sourceModel
()
->
index
(
source_row
,
0
,
source_parent
);
const
QVariantMap
&
data
=
qvariant_cast
<
QVariantMap
>
(
index
.
data
()
return
model
->
data
(
model
->
index
(
mapToSource
(
index
).
row
()
+
(
model
->
rowCount
()
-
rowCount
()),
0
),
role
);
}
return
data
[
"type"
].
toInt
()
==
m_entry_type_filter
;
void
ChatProxyModel
::
loadMoreEntries
()
{
// TODO.
}
void
ChatProxyModel
::
removeEntry
(
int
id
)
{
QModelIndex
source_index
=
mapToSource
(
index
(
id
,
0
));
static_cast
<
ChatModel
*>
(
m_chat_model_filter
.
sourceModel
())
->
removeEntry
(
mapToSource
(
source_index
).
row
()
);
}
tests/src/components/chat/ChatProxyModel.hpp
View file @
55a4e008
#ifndef CHAT_PROXY_MODEL_H_
#define CHAT_PROXY_MODEL_H_
#include <QSortFilterProxyModel>
#include "ChatModel.hpp"
#include "ChatModelFilter.hpp"
// ===================================================================
// Fetch the L last filtered chat entries.
// ===================================================================
class
ChatProxyModel
:
public
QSortFilterProxyModel
{
...
...
@@ -23,32 +23,38 @@ signals:
public:
ChatProxyModel
(
QObject
*
parent
=
Q_NULLPTR
);
public
slots
:
void
removeEntry
(
int
id
)
;
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
override
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
override
;
void
removeAllEntries
()
{
m_chat_model
.
removeAllEntries
();
}
public
slots
:
void
loadMoreEntries
();
void
setEntryTypeFilter
(
ChatModel
::
EntryType
type
)
{
m_entry_type_filter
=
type
;
invalidateFilter
();
m_chat_model_filter
.
setEntryTypeFilter
(
type
);
}
protected:
bool
filterAcceptsRow
(
int
source_row
,
const
QModelIndex
&
source_parent
)
const
;
void
removeEntry
(
int
id
);
void
removeAllEntries
()
{
static_cast
<
ChatModel
*>
(
m_chat_model_filter
.
sourceModel
())
->
removeAllEntries
();
}
private:
QString
getSipAddress
()
const
{
return
m_chat_model
.
getSipAddress
();
static_cast
<
ChatModel
*>
(
m_chat_model_filter
.
sourceModel
())
->
getSipAddress
();
}
void
setSipAddress
(
const
QString
&
sip_address
)
{
m_chat_model
.
setSipAddress
(
sip_address
);
static_cast
<
ChatModel
*>
(
m_chat_model_filter
.
sourceModel
())
->
setSipAddress
(
sip_address
);
}
ChatModel
m_chat_model
;
ChatModel
::
EntryType
m_entry_type_filter
=
ChatModel
::
EntryType
::
GenericEntry
;
ChatModelFilter
m_chat_model_filter
;
unsigned
int
m_n_max_displayed_entries
=
ENTRIES_CHUNK_SIZE
;
static
const
unsigned
int
ENTRIES_CHUNK_SIZE
;
};
#endif // CHAT_PROXY_MODEL_H_
tests/ui/modules/Linphone/Chat/Chat.qml
View file @
55a4e008
...
...
@@ -21,6 +21,18 @@ ColumnLayout {
ScrollableListView
{
id
:
chat
property
bool
_tryToLoadMoreEntries
:
false
function
_loadMoreEntries
()
{
if
(
chat
.
contentY
>
500
||
_tryToLoadMoreEntries
)
{
return
}
_tryToLoadMoreEntries
=
true
proxyModel
.
loadMoreEntries
()
}
Layout.fillHeight
:
true
Layout.fillWidth
:
true
...
...
@@ -164,6 +176,8 @@ ColumnLayout {
}
}
}
onContentYChanged
:
_loadMoreEntries
()
}
// -----------------------------------------------------------------
...
...
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