Skip to content
Permalink
Browse files

allow printing of html results in identify window (implements #6575)

  • Loading branch information
jef-n committed Nov 3, 2012
1 parent 744314d commit ab2442bbef5c5e97748bda21ef0f6877da753dd1
Showing with 26 additions and 0 deletions.
  1. +25 −0 src/app/qgsidentifyresults.cpp
  2. +1 −0 src/app/qgsidentifyresults.h
@@ -41,6 +41,8 @@
#include <QMenuBar>
#include <QPushButton>
#include <QWebView>
#include <QPrinter>
#include <QPrintDialog>
#include <QDesktopServices>
#include <QMessageBox>

@@ -286,6 +288,13 @@ void QgsIdentifyResults::addFeature( QgsRasterLayer *layer,
QWebView *wv = new QWebView( attrItem->treeWidget() );
wv->setHtml( attributes.begin().value() );
wv->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );

QAction *action = new QAction( tr( "Print" ), wv );
connect( action, SIGNAL( triggered() ), this, SLOT( print() ) );
wv->insertAction( 0, action );

wv->setContextMenuPolicy( Qt::ActionsContextMenu );

connect( wv, SIGNAL( linkClicked( const QUrl & ) ), this, SLOT( openUrl( const QUrl & ) ) );
attrItem->treeWidget()->setItemWidget( attrItem, 1, wv );
}
@@ -1020,6 +1029,22 @@ void QgsIdentifyResults::openUrl( const QUrl &url )
}
}

void QgsIdentifyResults::print()
{
QAction *action = qobject_cast<QAction*>( sender() );
if ( !action )
return;

QWebView *wv = qobject_cast<QWebView*>( action->parent() );
if ( !wv )
return;

QPrinter printer;
QPrintDialog *dialog = new QPrintDialog( &printer );
if ( dialog->exec() == QDialog::Accepted )
wv->print( &printer );
}

void QgsIdentifyResults:: on_mExpandNewToolButton_toggled( bool checked )
{
QSettings settings;
@@ -119,6 +119,7 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
void on_mCollapseToolButton_clicked( bool checked ) { Q_UNUSED( checked ); collapseAll(); }

void openUrl( const QUrl &url );
void print();

private:
QMenu *mActionPopup;

0 comments on commit ab2442b

Please sign in to comment.
You can’t perform that action at this time.