[Development] Proposal: reorganization of QtSystems module, since Qt5.x

Lorn Potter lorn.potter at gmail.com
Thu Sep 13 22:03:59 CEST 2012


Hi Denis,

On 13/09/2012, at 8:27 PM, Denis Shienkov <scapig2 at yandex.ru> wrote:

> Hello all.
> 
> As I'm concerned, at the moment Qt5 contains fragmented set of classes to 
> obtain information about the devices:
> 
> QPrinterInfo   -> QtBase/src/printsupport
> others info's  -> QtSystems/
> 

Because printing is a common and basic thing to want to add to applications. Getting info and notifications about cellId changes is more of a fringe use case.


> Since all of these entities are devices, it is logical to make the base
> class QDeviceInfo, from which derive all of the specific types of devices
> infos, like:

No, these aren't devices, they are peripherals.


> 
> class QDeviceInfo : public QObject
> {
> ...
> }
> 
> class QStorageInfo : public QDeviceInfo
> {
> ...
> }
> 
> ...
> ...
> 
> class QNetworkAdapterInfo : public QDeviceInfo
> {
> ...
> }

I don't understand why I would need information about manufacturer, model of the computer (from QDeviceInfo) when I want to get information about the network or storage?


> 
> Next, can create a separate class - watcher type QDeviceManeger (singleton), 
> which could provide a list of all available devices to send signals about 
> connecting/disconnecting devices, etc.

I think you may misunderstand 'device' in DeviceInfo. It is one computer - desktop, laptop, or mobile phone, and not really a peripheral like you are proposing.

> 
> class QDeviceManager : public QObject
> {
> public:
> 
>    enum DeviceType {
>        SerialPort,
>        LptPort,
>        MidiPort,
>        NetworkAdapter,
>        VideoAdapter,
>        AudioAdapter,
>        Monitor,
>        Drive,
>        ...
>        AllTypes
>    };
> 
>    QList<QDeviceInfo> devicesInfo(DeviceType dt = AllTypes);
>    void enableWatchForType(DeviceType dt = AllTypes);
>    bool isEnabledWatchForType(DeviceType dt = AllTypes);
> 
>    // Maybe add another methods
> 
> signals:
>    void connected(const QDeviceInfo &info);
>    void disconnected(const QDeviceInfo &info);
> 
>    // Maybe add another signals
> }
> 
> For a start here can add only the basic types of devices (already implemented), 
> and then on future can add new supported device types (step-by-step).
> 
> This is just pseudocode, I know that it contains errors. I just proposed the idea, 
> so please do not judge strictly.
> 
> Pros:
> + QtSystems module is already available, you just need to extend it.

This is more than extended it.

> + This solution will integrate all the disparate components of information in 
> one place.

Even though they are distinct types and use-cases for this information?
Having one grand class/signal for all this information is too much, and not object oriented.



> + Flexibility: you want - include the module, and you want - not.
> + Common notifier for all devices in which you can register and subscribe to 
> events on the desired device type.
> 
> Cons:
> - To use printing support need for a separate module QtSystems. Although previously
> it was not required.
> - Implementation is complex.
> 
> I'm waiting for comments and suggestions. :)
> 
> 
> Best regards,
> Denis
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development

Lorn Potter
Senior Software Engineer, QtSensors/QtSensorGestures/QtSystemInfo







More information about the Development mailing list