Skip to content

Commit 60cb517

Browse files
committed
add method to set raster options in QgsRasterFormatOptionsWidget
1 parent 0513bb3 commit 60cb517

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed

python/gui/qgsrasterformatsaveoptionswidget.sip

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,69 @@ class QgsRasterFormatSaveOptionsWidget : QWidget
2121
const QString& provider = "gdal" );
2222
~QgsRasterFormatSaveOptionsWidget();
2323

24+
/**
25+
* Set output raster format, it is used to determine list
26+
* of available options
27+
*/
2428
void setFormat( const QString& format );
29+
30+
/**
31+
* Set provider key, , it is used to determine list
32+
* of available options
33+
*/
2534
void setProvider( const QString& provider );
35+
36+
/**
37+
* Set output raster layer
38+
*/
2639
void setRasterLayer( QgsRasterLayer* rasterLayer );
40+
41+
/**
42+
* Set output raster file name
43+
*/
2744
void setRasterFileName( const QString& file );
45+
46+
/**
47+
* Returns list of selected options
48+
* @see setOptions()
49+
*/
2850
QStringList options() const;
51+
52+
/**
53+
* Populate widget with user-defined options
54+
* @see options()
55+
* @note added in QGIS 3.0
56+
*/
57+
void setOptions( const QString& options);
58+
59+
/**
60+
* Set widget look and feel
61+
*/
2962
void setType( QgsRasterFormatSaveOptionsWidget::Type type = Default );
63+
64+
/**
65+
* Set pyramids format to use
66+
*/
3067
void setPyramidsFormat( QgsRaster::RasterPyramidsFormat format );
3168

3269
public slots:
3370

3471
void apply();
72+
73+
/**
74+
* Opens window with options desctiption for given provider
75+
* and output format
76+
*/
3577
void helpOptions();
78+
79+
/**
80+
* Validates options correctness
81+
*/
3682
QString validateOptions( bool gui = true, bool reportOk = true );
83+
84+
/**
85+
* Reloads profiles list from QGIS settings
86+
*/
3787
void updateProfiles();
3888

3989
private slots:

src/gui/qgsrasterformatsaveoptionswidget.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,3 +631,28 @@ void QgsRasterFormatSaveOptionsWidget::showEvent( QShowEvent * event )
631631
QgsDebugMsg( "done" );
632632
}
633633

634+
void QgsRasterFormatSaveOptionsWidget::setOptions( const QString& options)
635+
{
636+
mOptionsTable->blockSignals( true );
637+
mOptionsTable->clearContents();
638+
639+
QStringList values;
640+
QStringList optionsList = options.trimmed().split( ' ', QString::SkipEmptyParts );
641+
Q_FOREACH ( const QString &opt, optionsList )
642+
{
643+
int rowCount = mOptionsTable->rowCount();
644+
mOptionsTable->insertRow( rowCount );
645+
646+
values = opt.split( '=' );
647+
QTableWidgetItem* nameItem = new QTableWidgetItem( values.at( 0 ) );
648+
mOptionsTable->setItem( rowCount, 0, nameItem );
649+
QTableWidgetItem* valueItem = new QTableWidgetItem( values.at( 1 ) );
650+
mOptionsTable->setItem( rowCount, 0, valueItem );
651+
}
652+
653+
mOptionsMap[ currentProfileKey()] = options.trimmed();
654+
mOptionsLineEdit->setText( options.trimmed() );
655+
mOptionsLineEdit->setCursorPosition( 0 );
656+
657+
mOptionsTable->blockSignals( false );
658+
}

src/gui/qgsrasterformatsaveoptionswidget.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,70 @@ class GUI_EXPORT QgsRasterFormatSaveOptionsWidget: public QWidget,
4747
QgsRasterFormatSaveOptionsWidget::Type type = Default,
4848
const QString& provider = "gdal" );
4949

50+
/**
51+
* Set output raster format, it is used to determine list
52+
* of available options
53+
*/
5054
void setFormat( const QString& format );
55+
56+
/**
57+
* Set provider key, , it is used to determine list
58+
* of available options
59+
*/
5160
void setProvider( const QString& provider );
61+
62+
/**
63+
* Set output raster layer
64+
*/
5265
void setRasterLayer( QgsRasterLayer* rasterLayer ) { mRasterLayer = rasterLayer; mRasterFileName = QString(); }
66+
67+
/**
68+
* Set output raster file name
69+
*/
5370
void setRasterFileName( const QString& file ) { mRasterLayer = nullptr; mRasterFileName = file; }
71+
72+
/**
73+
* Returns list of selected options
74+
* @see setOptions()
75+
*/
5476
QStringList options() const;
77+
78+
/**
79+
* Populate widget with user-defined options
80+
* @see options()
81+
* @note added in QGIS 3.0
82+
*/
83+
void setOptions( const QString& options);
84+
85+
/**
86+
* Set widget look and feel
87+
*/
5588
void setType( QgsRasterFormatSaveOptionsWidget::Type type = Default );
89+
90+
/**
91+
* Set pyramids format to use
92+
*/
5693
void setPyramidsFormat( QgsRaster::RasterPyramidsFormat format )
5794
{ mPyramids = true; mPyramidsFormat = format; }
5895

5996
public slots:
6097

6198
void apply();
99+
100+
/**
101+
* Opens window with options desctiption for given provider
102+
* and output format
103+
*/
62104
void helpOptions();
105+
106+
/**
107+
* Validates options correctness
108+
*/
63109
QString validateOptions( bool gui = true, bool reportOk = true );
110+
111+
/**
112+
* Reloads profiles list from QGIS settings
113+
*/
64114
void updateProfiles();
65115

66116
private slots:

0 commit comments

Comments
 (0)