6#ifndef QSK_TEXT_OPTIONS_H
7#define QSK_TEXT_OPTIONS_H
12#include <qtextoption.h>
20 Q_PROPERTY( TextFormat format READ format WRITE setFormat )
21 Q_PROPERTY( Qt::TextElideMode elideMode READ elideMode WRITE setElideMode )
22 Q_PROPERTY( WrapMode wrapMode READ wrapMode WRITE setWrapMode )
23 Q_PROPERTY( FontSizeMode fontSizeMode READ fontSizeMode WRITE setFontSizeMode )
24 Q_PROPERTY(
int maximumLineCount READ maximumLineCount WRITE setMaximumLineCount )
27 enum FontSizeMode : quint8
34 Q_ENUM( FontSizeMode )
36 enum WrapMode : quint8
38 NoWrap = QTextOption::NoWrap,
39 WordWrap = QTextOption::WordWrap,
40 WrapAnywhere = QTextOption::WrapAnywhere,
41 Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
45 enum TextFormat : quint8
47 PlainText = Qt::PlainText,
48 RichText = Qt::RichText,
49 AutoText = Qt::AutoText,
50 MarkdownText = Qt::MarkdownText,
57 constexpr TextFormat format()
const noexcept;
58 void setFormat( TextFormat )
noexcept;
60 TextFormat effectiveFormat(
const QString& text )
const;
62 constexpr Qt::TextElideMode elideMode()
const noexcept;
63 void setElideMode( Qt::TextElideMode )
noexcept;
65 constexpr Qt::TextElideMode effectiveElideMode()
const noexcept;
67 constexpr FontSizeMode fontSizeMode()
const noexcept;
68 void setFontSizeMode( FontSizeMode )
noexcept;
70 constexpr WrapMode wrapMode()
const noexcept;
71 void setWrapMode( WrapMode )
noexcept;
73 constexpr int maximumLineCount()
const noexcept;
74 void setMaximumLineCount(
int )
noexcept;
76 constexpr bool operator==(
const QskTextOptions& other )
const noexcept;
77 constexpr bool operator!=(
const QskTextOptions& other )
const noexcept;
79 QskHashValue hash( QskHashValue seed )
const noexcept;
81 int textFlags()
const noexcept;
84 int m_maximumLineCount;
85 FontSizeMode m_fontSizeMode : 2;
86 WrapMode m_wrapMode : 4;
87 TextFormat m_format : 3;
88 unsigned int m_elideMode : 2;
91inline constexpr QskTextOptions::QskTextOptions() noexcept
92 : m_maximumLineCount( std::numeric_limits<
int >::max() )
95 , m_format( PlainText )
96 , m_elideMode( Qt::ElideNone )
100inline void QskTextOptions::setFormat( TextFormat format )
noexcept
105constexpr inline QskTextOptions::TextFormat QskTextOptions::format() const noexcept
110inline void QskTextOptions::setElideMode( Qt::TextElideMode elideMode )
noexcept
112 m_elideMode = elideMode;
115constexpr inline Qt::TextElideMode QskTextOptions::elideMode() const noexcept
117 return static_cast< Qt::TextElideMode
>( m_elideMode );
120constexpr inline Qt::TextElideMode QskTextOptions::effectiveElideMode() const noexcept
122 return ( wrapMode() != QskTextOptions::NoWrap ) ?
123 Qt::ElideNone :
static_cast< Qt::TextElideMode
>( m_elideMode );
126inline void QskTextOptions::setWrapMode( WrapMode wrapMode )
noexcept
128 m_wrapMode = wrapMode;
131constexpr inline QskTextOptions::WrapMode QskTextOptions::wrapMode() const noexcept
136inline void QskTextOptions::setFontSizeMode( FontSizeMode fontSizeMode )
noexcept
138 m_fontSizeMode = fontSizeMode;
141constexpr inline QskTextOptions::FontSizeMode QskTextOptions::fontSizeMode() const noexcept
143 return m_fontSizeMode;
146inline void QskTextOptions::setMaximumLineCount(
int lineCount )
noexcept
148 m_maximumLineCount = lineCount;
151constexpr inline int QskTextOptions::maximumLineCount() const noexcept
153 return m_maximumLineCount;
156inline constexpr bool QskTextOptions::operator==(
159 return ( m_format == other.m_format ) &&
160 ( m_elideMode == other.m_elideMode ) &&
161 ( m_wrapMode == other.m_wrapMode ) &&
162 ( m_fontSizeMode == other.m_fontSizeMode ) &&
163 ( m_maximumLineCount == other.m_maximumLineCount );
166inline constexpr bool QskTextOptions::operator!=(
169 return !( *
this == other );
172#ifndef QT_NO_DEBUG_STREAM