Skip to content

Commit

Permalink
Room: make notificationCount, highlightCount Q_PROPERTYs
Browse files Browse the repository at this point in the history
Closes #299. Due to restrictions for the NOTIFY signal notificationCountChanged and highlightCountChanged no more carry Room* as a parameter, breaking back-compatibility.
  • Loading branch information
KitsuneRal committed Mar 13, 2019
1 parent ced57b0 commit b6b4b5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ void Room::resetNotificationCount()
if( d->notificationCount == 0 )
return;
d->notificationCount = 0;
emit notificationCountChanged(this);
emit notificationCountChanged();
}

int Room::highlightCount() const
Expand All @@ -828,7 +828,7 @@ void Room::resetHighlightCount()
if( d->highlightCount == 0 )
return;
d->highlightCount = 0;
emit highlightCountChanged(this);
emit highlightCountChanged();
}

void Room::switchVersion(QString newVersion)
Expand Down Expand Up @@ -1343,12 +1343,12 @@ void Room::updateData(SyncRoomData&& data, bool fromCache)
if( data.highlightCount != d->highlightCount )
{
d->highlightCount = data.highlightCount;
emit highlightCountChanged(this);
emit highlightCountChanged();
}
if( data.notificationCount != d->notificationCount )
{
d->notificationCount = data.notificationCount;
emit notificationCountChanged(this);
emit notificationCountChanged();
}
if (roomChanges != Change::NoChange)
{
Expand Down
6 changes: 4 additions & 2 deletions lib/room.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ namespace QMatrixClient
Q_PROPERTY(QString readMarkerEventId READ readMarkerEventId WRITE markMessagesAsRead NOTIFY readMarkerMoved)
Q_PROPERTY(bool hasUnreadMessages READ hasUnreadMessages NOTIFY unreadMessagesChanged)
Q_PROPERTY(int unreadCount READ unreadCount NOTIFY unreadMessagesChanged)
Q_PROPERTY(int highlightCount READ highlightCount NOTIFY highlightCountChanged RESET resetHighlightCount)
Q_PROPERTY(int notificationCount READ notificationCount NOTIFY notificationCountChanged RESET resetNotificationCount)
Q_PROPERTY(QStringList tagNames READ tagNames NOTIFY tagsChanged)
Q_PROPERTY(bool isFavourite READ isFavourite NOTIFY tagsChanged)
Q_PROPERTY(bool isLowPriority READ isLowPriority NOTIFY tagsChanged)
Expand Down Expand Up @@ -517,8 +519,8 @@ namespace QMatrixClient
void joinStateChanged(JoinState oldState, JoinState newState);
void typingChanged();

void highlightCountChanged(Room* room);
void notificationCountChanged(Room* room);
void highlightCountChanged();
void notificationCountChanged();

void displayedChanged(bool displayed);
void firstDisplayedEventChanged();
Expand Down

0 comments on commit b6b4b5e

Please sign in to comment.