mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-12 00:02:25 -04:00
cleaner handling of identify results
git-svn-id: http://svn.osgeo.org/qgis/trunk@12033 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
fbddab3e91
commit
486e4c0eba
@ -45,8 +45,6 @@ QgsMapToolIdentify::QgsMapToolIdentify( QgsMapCanvas* canvas )
|
|||||||
// set cursor
|
// set cursor
|
||||||
QPixmap myIdentifyQPixmap = QPixmap(( const char ** ) identify_cursor );
|
QPixmap myIdentifyQPixmap = QPixmap(( const char ** ) identify_cursor );
|
||||||
mCursor = QCursor( myIdentifyQPixmap, 1, 1 );
|
mCursor = QCursor( myIdentifyQPixmap, 1, 1 );
|
||||||
|
|
||||||
mResults = new QgsIdentifyResults( canvas, mCanvas->window() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsMapToolIdentify::~QgsMapToolIdentify()
|
QgsMapToolIdentify::~QgsMapToolIdentify()
|
||||||
@ -57,6 +55,14 @@ QgsMapToolIdentify::~QgsMapToolIdentify()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QgsIdentifyResults *QgsMapToolIdentify::results()
|
||||||
|
{
|
||||||
|
if ( !mResults )
|
||||||
|
mResults = new QgsIdentifyResults( mCanvas, mCanvas->window() );
|
||||||
|
|
||||||
|
return mResults;
|
||||||
|
}
|
||||||
|
|
||||||
void QgsMapToolIdentify::canvasMoveEvent( QMouseEvent * e )
|
void QgsMapToolIdentify::canvasMoveEvent( QMouseEvent * e )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -72,11 +78,7 @@ void QgsMapToolIdentify::canvasReleaseEvent( QMouseEvent * e )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !mResults )
|
results()->clear();
|
||||||
{
|
|
||||||
mResults = new QgsIdentifyResults( mCanvas, mCanvas->window() );
|
|
||||||
}
|
|
||||||
mResults->clear();
|
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
int identifyMode = settings.value( "/Map/identifyMode", 0 ).toInt();
|
int identifyMode = settings.value( "/Map/identifyMode", 0 ).toInt();
|
||||||
@ -139,8 +141,8 @@ void QgsMapToolIdentify::canvasReleaseEvent( QMouseEvent * e )
|
|||||||
|
|
||||||
if ( res )
|
if ( res )
|
||||||
{
|
{
|
||||||
mResults->show();
|
results()->show();
|
||||||
mResults->raise();
|
results()->raise();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -148,11 +150,11 @@ void QgsMapToolIdentify::canvasReleaseEvent( QMouseEvent * e )
|
|||||||
bool myDockFlag = mySettings.value( "/qgis/dockIdentifyResults", false ).toBool();
|
bool myDockFlag = mySettings.value( "/qgis/dockIdentifyResults", false ).toBool();
|
||||||
if ( !myDockFlag )
|
if ( !myDockFlag )
|
||||||
{
|
{
|
||||||
mResults->hide();
|
results()->hide();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mResults->clear();
|
results()->clear();
|
||||||
}
|
}
|
||||||
QMessageBox::information( 0, tr( "Identify results" ), tr( "No features at this position found." ) );
|
QMessageBox::information( 0, tr( "Identify results" ), tr( "No features at this position found." ) );
|
||||||
}
|
}
|
||||||
@ -160,17 +162,13 @@ void QgsMapToolIdentify::canvasReleaseEvent( QMouseEvent * e )
|
|||||||
|
|
||||||
void QgsMapToolIdentify::activate()
|
void QgsMapToolIdentify::activate()
|
||||||
{
|
{
|
||||||
if ( !mResults )
|
results()->activate();
|
||||||
{
|
|
||||||
mResults = new QgsIdentifyResults( mCanvas, mCanvas->window() );
|
|
||||||
}
|
|
||||||
mResults->activate();
|
|
||||||
QgsMapTool::activate();
|
QgsMapTool::activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsMapToolIdentify::deactivate()
|
void QgsMapToolIdentify::deactivate()
|
||||||
{
|
{
|
||||||
mResults->deactivate();
|
results()->deactivate();
|
||||||
QgsMapTool::deactivate();
|
QgsMapTool::deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +325,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
|
|||||||
|
|
||||||
derivedAttributes.insert( tr( "feature id" ), fid < 0 ? tr( "new feature" ) : QString::number( fid ) );
|
derivedAttributes.insert( tr( "feature id" ), fid < 0 ? tr( "new feature" ) : QString::number( fid ) );
|
||||||
|
|
||||||
mResults->addFeature( layer, fid, displayField, displayValue, attributes, derivedAttributes );
|
results()->addFeature( layer, fid, displayField, displayValue, attributes, derivedAttributes );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsDebugMsg( "Feature count on identify: " + QString::number( featureCount ) );
|
QgsDebugMsg( "Feature count on identify: " + QString::number( featureCount ) );
|
||||||
@ -388,18 +386,13 @@ bool QgsMapToolIdentify::identifyRasterLayer( QgsRasterLayer *layer, int x, int
|
|||||||
if ( res )
|
if ( res )
|
||||||
{
|
{
|
||||||
derivedAttributes.insert( tr( "(clicked coordinate)" ), idPoint.toString() );
|
derivedAttributes.insert( tr( "(clicked coordinate)" ), idPoint.toString() );
|
||||||
mResults->addFeature( layer, -1, type, "", attributes, derivedAttributes );
|
results()->addFeature( layer, -1, type, "", attributes, derivedAttributes );
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QgsMapToolIdentify::resultsDialogGone()
|
|
||||||
{
|
|
||||||
mResults = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QgsMapToolIdentify::convertMeasurement( QgsDistanceArea &calc, double &measure, QGis::UnitType &u, bool isArea )
|
void QgsMapToolIdentify::convertMeasurement( QgsDistanceArea &calc, double &measure, QGis::UnitType &u, bool isArea )
|
||||||
{
|
{
|
||||||
// Helper for converting between meters and feet
|
// Helper for converting between meters and feet
|
||||||
|
@ -82,9 +82,7 @@ class QgsMapToolIdentify : public QgsMapTool
|
|||||||
const QMap< QString, QString > &attributes,
|
const QMap< QString, QString > &attributes,
|
||||||
const QMap< QString, QString > &derivedAttributes );
|
const QMap< QString, QString > &derivedAttributes );
|
||||||
|
|
||||||
private slots:
|
QgsIdentifyResults *results();
|
||||||
// Let us know when the QgsIdentifyResults dialog box has been closed
|
|
||||||
void resultsDialogGone();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user