Skip to content
Permalink
Browse files

add profiles and validate and help buttons

  • Loading branch information
etiennesky committed Jul 22, 2012
1 parent 7c760b2 commit 4327e443503a8b52b9ea33f4301d08e995554438
@@ -583,7 +583,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :

// tabWidget->setCurrentIndex( settings.value( "/Windows/Options/row" ).toInt() );
int currentTab = settings.value( "/Windows/Options/row" ).toInt();
QgsDebugMsg(QString("current=%1").arg(currentTab));
tabWidget->setCurrentIndex( currentTab );
on_tabWidget_currentChanged( currentTab );
}
@@ -1069,37 +1068,46 @@ void QgsOptions::on_pbnSelectOtfProjection_clicked()
}
}

void QgsOptions::on_lstGdalDrivers_itemPressed( QTreeWidgetItem * item, int column )
{
// edit driver if "options" icon (column 3) is pressed
if ( item && column == 3 )
{
editGdalDriver( item->text( 0 ) );
}
}

void QgsOptions::on_lstGdalDrivers_itemDoubleClicked( QTreeWidgetItem * item, int column )
{
Q_UNUSED( column );
// edit driver if "options" icon (column 3) exists (only if driver supports write)
if ( item && ! item->icon( 3 ).isNull() )
// edit driver if driver supports write
if ( item && ( cmbEditCreateOptions->findText( item->text( 0 ) ) != -1 ) )
{
editGdalDriver( item->text( 0 ) );
}
}

void QgsOptions::on_pbnEditCreateOptions_pressed()
{
editGdalDriver( cmbEditCreateOptions->currentText() );
}

void QgsOptions::on_pbnEditPyramidsOptions_pressed()
{
editGdalDriver( "_pyramids" );
}

void QgsOptions::editGdalDriver( const QString& driverName )
{
// this will go to a standalone widget class
QDialog dlg( this );
if ( driverName.isEmpty() )
return;

QDialog dlg( this );
QVBoxLayout *layout = new QVBoxLayout();
QString title = tr( "Create Options - %1 Driver" ).arg( driverName );
if ( driverName == "_pyramids" )
title = tr( "Create Options - pyramids" );
dlg.setWindowTitle( title );
QLabel *label = new QLabel( title );
label->setAlignment( Qt::AlignHCenter );
layout->addWidget( label );
QgsRasterFormatOptionsWidget* optionsWidget = new QgsRasterFormatOptionsWidget( 0, driverName, "gdal" );
layout->addWidget( optionsWidget );
optionsWidget->showProfileButtons( true );
QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
connect(buttonBox, SIGNAL(accepted()), &dlg, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), &dlg, SLOT(reject()));
connect( buttonBox, SIGNAL( accepted() ), &dlg, SLOT( accept() ) );
connect( buttonBox, SIGNAL( rejected() ), &dlg, SLOT( reject() ) );
layout->addWidget( buttonBox );
dlg.setLayout( layout );

@@ -1331,7 +1339,6 @@ void QgsOptions::on_mClearCache_clicked()

void QgsOptions::on_tabWidget_currentChanged( int theTab )
{
QgsDebugMsg(QString("current=%1").arg(theTab));
// load gdal driver list when gdal tab is first opened
if ( theTab == 1 && ! mLoadedGdalDriverList )
{
@@ -1392,6 +1399,7 @@ void QgsOptions::loadGdalDriverList()
GDALDriverH myGdalDriver; // current driver
QString myGdalDriverDescription;
QStringList myDrivers;
QStringList myGdalWriteDrivers;
QMap<QString, QString> myDriversFlags, myDriversExt, myDriversLongName;

// make sure we save list when accept()
@@ -1421,7 +1429,10 @@ void QgsOptions::loadGdalDriverList()
// get driver R/W flags, taken from GDALGeneralCmdLineProcessor()
const char *pszRWFlag, *pszVirtualIO;
if ( GDALGetMetadataItem( myGdalDriver, GDAL_DCAP_CREATE, NULL ) )
{
myGdalWriteDrivers << myGdalDriverDescription;
pszRWFlag = "rw+";
}
else if ( GDALGetMetadataItem( myGdalDriver, GDAL_DCAP_CREATECOPY,
NULL ) )
pszRWFlag = "rw";
@@ -1448,18 +1459,11 @@ void QgsOptions::loadGdalDriverList()
// sort list case insensitive - no existing function for this!
QMap<QString, QString> strMap;
foreach( QString str, myDrivers )
{
strMap.insert( str.toLower(), str );
}
strMap.insert( str.toLower(), str );
myDrivers = strMap.values();

QStringListIterator myIterator( myDrivers );
QIcon myIcon = QgsApplication::getThemeIcon( "mActionOptions.png" );

while ( myIterator.hasNext() )
foreach( QString myName, myDrivers )
{
QString myName = myIterator.next();
// QListWidgetItem * mypItem = new QListWidgetItem( myName );
QTreeWidgetItem * mypItem = new QTreeWidgetItem( QStringList( myName ) );
if ( mySkippedDrivers.contains( myName ) )
{
@@ -1474,12 +1478,7 @@ void QgsOptions::loadGdalDriverList()
mypItem->setText( 1, myDriversExt[myName] );
QString myFlags = myDriversFlags[myName];
mypItem->setText( 2, myFlags );
if ( myFlags.contains( "w+" ) )
{
mypItem->setIcon( 3, myIcon );
}
mypItem->setText( 4, myDriversLongName[myName] );

mypItem->setText( 3, myDriversLongName[myName] );
lstGdalDrivers->addTopLevelItem( mypItem );
}
// adjust column width
@@ -1488,13 +1487,26 @@ void QgsOptions::loadGdalDriverList()
lstGdalDrivers->resizeColumnToContents( i );
lstGdalDrivers->setColumnWidth( i, lstGdalDrivers->columnWidth( i ) + 5 );
}

// populate cmbEditCreateOptions with gdal write drivers - sorted, GTiff first
strMap.clear();
foreach( QString str, myGdalWriteDrivers )
strMap.insert( str.toLower(), str );
myGdalWriteDrivers = strMap.values();
myGdalWriteDrivers.removeAll( "Gtiff" );
myGdalWriteDrivers.prepend( "GTiff" );
cmbEditCreateOptions->clear();
foreach( QString myName, myGdalWriteDrivers )
{
cmbEditCreateOptions->addItem( myName );
}

}

void QgsOptions::saveGdalDriverList()
{
for ( int i = 0; i < lstGdalDrivers->topLevelItemCount(); i++ )
{
// QListWidgetItem * mypItem = lstGdalDrivers->item( i );
QTreeWidgetItem * mypItem = lstGdalDrivers->topLevelItem( i );
if ( mypItem->checkState( 0 ) == Qt::Unchecked )
{
@@ -59,8 +59,9 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
void on_pbnSelectProjection_clicked();
//! Slot called when user chooses to change the default 'on the fly' projection.
void on_pbnSelectOtfProjection_clicked();
void on_lstGdalDrivers_itemPressed( QTreeWidgetItem * item, int column );
void on_lstGdalDrivers_itemDoubleClicked( QTreeWidgetItem * item, int column );
void on_pbnEditCreateOptions_pressed();
void on_pbnEditPyramidsOptions_pressed();
void editGdalDriver( const QString& driverName );
void saveOptions();
//! Slot to change the theme this is handled when the user

0 comments on commit 4327e44

Please sign in to comment.
You can’t perform that action at this time.