QGIS API Documentation  2.17.0-Master (6f7b933)
qgsrasterformatsaveoptionswidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasterformatsaveoptionswidget.cpp
3  -------------------
4  begin : July 2012
5  copyright : (C) 2012 by Etienne Tourigny
6  email : etourigny dot dev at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
19 #include "qgslogger.h"
20 #include "qgsdialog.h"
21 #include "qgsrasterlayer.h"
22 #include "qgsproviderregistry.h"
23 
24 #include <QSettings>
25 #include <QInputDialog>
26 #include <QMessageBox>
27 #include <QTextEdit>
28 #include <QMouseEvent>
29 #include <QMenu>
30 
31 
32 QMap< QString, QStringList > QgsRasterFormatSaveOptionsWidget::mBuiltinProfiles;
33 
34 static const QString PYRAMID_JPEG_YCBCR_COMPRESSION( "JPEG_QUALITY_OVERVIEW=75 COMPRESS_OVERVIEW=JPEG PHOTOMETRIC_OVERVIEW=YCBCR INTERLEAVE_OVERVIEW=PIXEL" );
35 static const QString PYRAMID_JPEG_COMPRESSION( "JPEG_QUALITY_OVERVIEW=75 COMPRESS_OVERVIEW=JPEG INTERLEAVE_OVERVIEW=PIXEL" );
36 
38  QgsRasterFormatSaveOptionsWidget::Type type, const QString& provider )
39  : QWidget( parent )
40  , mFormat( format )
41  , mProvider( provider )
42  , mRasterLayer( nullptr )
43  , mRasterFileName( QString() )
44  , mPyramids( false )
45  , mPyramidsFormat( QgsRaster::PyramidsGTiff )
46 
47 {
48  setupUi( this );
49 
50  setType( type );
51 
52  if ( mBuiltinProfiles.isEmpty() )
53  {
54  // key=profileKey values=format,profileName,options
55  mBuiltinProfiles[ "z_adefault" ] = ( QStringList() << "" << tr( "Default" ) << "" );
56 
57  // these GTiff profiles are based on Tim's benchmarks at
58  // http://linfiniti.com/2011/05/gdal-efficiency-of-various-compression-algorithms/
59  // big: no compression | medium: reasonable size/speed tradeoff | small: smallest size
60  mBuiltinProfiles[ "z_gtiff_1big" ] =
61  ( QStringList() << "GTiff" << tr( "No compression" )
62  << "COMPRESS=NONE BIGTIFF=IF_NEEDED" );
63  mBuiltinProfiles[ "z_gtiff_2medium" ] =
64  ( QStringList() << "GTiff" << tr( "Low compression" )
65  << "COMPRESS=PACKBITS" );
66  mBuiltinProfiles[ "z_gtiff_3small" ] =
67  ( QStringList() << "GTiff" << tr( "High compression" )
68  << "COMPRESS=DEFLATE PREDICTOR=2 ZLEVEL=9" );
69  mBuiltinProfiles[ "z_gtiff_4jpeg" ] =
70  ( QStringList() << "GTiff" << tr( "JPEG compression" )
71  << "COMPRESS=JPEG JPEG_QUALITY=75" );
72 
73  // overview compression schemes for GTiff format, see
74  // http://www.gdal.org/gdaladdo.html and http://www.gdal.org/frmt_gtiff.html
75  // TODO - should we offer GDAL_TIFF_OVR_BLOCKSIZE option here or in QgsRasterPyramidsOptionsWidget ?
76  mBuiltinProfiles[ "z__pyramids_gtiff_1big" ] =
77  ( QStringList() << "_pyramids" << tr( "No compression" )
78  << "COMPRESS_OVERVIEW=NONE BIGTIFF_OVERVIEW=IF_NEEDED" );
79  mBuiltinProfiles[ "z__pyramids_gtiff_2medium" ] =
80  ( QStringList() << "_pyramids" << tr( "Low compression" )
81  << "COMPRESS_OVERVIEW=PACKBITS" );
82  mBuiltinProfiles[ "z__pyramids_gtiff_3small" ] =
83  ( QStringList() << "_pyramids" << tr( "High compression" )
84  << "COMPRESS_OVERVIEW=DEFLATE PREDICTOR_OVERVIEW=2 ZLEVEL=9" ); // how to set zlevel?
85  mBuiltinProfiles[ "z__pyramids_gtiff_4jpeg" ] =
86  ( QStringList() << "_pyramids" << tr( "JPEG compression" )
88  }
89 
90  connect( mProfileComboBox, SIGNAL( currentIndexChanged( const QString & ) ),
91  this, SLOT( updateOptions() ) );
92  connect( mOptionsTable, SIGNAL( cellChanged( int, int ) ), this, SLOT( optionsTableChanged() ) );
93  connect( mOptionsHelpButton, SIGNAL( clicked() ), this, SLOT( helpOptions() ) );
94  connect( mOptionsValidateButton, SIGNAL( clicked() ), this, SLOT( validateOptions() ) );
95 
96  // create eventFilter to map right click to swapOptionsUI()
97  // mOptionsLabel->installEventFilter( this );
98  mOptionsLineEdit->installEventFilter( this );
99  mOptionsStackedWidget->installEventFilter( this );
100 
101  updateControls();
102  updateProfiles();
103 
104  QgsDebugMsg( "done" );
105 }
106 
108 {
109 }
110 
112 {
113  mFormat = format;
114  updateControls();
115  updateProfiles();
116 }
117 
119 {
120  mProvider = provider;
121  updateControls();
122 }
123 
124 // show/hide widgets - we need this function if widget is used in creator
126 {
127  QList< QWidget* > widgets = this->findChildren<QWidget *>();
128  if (( type == Table ) || ( type == LineEdit ) )
129  {
130  // hide all controls, except stacked widget
131  Q_FOREACH ( QWidget* widget, widgets )
132  widget->setVisible( false );
133  mOptionsStackedWidget->setVisible( true );
134  Q_FOREACH ( QWidget* widget, mOptionsStackedWidget->findChildren<QWidget *>() )
135  widget->setVisible( true );
136 
137  // show relevant page
138  if ( type == Table )
139  swapOptionsUI( 0 );
140  else if ( type == LineEdit )
141  swapOptionsUI( 1 );
142  }
143  else
144  {
145  // show all widgets, except profile buttons (unless Full)
146  Q_FOREACH ( QWidget* widget, widgets )
147  widget->setVisible( true );
148  if ( type != Full )
149  mProfileButtons->setVisible( false );
150 
151  // show elevant page
152  if ( type == ProfileLineEdit )
153  swapOptionsUI( 1 );
154  }
155 }
156 
157 QString QgsRasterFormatSaveOptionsWidget::pseudoFormat() const
158 {
159  return mPyramids ? "_pyramids" : mFormat;
160 }
161 
163 {
164  // build profiles list = user + builtin(last)
165  QString format = pseudoFormat();
166  QStringList profileKeys = profiles();
167  QMapIterator<QString, QStringList> it( mBuiltinProfiles );
168  while ( it.hasNext() )
169  {
170  it.next();
171  QString profileKey = it.key();
172  if ( ! profileKeys.contains( profileKey ) && !it.value().isEmpty() )
173  {
174  // insert key if is for all formats or this format (GTiff)
175  if ( it.value()[0] == "" || it.value()[0] == format )
176  {
177  profileKeys.insert( 0, profileKey );
178  }
179  }
180  }
181  qSort( profileKeys );
182 
183  // populate mOptionsMap and mProfileComboBox
184  mOptionsMap.clear();
185  mProfileComboBox->blockSignals( true );
186  mProfileComboBox->clear();
187  Q_FOREACH ( const QString& profileKey, profileKeys )
188  {
189  QString profileName, profileOptions;
190  profileOptions = createOptions( profileKey );
191  if ( mBuiltinProfiles.contains( profileKey ) )
192  {
193  profileName = mBuiltinProfiles[ profileKey ][ 1 ];
194  if ( profileOptions.isEmpty() )
195  profileOptions = mBuiltinProfiles[ profileKey ][ 2 ];
196  }
197  else
198  {
199  profileName = profileKey;
200  }
201  mOptionsMap[ profileKey ] = profileOptions;
202  mProfileComboBox->addItem( profileName, profileKey );
203  }
204 
205  // update UI
206  mProfileComboBox->blockSignals( false );
207  // mProfileComboBox->setCurrentIndex( 0 );
208  QSettings mySettings;
209  mProfileComboBox->setCurrentIndex( mProfileComboBox->findData( mySettings.value(
210  mProvider + "/driverOptions/" + format.toLower() + "/defaultProfile",
211  "z_adefault" ) ) );
212  updateOptions();
213 }
214 
215 void QgsRasterFormatSaveOptionsWidget::updateOptions()
216 {
217  QString myOptions = mOptionsMap.value( currentProfileKey() );
218  QStringList myOptionsList = myOptions.trimmed().split( ' ', QString::SkipEmptyParts );
219 
220  // If the default JPEG compression profile was selected, remove PHOTOMETRIC_OVERVIEW=YCBCR
221  // if the raster is not RGB. Otherwise this is bound to fail afterwards.
222  if ( mRasterLayer && mRasterLayer->bandCount() != 3 &&
223  myOptions == PYRAMID_JPEG_YCBCR_COMPRESSION )
224  {
225  myOptions = PYRAMID_JPEG_COMPRESSION;
226  }
227 
228  if ( mOptionsStackedWidget->currentIndex() == 0 )
229  {
230  mOptionsTable->setRowCount( 0 );
231  for ( int i = 0; i < myOptionsList.count(); i++ )
232  {
233  QStringList key_value = myOptionsList[i].split( '=' );
234  if ( key_value.count() == 2 )
235  {
236  mOptionsTable->insertRow( i );
237  mOptionsTable->setItem( i, 0, new QTableWidgetItem( key_value[0] ) );
238  mOptionsTable->setItem( i, 1, new QTableWidgetItem( key_value[1] ) );
239  }
240  }
241  }
242  else
243  {
244  mOptionsLineEdit->setText( myOptions );
245  mOptionsLineEdit->setCursorPosition( 0 );
246  }
247 
248  emit optionsChanged();
249 }
250 
252 {
253  setCreateOptions();
254 }
255 
256 // typedefs for gdal provider function pointers
257 typedef QString validateCreationOptionsFormat_t( const QStringList& createOptions, QString format );
259 
261 {
262  QString message;
263 
264  if ( mProvider == "gdal" && mFormat != "" && ! mPyramids )
265  {
266  // get helpCreationOptionsFormat() function ptr for provider
267  QLibrary *library = QgsProviderRegistry::instance()->providerLibrary( mProvider );
268  if ( library )
269  {
270  helpCreationOptionsFormat_t * helpCreationOptionsFormat =
271  ( helpCreationOptionsFormat_t * ) cast_to_fptr( library->resolve( "helpCreationOptionsFormat" ) );
272  if ( helpCreationOptionsFormat )
273  {
274  message = helpCreationOptionsFormat( mFormat );
275  }
276  else
277  {
278  message = library->fileName() + " does not have helpCreationOptionsFormat";
279  }
280  }
281  else
282  message = QString( "cannot load provider library %1" ).arg( mProvider );
283 
284 
285  if ( message.isEmpty() )
286  message = tr( "Cannot get create options for driver %1" ).arg( mFormat );
287  }
288  else if ( mProvider == "gdal" && mPyramids )
289  {
290  message = tr( "For details on pyramids options please see the following pages" );
291  message += "\n\nhttp://www.gdal.org/gdaladdo.html\n\nhttp://www.gdal.org/frmt_gtiff.html";
292  }
293  else
294  message = tr( "No help available" );
295 
296  // show simple non-modal dialog - should we make the basic xml prettier?
297  QgsDialog *dlg = new QgsDialog( this );
298  QTextEdit *textEdit = new QTextEdit( dlg );
299  textEdit->setReadOnly( true );
300  // message = tr( "Create Options:\n\n%1" ).arg( message );
301  textEdit->setText( message );
302  dlg->layout()->addWidget( textEdit );
303  dlg->resize( 600, 400 );
304 #ifdef Q_OS_MAC
305  dlg->exec(); //modal
306 #else
307  dlg->show(); //non modal
308 #endif
309 }
310 
312 {
313  QStringList createOptions = options();
314  QString message;
315 
316  QgsDebugMsg( QString( "layer: [%1] file: [%2] format: [%3]" ).arg( mRasterLayer ? mRasterLayer->id() : "none", mRasterFileName, mFormat ) );
317  // if no rasterLayer is defined, but we have a raster fileName, then create a temp. rasterLayer to validate options
318  // ideally we should keep it for future access, but this is trickier
319  QgsRasterLayer* rasterLayer = mRasterLayer;
320  bool tmpLayer = false;
321  if ( !( mRasterLayer && rasterLayer->dataProvider() ) && ! mRasterFileName.isNull() )
322  {
323  // temporarily override /Projections/defaultBehaviour to avoid dialog prompt
324  // this is taken from qgsbrowserdockwidget.cpp
325  // TODO - integrate this into qgis core
326  QSettings settings;
327  QString defaultProjectionOption = settings.value( "/Projections/defaultBehaviour", "prompt" ).toString();
328  if ( settings.value( "/Projections/defaultBehaviour", "prompt" ).toString() == "prompt" )
329  {
330  settings.setValue( "/Projections/defaultBehaviour", "useProject" );
331  }
332  tmpLayer = true;
333  rasterLayer = new QgsRasterLayer( mRasterFileName, QFileInfo( mRasterFileName ).baseName(), QString( "gdal" ) );
334  // restore /Projections/defaultBehaviour
335  if ( defaultProjectionOption == "prompt" )
336  {
337  settings.setValue( "/Projections/defaultBehaviour", defaultProjectionOption );
338  }
339  }
340 
341  if ( mProvider == "gdal" && mPyramids )
342  {
343  if ( rasterLayer && rasterLayer->dataProvider() )
344  {
345  QgsDebugMsg( "calling validate pyramids on layer's data provider" );
346  message = rasterLayer->dataProvider()->validatePyramidsConfigOptions( mPyramidsFormat, createOptions, mFormat );
347  }
348  else
349  {
350  message = tr( "cannot validate pyramid options" );
351  }
352  }
353  else if ( !createOptions.isEmpty() && mProvider == "gdal" && mFormat != "" )
354  {
355  if ( rasterLayer && rasterLayer->dataProvider() )
356  {
357  QgsDebugMsg( "calling validate on layer's data provider" );
358  message = rasterLayer->dataProvider()->validateCreationOptions( createOptions, mFormat );
359  }
360  else
361  {
362  // get validateCreationOptionsFormat() function ptr for provider
363  QLibrary *library = QgsProviderRegistry::instance()->providerLibrary( mProvider );
364  if ( library )
365  {
366  validateCreationOptionsFormat_t * validateCreationOptionsFormat =
367  ( validateCreationOptionsFormat_t * ) cast_to_fptr( library->resolve( "validateCreationOptionsFormat" ) );
368  if ( validateCreationOptionsFormat )
369  {
370  message = validateCreationOptionsFormat( createOptions, mFormat );
371  }
372  else
373  {
374  message = library->fileName() + " does not have validateCreationOptionsFormat";
375  }
376  }
377  else
378  message = QString( "cannot load provider library %1" ).arg( mProvider );
379  }
380  }
381  else if ( ! createOptions.isEmpty() )
382  {
383  QMessageBox::information( this, "", tr( "Cannot validate creation options" ), QMessageBox::Close );
384  if ( tmpLayer )
385  delete rasterLayer;
386  return QString();
387  }
388 
389  if ( gui )
390  {
391  if ( message.isNull() )
392  {
393  if ( reportOK )
394  QMessageBox::information( this, "", tr( "Valid" ), QMessageBox::Close );
395  }
396  else
397  {
398  QMessageBox::warning( this, "", tr( "Invalid %1:\n\n%2\n\nClick on help button to get valid creation options for this format." ).arg( mPyramids ? tr( "pyramid creation option" ) : tr( "creation option" ), message ), QMessageBox::Close );
399  }
400  }
401 
402  if ( tmpLayer )
403  delete rasterLayer;
404 
405  return message;
406 }
407 
408 void QgsRasterFormatSaveOptionsWidget::optionsTableChanged()
409 {
410  QTableWidgetItem *key, *value;
412  for ( int i = 0 ; i < mOptionsTable->rowCount(); i++ )
413  {
414  key = mOptionsTable->item( i, 0 );
415  if ( ! key || key->text().isEmpty() )
416  continue;
417  value = mOptionsTable->item( i, 1 );
418  if ( ! value || value->text().isEmpty() )
419  continue;
420  options += key->text() + '=' + value->text() + ' ';
421  }
422  options = options.trimmed();
423  mOptionsMap[ currentProfileKey()] = options;
424  mOptionsLineEdit->setText( options );
425  mOptionsLineEdit->setCursorPosition( 0 );
426 }
427 
428 void QgsRasterFormatSaveOptionsWidget::on_mOptionsLineEdit_editingFinished()
429 {
430  mOptionsMap[ currentProfileKey()] = mOptionsLineEdit->text().trimmed();
431 }
432 
433 void QgsRasterFormatSaveOptionsWidget::on_mProfileNewButton_clicked()
434 {
435  QString profileName = QInputDialog::getText( this, "", tr( "Profile name:" ) );
436  if ( ! profileName.isEmpty() )
437  {
438  profileName = profileName.trimmed();
439  mOptionsMap[ profileName ] = "";
440  mProfileComboBox->addItem( profileName, profileName );
441  mProfileComboBox->setCurrentIndex( mProfileComboBox->count() - 1 );
442  }
443 }
444 
445 void QgsRasterFormatSaveOptionsWidget::on_mProfileDeleteButton_clicked()
446 {
447  int index = mProfileComboBox->currentIndex();
448  QString profileKey = currentProfileKey();
449  if ( index != -1 && ! mBuiltinProfiles.contains( profileKey ) )
450  {
451  mOptionsMap.remove( profileKey );
452  mProfileComboBox->removeItem( index );
453  }
454 }
455 
456 void QgsRasterFormatSaveOptionsWidget::on_mProfileResetButton_clicked()
457 {
458  QString profileKey = currentProfileKey();
459  if ( mBuiltinProfiles.contains( profileKey ) )
460  {
461  mOptionsMap[ profileKey ] = mBuiltinProfiles[ profileKey ][ 2 ];
462  }
463  else
464  {
465  mOptionsMap[ profileKey ] = "";
466  }
467  mOptionsLineEdit->setText( mOptionsMap.value( currentProfileKey() ) );
468  mOptionsLineEdit->setCursorPosition( 0 );
469  updateOptions();
470 }
471 
472 void QgsRasterFormatSaveOptionsWidget::optionsTableEnableDeleteButton()
473 {
474  mOptionsDeleteButton->setEnabled( mOptionsTable->currentRow() >= 0 );
475 }
476 
477 void QgsRasterFormatSaveOptionsWidget::on_mOptionsAddButton_clicked()
478 {
479  mOptionsTable->insertRow( mOptionsTable->rowCount() );
480  // select the added row
481  int newRow = mOptionsTable->rowCount() - 1;
482  QTableWidgetItem* item = new QTableWidgetItem();
483  mOptionsTable->setItem( newRow, 0, item );
484  mOptionsTable->setCurrentItem( item );
485 }
486 
487 void QgsRasterFormatSaveOptionsWidget::on_mOptionsDeleteButton_clicked()
488 {
489  if ( mOptionsTable->currentRow() >= 0 )
490  {
491  mOptionsTable->removeRow( mOptionsTable->currentRow() );
492  // select the previous row or the next one if there is no previous row
493  QTableWidgetItem* item = mOptionsTable->item( mOptionsTable->currentRow(), 0 );
494  mOptionsTable->setCurrentItem( item );
495  optionsTableChanged();
496  }
497 }
498 
499 
500 QString QgsRasterFormatSaveOptionsWidget::settingsKey( QString profileName ) const
501 {
502  if ( profileName != "" )
503  profileName = "/profile_" + profileName;
504  else
505  profileName = "/profile_default" + profileName;
506  return mProvider + "/driverOptions/" + pseudoFormat().toLower() + profileName + "/create";
507 }
508 
509 QString QgsRasterFormatSaveOptionsWidget::currentProfileKey() const
510 {
511  return mProfileComboBox->itemData( mProfileComboBox->currentIndex() ).toString();
512 }
513 
515 {
516  return mOptionsMap.value( currentProfileKey() ).trimmed().split( ' ', QString::SkipEmptyParts );
517 }
518 
519 QString QgsRasterFormatSaveOptionsWidget::createOptions( const QString& profileName ) const
520 {
521  QSettings mySettings;
522  return mySettings.value( settingsKey( profileName ), "" ).toString();
523 }
524 
525 void QgsRasterFormatSaveOptionsWidget::deleteCreateOptions( const QString& profileName )
526 {
527  QSettings mySettings;
528  mySettings.remove( settingsKey( profileName ) );
529 }
530 
531 void QgsRasterFormatSaveOptionsWidget::setCreateOptions()
532 {
533  QSettings mySettings;
534  QString myProfiles;
536  while ( i != mOptionsMap.constEnd() )
537  {
538  setCreateOptions( i.key(), i.value() );
539  myProfiles += i.key() + QLatin1String( " " );
540  ++i;
541  }
542  mySettings.setValue( mProvider + "/driverOptions/" + pseudoFormat().toLower() + "/profiles",
543  myProfiles.trimmed() );
544  mySettings.setValue( mProvider + "/driverOptions/" + pseudoFormat().toLower() + "/defaultProfile",
545  currentProfileKey().trimmed() );
546 }
547 
548 void QgsRasterFormatSaveOptionsWidget::setCreateOptions( const QString& profileName, const QString& options )
549 {
550  QSettings mySettings;
551  mySettings.setValue( settingsKey( profileName ), options.trimmed() );
552 }
553 
554 void QgsRasterFormatSaveOptionsWidget::setCreateOptions( const QString& profileName, const QStringList& list )
555 {
556  setCreateOptions( profileName, list.join( " " ) );
557 }
558 
559 QStringList QgsRasterFormatSaveOptionsWidget::profiles() const
560 {
561  QSettings mySettings;
562  return mySettings.value( mProvider + "/driverOptions/" + pseudoFormat().toLower() + "/profiles", "" ).toString().trimmed().split( ' ', QString::SkipEmptyParts );
563 }
564 
565 void QgsRasterFormatSaveOptionsWidget::swapOptionsUI( int newIndex )
566 {
567  // set new page
568  int oldIndex;
569  if ( newIndex == -1 )
570  {
571  oldIndex = mOptionsStackedWidget->currentIndex();
572  newIndex = ( oldIndex + 1 ) % 2;
573  }
574  else
575  {
576  oldIndex = ( newIndex + 1 ) % 2;
577  }
578 
579  // resize pages to minimum - this works well with gdaltools merge ui, but not raster save as...
580  mOptionsStackedWidget->setCurrentIndex( newIndex );
581  mOptionsStackedWidget->widget( newIndex )->setSizePolicy(
582  QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
583  mOptionsStackedWidget->widget( oldIndex )->setSizePolicy(
584  QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored ) );
585  layout()->activate();
586 
587  updateOptions();
588 }
589 
590 void QgsRasterFormatSaveOptionsWidget::updateControls()
591 {
592  bool valid = mProvider == "gdal" && mFormat != "";
593  mOptionsValidateButton->setEnabled( valid );
594  mOptionsHelpButton->setEnabled( valid );
595 }
596 
597 // map options label left mouse click to optionsToggle()
598 bool QgsRasterFormatSaveOptionsWidget::eventFilter( QObject *obj, QEvent *event )
599 {
600  if ( event->type() == QEvent::MouseButtonPress )
601  {
602  QMouseEvent *mouseEvent = static_cast<QMouseEvent *>( event );
603  if ( mouseEvent && ( mouseEvent->button() == Qt::RightButton ) )
604  {
605  QMenu* menu = nullptr;
606  QString text;
607  if ( mOptionsStackedWidget->currentIndex() == 0 )
608  text = tr( "Use simple interface" );
609  else
610  text = tr( "Use table interface" );
611  if ( obj->objectName() == "mOptionsLineEdit" )
612  {
613  menu = mOptionsLineEdit->createStandardContextMenu();
614  menu->addSeparator();
615  }
616  else
617  menu = new QMenu( this );
618  QAction* action = new QAction( text, menu );
619  menu->addAction( action );
620  connect( action, SIGNAL( triggered() ), this, SLOT( swapOptionsUI() ) );
621  menu->exec( mouseEvent->globalPos() );
622  delete menu;
623  return true;
624  }
625  }
626  // standard event processing
627  return QObject::eventFilter( obj, event );
628 }
629 
631 {
632  Q_UNUSED( event );
633  mOptionsTable->horizontalHeader()->resizeSection( 0, mOptionsTable->width() - 115 );
634  QgsDebugMsg( "done" );
635 }
636 
QLayout * layout() const
static unsigned index
static QgsProviderRegistry * instance(const QString &pluginPath=QString::null)
Means of accessing canonical single instance.
Type type() const
void setupUi(QWidget *widget)
QgsRasterFormatSaveOptionsWidget(QWidget *parent=nullptr, const QString &format="GTiff", QgsRasterFormatSaveOptionsWidget::Type type=Default, const QString &provider="gdal")
bool contains(const Key &key) const
QString helpCreationOptionsFormat_t(QString format)
virtual QString validatePyramidsConfigOptions(QgsRaster::RasterPyramidsFormat pyramidsFormat, const QStringList &theConfigOptions, const QString &fileFormat)
Validates pyramid creation options for a specific dataset and destination format. ...
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
const_iterator constBegin() const
void addAction(QAction *action)
bool contains(const QString &str, Qt::CaseSensitivity cs) const
virtual void setVisible(bool visible)
A generic dialog with layout and button box.
Definition: qgsdialog.h:30
int exec()
QString join(const QString &separator) const
void clear()
QString tr(const char *sourceText, const char *disambiguation, int n)
StandardButton information(QWidget *parent, const QString &title, const QString &text, QFlags< QMessageBox::StandardButton > buttons, StandardButton defaultButton)
bool isNull() const
QList< T > findChildren(const QString &name) const
void setValue(const QString &key, const QVariant &value)
void resize(int w, int h)
QString validateCreationOptionsFormat_t(const QStringList &createOptions, QString format)
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
int count(const T &value) const
const QPoint & globalPos() const
int bandCount() const
Get the number of bands in this layer.
Qt::MouseButton button() const
QString validateOptions(bool gui=true, bool reportOk=true)
bool isEmpty() const
bool isEmpty() const
QString trimmed() const
const_iterator constEnd() const
static const QString PYRAMID_JPEG_COMPRESSION("JPEG_QUALITY_OVERVIEW=75 COMPRESS_OVERVIEW=JPEG INTERLEAVE_OVERVIEW=PIXEL")
QString id() const
Get this layer&#39;s unique ID, this ID is used to access this layer from map layer registry.
virtual bool eventFilter(QObject *watched, QEvent *event)
QAction * addSeparator()
static const QString PYRAMID_JPEG_YCBCR_COMPRESSION("JPEG_QUALITY_OVERVIEW=75 COMPRESS_OVERVIEW=JPEG PHOTOMETRIC_OVERVIEW=YCBCR INTERLEAVE_OVERVIEW=PIXEL")
const Key & key() const
const T & value() const
QAction * exec()
QString getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode, const QString &text, bool *ok, QFlags< Qt::WindowType > flags, QFlags< Qt::InputMethodHint > inputMethodHints)
QString toLower() const
void remove(const QString &key)
QString text() const
QLibrary * providerLibrary(const QString &providerKey) const
const Key key(const T &value) const
Raster namespace.
Definition: qgsraster.h:28
QVariant value(const QString &key, const QVariant &defaultValue) const
bool activate()
void * resolve(const char *symbol)
virtual void showEvent(QShowEvent *event) override
void insert(int i, const T &value)
QVBoxLayout * layout()
Returns the central layout. Widgets added to it must have this dialog as parent.
Definition: qgsdialog.h:40
QStringList split(const QString &sep, const QString &str, bool allowEmptyEntries)
void setType(QgsRasterFormatSaveOptionsWidget::Type type=Default)
StandardButton warning(QWidget *parent, const QString &title, const QString &text, QFlags< QMessageBox::StandardButton > buttons, StandardButton defaultButton)
virtual QString validateCreationOptions(const QStringList &createOptions, const QString &format)
Validates creation options for a specific dataset and destination format.
void(*)() cast_to_fptr(void *p)
Definition: qgis.h:272
QgsRasterDataProvider * dataProvider()
Returns the data provider.
void show()
bool isEmpty() const
void setReadOnly(bool ro)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setText(const QString &text)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QString toString() const
virtual bool event(QEvent *event)
bool hasNext() const
const T value(const Key &key) const
int remove(const Key &key)