Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-qt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-qt
Commits
cda1f335
Commit
cda1f335
authored
2 years ago
by
Andreas Traczyk
Browse files
Options
Downloads
Patches
Plain Diff
messagelistmodel: replace C++ filter proxy model with QML-SFPM
Change-Id: I7471b4cf5539bd253d4d1b9e9b2bfd10030a9525
parent
f644ab8a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/mainview/components/MessageListView.qml
+17
-1
17 additions, 1 deletion
src/app/mainview/components/MessageListView.qml
src/app/messagesadapter.cpp
+5
-10
5 additions, 10 deletions
src/app/messagesadapter.cpp
src/app/messagesadapter.h
+0
-28
0 additions, 28 deletions
src/app/messagesadapter.h
with
22 additions
and
39 deletions
src/app/mainview/components/MessageListView.qml
+
17
−
1
View file @
cda1f335
...
...
@@ -22,6 +22,8 @@ import QtQuick.Controls
import
QtQuick
.
Layouts
import
Qt
.
labs
.
qmlmodels
import
SortFilterProxyModel
0.2
import
net
.
jami
.
Models
1.1
import
net
.
jami
.
Adapters
1.1
import
net
.
jami
.
Constants
1.1
...
...
@@ -194,7 +196,21 @@ JamiListView {
boundsBehavior
:
Flickable
.
StopAtBounds
currentIndex
:
-
1
model
:
MessagesAdapter
.
messageListModel
model
:
SortFilterProxyModel
{
// There doesn't seem to a subscription to property change
// events in the expression for sourceModel. This was originally
// masked behind an unchanging QSortFilterProxyModel object that
// just reset it's sourceModel in MessagesAdapter.
property
var
messageListModel
:
MessagesAdapter
.
messageListModel
onMessageListModelChanged
:
sourceModel
=
messageListModel
filters
:
ExpressionFilter
{
readonly
property
int
mergeType
:
Interaction
.
Type
.
MERGE
expression
:
Body
!==
""
&&
Type
!==
mergeType
}
sorters
:
ExpressionSorter
{
expression
:
modelLeft
.
index
>
modelRight
.
index
}
}
delegate
:
DelegateChooser
{
id
:
delegateChooser
...
...
This diff is collapsed.
Click to expand it.
src/app/messagesadapter.cpp
+
5
−
10
View file @
cda1f335
...
...
@@ -49,18 +49,13 @@ MessagesAdapter::MessagesAdapter(AppSettingsManager* settingsManager,
:
QmlAdapterBase
(
instance
,
parent
)
,
settingsManager_
(
settingsManager
)
,
previewEngine_
(
previewEngine
)
,
filteredMsgListModel_
(
new
FilteredMsgListModel
(
this
))
{
connect
(
lrcInstance_
,
&
LRCInstance
::
selectedConvUidChanged
,
[
this
]()
{
set_replyToId
(
""
);
const
QString
&
convId
=
lrcInstance_
->
get_selectedConvUid
();
const
auto
&
conversation
=
lrcInstance_
->
getConversationFromConvUid
(
convId
);
filteredMsgListModel_
->
setSourceModel
(
conversation
.
interactions
.
get
());
set_messageListModel
(
QVariant
::
fromValue
(
filteredMsgListModel_
));
if
(
!
conversation
.
typers
.
empty
())
set_currentConvComposingList
(
conversationTypersUrlToName
(
conversation
.
typers
));
else
set_currentConvComposingList
({});
set_messageListModel
(
QVariant
::
fromValue
(
conversation
.
interactions
.
get
()));
set_currentConvComposingList
(
conversationTypersUrlToName
(
conversation
.
typers
));
});
connect
(
previewEngine_
,
&
PreviewEngine
::
infoReady
,
this
,
&
MessagesAdapter
::
onPreviewInfoReady
);
...
...
@@ -104,7 +99,7 @@ MessagesAdapter::loadMoreMessages()
void
MessagesAdapter
::
loadConversationUntil
(
const
QString
&
to
)
{
if
(
auto
*
model
=
static_cast
<
M
essageListModel
*>
(
filteredMsgListModel_
->
sourceModel
()
))
{
if
(
auto
*
model
=
m
essageListModel
_
.
value
<
MessageListModel
*>
(
))
{
auto
idx
=
model
->
indexOfMessage
(
to
);
if
(
idx
==
-
1
)
{
auto
accountId
=
lrcInstance_
->
get_currentAccountId
();
...
...
@@ -324,7 +319,7 @@ MessagesAdapter::getTransferStats(const QString& msgId, int status)
QVariant
MessagesAdapter
::
dataForInteraction
(
const
QString
&
interactionId
,
int
role
)
const
{
if
(
auto
*
model
=
static_cast
<
M
essageListModel
*>
(
filteredMsgListModel_
->
sourceModel
()
))
{
if
(
auto
*
model
=
m
essageListModel
_
.
value
<
MessageListModel
*>
(
))
{
auto
idx
=
model
->
indexOfMessage
(
interactionId
);
if
(
idx
!=
-
1
)
return
model
->
data
(
idx
,
role
);
...
...
@@ -335,7 +330,7 @@ MessagesAdapter::dataForInteraction(const QString& interactionId, int role) cons
int
MessagesAdapter
::
getIndexOfMessage
(
const
QString
&
interactionId
)
const
{
if
(
auto
*
model
=
static_cast
<
M
essageListModel
*>
(
filteredMsgListModel_
->
sourceModel
()
))
{
if
(
auto
*
model
=
m
essageListModel
_
.
value
<
MessageListModel
*>
(
))
{
return
model
->
indexOfMessage
(
interactionId
);
}
return
{};
...
...
This diff is collapsed.
Click to expand it.
src/app/messagesadapter.h
+
0
−
28
View file @
cda1f335
...
...
@@ -25,33 +25,6 @@
#include
<QObject>
#include
<QString>
#include
<QSortFilterProxyModel>
class
FilteredMsgListModel
final
:
public
QSortFilterProxyModel
{
Q_OBJECT
public:
explicit
FilteredMsgListModel
(
QObject
*
parent
=
nullptr
)
:
QSortFilterProxyModel
(
parent
)
{
sort
(
0
,
Qt
::
AscendingOrder
);
}
bool
filterAcceptsRow
(
int
sourceRow
,
const
QModelIndex
&
sourceParent
)
const
override
{
auto
index
=
sourceModel
()
->
index
(
sourceRow
,
0
,
sourceParent
);
auto
type
=
sourceModel
()
->
data
(
index
,
MessageList
::
Role
::
Type
).
toInt
();
auto
hasBody
=
!
sourceModel
()
->
data
(
index
,
MessageList
::
Role
::
Body
).
toString
().
isEmpty
();
return
static_cast
<
interaction
::
Type
>
(
type
)
!=
interaction
::
Type
::
MERGE
&&
hasBody
;
};
bool
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
override
{
return
left
.
row
()
>
right
.
row
();
};
};
class
AppSettingsManager
;
class
MessagesAdapter
final
:
public
QmlAdapterBase
...
...
@@ -138,7 +111,6 @@ private:
AppSettingsManager
*
settingsManager_
;
PreviewEngine
*
previewEngine_
;
FilteredMsgListModel
*
filteredMsgListModel_
;
static
constexpr
const
int
loadChunkSize_
{
20
};
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment