hash calls harmonized

This commit is contained in:
Uwe Rathmann 2022-03-25 11:21:32 +01:00
parent d46f63fef1
commit eaa5a63278
7 changed files with 13 additions and 15 deletions

View File

@ -63,7 +63,7 @@ void QskScaleTickmarks::invert()
std::reverse( m_ticks[ 2 ].begin(), m_ticks[ 2 ].end() ); std::reverse( m_ticks[ 2 ].begin(), m_ticks[ 2 ].end() );
} }
QskHashValue QskScaleTickmarks::hash( QskHashValue seed ) const QskHashValue QskScaleTickmarks::hash( QskHashValue seed ) const noexcept
{ {
seed = qHash( m_ticks[0], seed ); seed = qHash( m_ticks[0], seed );
seed = qHash( m_ticks[1], seed ); seed = qHash( m_ticks[1], seed );

View File

@ -53,7 +53,7 @@ class QSK_EXPORT QskScaleTickmarks
void invert(); void invert();
void reset(); void reset();
QskHashValue hash( QskHashValue seed = 0 ) const; QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
private: private:
QVector< qreal > m_ticks[ 3 ]; QVector< qreal > m_ticks[ 3 ];

View File

@ -9,7 +9,7 @@
#include <qhashfunctions.h> #include <qhashfunctions.h>
#include <qvariant.h> #include <qvariant.h>
QskHashValue QskTextColors::hash( QskHashValue seed ) const QskHashValue QskTextColors::hash( QskHashValue seed ) const noexcept
{ {
const QRgb rgb[] = { textColor.rgba(), styleColor.rgba(), linkColor.rgba() }; const QRgb rgb[] = { textColor.rgba(), styleColor.rgba(), linkColor.rgba() };
return qHashBits( rgb, sizeof( rgb ), seed ); return qHashBits( rgb, sizeof( rgb ), seed );

View File

@ -25,7 +25,7 @@ class QSK_EXPORT QskTextColors
static QVariant interpolate( const QskTextColors&, static QVariant interpolate( const QskTextColors&,
const QskTextColors&, qreal ratio ); const QskTextColors&, qreal ratio );
QskHashValue hash( QskHashValue seed = 0 ) const; QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
QColor textColor; QColor textColor;
QColor styleColor; QColor styleColor;

View File

@ -50,15 +50,13 @@ QskTextOptions::TextFormat QskTextOptions::effectiveFormat( const QString& text
return m_format; return m_format;
} }
QskHashValue qHash( const QskTextOptions& options, QskHashValue seed ) noexcept QskHashValue QskTextOptions::hash( QskHashValue seed ) const noexcept
{ {
QskHashValue hash; auto hash = qHash( m_maximumLineCount, seed );
hash = qHash( m_fontSizeMode, hash );
hash = qHash( options.maximumLineCount(), seed ); hash = qHash( m_wrapMode, hash );
hash = qHash( options.fontSizeMode(), hash ); hash = qHash( m_format, hash );
hash = qHash( options.wrapMode(), hash ); hash = qHash( m_elideMode, hash );
hash = qHash( options.format(), hash );
hash = qHash( options.elideMode(), hash );
return hash; return hash;
} }

View File

@ -74,6 +74,8 @@ class QSK_EXPORT QskTextOptions
constexpr bool operator==( const QskTextOptions& other ) const noexcept; constexpr bool operator==( const QskTextOptions& other ) const noexcept;
constexpr bool operator!=( const QskTextOptions& other ) const noexcept; constexpr bool operator!=( const QskTextOptions& other ) const noexcept;
QskHashValue hash( QskHashValue seed ) const noexcept;
int textFlags() const noexcept; int textFlags() const noexcept;
private: private:
@ -164,8 +166,6 @@ inline constexpr bool QskTextOptions::operator!=(
return !( *this == other ); return !( *this == other );
} }
QSK_EXPORT QskHashValue qHash( const QskTextOptions&, QskHashValue seed = 0 ) noexcept;
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
class QDebug; class QDebug;

View File

@ -20,7 +20,7 @@ static inline QskHashValue qskHash(
hash = qHash( text, hash ); hash = qHash( text, hash );
hash = qHash( font, hash ); hash = qHash( font, hash );
hash = qHash( options, hash ); hash = options.hash( hash );
hash = qHash( alignment, hash ); hash = qHash( alignment, hash );
hash = qHash( textStyle, hash ); hash = qHash( textStyle, hash );
hash = colors.hash( hash ); hash = colors.hash( hash );