swift
statusmessagelist.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_MISC_STATUSMESSAGELIST_H
7 #define SWIFT_MISC_STATUSMESSAGELIST_H
8 
9 #include <QJsonArray>
10 #include <QMap>
11 #include <QMetaType>
12 #include <QtGlobal>
13 
14 #include "misc/collection.h"
15 #include "misc/logcategory.h"
16 #include "misc/logcategorylist.h"
17 #include "misc/orderablelist.h"
18 #include "misc/sequence.h"
19 #include "misc/statusmessage.h"
20 #include "misc/swiftmiscexport.h"
22 
23 SWIFT_DECLARE_SEQUENCE_MIXINS(swift::misc, CStatusMessage, CStatusMessageList)
24 
25 namespace swift::misc
26 {
29  public CSequence<CStatusMessage>,
30  public ITimestampObjectList<CStatusMessage, CStatusMessageList>,
31  public IOrderableList<CStatusMessage, CStatusMessageList>,
32  public mixin::MetaType<CStatusMessageList>
33  {
34  public:
37 
39  CStatusMessageList() = default;
40 
43 
45  CStatusMessageList(const CStatusMessage &statusMessage);
46 
49 
52 
54  bool hasErrorMessages() const;
55 
57  bool hasWarningMessages() const;
58 
61 
63  bool isSuccess() const;
64 
66  bool isFailure() const;
67 
70 
73 
75  void addCategory(const CLogCategory &category);
76 
79 
81  void addCategories(const CLogCategoryList &categories);
82 
84  void addValidationMessage(const QString &validationText, CStatusMessage::StatusSeverity severity);
85 
87  void setCategory(const CLogCategory &category);
88 
90  void setCategories(const CLogCategoryList &categories);
91 
94 
97 
100 
103 
106 
109 
112 
115  int keepLatest(int estimtatedNumber);
116 
119 
122 
125 
127  QString toHtml(const CPropertyIndexList &indexes = simpleHtmlOutput()) const;
128 
131 
134 
136  static const QString &htmlStyleSheet();
137 
139  static CStatusMessageList fromDatabaseJson(const QJsonArray &array);
140  };
141 } // namespace swift::misc
142 
143 Q_DECLARE_METATYPE(swift::misc::CStatusMessageList)
145 
146 #endif // SWIFT_MISC_STATUSMESSAGELIST_H
Generic ordered container with value semantics.
Definition: collection.h:107
A log category is an arbitrary string tag which can be attached to log messages.
Definition: logcategory.h:28
A sequence of log categories.
Value object encapsulating a list of property indexes.
Generic sequential container with value semantics.
Definition: sequence.h:86
CSequence()=default
Default constructor.
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
bool isFailure() const
Any message is marked as failure.
int keepLatest(int estimtatedNumber)
Keep latest n status messages.
CStatusMessage toSingleMessage() const
Merge into a single message.
void removeInfoAndBelow()
Remove info and below.
void addValidationMessage(const QString &validationText, CStatusMessage::StatusSeverity severity)
Convenience function to push back a validation message.
CStatusMessageList findBySeverity(CStatusMessage::StatusSeverity severity) const
Find by severity.
void addCategory(const CLogCategory &category)
Add a category to all messages in the list.
QString toHtml(const CPropertyIndexList &indexes=simpleHtmlOutput()) const
Specialized version to convert to HTML.
static const CPropertyIndexList & timestampHtmlOutput()
Properties for CStatusMessageList::toHtml.
CStatusMessage::StatusSeverity worstSeverity() const
Find worst severity.
static const CPropertyIndexList & simpleHtmlOutput()
Properties for CStatusMessageList::toHtml.
CStatusMessageList findByCategory(const CLogCategory &category) const
Find by type.
bool hasWarningOrErrorMessages() const
Warning or error messages.
void setCategories(const CLogCategoryList &categories)
Reset the categories of all messages in the list.
static const QString & htmlStyleSheet()
Default style sheet which can be used with CStatusMessageList::toHtml.
void addCategories(const CLogCategoryList &categories)
Add some categories to all messages in the list.
void removeSeverity(CStatusMessage::StatusSeverity severity)
Remove given severity.
CStatusMessageList getErrorMessages() const
Get all error messages.
bool hasWarningMessages() const
Warning messages.
CStatusMessageList(const CSequence< CStatusMessage > &other)
Construct from a base class object.
void addValidationCategory()
Validation category.
void removeWarningsAndBelow()
Remove warnings and below.
bool hasErrorMessages() const
Error messages.
void sortBySeverity()
Sort by severity, lowest first.
void clampSeverity(CStatusMessage::StatusSeverity severity)
And higher (more critical) severity will be clipped to given severity.
static CStatusMessageList fromDatabaseJson(const QJsonArray &array)
From our database JSON format.
bool isSuccess() const
All messages are marked as success.
CStatusMessageList()=default
Constructor.
void warningToError()
Turn warnings into errors.
CStatusMessageList(const CStatusMessage &statusMessage)
Construct from single message.
CStatusMessageList getWarningAndErrorMessages() const
Get all warning and error messages.
QMap< int, int > countSeverities() const
Count number of messages per severity.
void sortBySeverityHighestFirst()
Sort by severity, highest first.
void setCategory(const CLogCategory &category)
Reset the category of all messages in the list.
List of orderable IOrderable objects.
Definition: orderablelist.h:19
List of objects with timestamp. Such objects should implement.
CRTP class template from which a derived class can inherit common methods dealing with the metatype o...
Definition: mixinmetatype.h:29
#define SWIFT_MISC_DECLARE_USING_MIXIN_METATYPE(DERIVED)
When a derived class and a base class both inherit from mixin::MetaType, the derived class uses this ...
Free functions in swift::misc.
StatusSeverity
Status severities.
Definition: statusmessage.h:35
#define SWIFT_DECLARE_SEQUENCE_MIXINS(Namespace, T, List)
Explicit template declaration of mixins for a CSequence subclass to be placed near the top of the hea...
Definition: sequence.h:62
#define SWIFT_MISC_EXPORT
Export a class or function from the library.