Skip to content
Permalink
Browse files

make html print option more visible in identify tool

  • Loading branch information
jef-n committed Nov 6, 2012
1 parent 9336af0 commit 4b789b891f2ad1b868d7dcb8fb65dd844bb5c1f8
Showing with 49 additions and 1 deletion.
  1. +27 −0 src/app/qgsidentifyresults.cpp
  2. +1 −0 src/app/qgsidentifyresults.h
  3. +21 −1 src/ui/qgsidentifyresultsbase.ui
@@ -94,6 +94,7 @@ QgsIdentifyResults::QgsIdentifyResults( QgsMapCanvas *canvas, QWidget *parent, Q
mExpandToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionExpandTree.png" ) );
mCollapseToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionCollapseTree.png" ) );
mExpandNewToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionExpandNewTree.png" ) );
mPrintToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionFilePrint.png" ) );

QSettings mySettings;
restoreGeometry( mySettings.value( "/Windows/Identify/geometry" ).toByteArray() );
@@ -120,6 +121,9 @@ QgsIdentifyResults::QgsIdentifyResults( QgsMapCanvas *canvas, QWidget *parent, Q

connect( lstResults, SIGNAL( itemClicked( QTreeWidgetItem*, int ) ),
this, SLOT( itemClicked( QTreeWidgetItem*, int ) ) );

connect( mPrintToolButton, SIGNAL( clicked() ),
this, SLOT( printCurrentItem() ) );
}

QgsIdentifyResults::~QgsIdentifyResults()
@@ -294,6 +298,7 @@ void QgsIdentifyResults::addFeature( QgsRasterLayer *layer,
wv->insertAction( 0, action );

wv->setContextMenuPolicy( Qt::ActionsContextMenu );
mPrintToolButton->setVisible( true );

connect( wv, SIGNAL( linkClicked( const QUrl & ) ), this, SLOT( openUrl( const QUrl & ) ) );
attrItem->treeWidget()->setItemWidget( attrItem, 1, wv );
@@ -546,6 +551,9 @@ void QgsIdentifyResults::clear()

lstResults->clear();
clearHighlights();

mPrintToolButton->setDisabled( true );
mPrintToolButton->setHidden( true );
}

void QgsIdentifyResults::activate()
@@ -699,6 +707,9 @@ void QgsIdentifyResults::handleCurrentItemChanged( QTreeWidgetItem *current, QTr
return;
}

QWebView *wv = qobject_cast<QWebView*>( current->treeWidget()->itemWidget( current, 1 ) );
mPrintToolButton->setEnabled( wv != 0 );

QTreeWidgetItem *layItem = layerItem( current );

if ( current == layItem )
@@ -1045,6 +1056,22 @@ void QgsIdentifyResults::print()
wv->print( &printer );
}

void QgsIdentifyResults::printCurrentItem()
{
QTreeWidgetItem *item = lstResults->currentItem();
if ( !item )
return;

QWebView *wv = qobject_cast<QWebView*>( item->treeWidget()->itemWidget( item, 1 ) );
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;
@@ -120,6 +120,7 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase

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

private:
QMenu *mActionPopup;
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>279</width>
<width>288</width>
<height>306</height>
</rect>
</property>
@@ -82,6 +82,26 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mPrintToolButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Print selected HTML response.</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mActionFilePrint.png</normaloff>../../images/themes/default/mActionFilePrint.png</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">

0 comments on commit 4b789b8

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