QskTextOptions improved
This commit is contained in:
parent
f21bed63c7
commit
609bd9aac7
@ -109,15 +109,15 @@ bool QskTextOptions::operator==( const QskTextOptions& other ) const
|
||||
&& ( m_maximumLineCount == other.m_maximumLineCount );
|
||||
}
|
||||
|
||||
bool QskTextOptions::isPlainText( const QString& text ) const
|
||||
QskTextOptions::TextFormat QskTextOptions::effectiveFormat( const QString& text ) const
|
||||
{
|
||||
if ( text.isEmpty() )
|
||||
return true;
|
||||
return PlainText;
|
||||
|
||||
if ( m_format == QskTextOptions::AutoText )
|
||||
return !Qt::mightBeRichText( text );
|
||||
|
||||
return m_format == QskTextOptions::PlainText;
|
||||
return Qt::mightBeRichText( text ) ? RichText : PlainText;
|
||||
else
|
||||
return m_format;
|
||||
}
|
||||
|
||||
uint qHash( const QskTextOptions &options, uint seed ) noexcept
|
||||
|
@ -55,6 +55,8 @@ public:
|
||||
TextFormat format() const;
|
||||
void setFormat( TextFormat );
|
||||
|
||||
TextFormat effectiveFormat( const QString& text ) const;
|
||||
|
||||
Qt::TextElideMode elideMode() const;
|
||||
void setElideMode( Qt::TextElideMode );
|
||||
|
||||
@ -70,8 +72,6 @@ public:
|
||||
bool operator==( const QskTextOptions& other ) const;
|
||||
bool operator!=( const QskTextOptions& other ) const;
|
||||
|
||||
bool isPlainText( const QString& text ) const;
|
||||
|
||||
int textFlags() const;
|
||||
|
||||
private:
|
||||
|
@ -74,7 +74,7 @@ bool QskListView::alternatingRowColors() const
|
||||
return m_data->alternatingRowColors;
|
||||
}
|
||||
|
||||
void QskListView::setTextOptions(const QskTextOptions& textOptions )
|
||||
void QskListView::setTextOptions( const QskTextOptions& textOptions )
|
||||
{
|
||||
if ( textOptions != m_data->textOptions )
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ QSizeF QskSkinRenderer::textSize( const QskSkinnable* skinnable,
|
||||
|
||||
auto font = skinnable->effectiveFont( subControl );
|
||||
|
||||
if ( options.isPlainText( text ) )
|
||||
if ( options.effectiveFormat( text ) == QskTextOptions::PlainText )
|
||||
{
|
||||
QskPlainTextRenderer renderer;
|
||||
renderer.setFont( font );
|
||||
@ -45,7 +45,7 @@ QSizeF QskSkinRenderer::textSize( const QskSkinnable* skinnable,
|
||||
{
|
||||
const auto font = skinnable->effectiveFont( subControl );
|
||||
|
||||
if ( options.isPlainText( text ) )
|
||||
if ( options.effectiveFormat( text ) == QskTextOptions::PlainText )
|
||||
{
|
||||
QskPlainTextRenderer renderer;
|
||||
renderer.setFont( font );
|
||||
@ -90,7 +90,7 @@ void QskSkinRenderer::updateText( const QskSkinnable* skinnable,
|
||||
subControl | Style, Qsk::Normal );
|
||||
}
|
||||
|
||||
const auto isPlainText = options.isPlainText( text );
|
||||
const auto isPlainText = options.effectiveFormat( text ) == QskTextOptions::PlainText;
|
||||
|
||||
// doesn't work - we end up with a black rectangle TODO ...
|
||||
#if 0
|
||||
|
@ -28,10 +28,7 @@ public:
|
||||
return textOptions;
|
||||
|
||||
if ( effectiveTextFormat == QskTextOptions::AutoText )
|
||||
{
|
||||
effectiveTextFormat = textOptions.isPlainText( text )
|
||||
? QskTextOptions::PlainText : QskTextOptions::RichText;
|
||||
}
|
||||
effectiveTextFormat = textOptions.effectiveFormat( text );
|
||||
|
||||
QskTextOptions options = textOptions;
|
||||
options.setFormat( effectiveTextFormat );
|
||||
|
Loading…
x
Reference in New Issue
Block a user