21 : QAbstractItemModel( parent )
22 , mProvider( provider )
25 Q_ASSERT( mMetadata );
35 if ( allowEmpty == mAllowEmpty )
40 beginInsertRows( QModelIndex(), 0, 0 );
46 beginRemoveRows( QModelIndex(), 0, 0 );
52 void QgsProviderConnectionModel::removeConnection(
const QString &connection )
54 const int index = mConnections.indexOf( connection );
58 beginRemoveRows( QModelIndex(),
index + ( mAllowEmpty ? 1 : 0 ),
index + ( mAllowEmpty ? 1 : 0 ) );
59 mConnections.removeAt(
index );
63 void QgsProviderConnectionModel::addConnection(
const QString &connection )
65 beginInsertRows( QModelIndex(), mConnections.count() + ( mAllowEmpty ? 1 : 0 ), mConnections.count() + ( mAllowEmpty ? 1 : 0 ) );
66 mConnections.append( connection );
82 return mConnections.count() + ( mAllowEmpty ? 1 : 0 );
94 if ( !
index.isValid() )
97 if (
index.row() == 0 && mAllowEmpty )
105 const QString connectionName = mConnections.value(
index.row() - ( mAllowEmpty ? 1 : 0 ) );
111 case Qt::DisplayRole:
115 return connectionName;
118 case Qt::DecorationRole:
121 return connection->icon();
128 case Qt::ToolTipRole:
133 return connection->uri();
145 return connection->configuration();
160 if ( hasIndex( row, column,
parent ) )
162 return createIndex( row, column, row );
165 return QModelIndex();