void QgsGrassNewMapset::pageSelected( int index ) { QgsDebugMsg( QString( "title = %1" ).arg( page( index ) ? page( index )->title() : "(null)" ) ); switch ( index ) { case LOCATION: if ( mPreviousPage == DATABASE ) { setLocationPage(); } break; case CRS: // Projection selector if ( !mProjectionSelector ) { QGridLayout *projectionLayout = new QGridLayout( mProjectionFrame ); mProjectionSelector = new QgsProjectionSelector( mProjectionFrame, "Projection", 0 ); mProjectionSelector->setEnabled( false ); projectionLayout->addWidget( mProjectionSelector, 0 , 0 ); mProjectionSelector->show(); connect( mProjectionSelector, SIGNAL( sridSelected( QString ) ), this, SLOT( sridSelected( QString ) ) ); // Se current QGIS projection int srsid = QgsProject::instance()->readNumEntry( "SpatialRefSys", "/ProjectCRSID", 0 ); QgsCoordinateReferenceSystem srs( srsid, QgsCoordinateReferenceSystem::InternalCrsId ); QgsDebugMsg( QString( "current project srsid = %1" ).arg( srsid ) ); QgsDebugMsg( QString( "srs.isValid() = %1" ).arg( srs.isValid() ) ); if ( srs.isValid() ) { mProjectionSelector->setSelectedCrsId( srsid ); mProjRadioButton->setChecked( true ); projRadioSwitched(); } } if ( mPreviousPage == LOCATION ) { setProjectionPage(); } break; case REGION: if ( !mRegionsInited ) { loadRegions(); mRegionsInited = true; } if ( mPreviousPage == CRS ) { setRegionPage(); } break; case MAPSET: if ( mPreviousPage == LOCATION || mPreviousPage == REGION ) { setMapsets(); mapsetChanged(); } break; case FINISH: setFinishPage(); break; } mPreviousPage = index; }
void QgsGrassSelect::setLocations() { elocation->clear(); emapset->clear(); emap->clear(); elayer->clear(); QDir d = QDir( egisdbase->text() ); int idx = 0; int sel = -1; // Add all subdirs containing PERMANENT/DEFAULT_WIND for ( unsigned int i = 0; i < d.count(); i++ ) { if ( d[i] == "." || d[i] == ".." ) continue; QString ldpath = egisdbase->text() + "/" + d[i]; if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 ) { if ( !G_is_location( ldpath.toLocal8Bit().constData() ) ) continue; } else { QString chf = egisdbase->text() + "/" + d[i] + "/PERMANENT/DEFAULT_WIND"; if ( !QFile::exists( chf ) ) continue; } // if type is MAPSET check also if at least one mapset owned by user exists if ( QgsGrassSelect::type == QgsGrassSelect::MAPSET ) { bool exists = false; QDir ld = QDir( ldpath ); for ( unsigned int j = 0; j < ld.count(); j++ ) { if ( !QgsGrass::isMapset( ldpath + "/" + ld[j] ) ) continue; QFileInfo info( ldpath + "/" + ld[j] ); if ( !info.isWritable() ) continue; // TODO: check if owner == user: how to get uer name in QT exists = true; break; } if ( !exists ) continue; } elocation->addItem( QString( d[i] ) ); if ( QString( d[i] ) == lastLocation ) { sel = idx; } idx++; } if ( sel >= 0 ) { elocation->setCurrentIndex( sel ); } buttonBox->button( QDialogButtonBox::Ok )->setDefault( true ); GisdbaseBrowse->setDefault( elocation->count() == 0 ); setMapsets(); }