Skip to content
Permalink
Browse files

[GRASS] skip currently being imported objects in browser refresh

  • Loading branch information
blazek committed Jun 25, 2015
1 parent fe8263b commit 113efcab140a8ea03b5dddc2788fe688f71992c7
Showing with 37 additions and 3 deletions.
  1. +36 −3 src/providers/grass/qgsgrassprovidermodule.cpp
  2. +1 −0 src/providers/grass/qgsgrassprovidermodule.h
@@ -111,16 +111,39 @@ QgsGrassMapsetItem::QgsGrassMapsetItem( QgsDataItem* parent, QString dirPath, QS
mIconName = "grass_mapset.png";
}

bool QgsGrassMapsetItem::objectInImports( QgsGrassObject grassObject )
{
foreach ( QgsGrassImport* import, mImports )
{
if ( !import )
{
continue;
}
if ( !import->grassObject().mapsetIdentical( grassObject )
|| import->grassObject().type() != grassObject.type() )
{
continue;
}
if ( import->names().contains( grassObject.name() ) )
{
return true;
}
}
return false;
}

QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
{
QgsDebugMsg( "Entered" );

QgsGrassObject mapsetObject( mGisdbase, mLocation, mName );
QVector<QgsDataItem*> items;

QStringList vectorNames = QgsGrass::vectors( mDirPath );

foreach ( QString name, vectorNames )
{
QgsGrassObject vectorObject( mGisdbase, mLocation, mName, name, QgsGrassObject::Vector );

// Skip temporary import maps. If Vect_open_old during refresh fails due to missing topo, hist file remains open
// and Windows do no allow to delete temporary map to qgis.v.in. In any case we don't want to show temporary import maps.
// TODO: add some auto cleaning mechanism to remove temporary maps left after import fail
@@ -132,7 +155,12 @@ QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
continue;
}

QgsGrassObject vectorObject( mGisdbase, mLocation, mName, name, QgsGrassObject::Vector );
if ( objectInImports( vectorObject ) )
{
QgsDebugMsg( "skip currently being imported vector " + name );
continue;
}

QString mapPath = mPath + "/vector/" + name;
QStringList layerNames;
QgsGrassVectorItem *map = 0;
@@ -242,6 +270,12 @@ QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
QgsDebugMsg( "uri = " + uri );

QgsGrassObject rasterObject( mGisdbase, mLocation, mName, name, QgsGrassObject::Raster );
if ( objectInImports( rasterObject ) )
{
QgsDebugMsg( "skip currently being imported raster " + name );
continue;
}

QgsGrassRasterItem *layer = new QgsGrassRasterItem( this, rasterObject, path, uri, QgsGrass::isExternal( rasterObject ) );
items.append( layer );
}
@@ -258,7 +292,6 @@ QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
items.append( layer );
}

QgsGrassObject mapsetObject( mGisdbase, mLocation, mName );
foreach ( QgsGrassImport* import, mImports )
{
if ( !import )
@@ -65,6 +65,7 @@ class QgsGrassMapsetItem : public QgsDirectoryItem
void onImportFinished( QgsGrassImport* import );

private:
bool objectInImports( QgsGrassObject grassObject );
//void showImportError(const QString& error);
QString mLocation;
QString mGisdbase;

0 comments on commit 113efca

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