29  qDeleteAll( mMetadata );
 
   34  if ( !mMetadata.isEmpty() )
 
   38                        QObject::tr( 
"TCP socket sensor" ),
 
   42    QgsTcpSocketSensorWidget *widget = 
new QgsTcpSocketSensorWidget( 
nullptr );
 
   43    widget->setSensor( sensor );
 
   47                        QObject::tr( 
"UDP socket sensor" ),
 
   51    QgsUdpSocketSensorWidget *widget = 
new QgsUdpSocketSensorWidget( 
nullptr );
 
   52    widget->setSensor( sensor );
 
   55#if defined( HAVE_QTSERIALPORT ) 
   57                        QObject::tr( 
"Serial port sensor" ),
 
   61    QgsSerialPortSensorWidget *widget = 
new QgsSerialPortSensorWidget( 
nullptr );
 
   62    widget->setSensor( sensor );
 
   71  return mMetadata.value( type );
 
   76  if ( !metadata || mMetadata.contains( metadata->
type() ) )
 
   79  mMetadata[metadata->
type()] = metadata;
 
   86  if ( !mMetadata.contains( type ) )
 
   89  std::unique_ptr< QgsAbstractSensor > sensor( mMetadata.value( type )->createSensor( parent ) );
 
   91    return sensor.release();
 
   98  if ( !sensor || !mMetadata.contains( sensor->
type() ) )
 
  101  return  mMetadata[sensor->
type()]->createSensorWidget( sensor );
 
  106  QMap<QString, QString> types;
 
  107  for ( 
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
 
  109    types.insert( it.key(), it.value()->visibleName() );
 
An abstract base class for sensor classes.
 
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.