16#include "moc_qgsproviderconnectionmodel.cpp" 
   22  : QAbstractItemModel( parent )
 
   23  , mProvider( provider )
 
   26  Q_ASSERT( mMetadata );
 
 
   36  if ( allowEmpty == mAllowEmpty )
 
   41    beginInsertRows( QModelIndex(), 0, 0 );
 
   47    beginRemoveRows( QModelIndex(), 0, 0 );
 
 
   53void QgsProviderConnectionModel::removeConnection( 
const QString &connection )
 
   55  const int index = mConnections.indexOf( connection );
 
   59  beginRemoveRows( QModelIndex(), 
index + ( mAllowEmpty ? 1 : 0 ), 
index + ( mAllowEmpty ? 1 : 0 ) );
 
   60  mConnections.removeAt( 
index );
 
   64void QgsProviderConnectionModel::addConnection( 
const QString &connection )
 
   66  beginInsertRows( QModelIndex(), mConnections.count() + ( mAllowEmpty ? 1 : 0 ), mConnections.count() + ( mAllowEmpty ? 1 : 0 ) );
 
   67  mConnections.append( connection );
 
   83  return mConnections.count() + ( mAllowEmpty ? 1 : 0 );
 
 
   95  if ( !
index.isValid() )
 
   98  if ( 
index.row() == 0 && mAllowEmpty )
 
  106  const QString connectionName = mConnections.value( 
index.row() - ( mAllowEmpty ? 1 : 0 ) );
 
  112    case Qt::DisplayRole:
 
  116      return connectionName;
 
  119    case Qt::DecorationRole:
 
  122        return connection->icon();
 
  129    case Qt::ToolTipRole:
 
  134        return connection->uri();
 
  146        return connection->configuration();
 
 
  163  if ( hasIndex( row, column, 
parent ) )
 
  165    return createIndex( row, column, row );
 
  168  return QModelIndex();
 
 
An interface for data provider connections.
 
QgsProviderConnectionModel(const QString &provider, QObject *parent=nullptr)
Constructor for QgsProviderConnectionModel, for the specified provider.
 
void setAllowEmptyConnection(bool allowEmpty)
Sets whether an optional empty connection ("not set") option is present in the model.
 
int rowCount(const QModelIndex &parent=QModelIndex()) const override
 
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
 
@ Configuration
Connection configuration variant map.
 
@ ConnectionName
Connection name.
 
@ Uri
Connection URI string.
 
@ Empty
Entry is an empty entry.
 
QModelIndex parent(const QModelIndex &child) const override
 
QModelIndex index(int row, int column, const QModelIndex &parent) const override
 
int columnCount(const QModelIndex &parent=QModelIndex()) const override
 
A registry / canonical manager of data providers.