22#include "moc_qgssensorguiregistry.cpp"
31 qDeleteAll( mMetadata );
36 if ( !mMetadata.isEmpty() )
40 QgsTcpSocketSensorWidget *widget =
new QgsTcpSocketSensorWidget(
nullptr );
41 widget->setSensor( sensor );
42 return widget; }, nullptr ) );
44 QgsUdpSocketSensorWidget *widget =
new QgsUdpSocketSensorWidget(
nullptr );
45 widget->setSensor( sensor );
46 return widget; }, nullptr ) );
47#if defined( HAVE_QTSERIALPORT )
49 QgsSerialPortSensorWidget *widget =
new QgsSerialPortSensorWidget(
nullptr );
50 widget->setSensor( sensor );
51 return widget; }, nullptr ) );
58 return mMetadata.value( type );
63 if ( !metadata || mMetadata.contains( metadata->
type() ) )
66 mMetadata[metadata->
type()] = metadata;
73 auto it = mMetadata.constFind( type );
74 if ( it == mMetadata.constEnd() )
77 std::unique_ptr<QgsAbstractSensor> sensor( it.value()->createSensor( parent ) );
79 return sensor.release();
89 auto it = mMetadata.constFind( sensor->
type() );
90 if ( it == mMetadata.constEnd() )
93 return it.value()->createSensorWidget( sensor );
98 QMap<QString, QString> types;
99 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
101 types.insert( it.key(), it.value()->visibleName() );
An abstract base class for sensors.
virtual QString type() const
Returns the sensor type.
static QgsSensorRegistry * sensorRegistry()
Returns the application's sensor registry, used for sensor types.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
QgsSensorGuiRegistry(QObject *parent=nullptr)
Creates a new empty sensor GUI registry.
~QgsSensorGuiRegistry() override
QgsSensorAbstractGuiMetadata * sensorMetadata(const QString &type) const
Returns the metadata for the specified sensor type.
QgsAbstractSensor * createSensor(const QString &type, QObject *parent=nullptr) const
Creates a new instance of a sensor given the type.
bool populate()
Populates the registry with standard sensor types.
void sensorAdded(const QString &type, const QString &name)
Emitted whenever a new sensor type is added to the registry, with the specified type.
QMap< QString, QString > sensorTypes() const
Returns a list of sensor types handled by the registry.
QgsAbstractSensorWidget * createSensorWidget(QgsAbstractSensor *sensor) const
Creates a new instance of a sensor configuration widget for the specified sensor.
bool addSensorGuiMetadata(QgsSensorAbstractGuiMetadata *metadata)
Registers the GUI metadata for a new sensor type.
QgsAbstractSensor * createSensor(const QString &type, QObject *parent=nullptr) const
Creates a new instance of a sensor given the type.