MessageCore::StringUtil
Enumerations | |
enum | AddressMode : uint8_t { ExpandableAddresses , FullAddresses } |
enum | Display : uint8_t { DisplayNameOnly , DisplayFullAddress } |
enum | Link : uint8_t { ShowLink , HideLink } |
Functions | |
bool | addressIsInAddressList (const QString &address, const QStringList &addresses) |
QByteArray | asSendableString (const KMime::Message::Ptr &message) |
QString | cleanFileName (const QString &fileName) |
QString | cleanSubject (KMime::Message *msg) |
QString | cleanSubject (KMime::Message *msg, const QStringList &prefixRegExps, bool replace, const QString &newPrefix) |
QString | emailAddrAsAnchor (const KMime::Headers::Generics::AddressList *addressList, Display display=DisplayNameOnly, const QString &cssStyle=QString(), Link link=ShowLink, AddressMode expandable=FullAddresses, const QString &fieldName=QString(), int collapseNumber=4) |
QString | emailAddrAsAnchor (const KMime::Headers::Generics::MailboxList *mailboxList, Display display=DisplayNameOnly, const QString &cssStyle=QString(), Link link=ShowLink, AddressMode expandable=FullAddresses, const QString &fieldName=QString(), int collapseNumber=4) |
QString | emailAddrAsAnchor (const KMime::Types::Mailbox::List &mailboxList, Display display, const QString &cssStyle, Link link, AddressMode expandable, const QString &fieldName, int collapseNumber) |
MESSAGECORE_EXPORT QString | emailAddrAsAnchor (const QList< KMime::Types::Mailbox > &mailboxList, Display display=DisplayNameOnly, const QString &cssStyle=QString(), Link link=ShowLink, AddressMode expandable=FullAddresses, const QString &fieldName=QString(), int collapseNumber=4) |
static bool | flushPart (QString &msg, QStringList &textParts, const QString &indent, int maxLength) |
QString | formatQuotePrefix (const QString &wildString, const QString &fromDisplayString) |
QString | forwardSubject (KMime::Message *msg) |
QString | generateMessageId (const QString &address, const QString &suffix) |
QString | guessEmailAddressFromLoginName (const QString &userName) |
QByteArray | headerAsSendableString (const KMime::Message::Ptr &message) |
QList< QPair< QString, QString > > | parseMailtoUrl (const QUrl &url) |
QString | quoteHtmlChars (const QString &text, bool removeLineBreaks=false) |
void | removePrivateHeaderFields (const KMime::Message::Ptr &message, bool cleanUpHeader=true) |
static void | removeTrailingSpace (QString &line) |
QString | replacePrefixes (const QString &str, const QStringList &prefixRegExps, bool replace, const QString &newPrefix) |
QString | replySubject (KMime::Message *msg) |
void | setEncodingFile (QUrl &url, const QString &encoding) |
QString | smartQuote (const QString &message, int maxLineLength) |
AddressList | splitAddressField (const QByteArray &text) |
static QString | splitLine (QString &line) |
QString | stripOffPrefixes (const QString &subject) |
QString | stripSignature (const QString &message) |
Detailed Description
This namespace contain helper functions for string manipulation.
Enumeration Type Documentation
◆ AddressMode
enum MessageCore::StringUtil::AddressMode : uint8_t |
Used to determine if the address field should be expandable/collapsible.
Definition at line 108 of file stringutil.h.
◆ Display
enum MessageCore::StringUtil::Display : uint8_t |
Used to determine if the visible part of the anchor contains only the name part and not the given emailAddr or the full address.
Definition at line 92 of file stringutil.h.
◆ Link
enum MessageCore::StringUtil::Link : uint8_t |
Used to determine if the address should be a link or not.
Definition at line 100 of file stringutil.h.
Function Documentation
◆ addressIsInAddressList()
|
nodiscard |
Returns true if the given address is contained in the given address list.
Definition at line 493 of file stringutil.cpp.
◆ asSendableString()
|
nodiscard |
Returns the message
contents with the headers that should not be sent stripped off.
Definition at line 380 of file stringutil.cpp.
◆ cleanFileName()
|
nodiscard |
Cleans a filename by replacing characters not allowed or wanted on the filesystem e.g.
':', '/', '\' with '_'
Definition at line 684 of file stringutil.cpp.
◆ cleanSubject() [1/2]
|
nodiscard |
Return this mails subject, with all "forward" and "reply" prefixes removed.
Definition at line 720 of file stringutil.cpp.
◆ cleanSubject() [2/2]
|
nodiscard |
Check for prefixes prefixRegExps
in #subject().
If none is found, newPrefix
+ ' ' is prepended to the subject and the resulting string is returned. If replace
is true, any sequence of whitespace-delimited prefixes at the beginning of #subject() is replaced by newPrefix
Definition at line 729 of file stringutil.cpp.
◆ emailAddrAsAnchor() [1/4]
|
nodiscard |
Same as above method, only for AddressList headers.
Definition at line 481 of file stringutil.cpp.
◆ emailAddrAsAnchor() [2/4]
|
nodiscard |
Converts the email address(es) to (a) nice HTML mailto: anchor(s).
display
determines if only the name part or the entire address should be returned. cssStyle
a custom css template. link
determines if the result should be a html link or not. expandable
determines if a long list of addresses should be expandable or shown in full. fieldName
the name that the divs should be based on if expandable is set to ExpanableAddesses. The
number of addresses to show before collapsing the rest, if expandable is set to ExpandableAddresses.
Definition at line 469 of file stringutil.cpp.
◆ emailAddrAsAnchor() [3/4]
QString MessageCore::StringUtil::emailAddrAsAnchor | ( | const KMime::Types::Mailbox::List & | mailboxList, |
Display | display, | ||
const QString & | cssStyle, | ||
Link | link, | ||
AddressMode | expandable, | ||
const QString & | fieldName, | ||
int | collapseNumber ) |
Definition at line 402 of file stringutil.cpp.
◆ emailAddrAsAnchor() [4/4]
|
nodiscard |
Same as the above, only for Mailbox::List types.
◆ flushPart()
|
static |
Definition at line 111 of file stringutil.cpp.
◆ formatQuotePrefix()
|
nodiscard |
Convert quote wildcards into the final quote prefix.
- Parameters
-
wildString the string to be converted fromDisplayString displayable string of the from email address
Definition at line 633 of file stringutil.cpp.
◆ forwardSubject()
|
nodiscard |
Return this mails subject, formatted for "forward" mails.
Definition at line 738 of file stringutil.cpp.
◆ generateMessageId()
|
nodiscard |
Generates the Message-Id.
It uses either the Message-Id suffix
defined by the user or the given email address as suffix. The address
must be given as addr-spec as defined in RFC 2822.
Definition at line 297 of file stringutil.cpp.
◆ guessEmailAddressFromLoginName()
|
nodiscard |
Uses the hostname as domain part and tries to determine the real name from the entries in the password file.
Definition at line 507 of file stringutil.cpp.
◆ headerAsSendableString()
|
nodiscard |
Return the message header with the headers that should not be sent stripped off.
Definition at line 391 of file stringutil.cpp.
◆ parseMailtoUrl()
|
nodiscard |
Parses a mailto: url and extracts the information in the QMap (field name as key).
Definition at line 159 of file stringutil.cpp.
◆ quoteHtmlChars()
|
nodiscard |
Quotes the following characters which have a special meaning in HTML: '<' '>' '&' '"'. Additionally '\n' is converted to "<br />" if removeLineBreaks
is false.
If removeLineBreaks
is true, then '\n' is removed. Last but not least '\r' is removed.
Definition at line 314 of file stringutil.cpp.
◆ removePrivateHeaderFields()
MESSAGECORE_EXPORT void MessageCore::StringUtil::removePrivateHeaderFields | ( | const KMime::Message::Ptr & | message, |
bool | cleanUpHeader = true ) |
Removes all private header fields (e.g.
Status: and X-KMail-) from the given message
. if cleanUpHeader is false don't remove X-KMail-Identity and X-KMail-Dictionary which is useful when we want restore mail.
Definition at line 351 of file stringutil.cpp.
◆ removeTrailingSpace()
|
static |
Definition at line 35 of file stringutil.cpp.
◆ replacePrefixes()
|
nodiscard |
Check for prefixes prefixRegExps
in str
.
If none is found, newPrefix
+ ' ' is prepended to str
and the resulting string is returned. If replace
is true, any sequence of whitespace-delimited prefixes at the beginning of str
is replaced by newPrefix
.
Definition at line 754 of file stringutil.cpp.
◆ replySubject()
|
nodiscard |
Return this mails subject, formatted for "reply" mails.
Definition at line 746 of file stringutil.cpp.
◆ setEncodingFile()
MESSAGECORE_EXPORT void MessageCore::StringUtil::setEncodingFile | ( | QUrl & | url, |
const QString & | encoding ) |
Definition at line 819 of file stringutil.cpp.
◆ smartQuote()
|
nodiscard |
Relayouts the given string so that the individual lines don't exceed the given maximal length.
As the name of the function implies, it is smart, which means it deals with quoting correctly. This means if a line already starts with quote characters and needs to be broken, the same quote characters are prepended to the next line as well.
This does not add new quote characters in front of every line, that is the responsibility of the caller.
- Parameters
-
message The string which it to be relayouted maxLineLength reformat text to be this amount of columns at maximum. Note that this also includes the trailing
!
Definition at line 527 of file stringutil.cpp.
◆ splitAddressField()
|
nodiscard |
Splits the given address list text
into separate addresses.
Definition at line 280 of file stringutil.cpp.
◆ splitLine()
Definition at line 48 of file stringutil.cpp.
◆ stripOffPrefixes()
|
nodiscard |
Removes the forward and reply marks (e.g.
Re: or Fwd:) from a subject
string. Additional markers to act on can be specified in the MessageCore::GlobalSettings object.
Definition at line 785 of file stringutil.cpp.
◆ stripSignature()
|
nodiscard |
Strips the signature blocks from a message text.
"-- " is considered as a signature block separator.
- Parameters
-
message The message to remove the signature block from.
Definition at line 220 of file stringutil.cpp.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 11:58:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.