@@ -152,21 +152,32 @@ void QgsGrassSelect::setLocations()
152
152
for ( unsigned int i = 0 ; i < d.count (); i++ ) {
153
153
if ( d[i] == " ." || d[i] == " .." ) continue ;
154
154
155
- QString chf = egisdbase->text () + " /" + d[i] + " /PERMANENT/DEFAULT_WIND" ;
156
-
157
- if ( !QFile::exists ( chf ) ) continue ;
155
+ QString ldpath = egisdbase->text () + " /" + d[i];
156
+
157
+ /* TODO: G_is_location() was added to GRASS 6.1 06-05-24,
158
+ enable its use after some period (others do update) */
159
+ /*
160
+ if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 )
161
+ {
162
+ if ( !G_is_location( ldpath.toLocal8Bit().constData() ) ) continue;
163
+ }
164
+ else
165
+ {
166
+ */
167
+ QString chf = egisdbase->text () + " /" + d[i] + " /PERMANENT/DEFAULT_WIND" ;
168
+ if ( !QFile::exists ( chf ) ) continue ;
169
+ // }
158
170
159
- // if type is MAPSET check also if at least one mapset woned by user exists
171
+ // if type is MAPSET check also if at least one mapset owned by user exists
160
172
if ( QgsGrassSelect::type == QgsGrassSelect::MAPSET )
161
173
{
162
174
bool exists = false ;
163
175
164
- QString ldpath = egisdbase->text () + " /" + d[i];
165
176
QDir ld = QDir ( ldpath );
166
177
167
- for ( unsigned int j = 0 ; j < ld.count (); j++ ) {
168
- QString windf = ldpath + " / " + ld[j] + " /WIND " ;
169
- if ( !QFile::exists ( windf ) ) continue ;
178
+ for ( unsigned int j = 0 ; j < ld.count (); j++ )
179
+ {
180
+ if ( !QgsGrass::isMapset ( ldpath + " / " + ld[j] ) ) continue ;
170
181
171
182
QFileInfo info ( ldpath + " /" + ld[j] );
172
183
if ( !info.isWritable () ) continue ;
@@ -214,10 +225,10 @@ void QgsGrassSelect::setMapsets()
214
225
int sel = -1 ;
215
226
216
227
// Go through all subdirs and add all subdirs from vector/
217
- for ( unsigned int i = 0 ; i < ld.count (); i++ ) {
218
- QString windf = ldpath + " / " + ld[i] + " /WIND " ;
219
-
220
- if ( QFile::exists ( windf ) ) {
228
+ for ( unsigned int i = 0 ; i < ld.count (); i++ )
229
+ {
230
+ if ( QgsGrass::isMapset ( ldpath + " / " + ld[i] ) )
231
+ {
221
232
emapset->insertItem ( ld[i], -1 );
222
233
if ( ld[i] == lastMapset ) {
223
234
sel = idx;
@@ -251,38 +262,34 @@ void QgsGrassSelect::setMaps()
251
262
int idx = 0 ;
252
263
int sel = -1 ;
253
264
254
- if (type == VECTOR ) { // vector
255
- ldpath.append ( " /vector/" );
256
- QDir md = QDir ( ldpath );
265
+ if (type == VECTOR ) // vector
266
+ {
267
+ QStringList list = QgsGrass::vectors ( egisdbase->text (),
268
+ elocation->currentText (), emapset->currentText () );
257
269
258
- for ( unsigned int j = 0 ; j < md.count (); j++ ) {
259
- QString chf = ldpath + md[j] + " /head" ;
260
-
261
- if ( QFile::exists ( chf ) ) {
262
- QString m = QString ( md[j] );
263
- emap->insertItem ( m, -1 );
264
- if ( m == lastVectorMap ) {
265
- sel = idx;
266
- }
267
- idx++;
268
- }
270
+ for ( int j = 0 ; j < list.count (); j++ )
271
+ {
272
+ emap->insertItem ( list[j], -1 );
273
+ if ( list[j] == lastVectorMap ) sel = idx;
274
+ idx++;
269
275
}
270
- } else if ( type == RASTER ) {
276
+ }
277
+ else if ( type == RASTER )
278
+ {
271
279
/* add cells */
272
- QDir md = QDir ( ldpath + " /cell/ " );
273
- md. setFilter (QDir::Files );
280
+ QStringList list = QgsGrass::rasters ( egisdbase-> text (),
281
+ elocation-> currentText (), emapset-> currentText () );
274
282
275
- for ( unsigned int j = 0 ; j < md.count (); j++ ) {
276
- QString m = QString ( md[j] );
277
- emap->insertItem ( m, -1 );
278
- if ( m == lastRasterMap ) {
279
- sel = idx;
280
- }
283
+ for ( int j = 0 ; j < list.count (); j++ )
284
+ {
285
+ emap->insertItem ( list[j], -1 );
286
+ if ( list[j] == lastRasterMap ) sel = idx;
281
287
idx++;
282
288
}
283
289
284
290
/* add groups */
285
- md = QDir ( ldpath + " /group/" );
291
+ // TODO add QgsGrass::groups ( use G_list( G_ELEMENT_GROUP) )
292
+ QDir md = QDir ( ldpath + " /group/" );
286
293
md.setFilter (QDir::Dirs);
287
294
288
295
for ( unsigned int j = 0 ; j < md.count (); j++ ) {
0 commit comments