20#include "moc_qgssensorguiregistry.cpp" 
   30  qDeleteAll( mMetadata );
 
 
   35  if ( !mMetadata.isEmpty() )
 
   39    QgsTcpSocketSensorWidget *widget = 
new QgsTcpSocketSensorWidget( 
nullptr );
 
   40    widget->setSensor( sensor );
 
   41    return widget; }, nullptr ) );
 
   43    QgsUdpSocketSensorWidget *widget = 
new QgsUdpSocketSensorWidget( 
nullptr );
 
   44    widget->setSensor( sensor );
 
   45    return widget; }, nullptr ) );
 
   46#if defined( HAVE_QTSERIALPORT ) 
   48    QgsSerialPortSensorWidget *widget = 
new QgsSerialPortSensorWidget( 
nullptr );
 
   49    widget->setSensor( sensor );
 
   50    return widget; }, nullptr ) );
 
 
   57  return mMetadata.value( type );
 
 
   62  if ( !metadata || mMetadata.contains( metadata->
type() ) )
 
   65  mMetadata[metadata->
type()] = metadata;
 
 
   72  if ( !mMetadata.contains( type ) )
 
   75  std::unique_ptr<QgsAbstractSensor> sensor( mMetadata.value( type )->createSensor( parent ) );
 
   77    return sensor.release();
 
 
   84  if ( !sensor || !mMetadata.contains( sensor->
type() ) )
 
   87  return mMetadata[sensor->
type()]->createSensorWidget( sensor );
 
 
   92  QMap<QString, QString> types;
 
   93  for ( 
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
 
   95    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.