Don't draw focus line on selected list item
ClosedPublic

Authored by broulik on Jul 7 2017, 9:06 AM.

Details

Summary

A fix I did for the focus line being drawn outside item boundaries resulted in the item selection rectangle being "cut off" by the focus line. The selection rectangle is enough of an indication anyway.

Test Plan

Before


After

Focus line still shown when the item is not selected:

Especially noticeable in KInfoCenter where there's a tree list and only the label is underlined but not the icon, resulting in an uneven "cut".

Diff Detail

Repository
R31 Breeze
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
broulik created this revision.Jul 7 2017, 9:06 AM
Restricted Application added a project: Plasma. · View Herald TranscriptJul 7 2017, 9:06 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik edited the test plan for this revision. (Show Details)Jul 7 2017, 9:06 AM
hpereiradacosta added inline comments.Jul 7 2017, 9:55 AM
kstyle/breezestyle.cpp
3082

Not sure which one is the most efficient:
Widget->inherits or qobject_cast ?
(My guess would need the second, but ...)
Can you double check ?

broulik added inline comments.Jul 7 2017, 10:22 AM
kstyle/breezestyle.cpp
3082

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)

hpereiradacosta accepted this revision.Jul 7 2017, 10:59 AM
hpereiradacosta added inline comments.
kstyle/breezestyle.cpp
3082

Code uses both actually (usually qobject_cast for "public" classes, from Qt, and inherits for "private" classes, or kde).
In any case, I trust your investigation :)

This revision is now accepted and ready to land.Jul 7 2017, 10:59 AM
This revision was automatically updated to reflect the committed changes.
cfeck added a subscriber: cfeck.Jul 7 2017, 12:08 PM
cfeck added inline comments.
kstyle/breezestyle.cpp
3082

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 added inline comments.Jul 7 2017, 12:12 PM
kstyle/breezestyle.cpp
3082

Also order to make the fastest test come first.

if ((state & State_Selected) && qobject_cast<QAbstractItemView *>(widget))