Skip to content

Export options

Alexander Stippich requested to merge astippich/libksane:exportOptions into master

This MR includes !21 (closed)

This exports the list of options provided by libsane in an encapsulated way that allows implementing a list of options in a QAbstractItemModel or by handling the options individually. Specific options can be queried via an enum if they are available in order to enforce specific layouts of the options by the application, e.g. for Skanlite. This will also remove the need to know the internal names of the options from libsane, which makes the API nicer to use.

This MR allows a full implementation of the interface in Skanpage with a QML only interface without affecting Skanlite. Ideally, the options would only be exported when the UI/logic split happens in KSaneCore (or whatever it will be named then), but I don't know how long this will take. I would like to remove the KSaneWidget Option view in Skanpage soon, as this is a major interface obstacle.

The reasoning I went for this solution instead of exporting a QAbstractItemModel directly is the maximum flexibility this grants to the application. It allows to easily find or hide the options as required by KSaneWidget/Skanlite and reorder the options as needed, for example with the extra sizing option of KSaneWidget. This is not impossible with QAbstractItemModel, but imho harder to achieve. I also have to admit that I haven't worked with QAbstractItemModels for a QWidget based implementation, and I would rather leave changing the QWidget option implementation in KSaneWidgetPrivate::createOptInterface be.

Currently the options are wrapped in a base class that only exports the API that is required for external usage. The wrapper can probably be changed into something that does not contain a vtable and just forwards to the KSaneOption, which would allow to better keep ABI compatibility when changes are required.

Anyway, let me know if you are willing to accept such a solution or if I have to get back to drawing board :)

Edited by Alexander Stippich

Merge request reports