Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
handle ogr sublayers with colon
(cherry picked from commit 2b703e3 & d875011)
  • Loading branch information
jef-n committed Jun 30, 2015
1 parent 2a066d8 commit 5bdaf44
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
24 changes: 22 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -2929,7 +2929,15 @@ bool QgisApp::addVectorLayers( const QStringList &theLayerQStringList, const QSt
QStringList sublayers = layer->dataProvider()->subLayers();
QStringList elements = sublayers.at( 0 ).split( ":" );
if ( layer->storageType() != "GeoJSON" )
{
while ( elements.size() > 4 )
{
elements[1] += ":" + elements[2];
elements.removeAt( 2 );
}

layer->setLayerName( elements.at( 1 ) );
}
myList << layer;
}
else
Expand Down Expand Up @@ -3254,8 +3262,20 @@ void QgisApp::loadOGRSublayers( QString layertype, QString uri, QStringList list
for ( int i = 0; i < list.size(); i++ )
{
QString composedURI;
QString layerName = list.at( i ).split( ':' ).value( 0 );
QString layerType = list.at( i ).split( ':' ).value( 1 );
QStringList elements = list.at( i ).split( ":" );
while ( elements.size() > 2 )
{
elements[0] += ":" + elements[1];
elements.removeAt( 1 );
}

QString layerName = elements.value( 0 );
QString layerType = elements.value( 1 );
if ( layerType == "any" )
{
layerType = "";
elements.removeAt( 1 );
}

if ( layertype != "GRASS" )
{
Expand Down
14 changes: 13 additions & 1 deletion src/gui/qgssublayersdialog.cpp
Expand Up @@ -81,10 +81,16 @@ QStringList QgsSublayersDialog::selectionNames()
count++;
}
}

if ( count > 1 )
{
name += ":" + layersTable->selectedItems().at( i )->text( 3 );
}
else
{
name += ":any";
}

list << name;
}
return list;
Expand All @@ -104,7 +110,13 @@ void QgsSublayersDialog::populateLayerTable( QStringList theList, QString delim
{
foreach ( QString item, theList )
{
layersTable->addTopLevelItem( new QTreeWidgetItem( item.split( delim ) ) );
QStringList elements = item.split( delim );
while ( elements.size() > 4 )
{
elements[1] += delim + elements[2];
elements.removeAt( 2 );
}
layersTable->addTopLevelItem( new QTreeWidgetItem( elements ) );
}

// resize columns
Expand Down

0 comments on commit 5bdaf44

Please sign in to comment.