1 change: 1 addition & 0 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<file>themes/default/mActionEditCut.png</file>
<file>themes/default/mActionEditPaste.png</file>
<file>themes/default/mActionExpandTree.png</file>
<file>themes/default/mActionExpandNewTree.png</file>
<file>themes/default/mActionExportMapServer.png</file>
<file>themes/default/mActionFileExit.png</file>
<file>themes/default/mActionFileNew.png</file>
Expand Down
Binary file added images/themes/default/mActionExpandNewTree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 19 additions & 1 deletion src/app/qgsidentifyresults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ QgsIdentifyResults::QgsIdentifyResults( QgsMapCanvas *canvas, QWidget *parent, Q
, mDock( NULL )
{
setupUi( this );

mExpandToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionExpandTree.png" ) );
mCollapseToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionCollapseTree.png" ) );
mExpandNewToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionExpandNewTree.png" ) );

QSettings mySettings;
restoreGeometry( mySettings.value( "/Windows/Identify/geometry" ).toByteArray() );
bool myDockFlag = mySettings.value( "/qgis/dockIdentifyResults", false ).toBool();
Expand All @@ -98,6 +103,7 @@ QgsIdentifyResults::QgsIdentifyResults( QgsMapCanvas *canvas, QWidget *parent, Q
mDock->setWidget( this );
QgisApp::instance()->addDockWidget( Qt::LeftDockWidgetArea, mDock );
}
mExpandNewToolButton->setChecked( mySettings.value( "/Map/identifyExpand", false ).toBool() );
lstResults->setColumnCount( 2 );
setColumnText( 0, tr( "Feature" ) );
setColumnText( 1, tr( "Value" ) );
Expand Down Expand Up @@ -371,6 +377,12 @@ void QgsIdentifyResults::show()
layItem->setExpanded( true );
}

// expand all if enabled
if ( mExpandNewToolButton->isChecked() )
{
lstResults->expandAll();
}

QDialog::show();
raise();
}
Expand Down Expand Up @@ -948,7 +960,7 @@ void QgsIdentifyResults::layerProperties()
void QgsIdentifyResults::layerProperties( QTreeWidgetItem *item )
{
QgsVectorLayer *vlayer = vectorLayer( item );
if( !vlayer )
if ( !vlayer )
return;

QgisApp::instance()->showLayerProperties( vlayer );
Expand Down Expand Up @@ -1007,3 +1019,9 @@ void QgsIdentifyResults::openUrl( const QUrl &url )
QMessageBox::warning( this, tr( "Could not open url" ), tr( "Could not open URL '%1'" ).arg( url.toString() ) );
}
}

void QgsIdentifyResults:: on_mExpandNewToolButton_toggled( bool checked )
{
QSettings settings;
settings.setValue( "/Map/identifyExpand", checked );
}
5 changes: 5 additions & 0 deletions src/app/qgsidentifyresults.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase

void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }

void on_mExpandNewToolButton_toggled( bool checked );

void on_mExpandToolButton_clicked( bool checked ) { expandAll(); }
void on_mCollapseToolButton_clicked( bool checked ) { collapseAll(); }

void openUrl( const QUrl &url );

private:
Expand Down
87 changes: 29 additions & 58 deletions src/app/qgsmaptoolidentify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,74 +335,45 @@ bool QgsMapToolIdentify::identifyRasterLayer( QgsRasterLayer *layer, int x, int
QgsDebugMsg( QString( "coordinate not reprojectable: %1" ).arg( cse.what() ) );
return false;
}
QgsDebugMsg( QString( "idPoint = %1 %2" ).arg( idPoint.x() ).arg( idPoint.y() ) );

if ( !layer->extent().contains( idPoint ) ) return false;

#if 0
if ( layer->providerType() == "wms" )
{
type = tr( "WMS layer" );

//if WMS layer does not cover the view origin,
//we need to map the view pixel coordinates
//to WMS layer pixel coordinates
QgsRectangle viewExtent = toLayerCoordinates( layer, mCanvas->extent() );
QgsRectangle layerExtent = layer->extent();
double mapUnitsPerPixel = mCanvas->mapUnitsPerPixel();
if ( mapUnitsPerPixel > 0 && viewExtent.intersects( layerExtent ) )
{
double xMinView = viewExtent.xMinimum();
double yMaxView = viewExtent.yMaximum();
double xMinLayer = layerExtent.xMinimum();
double yMaxLayer = layerExtent.yMaximum();

idPoint.set(
xMinView < xMinLayer ? floor( x - ( xMinLayer - xMinView ) / mapUnitsPerPixel ) : x,
yMaxView > yMaxLayer ? floor( y - ( yMaxView - yMaxLayer ) / mapUnitsPerPixel ) : y
);

attributes.insert( tr( "Feature info" ), layer->identifyAsHtml( idPoint ) );
}
else
{
res = false;
}
}
#endif
QgsRectangle viewExtent = mCanvas->extent();

// TODO: extent, width, heigh are approximated only if layer is reprojected!!!!
// How to do it better? We dont know source resolution used to reproject the layer.
QMap< QString, QString > attributes, derivedAttributes;

QgsRectangle viewExtent = mCanvas->extent();
// We can only use context (extent, width, heigh) if layer is not reprojected,
// otherwise we don't know source resolution (size).
if ( mCanvas->hasCrsTransformEnabled() && dprovider->crs() != mCanvas->mapRenderer()->destinationCrs() )
{
viewExtent = toLayerCoordinates( layer, viewExtent );
attributes = dprovider->identify( idPoint );
}
else
{
// It would be nice to use the same extent and size which was used for drawing,
// so that WCS can use cache from last draw, unfortunately QgsRasterLayer::draw()
// is doing some tricks with extent and size to allign raster to output which
// would be difficult to replicate here.
// Note: cutting the extent may result in slightly different x and y resolutions
// and thus shifted point calculated back in QGIS WMS (using average resolution)
//viewExtent = dprovider->extent().intersect( &viewExtent );

// It would be nice to use the same extent and size which was used for drawing,
// so that WCS can use cache from last draw, unfortunately QgsRasterLayer::draw()
// is doing some tricks with extent and size to allign raster to output which
// would be difficult to replicate here.
// Note: cutting the extent may result in slightly different x and y resolutions
// and thus shifted point calculated back in QGIS WMS (using average resolution)
//viewExtent = dprovider->extent().intersect( &viewExtent );

double mapUnitsPerPixel = mCanvas->mapUnitsPerPixel();
// Width and height are calculated from not projected extent and we hope that
// are similar to source width and height used to reproject layer for drawing.
// TODO: may be very dangerous, because it may result in different resolutions
// in source CRS, and WMS server (QGIS server) calcs wrong coor using average resolution.
int width = qRound( viewExtent.width() / mapUnitsPerPixel );
int height = qRound( viewExtent.height() / mapUnitsPerPixel );

QgsDebugMsg( QString( "viewExtent.width = %1 viewExtent.height = %2" ).arg( viewExtent.width() ).arg( viewExtent.height() ) );
QgsDebugMsg( QString( "width = %1 height = %2" ).arg( width ).arg( height ) );
QgsDebugMsg( QString( "xRes = %1 yRes = %2 mapUnitsPerPixel = %3" ).arg( viewExtent.width() / width ).arg( viewExtent.height() / height ).arg( mapUnitsPerPixel ) );

QMap< QString, QString > attributes, derivedAttributes;

QgsDebugMsg( QString( "idPoint: %1 %2" ).arg( idPoint.x() ).arg( idPoint.y() ) );
attributes = dprovider->identify( idPoint, viewExtent, width, height );
double mapUnitsPerPixel = mCanvas->mapUnitsPerPixel();
// Width and height are calculated from not projected extent and we hope that
// are similar to source width and height used to reproject layer for drawing.
// TODO: may be very dangerous, because it may result in different resolutions
// in source CRS, and WMS server (QGIS server) calcs wrong coor using average resolution.
int width = qRound( viewExtent.width() / mapUnitsPerPixel );
int height = qRound( viewExtent.height() / mapUnitsPerPixel );

QgsDebugMsg( QString( "viewExtent.width = %1 viewExtent.height = %2" ).arg( viewExtent.width() ).arg( viewExtent.height() ) );
QgsDebugMsg( QString( "width = %1 height = %2" ).arg( width ).arg( height ) );
QgsDebugMsg( QString( "xRes = %1 yRes = %2 mapUnitsPerPixel = %3" ).arg( viewExtent.width() / width ).arg( viewExtent.height() / height ).arg( mapUnitsPerPixel ) );

attributes = dprovider->identify( idPoint, viewExtent, width, height );
}

QString type;
type = tr( "Raster" );
Expand Down
84 changes: 76 additions & 8 deletions src/ui/qgsidentifyresultsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,82 @@
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="mExpandToolButton">
<property name="toolTip">
<string>Expand tree.</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mActionExpandTree.png</normaloff>../../images/themes/default/mActionExpandTree.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mCollapseToolButton">
<property name="toolTip">
<string>Collapse tree.</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mActionCollapseTree.png</normaloff>../../images/themes/default/mActionCollapseTree.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mExpandNewToolButton">
<property name="toolTip">
<string>New results will be expanded by default.</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mActionExpandNewTree.png</normaloff>../../images/themes/default/mActionExpandNewTree.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<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="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
Expand Down