Skip to content

applet: Factor the state out of delegates to a shared proxy model

ivan tkachenko requested to merge work/r/applet-delegate-state into master

Factor the state out of delegates to a shared proxy model

None of this belongs to the delegate's UI code. If model rows are shuffled around or delegates are recreated by the ListView for other reasons -- the state will be lost, or worse: retained with a new incorrect index/device. Thus, all and any state should be stored in the upstream models or middleware proxy models. To keep the state in sync between all instances of the Bluetooth applet, the new proxy model is exposed as a singleton, although it needed some trickery with .qml file to make it work, since we can't access BlueZ-Qt QML module's types from C++ in Bluedevil.

Error handling logic is moved out of the delegates as well. The proxy model now submits a KNotification itself, because, again, the delegate might be scrolled out of view and get destroyed so it won't be able to run the code safety for no good reason.


Other, not so important, patches include:

applet,kcm: Unify the code that toggles Bluetooth on and off

Also, gets rid of the last instance of duck typing in CompactRepresentation.qml component.

applet,kcm: Rename toggle actions such that their name makes sense

sendfile: Wrap potentially long error message label

applet: Factor adapterHciString method out to a helper class

So that the delegates won't have to access the devicesModel ID from context or pass it down explicitly. The method was downgraded from const to static, so we don't even need an instance of Utils in C++.

Edited by ivan tkachenko

Merge request reports

Loading