swift
Loading...
Searching...
No Matches
swift::misc::network::CTextMessageList Class Reference

Value object encapsulating a list of text messages. More...

#include <textmessagelist.h>

Inheritance diagram for swift::misc::network::CTextMessageList:
[legend]

Public Member Functions

 CTextMessageList ()=default
 Default constructor.
 CTextMessageList (const QString &message, const aviation::CCallsign &recipientCallsign)
 Constructor, single private message.
 CTextMessageList (const QString &message, const aviation::CCallsign &senderCallsign, const aviation::CCallsign &recipientCallsign)
 Constructor, single private message.
 CTextMessageList (const QString &message, const physical_quantities::CFrequency &frequency, const aviation::CCallsign &senderCallsign={})
 Constructor, single radio message.
 CTextMessageList (const CTextMessage &message)
 Constructor, single message.
 CTextMessageList (const QString &message, const QList< physical_quantities::CFrequency > &frequencies, const aviation::CCallsign &fromCallsign={})
 Constructor, multi-frequency radio messages.
 CTextMessageList (const CSequence< CTextMessage > &other)
 Construct from a base class object.
CTextMessageList getPrivateMessages () const
 Private messages.
bool containsPrivateMessages () const
 Contains private messages?
CTextMessageList getRadioMessages () const
 Public messages.
CTextMessageList getSupervisorMessages () const
 Supervisor messages.
bool containsRadioMessages () const
 Contains radio messages?
CTextMessageList containsSupervisorMessages () const
 Contains supervisor message.
CTextMessageList findByFrequency (const physical_quantities::CFrequency &frequency) const
 Find by frequency.
CTextMessageList findBySender (const swift::misc::aviation::CCallsign &sender) const
 Find by sender.
CTextMessageList findByRecipient (const swift::misc::aviation::CCallsign &recipient) const
 Find by recipient.
CTextMessageList findByNotForRecipient (const swift::misc::aviation::CCallsign &recipient) const
 Find by recipient is NOT addressed.
void toggleSenderRecipients ()
 Toggle all sender <-> recipients.
int relayedToPrivateMessages ()
 Turn relayed into normal private messages.
int removePrivateMessagesFromCallsign (const aviation::CCallsign &callsign)
 Remove private messages from callsign.
CTextMessageList withRelayedToPrivateMessages () const
 List with relayed messages (if any) as private messages.
CTextMessageList withRemovedPrivateMessagesFromCallsign (const aviation::CCallsign &callsign) const
 With removed private messages from callsign.
void markAsSent ()
 Mark all messages as sent.
CTextMessageList markedAsSent ()
 Marked as sent.
void addConsolidatedTextMessage (const CTextMessage &message)
 Add a text message, but append it to an existing message if possible.
 CSequence ()=default
 Default constructor.
 CSequence (std::initializer_list< T > il)
 Initializer list constructor.
 CSequence (QList< T > &&list)
 By QList of type T.
 CSequence (const QList< T > &list)
 By QList of type T.
template<typename It>
 CSequence (It first, It last)
 Range constructor.
 CSequence (const CSequence &other)=default
 Copy constructor.
 CSequence (CSequence &&other)=default
 Move constructor.
Public Member Functions inherited from swift::misc::CSequence< CTextMessage >
 CSequence ()=default
 Default constructor.
CSequence & operator= (const CSequence &other)=default
 Copy assignment.
 ~CSequence ()=default
 Destructor.
QVector< CTextMessage > toVector () const &
 Copy of internal vector.
iterator begin ()
 Returns iterator at the beginning of the sequence.
const_iterator cbegin () const
 Returns const iterator at the beginning of the sequence.
iterator end ()
 Returns iterator one past the end of the sequence.
const_iterator cend () const
 Returns const iterator one past the end of the sequence.
reverse_iterator rbegin ()
 Returns iterator at the beginning of the reversed sequence.
const_reverse_iterator crbegin () const
 Returns const iterator at the beginning of the reversed sequence.
reverse_iterator rend ()
 Returns iterator at the end of the reversed sequence.
const_reverse_iterator crend () const
 Returns const iterator at the end of the reversed sequence.
void swap (CSequence &other) noexcept
 Swap this sequence with another.
reference operator[] (size_type index)
 Access an element by its index.
reference front ()
 Access the first element.
const_reference frontOrDefault () const
 Access the first element, or a default-initialized value if the sequence is empty.
reference back ()
 Access the last element.
const_reference backOrDefault () const
 Access the last element, or a default value if the sequence is empty.
size_type size () const
 Returns number of elements in the sequence.
int sizeInt () const
 Avoid compiler warnings when using with int.
QString sizeString () const
 Convenience function.
bool empty () const
 Returns true if the sequence is empty.
bool isEmpty () const
 Synonym for empty.
void clear ()
 Removes all elements in the sequence.
void truncate (size_type maxSize)
 Changes the size of the sequence, if it is bigger than the given size.
iterator insert (iterator before, const CTextMessage &value)
 Inserts an element into the sequence.
void push_back (const CTextMessage &value)
 Appends an element at the end of the sequence.
void push_front (const CTextMessage &value)
 Insert as first element.
void push_frontMaxElements (const CTextMessage &value, int maxElements)
 Insert as first element by keep maxElements.
void push_backMaxElements (const CTextMessage &value, int maxElements)
 Insert as last element by keep maxElements.
CSequence join (const CSequence &other) const
 Concatenates two sequences and returns the result.
void pop_back ()
 Removes an element at the end of the sequence.
void pop_front ()
 Removes an element at the front of the sequence.
iterator erase (iterator pos)
 Remove the element pointed to by the given iterator.
iterator find (const CTextMessage &object)
 Return an iterator to the first element equal to the given object, or the end iterator if not found. O(n).
CSequence findBy (Predicate p) const
 Return a copy containing only those elements for which a given predicate returns true.
int applyIf (Predicate p, const VariantMap &newValues, bool skipEqualValues=false)
 Modify by applying a value map to each element for which a given predicate returns true.
int remove (const CTextMessage &object)
 Remove all elements equal to the given object, if it is contained.
int removeIf (Predicate p)
 Remove elements for which a given predicate returns true.
int removeIfIn (const CSequence &other)
 Remove all elements if they are in other.
void removeIfInSubset (const CSequence &other)
 Remove all elements if they are in other.
int replace (const CTextMessage &original, const CTextMessage &replacement)
 Replace elements matching the given element with a replacement.
int replaceIf (Predicate p, const CTextMessage &replacement)
 Replace elements for which a given predicate returns true.
void replaceOrAdd (const CTextMessage &original, const CTextMessage &replacement)
 Replace elements matching the given element. If there is no match, push the new element on the end.
void reverse ()
 In-place reverse.
Q_REQUIRED_RESULT CSequence reversed () const
 Reversed order.
void sort (Predicate p)
 In-place sort by a given comparator predicate.
void sortBy (K1 key1, Keys... keys)
 In-place sort by some particular key(s).
Q_REQUIRED_RESULT CSequence sorted (Predicate p) const
 Return a copy sorted by a given comparator predicate.
CSequence sortedBy (K1 key1, Keys... keys) const
 Return a copy sorted by some particular key(s).
void partiallySort (size_type n, Predicate p)
 In-place move the smallest n elements to the beginning and sort them.
void partiallySortBy (size_type n, K1 key1, Keys... keys)
 In-place partially sort by some particular key(s).
Q_REQUIRED_RESULT CSequence partiallySorted (size_type n, Predicate p) const
 Return a copy with the smallest n elements at the beginning and sorted.
CSequence partiallySortedBy (size_type n, K1 key1, Keys... keys) const
 Return a copy partially sorted by some particular key(s).
bool unorderedEqualsByKeys (const U &other, Key0 k0, Keys... keys) const
 Return true if this container equals another container, considering only the given element members. Order of elements is not considered; this is implemented using a transient sort, so don't overuse.
auto separate (Predicate p) const -> QMap< decltype(p(std::declval< CTextMessage >())), CSequence >
 Split up the sequence into subsequences for which the given predicate returns the same value.
auto separateBy (Key k) const -> QMap< decltype(std::invoke(k, std::declval< CTextMessage >())), CSequence >
 Split up the sequence into subsequences of elements having the same value for the given key.
void marshalToDataStream (QDataStream &stream) const
 Marshal a value to a QDataStream.
void unmarshalFromDataStream (QDataStream &stream)
 Unmarshal a value from a QDataStream.
Public Member Functions inherited from swift::misc::CContainerBase< CSequence< CTextMessage > >
auto to () const
 Return a new container of a different type, containing the same elements as this one.
int removeIf (K0 k0, V0 v0, KeysValues... keysValues)
 Remove elements matching some particular key/value pair(s).
QJsonObject toJson () const
 Cast to JSON object.
QString toJsonString (QJsonDocument::JsonFormat format=QJsonDocument::Indented) const
 Convenience function JSON as string.
void convertFromJson (const QJsonObject &json)
 Assign from JSON object.
CStatusMessage convertFromJsonNoThrow (const QJsonObject &json, const CLogCategoryList &categories, const QString &prefix)
 Call convertFromJson, catch any CJsonException that is thrown and return it as CStatusMessage.
QString convertToQString (bool i18n=false) const
 Cast as QString.
QStringList toStringList (bool i18n=false) const
 To string list.
void marshallToDbus (QDBusArgument &argument) const
 Marshall without begin/endStructure, for when composed within another object.
void unmarshallFromDbus (const QDBusArgument &argument)
 Unmarshall without begin/endStructure, for when composed within another object.
Public Member Functions inherited from swift::misc::CRangeBase< CSequence< CTextMessage > >
auto transform (F function) const
 Return a new container generated by applying some transformation function to all elements of this one.
auto findBy (Predicate p) const
 Return a copy containing only those elements for which a given predicate returns true.
const auto & findFirstBy (Predicate p) const
 Return a reference to the first element for which a given predicate returns true. Undefined if there is none.
auto findFirstByOrDefault (Predicate p, const Value &def) const
 Return a copy of the first element for which a given predicate returns true, or a default value if there is none.
bool containsBy (Predicate p) const
 Return true if there is an element for which a given predicate returns true.
bool contains (const T &object) const
 Return true if there is an element equal to given object. Uses the most efficient implementation available in the derived container.
bool equalsBy (const T &other, Predicate c) const
 Return true if this container equals another container according to the given element equality predicate.
bool equalsByKeys (const T &other, Key0 k0, Keys... keys) const
 Return true if this container equals another container, considering only the given element members.
T randomElement () const
 Pick one random element.
CSequence< CTextMessage > randomElements (int n) const
 Copy n elements from the container at random.
CSequence< CTextMessage > sampleElements (int n) const
 Copy n elements from the container, randomly selected but evenly distributed.
Public Member Functions inherited from swift::misc::mixin::MetaType< CSequence< CTextMessage > >
int getMetaTypeId () const
 Returns the Qt meta type ID of this object.
QString getClassName () const
 Class name.
bool isA (int metaTypeId) const
 Returns true if this object is an instance of the class with the given meta type ID, or one of its subclasses.
Public Member Functions inherited from swift::misc::mixin::String< CSequence< CTextMessage > >
QString toQString (bool i18n=false) const
 Cast as QString.
std::string toStdString (bool i18n=false) const
 To std string.
QString stringForStreaming () const
 String for streaming operators.
Public Member Functions inherited from swift::misc::mixin::Icon< CSequence< CTextMessage > >
CIcons::CIcons::StandardIconUnknown16 toIcon () const
 As icon, not implemented by all classes.
Public Member Functions inherited from swift::misc::ITimestampObjectList< CTextMessage, CTextMessageList >
CTextMessageList findBefore (const QDateTime &dateTime) const
 List of objects before dateTime (older).
CTextMessage findObjectBeforeOrDefault (qint64 msSinceEpoch) const
 Object before timestamp or default (older).
CTextMessageList findBeforeAndRemove (qint64 msSinceEpoch)
 Get objects before msSinceEpoch and remove those.
CTextMessageList findBeforeNowMinusOffset (qint64 msOffset) const
 List of objects before now - offset.
CTextMessageList findAfter (const QDateTime &dateTime) const
 List of objects after dateTime (newer).
CTextMessageList findAfterNowMinusOffset (qint64 msOffset) const
 List of objects before now - offset.
CTextMessage findObjectAfterOrDefault (qint64 msSinceEpoch) const
 List of objects after msSinceEpoch (newer).
CTextMessageList findInvalidTimestamps () const
 Objects without valid timestamp.
CTextMessage findClosestTimeDistance (qint64 msSinceEpoch) const
 Find closest (or default).
bool hasInvalidTimestamps () const
 Has invalid timestamp.
void setCurrentUtcTime ()
 Set all timestamps to now.
void setUtcTime (qint64 msSinceEpoch)
 Set all timestamps to given time.
void setInvalidTimestampsToCurrentUtcTime ()
 Set invalid timestamps to now.
QDateTime latestTimestamp () const
 Latest timestamp.
qint64 latestTimestampMsecsSinceEpoch () const
 Latest timestamp.
QDateTime oldestTimestamp () const
 Oldest timestamp.
qint64 oldestTimestampMsecsSinceEpoch () const
 Oldest timestamp.
CTextMessage latestObject () const
 Latest object.
CTextMessage oldestObject () const
 Latest object.
int removeBefore (const QDateTime &dateTime)
 Remove objects with timestamp before dateTime.
int removeOlderThanNowMinusOffset (qint64 offsetMs)
 Remove objects older than seconds.
void sortLatestFirst ()
 Sort by timestamp.
void sortOldestFirst ()
 Sort by timestamp.
void push_frontKeepLatestFirst (const CTextMessage &value, bool replaceSameTimestamp=true, int maxElements=-1)
 Insert as first element by keeping maxElements and the latest first.
void push_backIncreaseTimestamp (const CTextMessage &newObject)
 Push back and increase the timestamp at least by +1ms if equal to last element.
void push_backOverrideTimestamp (const CTextMessage &newObject, qint64 newTsMsSinceEpoch)
 Push back, but set new timestamp.
void setNewTimestampStartingLast (qint64 startTimeStampMs, qint64 deltaTimeMs)
 Set new timestamps starting with the last element.
int replaceIfSameTimestamp (const CTextMessage &newObject)
 Replace if an object has the same timestamp.
bool isSortedLatestLast () const
 Is completely sorted: latest last.
bool isSortedLatestFirst () const
 Is completely sorted: latest last.
void addMsecs (qint64 msToAdd)
 Adds a time to all values.
void setSortHint (HintTimestampSort hint)
 Set the hint.
MillisecondsMinMaxMean getTimestampDifferenceMinMaxMean () const
 Difference of timestamp values.
Public Member Functions inherited from swift::misc::mixin::MetaType< CTextMessageList >
int getMetaTypeId () const
 Returns the Qt meta type ID of this object.
QString getClassName () const
 Class name.
bool isA (int metaTypeId) const
 Returns true if this object is an instance of the class with the given meta type ID, or one of its subclasses.

Additional Inherited Members

Public Types inherited from swift::misc::CSequence< CTextMessage >
using key_type
 STL compatibility.
using value_type
 STL compatilibty.
using reference
 STL compatibility.
using const_reference
 STL compatibility.
using pointer
 STL compatibility.
using const_pointer
 STL compatibility.
using const_iterator
 STL compatibility.
using iterator
 STL compatibility.
using const_reverse_iterator
 STL compatibility.
using reverse_iterator
 STL compatibility.
using difference_type
 STL compatibility.
using size_type
 STL compatibility.
Public Types inherited from swift::misc::ITimestampObjectList< CTextMessage, CTextMessageList >
enum  HintTimestampSort
 Hint if the list is sorted. More...
Static Public Member Functions inherited from swift::misc::CContainerBase< CSequence< CTextMessage > >
static CSequence< CTextMessage > fromJson (const QJsonObject &json)
 Static version of convertFromJson.
static CSequence< CTextMessage > fromJsonNoThrow (const QString &jsonString, bool acceptCacheJson, bool &success, QString &errMsg)
 Static version of convertFromJson.
Static Public Member Functions inherited from swift::misc::mixin::MetaType< CSequence< CTextMessage > >
static void registerMetadata ()
 Register metadata.
Static Public Member Functions inherited from swift::misc::mixin::MetaType< CTextMessageList >
static void registerMetadata ()
 Register metadata.
Protected Member Functions inherited from swift::misc::CContainerBase< CSequence< CTextMessage > >
int getMetaTypeId () const
 Returns the Qt meta type ID of this object.
Protected Member Functions inherited from swift::misc::ITimestampObjectList< CTextMessage, CTextMessageList >
 ITimestampObjectList ()=default
 Constructor.
const CTextMessageList & container () const
 Container.
Static Protected Member Functions inherited from swift::misc::CRangeBase< CSequence< CTextMessage > >
static bool equalPointers (const T *a, const U *b)
 Efficiently compare addresses of two objects. Return false if types are not compatible.
Protected Attributes inherited from swift::misc::ITimestampObjectList< CTextMessage, CTextMessageList >
HintTimestampSort m_tsSortHint
 sort hint

Detailed Description

Value object encapsulating a list of text messages.

Definition at line 28 of file textmessagelist.h.

Constructor & Destructor Documentation

◆ CTextMessageList() [1/6]

swift::misc::network::CTextMessageList::CTextMessageList ( const QString & message,
const aviation::CCallsign & recipientCallsign )

Constructor, single private message.

Definition at line 19 of file textmessagelist.cpp.

◆ CTextMessageList() [2/6]

swift::misc::network::CTextMessageList::CTextMessageList ( const QString & message,
const aviation::CCallsign & senderCallsign,
const aviation::CCallsign & recipientCallsign )

Constructor, single private message.

Definition at line 25 of file textmessagelist.cpp.

◆ CTextMessageList() [3/6]

swift::misc::network::CTextMessageList::CTextMessageList ( const QString & message,
const physical_quantities::CFrequency & frequency,
const aviation::CCallsign & senderCallsign = {} )

Constructor, single radio message.

Definition at line 32 of file textmessagelist.cpp.

◆ CTextMessageList() [4/6]

swift::misc::network::CTextMessageList::CTextMessageList ( const CTextMessage & message)

Constructor, single message.

Definition at line 39 of file textmessagelist.cpp.

◆ CTextMessageList() [5/6]

swift::misc::network::CTextMessageList::CTextMessageList ( const QString & message,
const QList< physical_quantities::CFrequency > & frequencies,
const aviation::CCallsign & fromCallsign = {} )

Constructor, multi-frequency radio messages.

Definition at line 41 of file textmessagelist.cpp.

◆ CTextMessageList() [6/6]

swift::misc::network::CTextMessageList::CTextMessageList ( const CSequence< CTextMessage > & other)

Construct from a base class object.

Definition at line 52 of file textmessagelist.cpp.

Member Function Documentation

◆ addConsolidatedTextMessage()

void swift::misc::network::CTextMessageList::addConsolidatedTextMessage ( const CTextMessage & message)

Add a text message, but append it to an existing message if possible.

Definition at line 209 of file textmessagelist.cpp.

◆ containsPrivateMessages()

bool swift::misc::network::CTextMessageList::containsPrivateMessages ( ) const

Contains private messages?

Definition at line 59 of file textmessagelist.cpp.

◆ containsRadioMessages()

bool swift::misc::network::CTextMessageList::containsRadioMessages ( ) const

Contains radio messages?

Definition at line 79 of file textmessagelist.cpp.

◆ containsSupervisorMessages()

CTextMessageList swift::misc::network::CTextMessageList::containsSupervisorMessages ( ) const

Contains supervisor message.

Definition at line 64 of file textmessagelist.cpp.

◆ CSequence() [1/4]

swift::misc::CSequence< T >::CSequence ( const QList< T > & list)
inline

By QList of type T.

Definition at line 134 of file sequence.h.

◆ CSequence() [2/4]

template<typename It>
swift::misc::CSequence< T >::CSequence ( It first,
It last )
inline

Range constructor.

Definition at line 138 of file sequence.h.

◆ CSequence() [3/4]

swift::misc::CSequence< T >::CSequence ( QList< T > && list)
inline

By QList of type T.

Definition at line 131 of file sequence.h.

◆ CSequence() [4/4]

swift::misc::CSequence< T >::CSequence ( std::initializer_list< T > il)
inline

Initializer list constructor.

Definition at line 128 of file sequence.h.

◆ findByFrequency()

CTextMessageList swift::misc::network::CTextMessageList::findByFrequency ( const physical_quantities::CFrequency & frequency) const

Find by frequency.

Definition at line 81 of file textmessagelist.cpp.

◆ findByNotForRecipient()

CTextMessageList swift::misc::network::CTextMessageList::findByNotForRecipient ( const swift::misc::aviation::CCallsign & recipient) const

Find by recipient is NOT addressed.

Definition at line 96 of file textmessagelist.cpp.

◆ findByRecipient()

CTextMessageList swift::misc::network::CTextMessageList::findByRecipient ( const swift::misc::aviation::CCallsign & recipient) const

Find by recipient.

Definition at line 91 of file textmessagelist.cpp.

◆ findBySender()

CTextMessageList swift::misc::network::CTextMessageList::findBySender ( const swift::misc::aviation::CCallsign & sender) const

Find by sender.

Definition at line 86 of file textmessagelist.cpp.

◆ getPrivateMessages()

CTextMessageList swift::misc::network::CTextMessageList::getPrivateMessages ( ) const

Private messages.

Definition at line 54 of file textmessagelist.cpp.

◆ getRadioMessages()

CTextMessageList swift::misc::network::CTextMessageList::getRadioMessages ( ) const

Public messages.

Definition at line 69 of file textmessagelist.cpp.

◆ getSupervisorMessages()

CTextMessageList swift::misc::network::CTextMessageList::getSupervisorMessages ( ) const

Supervisor messages.

Definition at line 74 of file textmessagelist.cpp.

◆ markAsSent()

void swift::misc::network::CTextMessageList::markAsSent ( )

Mark all messages as sent.

Definition at line 193 of file textmessagelist.cpp.

◆ markedAsSent()

CTextMessageList swift::misc::network::CTextMessageList::markedAsSent ( )

Marked as sent.

Definition at line 198 of file textmessagelist.cpp.

◆ relayedToPrivateMessages()

int swift::misc::network::CTextMessageList::relayedToPrivateMessages ( )

Turn relayed into normal private messages.

Definition at line 126 of file textmessagelist.cpp.

◆ removePrivateMessagesFromCallsign()

int swift::misc::network::CTextMessageList::removePrivateMessagesFromCallsign ( const aviation::CCallsign & callsign)

Remove private messages from callsign.

Definition at line 144 of file textmessagelist.cpp.

◆ toggleSenderRecipients()

void swift::misc::network::CTextMessageList::toggleSenderRecipients ( )

Toggle all sender <-> recipients.

Definition at line 117 of file textmessagelist.cpp.

◆ withRelayedToPrivateMessages()

CTextMessageList swift::misc::network::CTextMessageList::withRelayedToPrivateMessages ( ) const

List with relayed messages (if any) as private messages.

Definition at line 160 of file textmessagelist.cpp.

◆ withRemovedPrivateMessagesFromCallsign()

CTextMessageList swift::misc::network::CTextMessageList::withRemovedPrivateMessagesFromCallsign ( const aviation::CCallsign & callsign) const

With removed private messages from callsign.

Definition at line 171 of file textmessagelist.cpp.


The documentation for this class was generated from the following files: