@@ -522,19 +522,21 @@ void QgsRasterHistogramWidget::on_mSaveAsImageButton_clicked()
522522 }
523523}
524524
525- void QgsRasterHistogramWidget::histoSaveAsImage ( const QString& theFilename )
525+ bool QgsRasterHistogramWidget::histoSaveAsImage ( const QString& theFilename,
526+ int width, int height, int quality )
526527{
527528 // make sure dir. exists
528- QDir myDir ( QFileInfo ( theFilename ).dir () );
529+ QFileInfo myInfo ( theFilename );
530+ QDir myDir ( myInfo.dir () );
529531 if ( ! myDir.exists () )
530532 {
531533 QgsDebugMsg ( QString ( " Error, directory %1 non-existent (theFilename = %2)" ).arg ( myDir.absolutePath () ).arg ( theFilename ) );
532- return ;
534+ return false ;
533535 }
534536
535537 // prepare the pixmap
536- QPixmap myPixmap ( 600 , 600 );
537- QRect myQRect ( 5 , 5 , 590 , 590 ); // leave a 5px border on all sides
538+ QPixmap myPixmap ( width, height );
539+ QRect myQRect ( 5 , 5 , width - 10 , height - 10 ); // leave a 5px border on all sides
538540 myPixmap.fill ( Qt::white ); // Qt::transparent ?
539541
540542#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
@@ -566,10 +568,15 @@ void QgsRasterHistogramWidget::histoSaveAsImage( const QString& theFilename )
566568#endif
567569
568570 // save pixmap to file
569- myPixmap.save ( theFilename );
571+ myPixmap.save ( theFilename, 0 , quality );
570572
571- #if defined(QWT_VERSION) && QWT_VERSION<0x060000
572- #endif
573+ // should do more error checking
574+ return true ;
575+ }
576+
577+ void QgsRasterHistogramWidget::setSelectedBand ( int theBandNo )
578+ {
579+ cboHistoBand->setCurrentIndex ( theBandNo - 1 );
573580}
574581
575582void QgsRasterHistogramWidget::on_cboHistoBand_currentIndexChanged ( int index )
@@ -610,16 +617,21 @@ void QgsRasterHistogramWidget::histoActionTriggered( QAction* action )
610617{
611618 if ( ! action )
612619 return ;
620+ histoAction ( action->data ().toString (), action->isChecked () );
621+ }
613622
614- // this approach is a bit of a hack, but this way we don't have to define slots for each action
615- QString actionName = action->data ().toString ();
623+ void QgsRasterHistogramWidget::histoAction ( const QString actionName, bool actionFlag )
624+ {
625+ if ( actionName == " " )
626+ return ;
616627
628+ // this approach is a bit of a hack, but this way we don't have to define slots for each action
617629 QgsDebugMsg ( QString ( " band = %1 action = %2" ).arg ( cboHistoBand->currentIndex () + 1 ).arg ( actionName ) );
618630
619631 // checkeable actions
620632 if ( actionName == " Show markers" )
621633 {
622- mHistoShowMarkers = action-> isChecked () ;
634+ mHistoShowMarkers = actionFlag ;
623635 updateHistoMarkers ();
624636 return ;
625637 }
@@ -643,7 +655,7 @@ void QgsRasterHistogramWidget::histoActionTriggered( QAction* action )
643655 }
644656 else if ( actionName == " Load apply all" )
645657 {
646- mHistoLoadApplyAll = action-> isChecked () ;
658+ mHistoLoadApplyAll = actionFlag ;
647659 return ;
648660 }
649661 // Load actions
0 commit comments