mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-24 23:28:09 +00:00
feat(components/chat): supports a button to remove all history
This commit is contained in:
parent
4023649184
commit
74be020133
5 changed files with 71 additions and 14 deletions
|
|
@ -141,6 +141,14 @@
|
|||
<source>newMessagePlaceholder</source>
|
||||
<translation type="vanished">Enter your message</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>removeAllEntriesDescription</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>removeAllEntriesTitle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DropZone</name>
|
||||
|
|
|
|||
|
|
@ -141,6 +141,14 @@
|
|||
<source>newMessagePlaceholder</source>
|
||||
<translation type="vanished">Entrer votre message.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>removeAllEntriesDescription</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>removeAllEntriesTitle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DropZone</name>
|
||||
|
|
|
|||
|
|
@ -46,18 +46,8 @@ bool ChatModel::removeRows (int row, int count, const QModelIndex &parent) {
|
|||
beginRemoveRows(parent, row, limit);
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
QPair<QVariantMap, shared_ptr<void> > pair = m_entries.takeAt(row);
|
||||
|
||||
switch (pair.first["type"].toInt()) {
|
||||
case ChatModel::MessageEntry:
|
||||
m_chat_room->deleteMessage(
|
||||
static_pointer_cast<linphone::ChatMessage>(pair.second)
|
||||
);
|
||||
break;
|
||||
case ChatModel::CallEntry:
|
||||
|
||||
break;
|
||||
}
|
||||
removeEntry(m_entries[row]);
|
||||
m_entries.removeAt(row);
|
||||
}
|
||||
|
||||
endRemoveRows();
|
||||
|
|
@ -74,8 +64,38 @@ void ChatModel::removeEntry (int id) {
|
|||
qWarning() << "Unable to remove chat entry:" << id;
|
||||
}
|
||||
|
||||
void ChatModel::removeAllEntries () {
|
||||
qInfo() << "Removing all chat entries of:" << getSipAddress();
|
||||
|
||||
beginResetModel();
|
||||
|
||||
for (auto &entry : m_entries)
|
||||
removeEntry(entry);
|
||||
|
||||
m_entries.clear();
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
void ChatModel::removeEntry (ChatEntryData &pair) {
|
||||
int type = pair.first["type"].toInt();
|
||||
|
||||
switch (type) {
|
||||
case ChatModel::MessageEntry:
|
||||
m_chat_room->deleteMessage(
|
||||
static_pointer_cast<linphone::ChatMessage>(pair.second)
|
||||
);
|
||||
break;
|
||||
case ChatModel::CallEntry:
|
||||
|
||||
break;
|
||||
default:
|
||||
qWarning() << "Unknown chat entry type:" << type;
|
||||
}
|
||||
}
|
||||
|
||||
QString ChatModel::getSipAddress () const {
|
||||
if (!m_chat_room)
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -42,15 +42,20 @@ public:
|
|||
|
||||
public slots:
|
||||
void removeEntry (int id);
|
||||
void removeAllEntries ();
|
||||
|
||||
signals:
|
||||
void sipAddressChanged (const QString &sipAddress);
|
||||
|
||||
private:
|
||||
typedef QPair<QVariantMap, std::shared_ptr<void> > ChatEntryData;
|
||||
|
||||
void removeEntry (ChatEntryData &pair);
|
||||
|
||||
QString getSipAddress () const;
|
||||
void setSipAddress (const QString &sip_address);
|
||||
|
||||
QList<QPair<QVariantMap, std::shared_ptr<void> > > m_entries;
|
||||
QList<ChatEntryData> m_entries;
|
||||
std::shared_ptr<linphone::ChatRoom> m_chat_room;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,20 @@ ColumnLayout {
|
|||
sipAddress
|
||||
) || sipAddress
|
||||
|
||||
function _removeAllEntries () {
|
||||
Utils.openConfirmDialog(window, {
|
||||
descriptionText: qsTr('removeAllEntriesDescription'),
|
||||
exitHandler: function (status) {
|
||||
if (status) {
|
||||
chatModel.removeAllEntries()
|
||||
}
|
||||
},
|
||||
title: qsTr('removeAllEntriesTitle')
|
||||
})
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
spacing: 0
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
|
@ -90,7 +104,7 @@ ColumnLayout {
|
|||
icon: 'delete'
|
||||
iconSize: ConversationStyle.bar.actions.edit.iconSize
|
||||
|
||||
onClicked: window.setView('Contact') // TODO.
|
||||
onClicked: _removeAllEntries()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -132,6 +146,8 @@ ColumnLayout {
|
|||
Layout.fillWidth: true
|
||||
contact: parent._contact
|
||||
model: ChatModel {
|
||||
id: chatModel
|
||||
|
||||
sipAddress: conversation.sipAddress
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue