mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-07-12 19:45:23 +02:00
conversationlistmodel: use removeConversation for swarm
Also, dataForItem MUST return a QVariant to be able to show the context menu Change-Id: Ia02a087e0eb3d55000cb2026d41c8fb53e8ae46c
This commit is contained in:
parent
0621cf5b9f
commit
a28c88becc
3 changed files with 19 additions and 7 deletions
|
@ -163,12 +163,12 @@ ConversationListModelBase::dataForItem(item_t item, int role) const
|
|||
auto peerUri = peerUriList.at(0);
|
||||
ContactModel* contactModel;
|
||||
contact::Info contact {};
|
||||
contactModel = lrcInstance_->getCurrentAccountInfo().contactModel.get();
|
||||
try {
|
||||
contactModel = lrcInstance_->getCurrentAccountInfo().contactModel.get();
|
||||
contact = contactModel->getContact(peerUri);
|
||||
} catch (const std::exception&) {
|
||||
qWarning() << Q_FUNC_INFO << "Can't find contact" << peerUri;
|
||||
return {};
|
||||
qWarning() << Q_FUNC_INFO << "Can't find contact" << peerUri
|
||||
<< " this is a bug, please report";
|
||||
}
|
||||
|
||||
switch (role) {
|
||||
|
|
|
@ -133,12 +133,14 @@ ListView {
|
|||
"title": model.dataForRow(row, ConversationList.Title),
|
||||
"uri": model.dataForRow(row, ConversationList.URI),
|
||||
"isSwarm": model.dataForRow(row, ConversationList.IsSwarm),
|
||||
"mode": model.dataForRow(row, ConversationList.Mode),
|
||||
"readOnly": model.dataForRow(row, ConversationList.ReadOnly)
|
||||
}
|
||||
|
||||
responsibleAccountId = LRCInstance.currentAccountId
|
||||
responsibleConvUid = item.convId
|
||||
isSwarm = item.isSwarm
|
||||
mode = item.mode
|
||||
contactType = LRCInstance.currentAccountType
|
||||
readOnly = item.readOnly
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ ContextMenuAutoLoader {
|
|||
property string responsibleAccountId: ""
|
||||
property string responsibleConvUid: ""
|
||||
property bool isSwarm: false
|
||||
property var mode: undefined
|
||||
property int contactType: Profile.Type.INVALID
|
||||
property bool hasCall: {
|
||||
if (responsibleAccountId && responsibleConvUid)
|
||||
|
@ -79,11 +80,20 @@ ContextMenuAutoLoader {
|
|||
GeneralMenuItem {
|
||||
id: removeContact
|
||||
|
||||
canTrigger: !hasCall && (contactType === Profile.Type.JAMI
|
||||
|| contactType === Profile.Type.SIP)
|
||||
itemName: JamiStrings.removeContact
|
||||
canTrigger: !hasCall
|
||||
itemName: {
|
||||
if (mode !== Conversation.Mode.ONE_TO_ONE && mode !== Conversation.Mode.NON_SWARM)
|
||||
return JamiStrings.removeConversation
|
||||
else
|
||||
return JamiStrings.removeContact
|
||||
}
|
||||
iconSource: JamiResources.ic_hangup_participant_24dp_svg
|
||||
onClicked: MessagesAdapter.removeContact(responsibleConvUid)
|
||||
onClicked: {
|
||||
if (isSwarm)
|
||||
MessagesAdapter.removeConversation(responsibleConvUid)
|
||||
else
|
||||
MessagesAdapter.removeContact(responsibleConvUid)
|
||||
}
|
||||
},
|
||||
GeneralMenuItem {
|
||||
id: hangup
|
||||
|
|
Loading…
Add table
Reference in a new issue