Commit 0b16cef6 authored by Martin Klapetek's avatar Martin Klapetek Committed by Alexander Akulich

[declarative] Add signals that can propagate last message change notifications

This should fix things being empty at the MainPage after opening a
conversation
parent fbc3d880
......@@ -66,6 +66,7 @@ Conversation::Conversation(const Tp::TextChannelPtr &channel,
d->messages = new MessagesModel(account, this);
connect(d->messages, &MessagesModel::unreadCountChanged, this, &Conversation::unreadMessagesChanged);
connect(d->messages, &MessagesModel::lastMessageChanged, this, &Conversation::lastMessageChanged);
setTextChannel(channel);
d->delegated = false;
......@@ -86,6 +87,7 @@ void Conversation::setTextChannel(const Tp::TextChannelPtr &channel)
if (!d->messages) {
d->messages = new MessagesModel(d->account, this);
connect(d->messages, &MessagesModel::unreadCountChanged, this, &Conversation::unreadMessagesChanged);
connect(d->messages, &MessagesModel::lastMessageChanged, this, &Conversation::lastMessageChanged);
}
if (d->messages->textChannel() != channel) {
d->messages->setTextChannel(channel);
......
......@@ -73,6 +73,7 @@ Q_SIGNALS:
void presenceIconChanged();
void conversationCloseRequested();
void unreadMessagesChanged();
void lastMessageChanged();
public Q_SLOTS:
void delegateToProperClient();
......
......@@ -124,6 +124,13 @@ void MessagesModel::setupChannelSignals(const Tp::TextChannelPtr &channel)
connect(channel.data(),
SIGNAL(pendingMessageRemoved(Tp::ReceivedMessage)),
SLOT(onPendingMessageRemoved()));
connect(channel.data(), &Tp::TextChannel::messageReceived,
this, &MessagesModel::lastMessageChanged);
connect(channel.data(), &Tp::TextChannel::messageSent,
this, &MessagesModel::lastMessageChanged);
connect(channel.data(), &Tp::TextChannel::pendingMessageRemoved,
this, &MessagesModel::lastMessageChanged);
}
void MessagesModel::setTextChannel(const Tp::TextChannelPtr &channel)
......@@ -182,6 +189,8 @@ void MessagesModel::onHistoryFetched(const QList<KTp::Message> &messages)
endInsertRows();
}
d->logsLoaded = true;
Q_EMIT lastMessageChanged();
}
void MessagesModel::onMessageReceived(const Tp::ReceivedMessage &message)
......
......@@ -91,6 +91,7 @@ class MessagesModel : public QAbstractListModel
Q_SIGNALS:
void visibleToUserChanged(bool visible);
void unreadCountChanged(int unreadMesssagesCount);
void lastMessageChanged();
public Q_SLOTS:
void sendNewMessage(const QString &message);
......
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