[Kicker] Property for hiding app categories in RootModel
Needs ReviewPublic

Authored by romangg on Feb 25 2017, 8:16 PM.

Details

Reviewers
None
Group Reviewers
Plasma
Summary

With RootModel it is possible to represent pretty much any combination of other Kicker models. What's not yet possible is to show for example exclusively "All Applications" together with "Recent Applications", but without the app categories (Developement, Education, etc.).

This small patch makes it possible to hide app categories by setting the property showAppCategories (defaults to true), which is also exported to QML. The main downside is, that we still query all application entries, even if we don't want to show them. But only doing that and afterwards removing them makes the code change trivial. Otherwise we would need to introduce a new class, which doesn't inherit from AppsModel, but the other way around.

Test Plan

Tested all relevant combinations in my WIP fork of SimpleMenu.

Diff Detail

Repository
R119 Plasma Desktop
Lint
Lint Skipped
Unit
Unit Tests Skipped
romangg created this revision.Feb 25 2017, 8:16 PM
hein added a subscriber: hein.Feb 27 2017, 10:27 AM

I'm not sure I like it. Maybe it's better to expose more of the individual models in the plugin so you can instanciate them directly?

In D4792#90384, @hein wrote:

I'm not sure I like it. Maybe it's better to expose more of the individual models in the plugin so you can instanciate them directly?

Well, you can already use most of the indivdiual models, for example the recently used documents and apps by using Kicker.RecentUsageModel {}. This is more a convenient access to have the same structure as for main model, which simplifies the QML part.

For example in my case: I want to show the list of program categories, which switches to a list "Recent Applications, Recent Documents" on user request. Using RecentUsageModel is difficult in this case, because it doesn't have group entrys like the RootModel. The best way would be of course to make the RootModel as a somewhat abstract class at the top and let the developer using Kicker interfaces decide which submodels (AppsModel with/without categories, RecentUsageModel Docs/Apps, ...) he wants to add by setting the QML properties (for most of the submodels it's already working this way).

hein added a comment.EditedFeb 27 2017, 12:54 PM

I totally get your argument, but this two-steps-forward-one-step-back code is still so ugly - we need some sort of new approach to composability here. It's more work but may lead us into a better direction long-term.

QML like this would be nice:

FooModel {
  id: foomodel
  RecentUsageModel {}
  RecentAppsModel {}
}

View {
  model: foomodel
}

I.e. be able to define your own menu structure in QML by writing a model that adds child objects to its own entry list.