libQuotient
A Qt library for building matrix clients
Quotient::EventStats Struct Reference

Counters of unread events and highlights with a precision flag. More...

#include <eventstats.h>

Public Types

using marker_t = Room::rev_iter_t
 

Public Member Functions

bool operator== (const EventStats &rhs) const
 
bool operator!= (const EventStats &rhs) const
 
Q_INVOKABLE bool empty () const
 Check whether the event statistics are empty. More...
 
bool updateOnMarkerMove (const Room *room, const marker_t &oldMarker, const marker_t &newMarker)
 Update statistics when a read marker moves down the timeline. More...
 
bool isValidFor (const Room *room, const marker_t &marker) const
 Validate the statistics object against the given marker. More...
 

Static Public Member Functions

static EventStats fromRange (const Room *room, const marker_t &from, const marker_t &to, const EventStats &init={ 0, 0, false })
 Build event statistics on a range of events. More...
 
static EventStats fromMarker (const Room *room, const marker_t &marker)
 Build event statistics on a range from sync edge to marker. More...
 
static EventStats fromCachedCounters (std::optional< int > notableCount, std::optional< int > highlightCount={})
 Loads a statistics object from the cached counters. More...
 

Public Attributes

qsizetype notableCount = 0
 

Properties

Q_GADGETqsizetype notableCount
 
qsizetype highlightCount = 0
 
bool isEstimate = true
 Whether the counter values above are exact. More...
 

Detailed Description

Counters of unread events and highlights with a precision flag.

This structure contains a static snapshot with values of unread counters returned by Room::partiallyReadStats and Room::unreadStats (properties or methods).

Note
It's just a simple grouping of counters and is not automatically updated from the room as subsequent syncs arrive.
See also
Room::unreadStats, Room::partiallyReadStats, Room::isEventNotable

Definition at line 19 of file eventstats.h.

Member Typedef Documentation

◆ marker_t

Definition at line 58 of file eventstats.h.

Member Function Documentation

◆ empty()

Q_INVOKABLE bool Quotient::EventStats::empty ( ) const
inline

Check whether the event statistics are empty.

Empty statistics have notable and highlight counters of zero and isEstimate set to false.

Definition at line 53 of file eventstats.h.

◆ fromCachedCounters()

static EventStats Quotient::EventStats::fromCachedCounters ( std::optional< int >  notableCount,
std::optional< int >  highlightCount = {} 
)
static

Loads a statistics object from the cached counters.

Sets isEstimate to true unless both notableCount and highlightCount are equal to -1.

◆ fromMarker()

static EventStats Quotient::EventStats::fromMarker ( const Room room,
const marker_t marker 
)
static

Build event statistics on a range from sync edge to marker.

This is mainly a shortcut for

<tt>fromRange(room, marker_t(room->syncEdge()), marker)</tt>
static EventStats fromRange(const Room *room, const marker_t &from, const marker_t &to, const EventStats &init={ 0, 0, false })
Build event statistics on a range of events.
Room::rev_iter_t marker_t
Definition: eventstats.h:58

except that it also sets isEstimate to true if (and only if) to == room->historyEdge().

◆ fromRange()

static EventStats Quotient::EventStats::fromRange ( const Room room,
const marker_t from,
const marker_t to,
const EventStats init = { 0, 0, false } 
)
static

Build event statistics on a range of events.

This is a factory that returns an EventStats instance with counts of notable and highlighted events between from and to reverse timeline iterators; the init parameter allows to override the initial statistics object and start from other values.

◆ isValidFor()

bool Quotient::EventStats::isValidFor ( const Room room,
const marker_t marker 
) const

Validate the statistics object against the given marker.

Checks whether the statistics object data are valid for a given marker. No stats recalculation takes place, only isEstimate and zero-ness of notableCount are checked.

◆ operator!=()

bool Quotient::EventStats::operator!= ( const EventStats rhs) const
inline

Definition at line 47 of file eventstats.h.

◆ operator==()

bool Quotient::EventStats::operator== ( const EventStats rhs) const
inline

Definition at line 41 of file eventstats.h.

◆ updateOnMarkerMove()

bool Quotient::EventStats::updateOnMarkerMove ( const Room room,
const marker_t oldMarker,
const marker_t newMarker 
)

Update statistics when a read marker moves down the timeline.

Removes events between oldMarker and newMarker from statistics calculation if oldMarker points to an existing event in the timeline, or recalculates the statistics entirely if oldMarker points to room->historyEdge(). Always results in exact statistics (isEstimate == false.

Parameters
oldMarkerMust point correspond to the current statistics isEstimate state, i.e. it should point to room->historyEdge() if isEstimate == true, or to a valid position within the timeline otherwise
newMarkerMust point to a valid position in the timeline (not to room->historyEdge() that is equal to or closer to the sync edge than oldMarker
Returns
true if either notableCount or highlightCount changed, or if the statistics was completely recalculated; false otherwise

Member Data Documentation

◆ notableCount

qsizetype Quotient::EventStats::notableCount = 0

The number of "notable" events in an events range

See also
Room::isEventNotable

Definition at line 27 of file eventstats.h.

Property Documentation

◆ highlightCount

qsizetype Quotient::EventStats::highlightCount = 0

Definition at line 20 of file eventstats.h.

◆ isEstimate

bool Quotient::EventStats::isEstimate = true

Whether the counter values above are exact.

This is false when the end marker (m.read receipt or m.fully_read) used to collect the stats points to an event loaded locally and the counters can therefore be calculated exactly using the locally available segment of the timeline; true when the marker points to an event outside of the local timeline (in which case the estimation is made basing on the data supplied by the homeserver as well as counters saved from the previous run of the client).

Definition at line 20 of file eventstats.h.

◆ notableCount

Q_GADGETqsizetype Quotient::EventStats::notableCount

Definition at line 20 of file eventstats.h.


The documentation for this struct was generated from the following file: