@@ -29,23 +29,25 @@ QVector<QgsDataItem*> QgsPGConnectionItem::createChildren()
29
29
QString mConnInfo = connection.connectionInfo ();
30
30
QgsDebugMsg ( " mConnInfo = " + mConnInfo );
31
31
32
- if ( !pgProvider->supportedLayers ( mLayerProperties , true , false , false ) )
32
+ QVector<QgsPostgresLayerProperty> layerProperties;
33
+ if ( !pgProvider->supportedLayers ( layerProperties, true , false , false ) )
33
34
{
34
35
children.append ( new QgsErrorItem ( this , tr ( " Failed to retrieve layers" ), mPath + " /error" ) );
35
36
return children;
36
37
}
37
38
38
- QMap<QString, QVector<QgsPostgresLayerProperty> > schemasMap;
39
- foreach ( QgsPostgresLayerProperty layerProperty, mLayerProperties )
39
+ // fill the schemas map
40
+ mSchemasMap .clear ();
41
+ foreach ( QgsPostgresLayerProperty layerProperty, layerProperties )
40
42
{
41
- schemasMap [ layerProperty.schemaName ].push_back ( layerProperty );
43
+ mSchemasMap [ layerProperty.schemaName ].push_back ( layerProperty );
42
44
}
43
45
44
- QMap<QString, QVector<QgsPostgresLayerProperty> >::const_iterator it = schemasMap .constBegin ();
45
- for ( ; it != schemasMap .constEnd (); it++ )
46
+ QMap<QString, QVector<QgsPostgresLayerProperty> >::const_iterator it = mSchemasMap .constBegin ();
47
+ for ( ; it != mSchemasMap .constEnd (); it++ )
46
48
{
47
49
QgsDebugMsg ( " schema: " + it.key () );
48
- QgsPGSchemaItem * schema = new QgsPGSchemaItem ( this , it.key (), mPath + " /" + it.key (), mConnInfo , it. value () );
50
+ QgsPGSchemaItem * schema = new QgsPGSchemaItem ( this , it.key (), mPath + " /" + it.key (), mConnInfo );
49
51
50
52
children.append ( schema );
51
53
}
@@ -118,20 +120,22 @@ QString QgsPGLayerItem::createUri()
118
120
}
119
121
120
122
// ---------------------------------------------------------------------------
121
- QgsPGSchemaItem::QgsPGSchemaItem ( QgsDataItem* parent, QString name, QString path, QString connInfo, QVector<QgsPostgresLayerProperty> layerProperties )
123
+ QgsPGSchemaItem::QgsPGSchemaItem ( QgsDataItem* parent, QString name, QString path, QString connInfo )
122
124
: QgsDataCollectionItem( parent, name, path )
123
125
{
124
126
mIcon = QIcon ( getThemePixmap ( " mIconDbSchema.png" ) );
125
127
mConnInfo = connInfo;
126
- mLayerProperties = layerProperties;
127
- populate ();
128
128
}
129
129
130
130
QVector<QgsDataItem*> QgsPGSchemaItem::createChildren ()
131
131
{
132
+ QgsPGConnectionItem* connItem = dynamic_cast <QgsPGConnectionItem*>( mParent );
133
+ Q_ASSERT ( connItem );
134
+ QVector<QgsPostgresLayerProperty> layers = connItem->mSchemasMap .value ( mName );
135
+
132
136
QVector<QgsDataItem*> children;
133
137
// Populate everything, it costs nothing, all info about layers is collected
134
- foreach ( QgsPostgresLayerProperty layerProperty, mLayerProperties )
138
+ foreach ( QgsPostgresLayerProperty layerProperty, layers )
135
139
{
136
140
QgsDebugMsg ( " table: " + layerProperty.schemaName + " ." + layerProperty.tableName );
137
141
0 commit comments