KI18n 5.109.0
|
Class for modifying KUIT markup in a given domain. More...
#include <KuitSetup>
Public Member Functions | |
~KuitSetup () | |
Destructor. | |
void | setFormatForMarker (const QString &marker, Kuit::VisualFormat format) |
Set the default visual format for a given UI marker. | |
void | setTagClass (const QString &tagName, Kuit::TagClass aClass) |
Set the KUIT class of the tag. | |
void | setTagPattern (const QString &tagName, const QStringList &attribNames, Kuit::VisualFormat format, const KLocalizedString &pattern, Kuit::TagFormatter formatter=nullptr, int leadingNewlines=0) |
Set the formatting string for a tag with attributes combination. | |
Class for modifying KUIT markup in a given domain.
Not directly constructed, but obtained through Kuit::setupForDomain
.
KuitSetup::~KuitSetup | ( | ) |
Destructor.
void KuitSetup::setFormatForMarker | ( | const QString & | marker, |
Kuit::VisualFormat | format | ||
) |
Set the default visual format for a given UI marker.
Giving "@<major>"
for marker
means to set the format only for standalone @<major>
marker, while "@<major>:"
(with trailing colon) means to set the same format for all @<major>:<minor>
combinations.
Defined UI marker major/minor combinations are listed in the section uimark_ctxt. If an UI marker combination outside of the defined is given as marker
, it will be ignored.
Setting Kuit::UndefinedFormat
as format
means to fall back to default format for the given UI marker.
marker | the UI marker |
format | the visual format |
void KuitSetup::setTagClass | ( | const QString & | tagName, |
Kuit::TagClass | aClass | ||
) |
Set the KUIT class of the tag.
tagName | the name of the tag |
aClass | the KUIT tag class |
void KuitSetup::setTagPattern | ( | const QString & | tagName, |
const QStringList & | attribNames, | ||
Kuit::VisualFormat | format, | ||
const KLocalizedString & | pattern, | ||
Kuit::TagFormatter | formatter = nullptr , |
||
int | leadingNewlines = 0 |
||
) |
Set the formatting string for a tag with attributes combination.
If a new tag name is given, this effectively defines a new tag. The same holds for attribute names.
The pattern string pattern
should contain placeholders for inserting the text and the attribute values. %1 will be replaced with the wrapped text, and %2 and upwards with attribute values in the order given by attrNames
. Non markup-aware translation call with context (ki18nc
) should be used to create the pattern string.
In addition to the pattern, a formatting function of the type TagFormatter
can be given. This function receives the full markup parsing context, so that it can do whatever is necessary with the wrapped text. The result of this function is then substituted into the pattern. You can also give an empty pattern (as KLocalizedString()
) together with the formatting function, in which case the function is assumed to do everything and no substitution is performed.
tagName | the name of the tag |
attribNames | the names of the attributes (empty names are ignored) |
format | the target visual format |
pattern | the pattern string |
leadingNewlines | the number of new lines (\n) to be maintained between any preceding text and the text wrapped with this tag (for formats where it matters) |