[QGIS Commit] r15301 - trunk/qgis/src/plugins/spatialquery
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Tue Mar 1 03:00:12 EST 2011
Author: timlinux
Date: 2011-03-01 00:00:12 -0800 (Tue, 01 Mar 2011)
New Revision: 15301
Modified:
trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.cpp
trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.h
trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.cpp
trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.h
trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialogbase.ui
Log:
Updates from Luiz for spatial query plugin
Modified: trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.cpp
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.cpp 2011-03-01 07:59:56 UTC (rev 15300)
+++ trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.cpp 2011-03-01 08:00:12 UTC (rev 15301)
@@ -16,7 +16,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
-/* $Id$ */
+/* $Id: qgsrubberselectid.cpp 13377 2010-04-25 01:07:36Z jef $ */
#include "qgsrubberselectid.h"
@@ -24,10 +24,14 @@
QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas* mapCanvas )
{
- mIsPolygon = true;
+ mIsPolygon = false;
mMapCanvas = mapCanvas;
mRubberBand = new QgsRubberBand( mMapCanvas, mIsPolygon );
-
+ mColorRGB[0] = 255;
+ mColorRGB[1] = 0;
+ mColorRGB[2] = 0;
+ mWidth = 2;
+ setStyle();
} // QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas* mapCanvas, bool isPolygon = true )
QgsRubberSelectId::~QgsRubberSelectId()
@@ -37,34 +41,33 @@
} // QgsRubberSelectId::~QgsRubberSelectId()
-void QgsRubberSelectId::isGeometryNotPolygon( bool isPolygon = false )
-{
- reset();
- delete mRubberBand;
- mIsPolygon = isPolygon;
- mRubberBand = new QgsRubberBand( mMapCanvas, mIsPolygon );
-
-} // void QgsRubberSelectId::isGeometryNotPolygon(bool isPolygon)
-
void QgsRubberSelectId::reset()
{
- mRubberBand->reset( mIsPolygon );
-
+ mRubberBand->reset( mIsPolygon );
} // void QgsRubberSelectId::reset()
-void QgsRubberSelectId::setColor( int colorRed, int colorGreen, int colorBlue, int width, float alfa = 0 )
+void QgsRubberSelectId::setStyle( int colorRed, int colorGreen, int colorBlue, int width )
{
- QColor color = QColor( colorRed, colorGreen, colorBlue );
- color.setAlpha( alfa );
- mRubberBand->setColor( color );
- mRubberBand->setWidth( width );
-
+ mColorRGB[0] = colorRed;
+ mColorRGB[1] = colorGreen;
+ mColorRGB[2] = colorBlue;
+ mWidth = width;
+ setStyle();
} // void QgsRubberSelectId::setColor(int colorRed, int colorGreen, int colorBlue, float alfa, width)
-void QgsRubberSelectId::addFeature( QgsVectorLayer* mLayer, int fid )
+void QgsRubberSelectId::addFeature( QgsVectorLayer* lyr, int fid )
{
+ bool isPolygon = ( lyr->geometryType() == QGis::Polygon );
+ if( mIsPolygon != isPolygon)
+ {
+ reset();
+ delete mRubberBand;
+ mIsPolygon = isPolygon;
+ mRubberBand = new QgsRubberBand( mMapCanvas, mIsPolygon );
+ setStyle();
+ }
QgsFeature feat;
- if ( !mLayer->featureAtId( fid, feat, true, false ) )
+ if ( !lyr->featureAtId( fid, feat, true, false ) )
{
return;
}
@@ -72,12 +75,17 @@
{
return;
}
-
- mRubberBand->setToGeometry( feat.geometry(), mLayer );
-
+ mRubberBand->setToGeometry( feat.geometry(), lyr );
} // void QgsRubberSelectId::addFeature( QgsVectorLayer* mLayer, int Id )
void QgsRubberSelectId::show()
{
mRubberBand->show();
} // QgsRubberSelectId::show()
+
+void QgsRubberSelectId::setStyle()
+{
+ QColor color = QColor( mColorRGB[0], mColorRGB[1], mColorRGB[2] );
+ mRubberBand->setColor( color );
+ mRubberBand->setWidth( mWidth );
+}
Modified: trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.h
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.h 2011-03-01 07:59:56 UTC (rev 15300)
+++ trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.h 2011-03-01 08:00:12 UTC (rev 15301)
@@ -15,7 +15,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
-/* $Id$ */
+/* $Id: qgsrubberselectid.h 13377 2010-04-25 01:07:36Z jef $ */
#ifndef QGSRUBBERSELECTID_H
#define QGSRUBBERSELECTID_H
@@ -42,12 +42,6 @@
~QgsRubberSelectId();
/**
- * \brief Set if is geometry polygon for rubber band
- * \param isPolygon boolean for type geometry is polygon
- */
- void isGeometryNotPolygon( bool isPolygon );
-
- /**
* \brief Reset rubber band
*/
void reset();
@@ -57,24 +51,28 @@
* \param colorRed integer for value red (0 - 255)
* \param colorGreen integer for value green (0 - 255)
* \param colorBlue integer for value blue (0 - 255)
- * \param alfa float for transparent(0.0 - 1)
*/
- void setColor( int colorRed, int colorGreen, int colorBlue, int width, float alfa );
+ void setStyle( int colorRed, int colorGreen, int colorBlue, int width);
/**
* \brief Create rubber band from geometry by feature
* \param mLayer pointer to QgsVectorLayer
* \param fid integer for ID for feature
*/
- void addFeature( QgsVectorLayer* mLayer, int fid );
+ void addFeature( QgsVectorLayer* lyr, int fid );
/**
* \brief Show rubber band
*/
void show();
private:
+ //! Set Style
+ void setStyle();
+
//! RubberBand
QgsRubberBand* mRubberBand;
+ int mColorRGB[3];
+ int mWidth;
bool mIsPolygon;
QgsMapCanvas* mMapCanvas;
};
Modified: trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.cpp
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.cpp 2011-03-01 07:59:56 UTC (rev 15300)
+++ trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.cpp 2011-03-01 08:00:12 UTC (rev 15301)
@@ -78,6 +78,8 @@
void QgsSpatialQueryDialog::initGui()
{
+ mRubberSelectId->setStyle(250, 0, 0, 2); // Same identify
+
showLogProcessing( false );
setLayoutResultInvalid( false );
@@ -101,13 +103,6 @@
} // QgsSpatialQueryDialog::initGui()
-void QgsSpatialQueryDialog::setColorRubberSelect()
-{
- mRGBRubberSelect[0] = 255 - QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorRedPart", 255 );
- mRGBRubberSelect[1] = 255 - QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorGreenPart", 255 );
- mRGBRubberSelect[2] = 255 - QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorBluePart", 0 );
-} // void QgsSpatialQueryDialog::setColorRubberSelectId()
-
void QgsSpatialQueryDialog::setLayer( bool isTarget, int index )
{
if ( isTarget )
@@ -137,20 +132,20 @@
void QgsSpatialQueryDialog::evaluateCheckBox( bool isTarget )
{
- QgsVectorLayer* layer = NULL;
+ QgsVectorLayer* lyr = NULL;
QCheckBox* checkbox = NULL;
if ( isTarget )
{
- layer = mLayerTarget;
+ lyr = mLayerTarget;
checkbox = ckbUsingSelectedTarget;
}
else
{
- layer = mLayerReference;
+ lyr = mLayerReference;
checkbox = ckbUsingSelectedReference;
}
- int selectedCount = layer->selectedFeatureCount();
- bool isCheckBoxValid = ( layer != NULL && selectedCount > 0 );
+ int selectedCount = lyr->selectedFeatureCount();
+ bool isCheckBoxValid = ( lyr != NULL && selectedCount > 0 );
checkbox->setChecked( isCheckBoxValid );
checkbox->setEnabled( isCheckBoxValid );
QString textCheckBox = isCheckBoxValid
@@ -274,15 +269,13 @@
msg = tr( "Finish at [%L1] (processing time %L2 minutes)" ).arg( datetimeEnd->toString() ).arg( timeProcess, 0, 'f', 2 );
teStatus->append( msg );
-
- mRubberSelectId->reset();
ckbLogProcessing->setChecked( false );
lbResultTarget->setText( mLayerTarget->name() );
lbInvalidTarget->setText( mLayerTarget->name() );
lbInvalidReference->setText( mLayerReference->name() );
- QString formatLabel( tr("Feature IDs(%1):"));
+ QString formatLabel( tr("Feature IDs(%1)"));
lbFIDresultTarget->setText( formatLabel.arg( mFeatureResult.size() ) );
lbFIDinvalidTarget->setText( formatLabel.arg( mFeatureInvalidTarget.size() ) );
lbFIDinvalidReference->setText( formatLabel.arg( mFeatureInvalidReference.size() ) );
@@ -299,6 +292,7 @@
// Button
pbSelectResultTarget->setEnabled( true );
evaluateButtonSelected();
+ ckbZoomItem->setEnabled( true ); // Show first the Result
}
else
{
@@ -307,6 +301,7 @@
pbSelectResultTargetRemove->setEnabled( false );
clearLwFeature( lwResultFeatureTarget );
lwResultFeatureTarget->setEnabled( false );
+ ckbZoomItem->setEnabled( false );
}
// Invalid target
if ( mFeatureInvalidTarget.size() > 0 )
@@ -338,17 +333,17 @@
adjustSize();
} // void QgsSpatialQueryDialog::showResultQuery(QDateTime *datetimeStart, QDateTime *datetimeEnd)
-void QgsSpatialQueryDialog::setLabelButtonSelected( QLabel *lb, QgsVectorLayer* layer, QPushButton *pb)
+void QgsSpatialQueryDialog::setLabelButtonSelected( QLabel *lb, QgsVectorLayer* lyr, QPushButton *pb)
{
- QString formatLabel("%1 of %2 selected items");
- int numSelected = layer->selectedFeatureCount();
- lb->setText( formatLabel.arg( numSelected ).arg( layer->featureCount() ) );
+ QString formatLabel("%1 of %2 selected features");
+ int numSelected = lyr->selectedFeatureCount();
+ lb->setText( formatLabel.arg( numSelected ).arg( lyr->featureCount() ) );
numSelected > 0 ? pb->setEnabled( true ) : pb->setEnabled( false );
}
-QString QgsSpatialQueryDialog::getSubsetSelected( QgsVectorLayer* layer )
+QString QgsSpatialQueryDialog::getSubsetSelected( QgsVectorLayer* lyr )
{
- QSet< int > selected = layer->selectedFeaturesIds();
+ QSet< int > selected = lyr->selectedFeaturesIds();
if( selected.size() == 0 )
{
return QString("");
@@ -363,56 +358,56 @@
QString qReturn = qFormat.arg( lstFID.join(",") );
lstFID.clear();
return qReturn;
-} // QString QgsSpatialQueryDialog::getSubsetSelected( QgsVectorLayer* layer )
+} // QString QgsSpatialQueryDialog::getSubsetSelected( QgsVectorLayer* lyr )
QString QgsSpatialQueryDialog::getDescriptionLayerShow( bool isTarget )
{
- QgsVectorLayer* layer = NULL;
+ QgsVectorLayer* lyr = NULL;
QCheckBox * checkBox = NULL;
if ( isTarget )
{
- layer = mLayerTarget;
+ lyr = mLayerTarget;
checkBox = ckbUsingSelectedTarget;
}
else
{
- layer = mLayerReference;
+ lyr = mLayerReference;
checkBox = ckbUsingSelectedReference;
}
QString sDescFeatures = checkBox->isChecked()
- ? tr( "%1 of %2" ).arg( layer->selectedFeatureCount() ).arg( layer->featureCount() )
- : tr( "all = %1" ).arg( layer->featureCount() );
+ ? tr( "%1 of %2" ).arg( lyr->selectedFeatureCount() ).arg( lyr->featureCount() )
+ : tr( "all = %1" ).arg( lyr->featureCount() );
- return QString( "%1 (%2)" ).arg( layer->name() ).arg( sDescFeatures );
+ return QString( "%1 (%2)" ).arg( lyr->name() ).arg( sDescFeatures );
} // QString QgsSpatialQueryDialog::getDescriptionLayerShow(bool isTarget)
QString QgsSpatialQueryDialog::getDescriptionInvalidFeaturesShow( bool isTarget )
{
- QgsVectorLayer* layer = NULL;
+ QgsVectorLayer* lyr = NULL;
QCheckBox* checkBox = NULL;
int totalInvalid = 0;
if ( isTarget )
{
- layer = mLayerTarget;
+ lyr = mLayerTarget;
checkBox = ckbUsingSelectedTarget;
totalInvalid = mFeatureInvalidTarget.size();
}
else
{
- layer = mLayerReference;
+ lyr = mLayerReference;
checkBox = ckbUsingSelectedReference;
totalInvalid = mFeatureInvalidReference.size();
}
QString sDescFeatures = checkBox->isChecked()
- ? tr( "%1 of %2(selected features)" ).arg( totalInvalid ).arg( layer->selectedFeatureCount() )
- : tr( "%1 of %2" ).arg( totalInvalid ).arg( layer->featureCount() );
+ ? tr( "%1 of %2(selected features)" ).arg( totalInvalid ).arg( lyr->selectedFeatureCount() )
+ : tr( "%1 of %2" ).arg( totalInvalid ).arg( lyr->featureCount() );
- return QString( "%1: %2" ).arg( layer->name() ).arg( sDescFeatures );
+ return QString( "%1: %2" ).arg( lyr->name() ).arg( sDescFeatures );
} // QString QgsSpatialQueryDialog::getDescriptionInvalidFeatures(bool isTarget)
@@ -508,31 +503,31 @@
} // QIcon QgsSpatialQueryDialog::getIconTypeGeometry(int typeGeometry)
-void QgsSpatialQueryDialog::addCbLayer( bool isTarget, QgsVectorLayer* vectorLayer )
+void QgsSpatialQueryDialog::addCbLayer( bool isTarget, QgsVectorLayer* lyr )
{
- QVariant item = QVariant::fromValue(( void * )vectorLayer );
+ QVariant item = QVariant::fromValue(( void * )lyr );
QComboBox * cmb = isTarget ? cbTargetLayer : cbReferenceLayer;
int idNew = cmb->count();
- QIcon icon = getIconTypeGeometry( vectorLayer->geometryType() );
- cmb->addItem( icon, vectorLayer->name(), item );
- cmb->setItemData( idNew, QVariant( vectorLayer->source() ), Qt::ToolTipRole );
+ QIcon icon = getIconTypeGeometry( lyr->geometryType() );
+ cmb->addItem( icon, lyr->name(), item );
+ cmb->setItemData( idNew, QVariant( lyr->source() ), Qt::ToolTipRole );
-} // void QgsSpatialQueryDialog::removeLayerCombobox(bool isTarget, QgsVectorLayer* vectorLayer)
+} // void QgsSpatialQueryDialog::removeLayerCombobox(bool isTarget, QgsVectorLayer* lyr)
-int QgsSpatialQueryDialog::getCbIndexLayer( bool isTarget, QgsVectorLayer* vectorLayer )
+int QgsSpatialQueryDialog::getCbIndexLayer( bool isTarget, QgsVectorLayer* lyr )
{
- QVariant item = QVariant::fromValue(( void * )vectorLayer );
+ QVariant item = QVariant::fromValue(( void * )lyr );
QComboBox * cmb = isTarget ? cbTargetLayer : cbReferenceLayer;
return cmb->findData( item );
} //
-void QgsSpatialQueryDialog::removeLayer( bool isTarget, QgsVectorLayer* lyrRemove )
+void QgsSpatialQueryDialog::removeLayer( bool isTarget, QgsVectorLayer* lyr )
{
QComboBox * cmb = isTarget ? cbTargetLayer : cbReferenceLayer;
cmb->blockSignals( true );
// Remove Combobox
- int index = getCbIndexLayer( isTarget, lyrRemove );
+ int index = getCbIndexLayer( isTarget, lyr );
if ( index > -1 )
{
cmb->removeItem( index );
@@ -547,7 +542,7 @@
{
lyrThis = mLayerReference;
}
- if ( lyrRemove == lyrThis )
+ if ( lyr == lyrThis )
{
lyrThis = NULL;
if ( cmb->count() > 0 )
@@ -556,7 +551,7 @@
setLayer( isTarget, 0 );
evaluateCheckBox( isTarget );
mRubberSelectId->reset();
- QString lbFID("Feature IDs(0):");
+ QString lbFID("Feature IDs(0)");
if ( isTarget )
{
// Result
@@ -580,7 +575,7 @@
}
cmb->blockSignals( false );
-} // void QgsSpatialQueryDialog::removeLayer(bool isTarget, QgsVectorLayer* lyrRemove)
+} // void QgsSpatialQueryDialog::removeLayer(bool isTarget, QgsVectorLayer* lyr)
void QgsSpatialQueryDialog::populateCbTargetLayer()
{
@@ -589,7 +584,7 @@
QMap <QString, QgsMapLayer*> map = QgsMapLayerRegistry::instance()->mapLayers();
QMapIterator <QString, QgsMapLayer*> item( map );
QgsMapLayer * mapLayer = NULL;
- QgsVectorLayer * vectorLayer = NULL;
+ QgsVectorLayer * lyr = NULL;
QString layerId;
while ( item.hasNext() )
{
@@ -599,14 +594,14 @@
{
continue;
}
- vectorLayer = qobject_cast<QgsVectorLayer *>( mapLayer );
- if ( !vectorLayer )
+ lyr = qobject_cast<QgsVectorLayer *>( mapLayer );
+ if ( !lyr )
{
continue;
}
- addCbLayer( true, vectorLayer );
- mMapIdVectorLayers.insert( vectorLayer->getLayerID(), vectorLayer );
+ addCbLayer( true, lyr );
+ mMapIdVectorLayers.insert( lyr->getLayerID(), lyr );
}
cbTargetLayer->setCurrentIndex( 0 );
cbTargetLayer->blockSignals( false );
@@ -622,20 +617,20 @@
QString itemText;
QVariant itemData;
QIcon itemIcon;
- QgsVectorLayer * itemLayer = NULL;
+ QgsVectorLayer * lyr = NULL;
int idNew = 0;
for ( int id = 0; id < cbTargetLayer->count(); id++ )
{
itemText = cbTargetLayer->itemText( id );
itemData = cbTargetLayer->itemData( id );
itemIcon = cbTargetLayer->itemIcon( id );
- itemLayer = static_cast<QgsVectorLayer *>( itemData.value<void *>() );
- if ( itemLayer == mLayerTarget )
+ lyr = static_cast<QgsVectorLayer *>( itemData.value<void *>() );
+ if ( lyr == mLayerTarget )
{
continue;
}
cbReferenceLayer->addItem( itemIcon, itemText, itemData );
- cbReferenceLayer->setItemData( idNew, QVariant( itemLayer->source() ), Qt::ToolTipRole );
+ cbReferenceLayer->setItemData( idNew, QVariant( lyr->source() ), Qt::ToolTipRole );
idNew++;
}
int idCurrent = getCbIndexLayer( false, mLayerReference );
@@ -721,23 +716,23 @@
listWidget->blockSignals( false );
} // void QgsSpatialQueryDialog::clearLwFeature( QListWidget *listWidget )
-void QgsSpatialQueryDialog::changeLwFeature( QListWidget *listWidget, QgsVectorLayer* vectorLayer, int fid )
+void QgsSpatialQueryDialog::changeLwFeature( QListWidget *listWidget, QgsVectorLayer* lyr, int fid )
{
listWidget->setEnabled( false ); // The showRubberFeature can be slow
- showRubberFeature( vectorLayer, fid );
+ showRubberFeature( lyr, fid );
// Zoom
if( ckbZoomItem->isChecked() )
{
- zoomFeatureTarget(vectorLayer, fid);
+ zoomFeatureTarget(lyr, fid);
}
listWidget->setEnabled( true );
listWidget->setFocus();
-} // void QgsSpatialQueryDialog::changeLwFeature( QListWidget *listWidget, QgsVectorLayer* layer, int fid )
+} // void QgsSpatialQueryDialog::changeLwFeature( QListWidget *listWidget, QgsVectorLayer* lyr, int fid )
-void QgsSpatialQueryDialog::zoomFeatureTarget(QgsVectorLayer* vectorLayer, int fid)
+void QgsSpatialQueryDialog::zoomFeatureTarget(QgsVectorLayer* lyr, int fid)
{
QgsFeature feat;
- if ( !vectorLayer->featureAtId( fid, feat, true, false ) )
+ if ( !lyr->featureAtId( fid, feat, true, false ) )
{
return;
}
@@ -746,17 +741,23 @@
return;
}
// Set system reference
- QgsCoordinateReferenceSystem srsSource = vectorLayer->srs();
+ QgsCoordinateReferenceSystem srsSource = lyr->srs();
QgsCoordinateReferenceSystem srcMapcanvas = mIface->mapCanvas()->mapRenderer()->destinationSrs();
- QgsCoordinateTransform * coordTransform = new QgsCoordinateTransform( srsSource, srcMapcanvas );
- QgsRectangle rectExtent = coordTransform->transform( feat.geometry()->boundingBox() );
- delete coordTransform;
-
- mIface->mapCanvas()->setExtent( rectExtent );
+ if( srsSource == srcMapcanvas)
+ {
+ mIface->mapCanvas()->setExtent( feat.geometry()->boundingBox() );
+ }
+ else
+ {
+ QgsCoordinateTransform * coordTransform = new QgsCoordinateTransform( srsSource, srcMapcanvas );
+ QgsRectangle rectExtent = coordTransform->transform( feat.geometry()->boundingBox() );
+ delete coordTransform;
+ mIface->mapCanvas()->setExtent( rectExtent );
+ }
mIface->mapCanvas()->refresh();
-} // void QgsSpatialQueryDialog::zoomFeatureTarget(QgsVectorLayer* vectorLayer, int fid)
+} // void QgsSpatialQueryDialog::zoomFeatureTarget(QgsVectorLayer* lyr, int fid)
-void QgsSpatialQueryDialog::showRubberFeature( QgsVectorLayer* vectorLayer, int id )
+void QgsSpatialQueryDialog::showRubberFeature( QgsVectorLayer* lyr, int id )
{
mRubberSelectId->reset();
@@ -766,12 +767,12 @@
c.setShape( Qt::WaitCursor );
setCursor( c );
- mRubberSelectId->addFeature( vectorLayer, id );
+ mRubberSelectId->addFeature( lyr, id );
mRubberSelectId->show();
c.setShape( shapeCurrent );
setCursor( c );
-} // void QgsSpatialQueryDialog::showRubberFeature( QgsVectorLayer* vectorLayer, int id )
+} // void QgsSpatialQueryDialog::showRubberFeature( QgsVectorLayer* lyr, int id )
//! Slots for signs of Dialog
void QgsSpatialQueryDialog::on_bbMain_accepted()
@@ -840,59 +841,54 @@
void QgsSpatialQueryDialog::on_lwResultFeatureTarget_currentItemChanged( QListWidgetItem * item )
{
- mRubberSelectId->setColor( mRGBRubberSelect[0], mRGBRubberSelect[1], mRGBRubberSelect[2], 0.5, 2 );
- int fid = item->data(Qt::UserRole).asInt();
+ bool isOk;
+ int fid = item->data(Qt::UserRole).toInt( &isOk );
changeLwFeature( lwResultFeatureTarget, mLayerTarget, fid );
} // void QgsSpatialQueryDialog::on_lwResultFeatureTarget_currentItemChanged( QListWidgetItem * item )
void QgsSpatialQueryDialog::on_twResultInvalid_currentChanged ( int index )
{
- if ( index == 0 ) // Result target
+ void ( QgsSpatialQueryDialog::* on_lw_currentItemChanged )( QListWidgetItem * ) = NULL;
+ QListWidget *lw = NULL;
+ switch (index)
{
- if ( lwResultFeatureTarget->count() > 0)
- {
- on_lwResultFeatureTarget_currentItemChanged( lwResultFeatureTarget->currentItem() );
- }
+ case 0: // Result target
+ on_lw_currentItemChanged = &QgsSpatialQueryDialog::on_lwResultFeatureTarget_currentItemChanged;
+ lw = lwResultFeatureTarget;
+ break;
+ case 1: // Invalid target
+ on_lw_currentItemChanged = &QgsSpatialQueryDialog::on_lwInvalidFeatureTarget_currentItemChanged;
+ lw = lwInvalidFeatureTarget;
+ break;
+ case 2: // Invalid reference
+ on_lw_currentItemChanged = &QgsSpatialQueryDialog::on_lwInvalidFeatureReference_currentItemChanged;
+ lw = lwInvalidFeatureReference;
+ break;
+ default:
+ return;
}
- else // Invalid target
+ if( lw->count() > 0)
{
- if ( lwInvalidFeatureTarget->count() > 0)
- {
- on_lwInvalidFeatureTarget_currentItemChanged( lwInvalidFeatureTarget->currentItem() );
- }
+ ckbZoomItem->setEnabled( true );
+ ( this->*on_lw_currentItemChanged )( lw->currentItem() );
}
-} // void QgsSpatialQueryDialog::on_twResultInvalid_currentChanged ( int index )
-
-void QgsSpatialQueryDialog::on_twInvalid_currentChanged ( int index )
-{
- if (index == 0 ) // Target
+ else
{
- if ( lwInvalidFeatureTarget->count() > 0)
- {
- on_lwInvalidFeatureTarget_currentItemChanged( lwInvalidFeatureTarget->currentItem() );
- }
+ ckbZoomItem->setEnabled( false );
}
- else // Reference
- {
- if ( lwInvalidFeatureReference->count() > 0)
- {
- on_lwInvalidFeatureReference_currentItemChanged( lwInvalidFeatureReference->currentItem() );
- }
- }
+} // void QgsSpatialQueryDialog::on_twResultInvalid_currentChanged ( int index )
-} // void QgsSpatialQueryDialog::on_twInvalid_currentChanged ( int index );
-
void QgsSpatialQueryDialog::on_lwInvalidFeatureTarget_currentItemChanged( QListWidgetItem * item )
{
- mRubberSelectId->setColor( 255, 0, 0, 0.5, 2 ); // RED
- int fid = item->data(Qt::UserRole).asInt();
+ bool isOk;
+ int fid = item->data(Qt::UserRole).toInt( &isOk );
changeLwFeature( lwInvalidFeatureTarget, mLayerTarget, fid );
} // void QgsSpatialQueryDialog::on_lwInvalidFeatureTarget_currentItemChanged( QListWidgetItem * item )
void QgsSpatialQueryDialog::on_lwInvalidFeatureReference_currentItemChanged( QListWidgetItem * item )
{
- mRubberSelectId->setColor( 255, 0, 0, 0.5, 2 ); // RED
- int fid = item->data(Qt::UserRole).asInt();
+ bool isOk;
+ int fid = item->data(Qt::UserRole).toInt( &isOk );
changeLwFeature( lwInvalidFeatureReference, mLayerReference, fid );
} // void QgsSpatialQueryDialog::on_lwInvalidFeatureReference_currentItemChanged( QListWidgetItem * item )
@@ -907,25 +903,32 @@
{
if( checked )
{
- QListWidget *lw = lwResultFeatureTarget;
- QgsVectorLayer *lyr = mLayerTarget;
- // Get current list feature (Result Target, Invalid Target and Invalid Reference)
- if( twResultInvalid->currentIndex() != 0 ) // Invalid
+ QListWidget *lw = NULL;
+ QgsVectorLayer *lyr = NULL;
+ int index = twResultInvalid->currentIndex();
+ switch (index)
{
- // 0 -> Invalid Target
- if( twInvalid->currentIndex() == 0 ) // Target
- {
+ case 0: // Result target
+ lyr = mLayerTarget;
+ lw = lwResultFeatureTarget;
+ break;
+ case 1: // Invalid target
+ lyr = mLayerTarget;
lw = lwInvalidFeatureTarget;
- }
- else // Reference
- {
+ break;
+ case 2: // Invalid reference
+ lyr = mLayerReference;
lw = lwInvalidFeatureReference;
- lyr = mLayerReference;
- }
+ break;
+ default:
+ return;
}
- bool ok;
- int fid = lw->currentItem()->text().toInt( &ok );
- zoomFeatureTarget(lyr, fid);
+ if( lw->count() > 0 )
+ {
+ bool ok;
+ int fid = lw->currentItem()->data(Qt::UserRole).toInt(&ok);
+ zoomFeatureTarget(lyr, fid);
+ }
}
} // QgsSpatialQueryDialog::on_ckbZoomItem_clicked( bool checked )
@@ -969,14 +972,21 @@
{
return;
}
- QgsVectorLayer * vectorLayer = qobject_cast<QgsVectorLayer *>( mapLayer );
- if ( !vectorLayer )
+ QgsVectorLayer * lyr = qobject_cast<QgsVectorLayer *>( mapLayer );
+ if ( !lyr )
{
return;
}
+<<<<<<< HEAD
addCbLayer( true, vectorLayer );
addCbLayer( false, vectorLayer );
mMapIdVectorLayers.insert( vectorLayer->getLayerID(), vectorLayer );
+=======
+ addCbLayer( true, lyr );
+ addCbLayer( false, lyr );
+ mMapIdVectorLayers.insert( lyr->getLayerID(), lyr );
+
+>>>>>>> Updates from Luiz for spatial query plugin
// Verify is can enable buttonBox
if ( !bbMain->button( QDialogButtonBox::Ok )->isEnabled() && cbTargetLayer->count() > 1 )
{
@@ -1000,9 +1010,9 @@
return;
}
mMapIdVectorLayers.remove( idLayer );
- QgsVectorLayer *vectorLayer = i.value();
- removeLayer( true, vectorLayer ); // set new target if need
- removeLayer( false, vectorLayer ); // set new reference if need
+ QgsVectorLayer *lyr = i.value();
+ removeLayer( true, lyr ); // set new target if need
+ removeLayer( false, lyr ); // set new reference if need
if ( mLayerTarget && getCbIndexLayer( cbReferenceLayer, mLayerTarget ) > -1 )
{
removeLayer( false, mLayerTarget );
Property changes on: trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.cpp
___________________________________________________________________
Deleted: svn:executable
- *
Modified: trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.h
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.h 2011-03-01 07:59:56 UTC (rev 15300)
+++ trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.h 2011-03-01 08:00:12 UTC (rev 15301)
@@ -61,7 +61,6 @@
void on_cbReferenceLayer_currentIndexChanged( int index );
void on_lwResultFeatureTarget_currentItemChanged( QListWidgetItem * item );
void on_twResultInvalid_currentChanged ( int index );
- void on_twInvalid_currentChanged ( int index );
void on_lwInvalidFeatureTarget_currentItemChanged( QListWidgetItem * item );
void on_lwInvalidFeatureReference_currentItemChanged( QListWidgetItem * item );
void on_ckbLogProcessing_clicked( bool checked );
@@ -84,8 +83,6 @@
private:
//! Initialize the Gui
void initGui();
- //! Set Color RGB for select - mRGBRubberSelect
- void setColorRubberSelect();
//! Set Layer (Target or Reference)
void setLayer( bool isTarget, int index );
//! Evaluate status of selected features from layer (Target or Reference)
@@ -99,9 +96,9 @@
//! Show result of query
void showResultQuery( QDateTime *datetimeStart, QDateTime *datetimeEnd );
//! Set label with number's selected features of layer
- void setLabelButtonSelected( QLabel *lb, QgsVectorLayer* layer, QPushButton *pb);
+ void setLabelButtonSelected( QLabel *lb, QgsVectorLayer* lyr, QPushButton *pb);
//! Get string subset with selected FID
- QString getSubsetSelected( QgsVectorLayer* layer );
+ QString getSubsetSelected( QgsVectorLayer* lyr );
//! Get Description Layer to show result
QString getDescriptionLayerShow( bool isTarget );
//! Get Description Layer to show result
@@ -117,11 +114,11 @@
//! Get Icon for vector layer
QIcon getIconTypeGeometry( QGis::GeometryType geomType );
//! Add layer in combobox (text, data and tooltips)
- void addCbLayer( bool isTarget, QgsVectorLayer* vectorLayer );
+ void addCbLayer( bool isTarget, QgsVectorLayer* lyr );
//! Find Layer in combobox
- int getCbIndexLayer( bool isTarget, QgsVectorLayer* vectorLayer );
+ int getCbIndexLayer( bool isTarget, QgsVectorLayer* lyr );
//! Remove layer in combobox and setting GUI
- void removeLayer( bool isTarget, QgsVectorLayer* lyrRemove );
+ void removeLayer( bool isTarget, QgsVectorLayer* lyr );
//! Populates cbTargetLayer with all layers
void populateCbTargetLayer();
//! Populates cbReferenceLayer with all layers except the current target layer
@@ -133,11 +130,11 @@
//! Clear the features of QListWidget (use by result, invalid target and reference)
void clearLwFeature( QListWidget *listWidget );
//! Make action when change item in ListWidget
- void changeLwFeature( QListWidget *listWidget, QgsVectorLayer* vectorLayer, int fid );
+ void changeLwFeature( QListWidget *listWidget, QgsVectorLayer* lyr, int fid );
//! Zoom mapcanvas to current feature in listbox target
- void zoomFeatureTarget(QgsVectorLayer* vectorLayer, int fid);
+ void zoomFeatureTarget(QgsVectorLayer* lyr, int fid);
//! Show rubber from feature
- void showRubberFeature( QgsVectorLayer* vectorLayer, int id );
+ void showRubberFeature( QgsVectorLayer* lyr, int id );
//! Pointer to Interface QGIS
QgisInterface* mIface;
@@ -155,8 +152,6 @@
QMap<QString, QgsVectorLayer *> mMapIdVectorLayers;
//! Rubber band for features result
QgsRubberSelectId* mRubberSelectId;
- //! RGB select feature result
- int mRGBRubberSelect[3];
// Message
QString mMsgLayersLessTwo;
Property changes on: trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.h
___________________________________________________________________
Deleted: svn:executable
- *
Modified: trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialogbase.ui
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialogbase.ui 2011-03-01 07:59:56 UTC (rev 15300)
+++ trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialogbase.ui 2011-03-01 08:00:12 UTC (rev 15301)
@@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>520</width>
+ <width>586</width>
<height>495</height>
</rect>
</property>
@@ -34,7 +34,7 @@
<property name="locale">
<locale language="English" country="UnitedKingdom"/>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_8">
+ <layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="lytOperatorResultInvalid">
<property name="sizeConstraint">
@@ -196,7 +196,7 @@
</size>
</property>
<property name="toolTip">
- <string>Total of features from query</string>
+ <string>Target layer</string>
</property>
<property name="text">
<string>Layer</string>
@@ -219,7 +219,7 @@
<item>
<widget class="QPushButton" name="pbSelectResultTarget">
<property name="toolTip">
- <string>New selection with features of result</string>
+ <string>New selection with list of FIDs</string>
</property>
<property name="text">
<string/>
@@ -233,7 +233,7 @@
<item>
<widget class="QPushButton" name="pbSelectResultTargetAdd">
<property name="toolTip">
- <string>Add selection with features of result</string>
+ <string>Add selection with list of FIDs</string>
</property>
<property name="text">
<string/>
@@ -247,7 +247,7 @@
<item>
<widget class="QPushButton" name="pbSelectResultTargetRemove">
<property name="toolTip">
- <string>Remove selection with features of result</string>
+ <string>Remove selection with list of FIDs</string>
</property>
<property name="text">
<string/>
@@ -262,8 +262,11 @@
</item>
<item>
<widget class="QLabel" name="lbFIDresultTarget">
+ <property name="toolTip">
+ <string>List of FIDs from result of query</string>
+ </property>
<property name="text">
- <string>Feature IDs:</string>
+ <string>Feature IDs</string>
</property>
</widget>
</item>
@@ -276,7 +279,7 @@
</size>
</property>
<property name="toolTip">
- <string>Select item to identify geometry of feature</string>
+ <string>Select one FID to identify geometry of feature</string>
</property>
</widget>
</item>
@@ -284,11 +287,14 @@
<layout class="QHBoxLayout" name="lytSelected">
<item>
<widget class="QLabel" name="lbSelected">
+ <property name="toolTip">
+ <string>Number of selected features in map</string>
+ </property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
- <string notr="true">selected items</string>
+ <string notr="true">selected features</string>
</property>
</widget>
</item>
@@ -308,7 +314,7 @@
<item>
<widget class="QPushButton" name="pbSelectedSubsetLayer">
<property name="toolTip">
- <string>Set subset in layer with selected items</string>
+ <string>Set subset in layer with list of FIDs</string>
</property>
<property name="text">
<string/>
@@ -323,138 +329,130 @@
</item>
</layout>
</widget>
- <widget class="QWidget" name="tabInvalid">
+ <widget class="QWidget" name="tab">
<attribute name="title">
- <string>Invalid features</string>
+ <string>Invalid target</string>
</attribute>
- <layout class="QVBoxLayout" name="verticalLayout_6">
+ <layout class="QVBoxLayout" name="verticalLayout">
<item>
- <widget class="QTabWidget" name="twInvalid">
- <property name="currentIndex">
- <number>0</number>
+ <layout class="QHBoxLayout" name="lytTargetInvalid">
+ <item>
+ <widget class="QLabel" name="lbInvalidTarget">
+ <property name="toolTip">
+ <string>Target layer</string>
+ </property>
+ <property name="text">
+ <string>Layer</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pbSelectInvalidTarget">
+ <property name="toolTip">
+ <string>New selection with list of FIDs</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="qgsspatialquerydialogbase.qrc">
+ <normaloff>:/icons/select.png</normaloff>:/icons/select.png</iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="lbFIDinvalidTarget">
+ <property name="text">
+ <string>Feature IDs</string>
</property>
- <widget class="QWidget" name="tabTarget">
- <attribute name="title">
- <string>Target</string>
- </attribute>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="lytTargetInvalid">
- <item>
- <widget class="QLabel" name="lbInvalidTarget">
- <property name="text">
- <string>Layer</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="pbSelectInvalidTarget">
- <property name="toolTip">
- <string>select all features invalid target</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="qgsspatialquerydialogbase.qrc">
- <normaloff>:/icons/select.png</normaloff>:/icons/select.png</iconset>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QLabel" name="lbFIDinvalidTarget">
- <property name="text">
- <string>Feature IDs:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QListWidget" name="lwInvalidFeatureTarget">
- <property name="toolTip">
- <string>Select item to identify geometry of feature</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="tabReference">
- <attribute name="title">
- <string>Reference</string>
- </attribute>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <layout class="QHBoxLayout" name="lytReferenceInvalid">
- <item>
- <widget class="QLabel" name="lbInvalidReference">
- <property name="text">
- <string>Layer</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="pbSelectInvalidReference">
- <property name="toolTip">
- <string>select all features invalid reference</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="qgsspatialquerydialogbase.qrc">
- <normaloff>:/icons/select.png</normaloff>:/icons/select.png</iconset>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QLabel" name="lbFIDinvalidReference">
- <property name="text">
- <string>Feature IDs:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QListWidget" name="lwInvalidFeatureReference">
- <property name="toolTip">
- <string>Select item to identify geometry of feature</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
</widget>
</item>
+ <item>
+ <widget class="QListWidget" name="lwInvalidFeatureTarget">
+ <property name="toolTip">
+ <string>Select item to identify geometry of feature</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Invalid reference</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QHBoxLayout" name="lytReferenceInvalid">
+ <item>
+ <widget class="QLabel" name="lbInvalidReference">
+ <property name="toolTip">
+ <string>Reference layer</string>
+ </property>
+ <property name="text">
+ <string>Layer</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pbSelectInvalidReference">
+ <property name="toolTip">
+ <string>New selection with list of FIDs</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="qgsspatialquerydialogbase.qrc">
+ <normaloff>:/icons/select.png</normaloff>:/icons/select.png</iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="lbFIDinvalidReference">
+ <property name="text">
+ <string>Feature IDs</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListWidget" name="lwInvalidFeatureReference">
+ <property name="toolTip">
+ <string>Select item to identify geometry of feature</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
</layout>
@@ -464,7 +462,7 @@
<item>
<widget class="QCheckBox" name="ckbZoomItem">
<property name="text">
- <string>Zoom to selected item</string>
+ <string>Zoom to identify FID</string>
</property>
</widget>
</item>
Property changes on: trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialogbase.ui
___________________________________________________________________
Deleted: svn:executable
- *
More information about the QGIS-commit
mailing list