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

Denis Shienkov scapig2 at yandex.ru
Thu Sep 13 12:27:18 CEST 2012


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/

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:

class QDeviceInfo : public QObject
{
...
}

class QStorageInfo : public QDeviceInfo
{
...
}

...
...

class QNetworkAdapterInfo : public QDeviceInfo
{
...
}

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.

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 solution will integrate all the disparate components of information in 
one place.
+ 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



More information about the Development mailing list