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
946491a5
Commit
946491a5
authored
3 years ago
by
Andreas Traczyk
Browse files
Options
Downloads
Patches
Plain Diff
conversationsadapter: replace signal reconnect with unique connect
Change-Id: I34b1dca62ad5b28b49ddf319c4ea9724efd66b21
parent
8152db58
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/conversationsadapter.cpp
+87
-84
87 additions, 84 deletions
src/conversationsadapter.cpp
src/conversationsadapter.h
+0
-15
0 additions, 15 deletions
src/conversationsadapter.h
with
87 additions
and
99 deletions
src/conversationsadapter.cpp
+
87
−
84
View file @
946491a5
...
...
@@ -155,7 +155,6 @@ ConversationsAdapter::deselectConversation()
void
ConversationsAdapter
::
onCurrentAccountIdChanged
()
{
disconnectConversationModel
();
connectConversationModel
();
setProperty
(
"currentTypeFilter"
,
...
...
@@ -265,8 +264,11 @@ ConversationsAdapter::connectConversationModel(bool updateFilter)
// Signal connections
auto
currentConversationModel
=
lrcInstance_
->
getCurrentConversationModel
();
modelSortedConnection_
=
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
modelChanged
,
[
this
]()
{
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
modelChanged
,
this
,
[
this
]()
{
conversationSmartListModel_
->
fillConversationsList
();
updateConversationsFilterWidget
();
...
...
@@ -284,76 +286,94 @@ ConversationsAdapter::connectConversationModel(bool updateFilter)
return
;
}
Q_EMIT
modelSorted
(
QVariant
::
fromValue
(
convInfo
.
uid
));
});
contactProfileUpdatedConnection_
=
QObject
::
connect
(
lrcInstance_
->
getCurrentAccountInfo
().
contactModel
.
get
(),
&
lrc
::
api
::
ContactModel
::
profileUpdated
,
[
this
](
const
QString
&
contactUri
)
{
conversationSmartListModel_
->
updateContactAvatarUid
(
contactUri
);
Q_EMIT
updateListViewRequested
();
});
modelUpdatedConnection_
=
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
conversationUpdated
,
[
this
](
const
QString
&
)
{
updateConversationsFilterWidget
();
Q_EMIT
updateListViewRequested
();
});
filterChangedConnection_
=
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
filterChanged
,
[
this
]()
{
conversationSmartListModel_
->
fillConversationsList
();
updateConversationsFilterWidget
();
if
(
!
lrcInstance_
->
get_selectedConvUid
().
isEmpty
())
Q_EMIT
indexRepositionRequested
();
Q_EMIT
updateListViewRequested
();
});
newConversationConnection_
=
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
newConversation
,
[
this
](
const
QString
&
convUid
)
{
conversationSmartListModel_
->
fillConversationsList
();
updateConversationForNewContact
(
convUid
);
});
conversationRemovedConnection_
=
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
conversationRemoved
,
[
this
]()
{
backToWelcomePage
();
});
conversationClearedConnection
=
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
conversationCleared
,
[
this
](
const
QString
&
convUid
)
{
// If currently selected, switch to welcome screen (deselecting
// current smartlist item).
if
(
convUid
!=
lrcInstance_
->
get_selectedConvUid
())
{
return
;
}
backToWelcomePage
();
});
searchStatusChangedConnection_
=
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
searchStatusChanged
,
[
this
](
const
QString
&
status
)
{
Q_EMIT
showSearchStatus
(
status
);
});
},
Qt
::
UniqueConnection
);
QObject
::
connect
(
lrcInstance_
->
getCurrentAccountInfo
().
contactModel
.
get
(),
&
lrc
::
api
::
ContactModel
::
profileUpdated
,
this
,
[
this
](
const
QString
&
contactUri
)
{
conversationSmartListModel_
->
updateContactAvatarUid
(
contactUri
);
Q_EMIT
updateListViewRequested
();
},
Qt
::
UniqueConnection
);
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
conversationUpdated
,
this
,
[
this
](
const
QString
&
)
{
updateConversationsFilterWidget
();
Q_EMIT
updateListViewRequested
();
},
Qt
::
UniqueConnection
);
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
filterChanged
,
this
,
[
this
]()
{
conversationSmartListModel_
->
fillConversationsList
();
updateConversationsFilterWidget
();
if
(
!
lrcInstance_
->
get_selectedConvUid
().
isEmpty
())
Q_EMIT
indexRepositionRequested
();
Q_EMIT
updateListViewRequested
();
},
Qt
::
UniqueConnection
);
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
newConversation
,
this
,
[
this
](
const
QString
&
convUid
)
{
conversationSmartListModel_
->
fillConversationsList
();
updateConversationForNewContact
(
convUid
);
},
Qt
::
UniqueConnection
);
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
conversationRemoved
,
this
,
[
this
]()
{
backToWelcomePage
();
},
Qt
::
UniqueConnection
);
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
conversationCleared
,
this
,
[
this
](
const
QString
&
convUid
)
{
// If currently selected, switch to welcome screen (deselecting
// current smartlist item).
if
(
convUid
!=
lrcInstance_
->
get_selectedConvUid
())
{
return
;
}
backToWelcomePage
();
},
Qt
::
UniqueConnection
);
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
searchStatusChanged
,
this
,
[
this
](
const
QString
&
status
)
{
Q_EMIT
showSearchStatus
(
status
);
},
Qt
::
UniqueConnection
);
// This connection is ideal when separated search results list.
// This signal is guaranteed to fire just after filterChanged during a search if results are
// changed, and once before filterChanged when calling setFilter.
// NOTE: Currently, when searching, the entire conversation list will be copied 2-3 times each
// keystroke :/.
searchResultUpdatedConnection_
=
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
searchResultUpdated
,
[
this
]()
{
conversationSmartListModel_
->
fillConversationsList
();
Q_EMIT
updateListViewRequested
();
});
QObject
::
connect
(
currentConversationModel
,
&
lrc
::
api
::
ConversationModel
::
searchResultUpdated
,
this
,
[
this
]()
{
conversationSmartListModel_
->
fillConversationsList
();
Q_EMIT
updateListViewRequested
();
},
Qt
::
UniqueConnection
);
if
(
updateFilter
)
{
currentTypeFilter_
=
lrc
::
api
::
profile
::
Type
::
INVALID
;
...
...
@@ -361,23 +381,6 @@ ConversationsAdapter::connectConversationModel(bool updateFilter)
return
true
;
}
void
ConversationsAdapter
::
disconnectConversationModel
()
{
QObject
::
disconnect
(
modelSortedConnection_
);
QObject
::
disconnect
(
modelUpdatedConnection_
);
QObject
::
disconnect
(
filterChangedConnection_
);
QObject
::
disconnect
(
newConversationConnection_
);
QObject
::
disconnect
(
conversationRemovedConnection_
);
QObject
::
disconnect
(
conversationClearedConnection
);
QObject
::
disconnect
(
selectedCallChanged_
);
QObject
::
disconnect
(
smartlistSelectionConnection_
);
QObject
::
disconnect
(
interactionRemovedConnection_
);
QObject
::
disconnect
(
searchStatusChangedConnection_
);
QObject
::
disconnect
(
searchResultUpdatedConnection_
);
QObject
::
disconnect
(
contactProfileUpdatedConnection_
);
}
void
ConversationsAdapter
::
updateConversationForNewContact
(
const
QString
&
convUid
)
{
...
...
This diff is collapsed.
Click to expand it.
src/conversationsadapter.h
+
0
−
15
View file @
946491a5
...
...
@@ -44,7 +44,6 @@ protected:
public:
Q_INVOKABLE
bool
connectConversationModel
(
bool
updateFilter
=
true
);
Q_INVOKABLE
void
disconnectConversationModel
();
Q_INVOKABLE
void
selectConversation
(
const
QString
&
accountId
,
const
QString
&
uid
);
Q_INVOKABLE
void
deselectConversation
();
Q_INVOKABLE
void
refill
();
...
...
@@ -82,19 +81,5 @@ private:
lrc
::
api
::
profile
::
Type
currentTypeFilter_
{};
// Connections.
QMetaObject
::
Connection
modelSortedConnection_
;
QMetaObject
::
Connection
modelUpdatedConnection_
;
QMetaObject
::
Connection
filterChangedConnection_
;
QMetaObject
::
Connection
newConversationConnection_
;
QMetaObject
::
Connection
conversationRemovedConnection_
;
QMetaObject
::
Connection
conversationClearedConnection
;
QMetaObject
::
Connection
contactProfileUpdatedConnection_
;
QMetaObject
::
Connection
selectedCallChanged_
;
QMetaObject
::
Connection
smartlistSelectionConnection_
;
QMetaObject
::
Connection
interactionRemovedConnection_
;
QMetaObject
::
Connection
searchStatusChangedConnection_
;
QMetaObject
::
Connection
searchResultUpdatedConnection_
;
SystemTray
*
systemTray_
;
};
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