KI18n 5.109.0
Public Member Functions | List of all members
KuitSetup

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.
 

Detailed Description

Class for modifying KUIT markup in a given domain.

Not directly constructed, but obtained through Kuit::setupForDomain.

Constructor & Destructor Documentation

◆ ~KuitSetup()

KuitSetup::~KuitSetup ( )

Destructor.

Member Function Documentation

◆ setFormatForMarker()

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.

Parameters
markerthe UI marker
formatthe visual format

◆ setTagClass()

void KuitSetup::setTagClass ( const QString &  tagName,
Kuit::TagClass  aClass 
)

Set the KUIT class of the tag.

Parameters
tagNamethe name of the tag
aClassthe KUIT tag class

◆ setTagPattern()

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.

Parameters
tagNamethe name of the tag
attribNamesthe names of the attributes (empty names are ignored)
formatthe target visual format
patternthe pattern string
leadingNewlinesthe number of new lines (\n) to be maintained between any preceding text and the text wrapped with this tag (for formats where it matters)