mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-23 14:48:15 +00:00
feat(ui/modules/Linphone/Chat/OutgoingMessage): supports resend action
This commit is contained in:
parent
bd47b42141
commit
67e0a4fa4e
5 changed files with 36 additions and 2 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue