summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Klapetek <mklapetek@kde.org>2016-03-02 23:14:22 (GMT)
committerAlexandr Akulich <akulichalexander@gmail.com>2016-09-21 13:05:33 (GMT)
commita63c02dc22b6271382c8d33fdca8165426642595 (patch)
treed3f175d3e8d35cb6e3e15e8141bf1a167441720d
parentc0bd88ef554105375d4f8a12a32cf963c0aefb00 (diff)
[declarative] Add property hasUnreadMessages directly to Conversation
Reviewed-by: Alexandr Akulich <akulichalexander@gmail.com>
-rw-r--r--KTp/Declarative/conversation.cpp11
-rw-r--r--KTp/Declarative/conversation.h4
2 files changed, 15 insertions, 0 deletions
diff --git a/KTp/Declarative/conversation.cpp b/KTp/Declarative/conversation.cpp
index 2742320..a479603 100644
--- a/KTp/Declarative/conversation.cpp
+++ b/KTp/Declarative/conversation.cpp
@@ -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;
+}
diff --git a/KTp/Declarative/conversation.h b/KTp/Declarative/conversation.h
index 6f07d66..0ab8321 100644
--- a/KTp/Declarative/conversation.h
+++ b/KTp/Declarative/conversation.h
@@ -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();