[applets/SystemTray] Implement sorting in the model
ClosedPublic

Authored by kmaterka on Feb 1 2020, 4:04 PM.

Details

Summary

Replace two wrapping PlasmaCore.SortFilterModel with custom sorting on model side. Extract common code to base class.
This fixes small issue in sorting and allows to implement other improvements (later on).

Test Plan

Everything should work as before.

Diff Detail

Repository
R120 Plasma Workspace
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 22698
Build 22716: arc lint + arc unit
kmaterka requested review of this revision.Feb 1 2020, 4:04 PM
kmaterka created this revision.

Extracted from D26992 to make review easier

kmaterka edited the summary of this revision. (Show Details)Feb 4 2020, 8:04 PM
kmaterka retitled this revision from [SystemTray] Implement sorting in the model to [applets/SystemTray] Implement sorting in the model.Feb 14 2020, 7:05 PM
ngraham accepted this revision.Feb 14 2020, 9:20 PM
ngraham added a subscriber: mart.

LGTM but let's make sure one of our model experts (@davidedmundson, @broulik, @mart) gets a chance to make sure I'm not smoking crack by approving this. :)

This revision is now accepted and ready to land.Feb 14 2020, 9:20 PM

OK, I will wait for second review from @davidedmundson, @broulik or @mart.

davidedmundson requested changes to this revision.Feb 18 2020, 5:26 PM

The role names part is nice.

I have one major-ish comment, and 2 pendantic comments that I don't really care about.

applets/systemtray/sortedsystemtraymodel.cpp
47 ↗(On Diff #75112)

I think calling QSortFilterProxyModel::lessThan(left, right); would do the same

then you don't need compareDisplayAlphabetically

your implementation looks fine though, so do whichever

applets/systemtray/sortedsystemtraymodel.h
35 ↗(On Diff #75112)

We tend not to write virtual at the start now we have the clearer override keyword

applets/systemtray/systemtraymodel.cpp
115 ↗(On Diff #75112)

The applet is still alive after removeApplet is called. "this" is still alive

dataItem is not.

If an applet is added, removed and then (potentially during applet teardown) it changes its title, this would crash.

I don't know if that's a realistic scenario or not, but I would still maybe disconnect all signals from applet -> this on removeApplet?

This revision now requires changes to proceed.Feb 18 2020, 5:26 PM
kmaterka added inline comments.Feb 19 2020, 5:34 PM
applets/systemtray/sortedsystemtraymodel.cpp
47 ↗(On Diff #75112)

The question of being implicit or explicit. I like your idea more, will change that.

applets/systemtray/sortedsystemtraymodel.h
35 ↗(On Diff #75112)

Another embarrassing lack of C++ knowledge... Especially this "new" (hehe, C++11) feature :)

applets/systemtray/systemtraymodel.cpp
115 ↗(On Diff #75112)

During lifetime of the SystemTray, dataItems are never removed, they are just marked as not "renderable". Item is still alive, it is needed in configuration page (you can enable applet again in the configuration).

Anyway, it is a good idea to disconnect signals, for the sake of consisteny. In addition, dataItems are deleted eventually which may (?) lead to a crash on shutdown.

kmaterka updated this revision to Diff 76026.Feb 19 2020, 9:04 PM

Review fixes

davidedmundson accepted this revision.Feb 19 2020, 9:07 PM
This revision is now accepted and ready to land.Feb 19 2020, 9:07 PM
This revision was automatically updated to reflect the committed changes.