-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e49c42
commit 7c760b2
Showing
8 changed files
with
409 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#include "qgsrasterformatoptionswidget.h" | ||
#include "qgslogger.h" | ||
|
||
#include <QSettings> | ||
#include <QInputDialog> | ||
|
||
QgsRasterFormatOptionsWidget::QgsRasterFormatOptionsWidget( QWidget* parent, QString format, QString provider ): QWidget( parent ), mFormat( format ), mProvider( provider ) | ||
|
||
{ | ||
setupUi( this ); | ||
showProfileButtons( false ); | ||
connect( mProfileComboBox, SIGNAL( currentIndexChanged ( const QString & ) ), | ||
this, SLOT( profileChanged() ) ); | ||
connect( mProfileApplyButton, SIGNAL( clicked() ), this, SLOT( apply() ) ); | ||
update(); | ||
} | ||
|
||
QgsRasterFormatOptionsWidget::~QgsRasterFormatOptionsWidget() | ||
{ | ||
} | ||
|
||
|
||
void QgsRasterFormatOptionsWidget::showProfileButtons( bool show ) | ||
{ | ||
mProfileButtons->setVisible( show ); | ||
} | ||
|
||
void QgsRasterFormatOptionsWidget::update() | ||
{ | ||
// mCreateOptionsLineEdit->setText( createOption( mProfileComboBox->currentText() ) ); | ||
mProfileComboBox->blockSignals( true ); | ||
mProfileComboBox->clear(); | ||
foreach ( QString profileName, profiles() ) | ||
{ | ||
mProfileComboBox->addItem( profileName ); | ||
} | ||
mProfileComboBox->blockSignals( false ); | ||
mProfileComboBox->setCurrentIndex( 0 ); | ||
profileChanged(); | ||
} | ||
|
||
void QgsRasterFormatOptionsWidget::apply() | ||
{ | ||
setProfiles(); | ||
setCreateOptions( mProfileComboBox->currentText(), mCreateOptionsLineEdit->text() ); | ||
profileChanged(); | ||
} | ||
|
||
// void QgsRasterFormatOptionsWidget::on_mProfileComboBox_currentIndexChanged( const QString & text ) | ||
void QgsRasterFormatOptionsWidget::profileChanged() | ||
{ | ||
QgsDebugMsg("Entered"); | ||
mCreateOptionsLineEdit->setText( createOptions( mProfileComboBox->currentText() ) ); | ||
} | ||
|
||
void QgsRasterFormatOptionsWidget::on_mProfileNewButton_clicked() | ||
{ | ||
QString profileName = QInputDialog::getText( this, "", tr("Profile name:") ); | ||
if ( ! profileName.isEmpty() ) | ||
{ | ||
profileName = profileName.trimmed(); | ||
profileName.replace( " ", "_" ); | ||
profileName.replace( "=", "_" ); | ||
mProfileComboBox->addItem( profileName ); | ||
mProfileComboBox->setCurrentIndex( mProfileComboBox->count()-1 ); | ||
} | ||
} | ||
|
||
void QgsRasterFormatOptionsWidget::on_mProfileDeleteButton_clicked() | ||
{ | ||
int index = mProfileComboBox->currentIndex(); | ||
QString profileName = mProfileComboBox->currentText(); | ||
if ( index != -1 ) | ||
{ | ||
mProfileComboBox->removeItem( index ); | ||
setCreateOptions( profileName, "" ); | ||
} | ||
} | ||
|
||
QString QgsRasterFormatOptionsWidget::settingsKey( QString profileName ) const | ||
{ | ||
if ( profileName != "" ) | ||
profileName = "/profile_" + profileName; | ||
else | ||
profileName = "/profile_default" + profileName; | ||
return mProvider + "/driverOptions/" + mFormat.toLower() + profileName + "/create"; | ||
} | ||
|
||
QStringList QgsRasterFormatOptionsWidget::createOptions() const | ||
{ | ||
return mCreateOptionsLineEdit->text().trimmed().split( " " ) ; | ||
} | ||
|
||
QString QgsRasterFormatOptionsWidget::createOptions( QString profileName ) const | ||
{ | ||
QSettings mySettings; | ||
return mySettings.value( settingsKey( profileName ), "" ).toString(); | ||
} | ||
|
||
void QgsRasterFormatOptionsWidget::deleteCreateOptions( QString profileName ) | ||
{ | ||
QSettings mySettings; | ||
mySettings.remove( settingsKey( profileName ) ); | ||
} | ||
|
||
void QgsRasterFormatOptionsWidget::setCreateOptions( QString profileName, QString value ) | ||
{ | ||
QSettings mySettings; | ||
mySettings.setValue( settingsKey( profileName ), value.trimmed() ); | ||
} | ||
|
||
QStringList QgsRasterFormatOptionsWidget::profiles() const | ||
{ | ||
QSettings mySettings; | ||
return mySettings.value( mProvider + "/driverOptions/" + mFormat.toLower() + "/profiles", "" ).toString().split( " " ); | ||
} | ||
|
||
void QgsRasterFormatOptionsWidget::setProfiles() const | ||
{ | ||
QSettings mySettings; | ||
QString myProfiles; | ||
for ( int i = 0 ; i < mProfileComboBox->count() ; i++ ) | ||
myProfiles += mProfileComboBox->itemText( i ) + QString( " " ); | ||
return mySettings.setValue( mProvider + "/driverOptions/" + mFormat.toLower() + "/profiles", myProfiles.trimmed() ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#ifndef QGSRASTERFORMATOPTIONSWIDGET_H | ||
#define QGSRASTERFORMATOPTIONSWIDGET_H | ||
|
||
#include "ui_qgsrasterformatoptionswidgetbase.h" | ||
|
||
//class QgsRasterDataProvider; | ||
|
||
class GUI_EXPORT QgsRasterFormatOptionsWidget: public QWidget, private Ui::QgsRasterFormatOptionsWidgetBase | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsRasterFormatOptionsWidget( QWidget* parent = 0, QString format = "GTiff", QString provider = "gdal" ); | ||
~QgsRasterFormatOptionsWidget(); | ||
|
||
void setFormat( QString format ) { mFormat = format; } | ||
void setProvider( QString provider ) { mProvider = provider; } | ||
|
||
public slots: | ||
QStringList createOptions() const; | ||
void showProfileButtons( bool show = true ); | ||
void update(); | ||
void apply(); | ||
|
||
private slots: | ||
/* void on_mProfileComboBox_currentIndexChanged( const QString & text ); */ | ||
void profileChanged(); | ||
void on_mProfileNewButton_clicked(); | ||
void on_mProfileDeleteButton_clicked(); | ||
|
||
private: | ||
|
||
QString mFormat; | ||
QString mProvider; | ||
|
||
QString settingsKey( QString profile ) const; | ||
QString createOptions( QString profile ) const; | ||
void deleteCreateOptions( QString profile ); | ||
void setCreateOptions( QString profile, QString value ); | ||
QStringList profiles() const; | ||
void setProfiles() const; | ||
|
||
}; | ||
|
||
#endif // QGSRASTERLAYERSAVEASDIALOG_H |
Oops, something went wrong.