Changeset View
Changeset View
Standalone View
Standalone View
kstyle/breezestyle.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 3071 Lines • ▼ Show 20 Line(s) | 3065 | { | |||
---|---|---|---|---|---|
3072 | { return true; } | 3072 | { return true; } | ||
3073 | 3073 | | |||
3074 | #if QT_VERSION >= 0x050000 | 3074 | #if QT_VERSION >= 0x050000 | ||
3075 | if ( option->styleObject && option->styleObject->property("elementType") == QLatin1String("button") ) | 3075 | if ( option->styleObject && option->styleObject->property("elementType") == QLatin1String("button") ) | ||
3076 | { return true; } | 3076 | { return true; } | ||
3077 | #endif | 3077 | #endif | ||
3078 | 3078 | | |||
3079 | const State& state( option->state ); | 3079 | const State& state( option->state ); | ||
3080 | | ||||
3081 | // no focus indicator on selected list items | ||||
3082 | if (widget && widget->inherits("QAbstractItemView") && (state & State_Selected)) | ||||
hpereiradacosta: Not sure which one is the most efficient:
Widget->inherits or qobject_cast ?
(My guess would… | |||||
From what I can tell the difference is negligible. qobject_cast goes through QMetaObject::cast which then calls inherits internally, so I'd say inherits is the better choice. I didn't benchmark, though. I just followed what the rest of the code around it was doing (inherits) broulik: From what I can tell the difference is negligible. `qobject_cast` goes through `QMetaObject… | |||||
Code uses both actually (usually qobject_cast for "public" classes, from Qt, and inherits for "private" classes, or kde). hpereiradacosta: Code uses both actually (usually qobject_cast for "public" classes, from Qt, and inherits for… | |||||
Of course inherits(QString) is slower than qobject_cast<>. The only reason to use inherits() is when you do not link to the library that the class defines. cfeck: Of course inherits(QString) is slower than qobject_cast<>.
The only reason to use inherits()… | |||||
Also order to make the fastest test come first. if ((state & State_Selected) && qobject_cast<QAbstractItemView *>(widget)) cfeck: Also order to make the fastest test come first.
if ((state & State_Selected) &&… | |||||
3083 | { return true; } | ||||
3084 | | ||||
3080 | const QRect rect( option->rect.adjusted( 0, 0, 0, 1 ) ); | 3085 | const QRect rect( option->rect.adjusted( 0, 0, 0, 1 ) ); | ||
3081 | const QPalette& palette( option->palette ); | 3086 | const QPalette& palette( option->palette ); | ||
3082 | 3087 | | |||
3083 | if( rect.width() < 10 ) return true; | 3088 | if( rect.width() < 10 ) return true; | ||
3084 | 3089 | | |||
3085 | const QColor outlineColor( state & State_Selected ? palette.color( QPalette::HighlightedText ):palette.color( QPalette::Highlight ) ); | 3090 | const QColor outlineColor( state & State_Selected ? palette.color( QPalette::HighlightedText ):palette.color( QPalette::Highlight ) ); | ||
3086 | painter->setRenderHint( QPainter::Antialiasing, false ); | 3091 | painter->setRenderHint( QPainter::Antialiasing, false ); | ||
3087 | painter->setPen( outlineColor ); | 3092 | painter->setPen( outlineColor ); | ||
▲ Show 20 Lines • Show All 3974 Lines • Show Last 20 Lines |
Not sure which one is the most efficient:
Widget->inherits or qobject_cast ?
(My guess would need the second, but ...)
Can you double check ?