Commit 67e0a4fa authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/modules/Linphone/Chat/OutgoingMessage): supports resend action

parent bd47b421
......@@ -253,6 +253,28 @@ void ChatModel::sendMessage (const QString &message) {
emit messageSent(_message);
}
void ChatModel::resendMessage (int id) {
if (id < 0 || id > m_entries.count()) {
qWarning() << QStringLiteral("Entry %1 not exists.").arg(id);
return;
}
const ChatEntryData &entry = m_entries[id];
if (entry.first["type"] != EntryType::MessageEntry) {
qWarning() << QStringLiteral("Unable to resend entry %1. It's not a message.").arg(id);
return;
}
shared_ptr<linphone::ChatMessage> message = static_pointer_cast<linphone::ChatMessage>(entry.second);
if (message->getState() != linphone::ChatMessageStateNotDelivered) {
qWarning() << QStringLiteral("Unable to resend message: %1. Bad state.").arg(id);
return;
}
message->setListener(m_message_handlers);
m_chat_room->sendMessage(message);
}
// -----------------------------------------------------------------------------
void ChatModel::fillMessageEntry (
......
......@@ -68,6 +68,8 @@ public:
void sendMessage (const QString &message);
void resendMessage (int id);
signals:
void sipAddressChanged (const QString &sip_address);
void allEntriesRemoved ();
......
......@@ -98,6 +98,13 @@ void ChatProxyModel::sendMessage (const QString &message) {
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->sendMessage(message);
}
void ChatProxyModel::resendMessage (int id) {
QModelIndex source_index = mapToSource(index(id, 0));
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->resendMessage(
m_chat_model_filter->mapToSource(source_index).row()
);
}
bool ChatProxyModel::filterAcceptsRow (int source_row, const QModelIndex &) const {
return m_chat_model_filter->rowCount() - source_row <= m_n_max_displayed_entries;
}
......
......@@ -29,6 +29,7 @@ public:
Q_INVOKABLE void removeAllEntries ();
Q_INVOKABLE void sendMessage (const QString &message);
Q_INVOKABLE void resendMessage (int id);
signals:
void sipAddressChanged (const QString &sip_address);
......
......@@ -32,12 +32,14 @@ Item {
id: icon
Icon {
icon: $chatEntry.status === ChatModel.MessageStatusNotDelivered ? 'chat_error' : 'chat_send'
property bool isNotDelivered: $chatEntry.status === ChatModel.MessageStatusNotDelivered
icon: isNotDelivered ? 'chat_error' : 'chat_send'
iconSize: ChatStyle.entry.message.outgoing.sendIconSize
MouseArea {
anchors.fill: parent
onClicked: console.log('resend')
onClicked: isNotDelivered && proxyModel.resendMessage(index)
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment