qskinny/src/common/QskTextOptions.cpp

85 lines
2.1 KiB
C++
Raw Normal View History

2017-07-21 16:21:34 +00:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#include "QskTextOptions.h"
2018-07-19 12:10:48 +00:00
#include <qtextdocument.h>
2017-07-21 16:21:34 +00:00
2020-05-03 12:06:56 +00:00
int QskTextOptions::textFlags() const noexcept
2017-07-21 16:21:34 +00:00
{
int flags = 0;
2018-08-03 06:15:28 +00:00
switch ( m_wrapMode )
2017-07-21 16:21:34 +00:00
{
2018-08-03 06:15:28 +00:00
case QskTextOptions::NoWrap:
2017-07-21 16:21:34 +00:00
{
2018-12-13 10:29:40 +00:00
// flags |= Qt::TextSingleLine;
2017-07-21 16:21:34 +00:00
break;
}
case QskTextOptions::WordWrap:
{
flags |= Qt::TextWordWrap;
break;
}
case QskTextOptions::WrapAnywhere:
{
flags |= Qt::TextWrapAnywhere;
break;
}
case QskTextOptions::Wrap:
{
// ???
flags |= Qt::TextWrapAnywhere;
flags |= Qt::TextWordWrap;
break;
}
}
return flags;
}
2017-10-20 11:31:55 +00:00
QskTextOptions::TextFormat QskTextOptions::effectiveFormat( const QString& text ) const
2017-07-21 16:21:34 +00:00
{
if ( text.isEmpty() )
2017-10-20 11:31:55 +00:00
return PlainText;
2017-07-21 16:21:34 +00:00
if ( m_format == QskTextOptions::AutoText )
return Qt::mightBeRichText( text ) ? StyledText : PlainText;
2017-10-20 11:31:55 +00:00
else
return m_format;
2017-07-21 16:21:34 +00:00
}
2018-08-03 06:15:28 +00:00
uint qHash( const QskTextOptions& options, uint seed ) noexcept
2017-07-21 16:21:34 +00:00
{
uint hash;
hash = qHash( options.maximumLineCount(), seed );
hash = qHash( options.fontSizeMode(), hash );
hash = qHash( options.wrapMode(), hash );
hash = qHash( options.format(), hash );
hash = qHash( options.elideMode(), hash );
return hash;
}
#ifndef QT_NO_DEBUG_STREAM
2018-07-19 12:10:48 +00:00
#include <qdebug.h>
2017-07-21 16:21:34 +00:00
QDebug operator<<( QDebug debug, const QskTextOptions& options )
{
QDebugStateSaver saver( debug );
debug.nospace();
debug << "TextOptions" << '(';
debug << options.format() << "," << options.elideMode()
<< options.fontSizeMode() << options.wrapMode()
<< "," << options.maximumLineCount();
debug << ')';
return debug;
}
#endif
#include "moc_QskTextOptions.cpp"