@@ -94,6 +94,7 @@ QgsIdentifyResults::QgsIdentifyResults( QgsMapCanvas *canvas, QWidget *parent, Q
94
94
mExpandToolButton ->setIcon ( QgsApplication::getThemeIcon ( " /mActionExpandTree.png" ) );
95
95
mCollapseToolButton ->setIcon ( QgsApplication::getThemeIcon ( " /mActionCollapseTree.png" ) );
96
96
mExpandNewToolButton ->setIcon ( QgsApplication::getThemeIcon ( " /mActionExpandNewTree.png" ) );
97
+ mPrintToolButton ->setIcon ( QgsApplication::getThemeIcon ( " /mActionFilePrint.png" ) );
97
98
98
99
QSettings mySettings;
99
100
restoreGeometry ( mySettings.value ( " /Windows/Identify/geometry" ).toByteArray () );
@@ -120,6 +121,9 @@ QgsIdentifyResults::QgsIdentifyResults( QgsMapCanvas *canvas, QWidget *parent, Q
120
121
121
122
connect ( lstResults, SIGNAL ( itemClicked ( QTreeWidgetItem*, int ) ),
122
123
this , SLOT ( itemClicked ( QTreeWidgetItem*, int ) ) );
124
+
125
+ connect ( mPrintToolButton , SIGNAL ( clicked () ),
126
+ this , SLOT ( printCurrentItem () ) );
123
127
}
124
128
125
129
QgsIdentifyResults::~QgsIdentifyResults ()
@@ -294,6 +298,7 @@ void QgsIdentifyResults::addFeature( QgsRasterLayer *layer,
294
298
wv->insertAction ( 0 , action );
295
299
296
300
wv->setContextMenuPolicy ( Qt::ActionsContextMenu );
301
+ mPrintToolButton ->setVisible ( true );
297
302
298
303
connect ( wv, SIGNAL ( linkClicked ( const QUrl & ) ), this , SLOT ( openUrl ( const QUrl & ) ) );
299
304
attrItem->treeWidget ()->setItemWidget ( attrItem, 1 , wv );
@@ -546,6 +551,9 @@ void QgsIdentifyResults::clear()
546
551
547
552
lstResults->clear ();
548
553
clearHighlights ();
554
+
555
+ mPrintToolButton ->setDisabled ( true );
556
+ mPrintToolButton ->setHidden ( true );
549
557
}
550
558
551
559
void QgsIdentifyResults::activate ()
@@ -699,6 +707,9 @@ void QgsIdentifyResults::handleCurrentItemChanged( QTreeWidgetItem *current, QTr
699
707
return ;
700
708
}
701
709
710
+ QWebView *wv = qobject_cast<QWebView*>( current->treeWidget ()->itemWidget ( current, 1 ) );
711
+ mPrintToolButton ->setEnabled ( wv != 0 );
712
+
702
713
QTreeWidgetItem *layItem = layerItem ( current );
703
714
704
715
if ( current == layItem )
@@ -1045,6 +1056,22 @@ void QgsIdentifyResults::print()
1045
1056
wv->print ( &printer );
1046
1057
}
1047
1058
1059
+ void QgsIdentifyResults::printCurrentItem ()
1060
+ {
1061
+ QTreeWidgetItem *item = lstResults->currentItem ();
1062
+ if ( !item )
1063
+ return ;
1064
+
1065
+ QWebView *wv = qobject_cast<QWebView*>( item->treeWidget ()->itemWidget ( item, 1 ) );
1066
+ if ( !wv )
1067
+ return ;
1068
+
1069
+ QPrinter printer;
1070
+ QPrintDialog *dialog = new QPrintDialog ( &printer );
1071
+ if ( dialog->exec () == QDialog::Accepted )
1072
+ wv->print ( &printer );
1073
+ }
1074
+
1048
1075
void QgsIdentifyResults:: on_mExpandNewToolButton_toggled( bool checked )
1049
1076
{
1050
1077
QSettings settings;
0 commit comments