20 : QAbstractItemModel( parent )
21 , mProvider( provider )
24 Q_ASSERT( mMetadata );
34 if ( allowEmpty == mAllowEmpty )
39 beginInsertRows( QModelIndex(), 0, 0 );
45 beginRemoveRows( QModelIndex(), 0, 0 );
51 void QgsProviderConnectionModel::removeConnection(
const QString &connection )
53 int index = mConnections.indexOf( connection );
57 beginRemoveRows( QModelIndex(),
index + ( mAllowEmpty ? 1 : 0 ),
index + ( mAllowEmpty ? 1 : 0 ) );
58 mConnections.removeAt(
index );
62 void QgsProviderConnectionModel::addConnection(
const QString &connection )
64 beginInsertRows( QModelIndex(), mConnections.count() + ( mAllowEmpty ? 1 : 0 ), mConnections.count() + ( mAllowEmpty ? 1 : 0 ) );
65 mConnections.append( connection );
81 return mConnections.count() + ( mAllowEmpty ? 1 : 0 );
93 if ( !
index.isValid() )
96 if (
index.row() == 0 && mAllowEmpty )
104 const QString connectionName = mConnections.value(
index.row() - ( mAllowEmpty ? 1 : 0 ) );
110 case Qt::DisplayRole:
114 return connectionName;
117 case Qt::DecorationRole:
120 return connection->icon();
127 case Qt::ToolTipRole:
132 return connection->uri();
144 return connection->configuration();
159 if ( hasIndex( row, column,
parent ) )
161 return createIndex( row, column, row );
164 return QModelIndex();