Skip to content

Commit

Permalink
[GRASS] optionally show virtual topo layers
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Sep 24, 2015
1 parent c8785ec commit e655c26
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/providers/grass/qgsgrass.cpp
Expand Up @@ -1174,7 +1174,7 @@ QStringList QgsGrass::vectorLayers( const QString& gisdbase, const QString& loca

// TODO: add option in GUI to set listTopoLayers
QSettings settings;
bool listTopoLayers = settings.value( "/GRASS/listTopoLayers", false ).toBool();
bool listTopoLayers = settings.value( "/GRASS/showTopoLayers", false ).toBool();
if ( listTopoLayers )
{
// add topology layers
Expand Down
4 changes: 2 additions & 2 deletions src/providers/grass/qgsgrassfeatureiterator.cpp
Expand Up @@ -465,7 +465,7 @@ bool QgsGrassFeatureIterator::fetchFeature( QgsFeature& feature )
mSource->mLayer->map()->unlockReadWrite();
return false; // No more features
}
if ( type == 0 ) // should not happen
if ( type == 0 && mSource->mLayerType != QgsGrassProvider::TOPO_NODE )
{
QgsDebugMsg( "unknown type" );
close();
Expand Down Expand Up @@ -507,6 +507,7 @@ bool QgsGrassFeatureIterator::fetchFeature( QgsFeature& feature )
}
else
{
feature.initAttributes( mSource->mFields.size() );
feature.setAttribute( 0, lid );
#if GRASS_VERSION_MAJOR < 7
if ( mSource->mLayerType == QgsGrassProvider::TOPO_POINT || mSource->mLayerType == QgsGrassProvider::TOPO_LINE )
Expand All @@ -518,7 +519,6 @@ bool QgsGrassFeatureIterator::fetchFeature( QgsFeature& feature )
feature.setAttribute( 1, QgsGrass::vectorTypeName( type ) );

int node1, node2;;
close();
Vect_get_line_nodes( mSource->map(), lid, &node1, &node2 );
feature.setAttribute( 2, node1 );
if ( mSource->mLayerType == QgsGrassProvider::TOPO_LINE )
Expand Down
4 changes: 4 additions & 0 deletions src/providers/grass/qgsgrassoptions.cpp
Expand Up @@ -76,6 +76,8 @@ QgsGrassOptions::QgsGrassOptions( QWidget *parent )

mImportExternalCheckBox->setChecked( settings.value( mImportSettingsPath + "/external", true ).toBool() );

mTopoLayersCheckBox->setChecked( settings.value( "/GRASS/showTopoLayers", false ).toBool() );

// Region
QPen regionPen = QgsGrass::regionPen();
mRegionColorButton->setContext( "gui" );
Expand Down Expand Up @@ -160,6 +162,8 @@ void QgsGrassOptions::saveOptions()

settings.setValue( mImportSettingsPath + "/external", mImportExternalCheckBox->isChecked() );

settings.setValue( "/GRASS/showTopoLayers", mTopoLayersCheckBox->isChecked() );

// Region
QPen regionPen = QgsGrass::regionPen();
regionPen.setColor( mRegionColorButton->color() );
Expand Down
30 changes: 26 additions & 4 deletions src/providers/grass/qgsgrassoptionsbase.ui
Expand Up @@ -149,7 +149,7 @@
<number>0</number>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="mGeneralPage">
<layout class="QVBoxLayout" name="verticalLayout_11">
Expand Down Expand Up @@ -246,8 +246,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>408</width>
<height>311</height>
<width>247</width>
<height>141</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down Expand Up @@ -351,7 +351,7 @@
<height>329</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_28">
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<widget class="QgsCollapsibleGroupBox" name="mImportGroupBox">
<property name="title">
Expand Down Expand Up @@ -402,6 +402,28 @@
</layout>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="mLayersBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Layers</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QCheckBox" name="mTopoLayersCheckBox">
<property name="text">
<string>Show virtual topological layers</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand Down
2 changes: 1 addition & 1 deletion src/providers/grass/qgsgrassprovidermodule.cpp
Expand Up @@ -484,7 +484,7 @@ QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
QString typeName = layerName.split( "_" ).value( 1 );
QString baseLayerName = layerName.split( "_" ).value( 0 );

if ( typeName == "point" )
if ( typeName == "point" || typeName == "node" )
layerType = QgsLayerItem::Point;
else if ( typeName == "line" )
layerType = QgsLayerItem::Line;
Expand Down

0 comments on commit e655c26

Please sign in to comment.