diff --git a/tests/assets/languages/en.ts b/tests/assets/languages/en.ts
index 34598f97c..8a6e05fdb 100644
--- a/tests/assets/languages/en.ts
+++ b/tests/assets/languages/en.ts
@@ -141,6 +141,14 @@
newMessagePlaceholder
Enter your message
+
+ removeAllEntriesDescription
+
+
+
+ removeAllEntriesTitle
+
+
DropZone
diff --git a/tests/assets/languages/fr.ts b/tests/assets/languages/fr.ts
index 824e3d752..e6c13f001 100644
--- a/tests/assets/languages/fr.ts
+++ b/tests/assets/languages/fr.ts
@@ -141,6 +141,14 @@
newMessagePlaceholder
Entrer votre message.
+
+ removeAllEntriesDescription
+
+
+
+ removeAllEntriesTitle
+
+
DropZone
diff --git a/tests/src/components/chat/ChatModel.cpp b/tests/src/components/chat/ChatModel.cpp
index 65a909dd6..97d2fe877 100644
--- a/tests/src/components/chat/ChatModel.cpp
+++ b/tests/src/components/chat/ChatModel.cpp
@@ -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 > pair = m_entries.takeAt(row);
-
- switch (pair.first["type"].toInt()) {
- case ChatModel::MessageEntry:
- m_chat_room->deleteMessage(
- static_pointer_cast(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(pair.second)
+ );
+ break;
+ case ChatModel::CallEntry:
+
+ break;
+ default:
+ qWarning() << "Unknown chat entry type:" << type;
+ }
+}
+
QString ChatModel::getSipAddress () const {
if (!m_chat_room)
return "";
diff --git a/tests/src/components/chat/ChatModel.hpp b/tests/src/components/chat/ChatModel.hpp
index c0c214246..398454684 100644
--- a/tests/src/components/chat/ChatModel.hpp
+++ b/tests/src/components/chat/ChatModel.hpp
@@ -42,15 +42,20 @@ public:
public slots:
void removeEntry (int id);
+ void removeAllEntries ();
signals:
void sipAddressChanged (const QString &sipAddress);
private:
+ typedef QPair > ChatEntryData;
+
+ void removeEntry (ChatEntryData &pair);
+
QString getSipAddress () const;
void setSipAddress (const QString &sip_address);
- QList > > m_entries;
+ QList m_entries;
std::shared_ptr m_chat_room;
};
diff --git a/tests/ui/views/App/MainWindow/Conversation.qml b/tests/ui/views/App/MainWindow/Conversation.qml
index ffa92c946..239dbcbaf 100644
--- a/tests/ui/views/App/MainWindow/Conversation.qml
+++ b/tests/ui/views/App/MainWindow/Conversation.qml
@@ -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
}
}