qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
Text Class Reference

#include <text.h>

Inheritance diagram for Text:
Inheritance graph
Collaboration diagram for Text:
Collaboration graph

Public Types

enum  TextType { NORMAL, ACTION, CUSTOM }
 
- Public Types inherited from ChatLineContent
enum  GraphicsItemType { ChatLineContentType = QGraphicsItem::UserType + 1 }
 

Public Member Functions

 Text (const QString &txt="", const QFont &font=QFont(), bool enableElide=false, const QString &rawText=QString(), const TextType &type=NORMAL, const QColor &custom=Style::getColor(Style::MainText))
 
virtual ~Text ()
 
void setText (const QString &txt)
 
void selectText (const QString &txt, const std::pair< int, int > &point)
 
void selectText (const QRegularExpression &exp, const std::pair< int, int > &point)
 
void deselectText ()
 
void setWidth (qreal width) final
 
void selectionMouseMove (QPointF scenePos) final
 
void selectionStarted (QPointF scenePos) final
 
void selectionCleared () final
 
void selectionDoubleClick (QPointF scenePos) final
 
void selectionTripleClick (QPointF scenePos) final
 
void selectionFocusChanged (bool focusIn) final
 
bool isOverSelection (QPointF scenePos) const final
 
QString getSelectedText () const final
 
void fontChanged (const QFont &font) final
 
QRectF boundingRect () const final
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) final
 
void visibilityChanged (bool keepInMemory) final
 
void reloadTheme () final
 
qreal getAscent () const final
 
void mousePressEvent (QGraphicsSceneMouseEvent *event) final
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) final
 
void hoverMoveEvent (QGraphicsSceneHoverEvent *event) final
 
QString getText () const final
 
QString getLinkAt (QPointF scenePos) const
 Extracts the target of a link from the text at a given coordinate. More...
 
- Public Member Functions inherited from ChatLineContent
int getColumn () const
 
int type () const final
 

Protected Member Functions

void regenerate ()
 
void freeResources ()
 
virtual QSizeF idealSize ()
 
int cursorFromPos (QPointF scenePos, bool fuzzy=true) const
 
int getSelectionEnd () const
 
int getSelectionStart () const
 
bool hasSelection () const
 
QString extractSanitizedText (int from, int to) const
 
QString extractImgTooltip (int pos) const
 

Protected Attributes

QTextDocument * doc = nullptr
 
QSizeF size
 
qreal width = 0.0
 

Private Member Functions

void selectText (QTextCursor &cursor, const std::pair< int, int > &point)
 
QColor textColor () const
 

Private Attributes

QString text
 
QString rawText
 
QString selectedText
 
bool keepInMemory = false
 
bool elide = false
 
bool dirty = false
 
bool selectionHasFocus = true
 
int selectionEnd = -1
 
int selectionAnchor = -1
 
qreal ascent = 0.0
 
QFont defFont
 
QString defStyleSheet
 
TextType textType
 
QColor color
 
QColor customColor
 

Detailed Description

Definition at line 29 of file text.h.

Member Enumeration Documentation

◆ TextType

Enumerator
NORMAL 
ACTION 
CUSTOM 

Definition at line 34 of file text.h.

Constructor & Destructor Documentation

◆ Text()

Text::Text ( const QString &  txt = "",
const QFont &  font = QFont(),
bool  enableElide = false,
const QString &  rawText = QString(),
const TextType type = NORMAL,
const QColor &  custom = Style::getColor(Style::MainText) 
)

Definition at line 34 of file text.cpp.

Here is the call graph for this function:

◆ ~Text()

Text::~Text ( )
virtual

Definition at line 49 of file text.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ boundingRect()

QRectF Text::boundingRect ( ) const
finalvirtual

Implements ChatLineContent.

Definition at line 206 of file text.cpp.

Here is the caller graph for this function:

◆ cursorFromPos()

int Text::cursorFromPos ( QPointF  scenePos,
bool  fuzzy = true 
) const
protected

Definition at line 377 of file text.cpp.

Here is the caller graph for this function:

◆ deselectText()

void Text::deselectText ( )

Definition at line 87 of file text.cpp.

Here is the call graph for this function:

◆ extractImgTooltip()

QString Text::extractImgTooltip ( int  pos) const
protected

Definition at line 442 of file text.cpp.

Here is the caller graph for this function:

◆ extractSanitizedText()

QString Text::extractSanitizedText ( int  from,
int  to 
) const
protected

Definition at line 401 of file text.cpp.

Here is the caller graph for this function:

◆ fontChanged()

void Text::fontChanged ( const QFont &  font)
finalvirtual

Reimplemented from ChatLineContent.

Definition at line 201 of file text.cpp.

◆ freeResources()

void Text::freeResources ( )
protected

Definition at line 363 of file text.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAscent()

qreal Text::getAscent ( ) const
finalvirtual

Reimplemented from ChatLineContent.

Definition at line 259 of file text.cpp.

◆ getLinkAt()

QString Text::getLinkAt ( QPointF  scenePos) const

Extracts the target of a link from the text at a given coordinate.

Parameters
scenePosPosition in scene coordinates
Returns
The link target URL, or an empty string if there is no link there

Definition at line 308 of file text.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSelectedText()

QString Text::getSelectedText ( ) const
finalvirtual

Reimplemented from ChatLineContent.

Definition at line 196 of file text.cpp.

◆ getSelectionEnd()

int Text::getSelectionEnd ( ) const
protected

Definition at line 386 of file text.cpp.

Here is the caller graph for this function:

◆ getSelectionStart()

int Text::getSelectionStart ( ) const
protected

Definition at line 391 of file text.cpp.

Here is the caller graph for this function:

◆ getText()

QString Text::getText ( ) const
finalvirtual

Reimplemented from ChatLineContent.

Definition at line 298 of file text.cpp.

◆ hasSelection()

bool Text::hasSelection ( ) const
protected

Definition at line 396 of file text.cpp.

Here is the caller graph for this function:

◆ hoverMoveEvent()

void Text::hoverMoveEvent ( QGraphicsSceneHoverEvent *  event)
final

Definition at line 282 of file text.cpp.

Here is the call graph for this function:

◆ idealSize()

QSizeF Text::idealSize ( )
protectedvirtual

Reimplemented in Timestamp.

Definition at line 369 of file text.cpp.

Here is the caller graph for this function:

◆ isOverSelection()

bool Text::isOverSelection ( QPointF  scenePos) const
finalvirtual

Reimplemented from ChatLineContent.

Definition at line 187 of file text.cpp.

Here is the call graph for this function:

◆ mousePressEvent()

void Text::mousePressEvent ( QGraphicsSceneMouseEvent *  event)
final

Definition at line 264 of file text.cpp.

◆ mouseReleaseEvent()

void Text::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  event)
final

Definition at line 270 of file text.cpp.

◆ paint()

void Text::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget 
)
finalvirtual

Implements ChatLineContent.

Definition at line 211 of file text.cpp.

Here is the call graph for this function:

◆ regenerate()

void Text::regenerate ( )
protected

Definition at line 315 of file text.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reloadTheme()

void Text::reloadTheme ( )
finalvirtual

Reimplemented from ChatLineContent.

Definition at line 250 of file text.cpp.

Here is the call graph for this function:

◆ selectionCleared()

void Text::selectionCleared ( )
finalvirtual

Reimplemented from ChatLineContent.

Definition at line 125 of file text.cpp.

◆ selectionDoubleClick()

void Text::selectionDoubleClick ( QPointF  scenePos)
finalvirtual

Reimplemented from ChatLineContent.

Definition at line 136 of file text.cpp.

Here is the call graph for this function:

◆ selectionFocusChanged()

void Text::selectionFocusChanged ( bool  focusIn)
finalvirtual

Reimplemented from ChatLineContent.

Definition at line 181 of file text.cpp.

◆ selectionMouseMove()

void Text::selectionMouseMove ( QPointF  scenePos)
finalvirtual

Reimplemented from ChatLineContent.

Definition at line 102 of file text.cpp.

Here is the call graph for this function:

◆ selectionStarted()

void Text::selectionStarted ( QPointF  scenePos)
finalvirtual

Reimplemented from ChatLineContent.

Definition at line 116 of file text.cpp.

Here is the call graph for this function:

◆ selectionTripleClick()

void Text::selectionTripleClick ( QPointF  scenePos)
finalvirtual

Reimplemented from ChatLineContent.

Definition at line 157 of file text.cpp.

Here is the call graph for this function:

◆ selectText() [1/3]

void Text::selectText ( const QRegularExpression &  exp,
const std::pair< int, int > &  point 
)

Definition at line 74 of file text.cpp.

Here is the call graph for this function:

◆ selectText() [2/3]

void Text::selectText ( const QString &  txt,
const std::pair< int, int > &  point 
)

Definition at line 61 of file text.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ selectText() [3/3]

void Text::selectText ( QTextCursor &  cursor,
const std::pair< int, int > &  point 
)
private

Definition at line 454 of file text.cpp.

Here is the call graph for this function:

◆ setText()

void Text::setText ( const QString &  txt)

Definition at line 55 of file text.cpp.

Here is the caller graph for this function:

◆ setWidth()

void Text::setWidth ( qreal  width)
finalvirtual

Implements ChatLineContent.

Definition at line 94 of file text.cpp.

Here is the call graph for this function:

◆ textColor()

QColor Text::textColor ( ) const
private

Definition at line 471 of file text.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ visibilityChanged()

void Text::visibilityChanged ( bool  keepInMemory)
finalvirtual

Reimplemented from ChatLineContent.

Definition at line 242 of file text.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ ascent

qreal Text::ascent = 0.0
private

Definition at line 106 of file text.h.

◆ color

QColor Text::color
private

Definition at line 110 of file text.h.

◆ customColor

QColor Text::customColor
private

Definition at line 111 of file text.h.

◆ defFont

QFont Text::defFont
private

Definition at line 107 of file text.h.

◆ defStyleSheet

QString Text::defStyleSheet
private

Definition at line 108 of file text.h.

◆ dirty

bool Text::dirty = false
private

Definition at line 102 of file text.h.

◆ doc

QTextDocument* Text::doc = nullptr
protected

Definition at line 89 of file text.h.

◆ elide

bool Text::elide = false
private

Definition at line 101 of file text.h.

◆ keepInMemory

bool Text::keepInMemory = false
private

Definition at line 100 of file text.h.

◆ rawText

QString Text::rawText
private

Definition at line 98 of file text.h.

◆ selectedText

QString Text::selectedText
private

Definition at line 99 of file text.h.

◆ selectionAnchor

int Text::selectionAnchor = -1
private

Definition at line 105 of file text.h.

◆ selectionEnd

int Text::selectionEnd = -1
private

Definition at line 104 of file text.h.

◆ selectionHasFocus

bool Text::selectionHasFocus = true
private

Definition at line 103 of file text.h.

◆ size

QSizeF Text::size
protected

Definition at line 90 of file text.h.

◆ text

QString Text::text
private

Definition at line 97 of file text.h.

◆ textType

TextType Text::textType
private

Definition at line 109 of file text.h.

◆ width

qreal Text::width = 0.0
protected

Definition at line 91 of file text.h.


The documentation for this class was generated from the following files: