Skip to content

Commit 539b7cb

Browse files
committedAug 1, 2012
implement #6128
1 parent 0968589 commit 539b7cb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
 

‎src/app/qgsidentifyresults.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#include <QMenuBar>
4242
#include <QPushButton>
4343
#include <QWebView>
44+
#include <QDesktopServices>
45+
#include <QMessageBox>
4446

4547
#include "qgslogger.h"
4648

@@ -277,6 +279,8 @@ void QgsIdentifyResults::addFeature( QgsRasterLayer *layer,
277279

278280
QWebView *wv = new QWebView( attrItem->treeWidget() );
279281
wv->setHtml( attributes.begin().value() );
282+
wv->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
283+
connect( wv, SIGNAL( linkClicked( const QUrl & ) ), this, SLOT( openUrl( const QUrl & ) ) );
280284
attrItem->treeWidget()->setItemWidget( attrItem, 1, wv );
281285
}
282286
else
@@ -980,3 +984,11 @@ void QgsIdentifyResults::copyFeatureAttributes()
980984
QgsDebugMsg( QString( "set clipboard: %1" ).arg( text ) );
981985
clipboard->setText( text );
982986
}
987+
988+
void QgsIdentifyResults::openUrl( const QUrl &url )
989+
{
990+
if ( !QDesktopServices::openUrl( url ) )
991+
{
992+
QMessageBox::warning( this, tr( "Could not open url" ), tr( "Could not open URL '%1'" ).arg( url.toString() ) );
993+
}
994+
}

‎src/app/qgsidentifyresults.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
112112

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

115+
void openUrl( const QUrl &url );
116+
115117
private:
116118
QMenu *mActionPopup;
117119
QMap<QTreeWidgetItem *, QgsHighlight * > mHighlights;

0 commit comments

Comments
 (0)
Please sign in to comment.