Fix showing updates when the option is selected
ClosedPublic

Authored by leinir on May 5 2020, 2:42 PM.

Details

Summary

This patch primarily fixes the issue that when picking the "Updateable Only" option on NewStuff.Page, we would be shown all the entries anyway. It also fixes duplicated entries on the "Installed Only" option, and further adds a little placeholder for when the view is expectedly empty.

  • Use the right connections for update entry display
  • While potentially expensive, only add entries to the model once
  • Use Kirigami.PlaceholderMessage to show we have no entries when we don't

BUG:416762

Test Plan

Without this patch, behaviour is as shown in https://bugs.kde.org/show_bug.cgi?id=416762

With this patch, the behaviour is as expected (shows only updateable entries with that option selected, only shows installed entries once with that option, and shows a useful message when the list is empty and expected to be empty)

Diff Detail

Repository
R304 KNewStuff
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
leinir created this revision.May 5 2020, 2:42 PM
Restricted Application added a project: Frameworks. Β· View Herald TranscriptMay 5 2020, 2:42 PM
Restricted Application added a subscriber: kde-frameworks-devel. Β· View Herald Transcript
leinir requested review of this revision.May 5 2020, 2:42 PM
alex added a subscriber: alex.May 5 2020, 3:11 PM
alex added inline comments.
src/core/itemsmodel.cpp
71

Use qAsConst(m_entries) and space before & not after :-)

leinir updated this revision to Diff 82003.May 5 2020, 4:15 PM

Address comment by @alex

  • Fix style (and consty things)
ngraham accepted this revision.May 5 2020, 4:43 PM
This revision is now accepted and ready to land.May 5 2020, 4:43 PM
alex added inline comments.May 5 2020, 7:06 PM
src/core/itemsmodel.cpp
71

On second thought why not just use:
bool duplicate = m_entries.contains(entry);

leinir added inline comments.May 5 2020, 7:36 PM
src/core/itemsmodel.cpp
71

Quite, thank you :)

71

Hmm... i do wonder slight of the cost of that, but also... much simpler code, so... basically can just go

if (!m_entries.contains(entry)) {

below, rather than this more elaborate version.

leinir updated this revision to Diff 82021.May 5 2020, 7:45 PM

As @alex suggests, just use qlist::contains, it is supposed to be
reasonably cheap, so... yup, trust the framework! ;)

  • Just use qlist::contains
leinir marked 2 inline comments as done.May 5 2020, 7:46 PM

Thanks for making me realise that it doesn't have to be quite so elaborate, @alex ;)

alex added a comment.May 5 2020, 7:47 PM

No problem, always happy to help πŸ˜ƒ

This revision was automatically updated to reflect the committed changes.