mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-06 02:16:04 +08:00
Status message without tabs/CR
This commit is contained in:
@@ -14,6 +14,8 @@
|
|||||||
#include "loghandler.h"
|
#include "loghandler.h"
|
||||||
#include "logmessage.h"
|
#include "logmessage.h"
|
||||||
#include "comparefunctions.h"
|
#include "comparefunctions.h"
|
||||||
|
#include "stringutils.h"
|
||||||
|
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
|
|
||||||
@@ -223,6 +225,13 @@ namespace BlackMisc
|
|||||||
return this->getSeverity() == SeverityError;
|
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)
|
void CStatusMessage::prependMessage(const QString &msg)
|
||||||
{
|
{
|
||||||
if (msg.isEmpty()) { return; }
|
if (msg.isEmpty()) { return; }
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ namespace BlackMisc
|
|||||||
IndexSeverity,
|
IndexSeverity,
|
||||||
IndexSeverityAsString,
|
IndexSeverityAsString,
|
||||||
IndexMessage,
|
IndexMessage,
|
||||||
|
IndexMessageNoLineBreaks,
|
||||||
IndexMessageAsHtml
|
IndexMessageAsHtml
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -271,6 +272,9 @@ namespace BlackMisc
|
|||||||
//! Message
|
//! Message
|
||||||
QString getMessage() const { return this->message(); }
|
QString getMessage() const { return this->message(); }
|
||||||
|
|
||||||
|
//! Message without line breaks
|
||||||
|
QString getMessageNoLineBreaks() const;
|
||||||
|
|
||||||
//! Prepend message
|
//! Prepend message
|
||||||
void prependMessage(const QString &msg);
|
void prependMessage(const QString &msg);
|
||||||
|
|
||||||
@@ -336,15 +340,15 @@ namespace BlackMisc
|
|||||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
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;
|
int comparePropertyByIndex(const CPropertyIndex &index, const CStatusMessage &compareValue) const;
|
||||||
|
|
||||||
//! To HTML
|
|
||||||
QString toHtml() const;
|
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||||
QString convertToQString(bool i18n = false) const;
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
|
//! To HTML
|
||||||
|
QString toHtml() const;
|
||||||
|
|
||||||
//! Representing icon
|
//! Representing icon
|
||||||
static const CIcon &convertToIcon(const CStatusMessage &statusMessage);
|
static const CIcon &convertToIcon(const CStatusMessage &statusMessage);
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,12 @@ namespace BlackMisc
|
|||||||
return result;
|
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 "-", " "
|
//! Remove the typical separators such as "-", " "
|
||||||
BLACKMISC_EXPORT QString removeDateTimeSeparators(const QString &s);
|
BLACKMISC_EXPORT QString removeDateTimeSeparators(const QString &s);
|
||||||
|
|
||||||
@@ -53,6 +59,12 @@ namespace BlackMisc
|
|||||||
return std::any_of(s.begin(), s.end(), predicate);
|
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.
|
//! 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)
|
template <class F> int indexOfChar(const QString &s, F predicate)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user