Skip to content

Commit

Permalink
make html print option more visible in identify tool
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Nov 6, 2012
1 parent 9336af0 commit 4b789b8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/app/qgsidentifyresults.cpp
Expand Up @@ -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() );
Expand All @@ -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()
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -546,6 +551,9 @@ void QgsIdentifyResults::clear()

lstResults->clear();
clearHighlights();

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

void QgsIdentifyResults::activate()
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsidentifyresults.h
Expand Up @@ -120,6 +120,7 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase

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

private:
QMenu *mActionPopup;
Expand Down
22 changes: 21 additions & 1 deletion src/ui/qgsidentifyresultsbase.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>279</width>
<width>288</width>
<height>306</height>
</rect>
</property>
Expand Down Expand Up @@ -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">
Expand Down

0 comments on commit 4b789b8

Please sign in to comment.