Remove KF5::ItemModels from public interface of KDevPlatformUtil
ClosedPublic

Authored by kossebau on Dec 13 2017, 4:44 PM.

Details

Summary

Having everyone who links to KDevPlatformUtil (which is almost everything
not only via public link interface of KDevPlatformProject) also link
to KF5::ItemModels, just because of a single enum which also is used
currently only from a single plugin, is worth to avoid, by the price
of a small enum-matching wrapper method.

Test Plan

Builds as before.

Diff Detail

Repository
R32 KDevelop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kossebau created this revision.Dec 13 2017, 4:44 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptDec 13 2017, 4:44 PM
kossebau requested review of this revision.Dec 13 2017, 4:44 PM
kossebau added inline comments.Dec 13 2017, 5:06 PM
kdevplatform/util/multilevellistview.cpp
458

That dynamic_cast without testing the result deserves a separate fixing commit, possibly with global check for similar ones. Noted, so you do not have to :)

kfunk requested changes to this revision.Dec 13 2017, 5:51 PM
kfunk added a subscriber: kfunk.

To be honest, I'm not sure I like this change. It's adding code which we need to maintain (what if the KSelectionProxyModel::FilterBehavior enum is extended?) for very, very little gain.

I'd propose to just abandon this change, sorry.

kdevplatform/util/multilevellistview.cpp
458

Right, d->proxies.last() can potentially be an instance not inheriting KSelectionProxyModel (iiuc when passing 1 to MultiLevelListView::setLevels(...)). Someone should check this code :)

kdevplatform/util/multilevellistview.h
46

It's not an implementation detail if we pass the exact same value through to KSelectionProxyModel.

This revision now requires changes to proceed.Dec 13 2017, 5:51 PM
brauch requested changes to this revision.Dec 13 2017, 10:38 PM
brauch added a subscriber: brauch.

Yeah, sorry, I'm also against this. Linking an extra lib we depend on anyways is a problem a compuer has to deal with, extra code is a problem humans have to deal with. The former wins against the latter unless there is a very good reason why not.

In D9316#179221, @kfunk wrote:

It's adding code which we need to maintain (what if the KSelectionProxyModel::FilterBehavior enum is extended?)

Since MultiLevelListView::FilterBehavior is translated into KSelectionProxyModel::FilterBehavior, there should be no problem if the latter is extended. Of course one could think about also extending the former then, but I don't see something terrible happen if we don't.

My understanding isn't very deep here, but maybe we wouldn't want to blindly allow all values of KSelectionProxyModel::FilterBehavior? Say if there is a new value added, but we don't want to allow it, how would we do that? Right now we're enabling KSelectionProxyModel to extend the interface of MultiLevelListView, which doesn't exactly follow the OOP doctrine. I'm not saying this is necessarily a bad thing, but it deserves some further consideration.

mreeves removed a subscriber: mreeves.Dec 14 2017, 4:31 AM
kossebau updated this revision to Diff 23901.Dec 14 2017, 12:38 PM

Do a proper custom enum matching the MultiLevelListView API

@brauch @kfunk I see your point in general. Just allow me to represent the case, initial patch was too much focussed on removing the lib dep

The old API of MultiLevelListView was using the raw KSelectionProxyModel::FilterBehavior enum in the API, as also used in the actual implementation.
Just, most values of that enum do not make sense with the idea of MultiLevelListView, actually it is just two of them, matching two different modes:

  • showing complete subtrees in the view of the last level
  • showing just the children of that level

The updated patch now also improves the API of MultiLevelListView to describe the actual design of the class, instead of being driven by implementation details as before.

Like @aaronpuchert said, here it is just a one directional mapping to a subset of the enum. That a KSelectionProxyModel is used behind the scenes is completely irrelevant to the API of MultiLevelListView itself, actually only confuses the API consumer if exposed.

Does it make more sense to you now? I should have done the API improvement already in the initial patch, blame me for being lazy here.

kossebau updated this revision to Diff 23953.Dec 15 2017, 10:16 AM

update to latest master

I'm fine with the change otherwise, but I think @kfunk and/or @brauch should have a chance to revise or reaffirm their position.

kdevplatform/util/multilevellistview.cpp
448–451

As soon as I commit D9042 this will generate a warning. I'd just remove this label and add Q_UNREACHABLE() after the switch statement.

kfunk accepted this revision.Dec 19 2017, 10:31 PM

Whatever. Go for it.

kdevplatform/util/multilevellistview.cpp
448–451

+1

kdevplatform/util/multilevellistview.h
46

'Modus' is non-existent in English. => 'Mode'?

120–121

Dito (and more occasions below)

This revision was automatically updated to reflect the committed changes.
kossebau marked 3 inline comments as done.