Skip to content

Commit

Permalink
fix #2244
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12403 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Dec 10, 2009
1 parent 52ef19b commit 3715f34
Showing 1 changed file with 21 additions and 30 deletions.
51 changes: 21 additions & 30 deletions src/app/qgsavoidintersectionsdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
#include "qgsavoidintersectionsdialog.h"
#include "qgsmapcanvas.h"
#include "qgsvectorlayer.h"
#include "qgsmaplayerregistry.h"

QgsAvoidIntersectionsDialog::QgsAvoidIntersectionsDialog( QgsMapCanvas* canvas, const QSet<QString>& enabledLayers, QWidget * parent, Qt::WindowFlags f ): \
QgsAvoidIntersectionsDialog::QgsAvoidIntersectionsDialog( QgsMapCanvas* canvas, const QSet<QString>& enabledLayers, QWidget * parent, Qt::WindowFlags f ):
QDialog( parent, f ), mMapCanvas( canvas )
{
setupUi( this );

int nLayers = mMapCanvas->layerCount();
QgsVectorLayer* currentLayer = 0;
QListWidgetItem* newItem = 0;
const QMap<QString, QgsMapLayer*> &mapLayers = QgsMapLayerRegistry::instance()->mapLayers();

for ( int i = 0; i < nLayers; ++i )
int i = 0;
for ( QMap<QString, QgsMapLayer*>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); it++, i++ )
{
currentLayer = dynamic_cast<QgsVectorLayer*>( mMapCanvas->layer( i ) );
if ( currentLayer )
QgsVectorLayer* currentLayer = dynamic_cast<QgsVectorLayer*>( it.value() );
if ( !currentLayer || currentLayer->geometryType() != QGis::Polygon )
continue;

QListWidgetItem *newItem = new QListWidgetItem( mLayersListWidget );
newItem->setText( currentLayer->name() );
newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
newItem->setData( Qt::UserRole, currentLayer->getLayerID() );
if ( enabledLayers.contains( currentLayer->getLayerID() ) )
{
//only consider polygon or multipolygon layers
if ( currentLayer->geometryType() == QGis::Polygon )
{
newItem = new QListWidgetItem( mLayersListWidget );
newItem->setText( currentLayer->name() );
newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
newItem->setData( Qt::UserRole, currentLayer->getLayerID() );
if ( enabledLayers.contains( currentLayer->getLayerID() ) )
{
newItem->setCheckState( Qt::Checked );
}
else
{
newItem->setCheckState( Qt::Unchecked );
}
}
newItem->setCheckState( Qt::Checked );
}
else
{
newItem->setCheckState( Qt::Unchecked );
}
}
}
Expand All @@ -45,16 +40,12 @@ void QgsAvoidIntersectionsDialog::enabledLayers( QSet<QString>& enabledLayers )
{
enabledLayers.clear();

int itemCount = mLayersListWidget->count();
QListWidgetItem* currentItem = 0;

for ( int i = 0; i < itemCount; ++i )
for ( int i = 0; i < mLayersListWidget->count(); ++i )
{
currentItem = mLayersListWidget->item( i );
QListWidgetItem *currentItem = mLayersListWidget->item( i );
if ( currentItem->checkState() == Qt::Checked )
{
enabledLayers.insert( currentItem->data( Qt::UserRole ).toString() );
}
}
}

0 comments on commit 3715f34

Please sign in to comment.