mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 08:45:36 +08:00
Status message without tabs/CR
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
#include "loghandler.h"
|
||||
#include "logmessage.h"
|
||||
#include "comparefunctions.h"
|
||||
#include "stringutils.h"
|
||||
|
||||
#include <QMetaEnum>
|
||||
#include <QStringBuilder>
|
||||
|
||||
@@ -223,6 +225,13 @@ namespace BlackMisc
|
||||
return this->getSeverity() == SeverityError;
|
||||
}
|
||||
|
||||
QString CStatusMessage::getMessageNoLineBreaks() const
|
||||
{
|
||||
const QString m = this->getMessage();
|
||||
if (!containsLineBreakOrTab(m)) { return m; } // by far most messages will NOT contain tabs/CR
|
||||
return removeLineBreakAndTab(m);
|
||||
}
|
||||
|
||||
void CStatusMessage::prependMessage(const QString &msg)
|
||||
{
|
||||
if (msg.isEmpty()) { return; }
|
||||
|
||||
@@ -182,6 +182,7 @@ namespace BlackMisc
|
||||
IndexSeverity,
|
||||
IndexSeverityAsString,
|
||||
IndexMessage,
|
||||
IndexMessageNoLineBreaks,
|
||||
IndexMessageAsHtml
|
||||
};
|
||||
|
||||
@@ -271,6 +272,9 @@ namespace BlackMisc
|
||||
//! Message
|
||||
QString getMessage() const { return this->message(); }
|
||||
|
||||
//! Message without line breaks
|
||||
QString getMessageNoLineBreaks() const;
|
||||
|
||||
//! Prepend message
|
||||
void prependMessage(const QString &msg);
|
||||
|
||||
@@ -336,15 +340,15 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Compare for index
|
||||
//! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CStatusMessage &compareValue) const;
|
||||
|
||||
//! To HTML
|
||||
QString toHtml() const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! To HTML
|
||||
QString toHtml() const;
|
||||
|
||||
//! Representing icon
|
||||
static const CIcon &convertToIcon(const CStatusMessage &statusMessage);
|
||||
|
||||
|
||||
@@ -44,6 +44,12 @@ namespace BlackMisc
|
||||
return result;
|
||||
}
|
||||
|
||||
//! Remove line breaks and tabs
|
||||
inline QString removeLineBreakAndTab(const QString &s)
|
||||
{
|
||||
return removeChars(s, [](QChar c) { return c == '\n' || c == '\t'; });
|
||||
}
|
||||
|
||||
//! Remove the typical separators such as "-", " "
|
||||
BLACKMISC_EXPORT QString removeDateTimeSeparators(const QString &s);
|
||||
|
||||
@@ -53,6 +59,12 @@ namespace BlackMisc
|
||||
return std::any_of(s.begin(), s.end(), predicate);
|
||||
}
|
||||
|
||||
//! Contains a line break or tab
|
||||
inline bool containsLineBreakOrTab(const QString &s)
|
||||
{
|
||||
return containsChar(s, [](QChar c) { return c == '\n' || c == '\t'; });
|
||||
}
|
||||
|
||||
//! Index of first character in the string matching the given predicate, or -1 if not found.
|
||||
template <class F> int indexOfChar(const QString &s, F predicate)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user