Commit a63c02dc authored by Martin Klapetek's avatar Martin Klapetek Committed by Alexander Akulich

[declarative] Add property hasUnreadMessages directly to Conversation

Reviewed-by: Alexander Akulich's avatarAlexandr Akulich <akulichalexander@gmail.com>
parent c0bd88ef
......@@ -64,6 +64,7 @@ Conversation::Conversation(const Tp::TextChannelPtr &channel,
connect(d->account.data(), SIGNAL(connectionChanged(Tp::ConnectionPtr)), SLOT(onAccountConnectionChanged(Tp::ConnectionPtr)));
d->messages = new MessagesModel(account, this);
connect(d->messages, &MessagesModel::unreadCountChanged, this, &Conversation::unreadMessagesChanged);
setTextChannel(channel);
d->delegated = false;
......@@ -82,6 +83,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);
}
if (d->messages->textChannel() != channel) {
d->messages->setTextChannel(channel);
......@@ -257,3 +259,12 @@ Conversation::~Conversation()
}
delete d;
}
bool Conversation::hasUnreadMessages() const
{
if (d->messages) {
return d->messages->unreadCount() > 0;
}
return false;
}
......@@ -39,6 +39,7 @@ class Conversation : public QObject
Q_PROPERTY(QIcon avatar READ avatar NOTIFY avatarChanged)
Q_PROPERTY(Tp::AccountPtr account READ account CONSTANT)
Q_PROPERTY(KTp::ContactPtr targetContact READ targetContact CONSTANT)
Q_PROPERTY(bool hasUnreadMessages READ hasUnreadMessages NOTIFY unreadMessagesChanged)
public:
Conversation(const Tp::TextChannelPtr &channel, const Tp::AccountPtr &account, QObject *parent = 0);
......@@ -61,12 +62,15 @@ public:
bool isValid();
bool hasUnreadMessages() const;
Q_SIGNALS:
void validityChanged(bool isValid);
void avatarChanged();
void titleChanged();
void presenceIconChanged();
void conversationCloseRequested();
void unreadMessagesChanged();
public Q_SLOTS:
void delegateToProperClient();
......
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