KTextEditor::Attribute

Search for usage in LXR

KTextEditor::Attribute Class Reference

#include <KTextEditor/Attribute>

Inheritance diagram for KTextEditor::Attribute:

Public Types

typedef QExplicitlySharedDataPointer< AttributePtr
 
- Public Types inherited from QTextCharFormat
enum  FontPropertiesInheritanceBehavior
 
enum  UnderlineStyle
 
enum  VerticalAlignment
 
- Public Types inherited from QTextFormat
enum  FormatType
 
enum  ObjectTypes
 
enum  PageBreakFlag
 
enum  Property
 

Public Member Functions

 Attribute ()
 
 Attribute (const QString &name, DefaultStyle style)
 
 Attribute (const Attribute &a)
 
virtual ~Attribute ()
 
Attributeoperator+= (const Attribute &a)
 
Attributeoperator= (const Attribute &a)
 
Custom properties

The following functions provide custom properties which can be set for rendering by editor implementations.

QString name () const
 
void setName (const QString &name)
 
DefaultStyle defaultStyle () const
 
void setDefaultStyle (DefaultStyle style)
 
bool skipSpellChecking () const
 
void setSkipSpellChecking (bool skipspellchecking)
 
bool fontBold () const
 
void setFontBold (bool bold=true)
 
QBrush outline () const
 
void setOutline (const QBrush &brush)
 
QBrush selectedForeground () const
 
void setSelectedForeground (const QBrush &foreground)
 
QBrush selectedBackground () const
 
void setSelectedBackground (const QBrush &brush)
 
bool backgroundFillWhitespace () const
 
void setBackgroundFillWhitespace (bool fillWhitespace)
 
void clear ()
 
bool hasAnyProperty () const
 
- Public Member Functions inherited from QTextCharFormat
QString anchorHref () const const
 
QString anchorName () const const
 
QStringList anchorNames () const const
 
QFont font () const const
 
QFont::Capitalization fontCapitalization () const const
 
QVariant fontFamilies () const const
 
QString fontFamily () const const
 
bool fontFixedPitch () const const
 
QFont::HintingPreference fontHintingPreference () const const
 
bool fontItalic () const const
 
bool fontKerning () const const
 
qreal fontLetterSpacing () const const
 
QFont::SpacingType fontLetterSpacingType () const const
 
bool fontOverline () const const
 
qreal fontPointSize () const const
 
int fontStretch () const const
 
bool fontStrikeOut () const const
 
QFont::StyleHint fontStyleHint () const const
 
QVariant fontStyleName () const const
 
QFont::StyleStrategy fontStyleStrategy () const const
 
bool fontUnderline () const const
 
int fontWeight () const const
 
qreal fontWordSpacing () const const
 
bool isAnchor () const const
 
bool isValid () const const
 
void setAnchor (bool anchor)
 
void setAnchorHref (const QString &value)
 
void setAnchorName (const QString &name)
 
void setAnchorNames (const QStringList &names)
 
void setFont (const QFont &font)
 
void setFont (const QFont &font, QTextCharFormat::FontPropertiesInheritanceBehavior behavior)
 
void setFontCapitalization (QFont::Capitalization capitalization)
 
void setFontFamilies (const QStringList &families)
 
void setFontFamily (const QString &family)
 
void setFontFixedPitch (bool fixedPitch)
 
void setFontHintingPreference (QFont::HintingPreference hintingPreference)
 
void setFontItalic (bool italic)
 
void setFontKerning (bool enable)
 
void setFontLetterSpacing (qreal spacing)
 
void setFontLetterSpacingType (QFont::SpacingType letterSpacingType)
 
void setFontOverline (bool overline)
 
void setFontPointSize (qreal size)
 
void setFontStretch (int factor)
 
void setFontStrikeOut (bool strikeOut)
 
void setFontStyleHint (QFont::StyleHint hint, QFont::StyleStrategy strategy)
 
void setFontStyleName (const QString &styleName)
 
void setFontStyleStrategy (QFont::StyleStrategy strategy)
 
void setFontUnderline (bool underline)
 
void setFontWeight (int weight)
 
void setFontWordSpacing (qreal spacing)
 
void setTextOutline (const QPen &pen)
 
void setToolTip (const QString &text)
 
void setUnderlineColor (const QColor &color)
 
void setUnderlineStyle (QTextCharFormat::UnderlineStyle style)
 
void setVerticalAlignment (QTextCharFormat::VerticalAlignment alignment)
 
QPen textOutline () const const
 
QString toolTip () const const
 
QColor underlineColor () const const
 
QTextCharFormat::UnderlineStyle underlineStyle () const const
 
QTextCharFormat::VerticalAlignment verticalAlignment () const const
 
- Public Member Functions inherited from QTextFormat
 QTextFormat (int type)
 
 QTextFormat (const QTextFormat &other)
 
QBrush background () const const
 
bool boolProperty (int propertyId) const const
 
QBrush brushProperty (int propertyId) const const
 
void clearBackground ()
 
void clearForeground ()
 
void clearProperty (int propertyId)
 
QColor colorProperty (int propertyId) const const
 
qreal doubleProperty (int propertyId) const const
 
QBrush foreground () const const
 
bool hasProperty (int propertyId) const const
 
int intProperty (int propertyId) const const
 
bool isBlockFormat () const const
 
bool isCharFormat () const const
 
bool isEmpty () const const
 
bool isFrameFormat () const const
 
bool isImageFormat () const const
 
bool isListFormat () const const
 
bool isTableCellFormat () const const
 
bool isTableFormat () const const
 
bool isValid () const const
 
Qt::LayoutDirection layoutDirection () const const
 
QTextLength lengthProperty (int propertyId) const const
 
QVector< QTextLengthlengthVectorProperty (int propertyId) const const
 
void merge (const QTextFormat &other)
 
int objectIndex () const const
 
int objectType () const const
 
QVariant operator QVariant () const const
 
bool operator!= (const QTextFormat &other) const const
 
QTextFormatoperator= (const QTextFormat &other)
 
bool operator== (const QTextFormat &other) const const
 
QPen penProperty (int propertyId) const const
 
QMap< int, QVariantproperties () const const
 
QVariant property (int propertyId) const const
 
int propertyCount () const const
 
void setBackground (const QBrush &brush)
 
void setForeground (const QBrush &brush)
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setObjectIndex (int index)
 
void setObjectType (int type)
 
void setProperty (int propertyId, const QVector< QTextLength > &value)
 
void setProperty (int propertyId, const QVariant &value)
 
QString stringProperty (int propertyId) const const
 
void swap (QTextFormat &other)
 
QTextBlockFormat toBlockFormat () const const
 
QTextCharFormat toCharFormat () const const
 
QTextFrameFormat toFrameFormat () const const
 
QTextImageFormat toImageFormat () const const
 
QTextListFormat toListFormat () const const
 
QTextTableCellFormat toTableCellFormat () const const
 
QTextTableFormat toTableFormat () const const
 
int type () const const
 
- Public Member Functions inherited from QSharedData
 QSharedData (const QSharedData &)
 

Dynamic highlighting

The following functions allow for text to be highlighted dynamically based on several events.

enum  ActivationType { ActivateMouseIn = 0, ActivateCaretIn }
 
Attribute::Ptr dynamicAttribute (ActivationType type) const
 
void setDynamicAttribute (ActivationType type, Attribute::Ptr attribute)
 

Additional Inherited Members

- Public Attributes inherited from QTextCharFormat
 AlignBaseline
 
 AlignBottom
 
 AlignMiddle
 
 AlignNormal
 
 AlignSubScript
 
 AlignSuperScript
 
 AlignTop
 
 DashDotDotLine
 
 DashDotLine
 
 DashUnderline
 
 DotLine
 
 FontPropertiesAll
 
 FontPropertiesSpecifiedOnly
 
 NoUnderline
 
 SingleUnderline
 
 SpellCheckUnderline
 
 WaveUnderline
 
- Public Attributes inherited from QTextFormat
 AnchorHref
 
 AnchorName
 
 BackgroundBrush
 
 BackgroundImageUrl
 
 BlockAlignment
 
 BlockBottomMargin
 
 BlockCodeFence
 
 BlockCodeLanguage
 
 BlockFormat
 
 BlockIndent
 
 BlockLeftMargin
 
 BlockMarker
 
 BlockNonBreakableLines
 
 BlockQuoteLevel
 
 BlockRightMargin
 
 BlockTopMargin
 
 BlockTrailingHorizontalRulerWidth
 
 CharFormat
 
 CssFloat
 
 FirstFontProperty
 
 FontCapitalization
 
 FontFamilies
 
 FontFamily
 
 FontFixedPitch
 
 FontHintingPreference
 
 FontItalic
 
 FontKerning
 
 FontLetterSpacing
 
 FontLetterSpacingType
 
 FontOverline
 
 FontPixelSize
 
 FontPointSize
 
 FontSizeAdjustment
 
 FontSizeIncrement
 
 FontStretch
 
 FontStrikeOut
 
 FontStyleHint
 
 FontStyleName
 
 FontStyleStrategy
 
 FontUnderline
 
 FontWeight
 
 FontWordSpacing
 
 ForegroundBrush
 
 FrameBorder
 
 FrameBorderBrush
 
 FrameBorderStyle
 
 FrameBottomMargin
 
 FrameFormat
 
 FrameHeight
 
 FrameLeftMargin
 
 FrameMargin
 
 FramePadding
 
 FrameRightMargin
 
 FrameTopMargin
 
 FrameWidth
 
 FullWidthSelection
 
 HeadingLevel
 
 ImageAltText
 
 ImageHeight
 
 ImageName
 
 ImageObject
 
 ImageQuality
 
 ImageTitle
 
 ImageWidth
 
 InvalidFormat
 
 IsAnchor
 
 LastFontProperty
 
 LayoutDirection
 
 LineHeight
 
 LineHeightType
 
 ListFormat
 
 ListIndent
 
 ListNumberPrefix
 
 ListNumberSuffix
 
 ListStyle
 
 NoObject
 
 ObjectIndex
 
 ObjectType
 
 OutlinePen
 
 PageBreak_AlwaysAfter
 
 PageBreak_AlwaysBefore
 
 PageBreak_Auto
 
typedef PageBreakFlags
 
 PageBreakPolicy
 
 TableBorderCollapse
 
 TableCellBottomBorder
 
 TableCellBottomBorderBrush
 
 TableCellBottomBorderStyle
 
 TableCellBottomPadding
 
 TableCellColumnSpan
 
 TableCellLeftBorder
 
 TableCellLeftBorderBrush
 
 TableCellLeftBorderStyle
 
 TableCellLeftPadding
 
 TableCellObject
 
 TableCellPadding
 
 TableCellRightBorder
 
 TableCellRightBorderBrush
 
 TableCellRightBorderStyle
 
 TableCellRightPadding
 
 TableCellRowSpan
 
 TableCellSpacing
 
 TableCellTopBorder
 
 TableCellTopBorderBrush
 
 TableCellTopBorderStyle
 
 TableCellTopPadding
 
 TableColumns
 
 TableColumnWidthConstraints
 
 TableFormat
 
 TableHeaderRowCount
 
 TableObject
 
 TabPositions
 
 TextIndent
 
 TextOutline
 
 TextToolTip
 
 TextUnderlineColor
 
 TextUnderlineStyle
 
 TextVerticalAlignment
 
 UserFormat
 
 UserObject
 
 UserProperty
 

Detailed Description

A class which provides customized text decorations.

The Attribute class extends QTextCharFormat, the class which Qt uses internally to provide formatting information to characters in a text document.

In addition to its inherited properties, it provides support for:

  • several customized text formatting properties
  • dynamic highlighting of associated ranges of text
  • binding of actions with associated ranges of text (note: not currently implemented)

Implementations are not required to support all properties. In particular, several properties are not supported for dynamic highlighting (notably: font() and fontBold()).

Unfortunately, as QTextFormat's setProperty() is not virtual, changes that are made to this attribute cannot automatically be redrawn. Once you have finished changing properties, you should call changed() to force redrawing of affected ranges of text.

See also
MovingInterface
Author
Hamish Rodda <rodda[email protected]@kde[email protected].org>

Definition at line 142 of file attribute.h.

Member Typedef Documentation

Shared data pointer for Attribute.

Definition at line 148 of file attribute.h.

Member Enumeration Documentation

Several automatic activation mechanisms exist for associated attributes.

Using this you can conveniently have your ranges highlighted when either the mouse or cursor enter the range.

Enumerator
ActivateMouseIn 

Activate attribute on mouse in.

ActivateCaretIn 

Activate attribute on caret in.

Definition at line 336 of file attribute.h.

Constructor & Destructor Documentation

Attribute::Attribute ( )

Default constructor.

The resulting Attribute has no properties set to begin with.

Definition at line 24 of file attribute.cpp.

Attribute::Attribute ( const QString name,
DefaultStyle  style 
)

Construct attribute with given name & default style properties.

Parameters
nameattribute name
styleattribute default style

Definition at line 29 of file attribute.cpp.

Attribute::Attribute ( const Attribute a)

Copy constructor.

Definition at line 36 of file attribute.cpp.

Attribute::~Attribute ( )
virtual

Virtual destructor.

Definition at line 44 of file attribute.cpp.

Member Function Documentation

bool Attribute::backgroundFillWhitespace ( ) const

Determine whether background color is drawn over whitespace.

Defaults to true if not set.

Returns
whether the background color should be drawn over whitespace

Definition at line 142 of file attribute.cpp.

void Attribute::clear ( )

Clear all set properties.

Definition at line 170 of file attribute.cpp.

DefaultStyle Attribute::defaultStyle ( ) const

Default style of this attribute.

Returns
default style

Definition at line 94 of file attribute.cpp.

Attribute::Ptr Attribute::dynamicAttribute ( ActivationType  type) const

Return the attribute to use when the event referred to by type occurs.

Parameters
typethe activation type for which to return the Attribute.
Returns
the attribute to be used for events specified by type, or null if none is set.

Definition at line 66 of file attribute.cpp.

bool Attribute::fontBold ( ) const

Find out if the font weight is set to QFont::Bold.

Returns
true if the font weight is exactly QFont::Bold, otherwise false
See also
QTextCharFormat::fontWeight()

Definition at line 179 of file attribute.cpp.

bool Attribute::hasAnyProperty ( ) const

Determine if any properties are set.

Returns
true if any properties are set, otherwise false

Definition at line 189 of file attribute.cpp.

QString Attribute::name ( ) const

Attribute name.

Returns
attribute name

Definition at line 84 of file attribute.cpp.

Attribute & Attribute::operator+= ( const Attribute a)

Addition assignment operator.

Use this to merge another Attribute with this Attribute. Where both attributes have a particular property set, the property in a will be used.

Parameters
aattribute to merge into this attribute.

Definition at line 49 of file attribute.cpp.

Attribute & KTextEditor::Attribute::operator= ( const Attribute a)

Replacement assignment operator.

Use this to overwrite this Attribute with another Attribute.

Parameters
aattribute to assign to this attribute.

Definition at line 194 of file attribute.cpp.

QBrush Attribute::outline ( ) const

Get the brush used to draw an outline around text, if any.

Returns
brush to be used to draw an outline, or Qt::NoBrush if no outline is set.

Definition at line 114 of file attribute.cpp.

QBrush Attribute::selectedBackground ( ) const

Get the brush used to draw the background of selected text, if any.

Returns
brush to be used to draw the background of selected text, or Qt::NoBrush if not set

Definition at line 156 of file attribute.cpp.

QBrush Attribute::selectedForeground ( ) const

Get the brush used to draw text when it is selected, if any.

Returns
brush to be used to draw selected text, or Qt::NoBrush if not set

Definition at line 128 of file attribute.cpp.

void Attribute::setBackgroundFillWhitespace ( bool  fillWhitespace)

Set whether background color is drawn over whitespace.

Defaults to true if not set.

Use clearProperty(BackgroundFillWhitespace) to clear.

Parameters
fillWhitespacewhether the background should be drawn over whitespace.

Definition at line 151 of file attribute.cpp.

void Attribute::setDefaultStyle ( DefaultStyle  style)

Set default style of this attribute.

Parameters
stylenew default style

Definition at line 99 of file attribute.cpp.

void Attribute::setDynamicAttribute ( ActivationType  type,
Attribute::Ptr  attribute 
)

Set the attribute to use when the event referred to by type occurs.

Note
Nested dynamic attributes are ignored.
Parameters
typethe activation type to set the attribute for
attributethe attribute to assign. As attribute is refcounted, ownership is not an issue.

Definition at line 75 of file attribute.cpp.

void Attribute::setFontBold ( bool  bold = true)

Set the font weight to QFont::Bold.

If bold is false, the weight will be set to 0 (normal).

Parameters
boldwhether the font weight should be bold or not.
See also
QTextCharFormat::setFontWeight()

Definition at line 184 of file attribute.cpp.

void Attribute::setName ( const QString name)

Set attribute name.

Parameters
namenew attribute name

Definition at line 89 of file attribute.cpp.

void Attribute::setOutline ( const QBrush brush)

Set a brush to be used to draw an outline around text.

Use clearProperty(Outline) to clear.

Parameters
brushbrush to be used to draw an outline.

Definition at line 123 of file attribute.cpp.

void Attribute::setSelectedBackground ( const QBrush brush)

Set a brush to be used to draw the background of selected text, if any.

Use clearProperty(SelectedBackground) to clear.

Parameters
brushbrush to be used to draw the background of selected text

Definition at line 165 of file attribute.cpp.

void Attribute::setSelectedForeground ( const QBrush foreground)

Set a brush to be used to draw selected text.

Use clearProperty(SelectedForeground) to clear.

Parameters
foregroundbrush to be used to draw selected text.

Definition at line 137 of file attribute.cpp.

void Attribute::setSkipSpellChecking ( bool  skipspellchecking)

Set if we should spellchecking be skipped?

Parameters
skipspellcheckingshould spellchecking be skipped?

Definition at line 109 of file attribute.cpp.

bool Attribute::skipSpellChecking ( ) const

Should spellchecking be skipped?

Returns
skip spellchecking?

Definition at line 104 of file attribute.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Oct 15 2021 22:59:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.