Skip to content
Permalink
Browse files

[GRASS] mapset item refresh on file system change

  • Loading branch information
blazek committed Jun 25, 2015
1 parent 580ae03 commit 91058aafbdcff739f7a54a5f0c735cbd6462728b
Showing with 29 additions and 0 deletions.
  1. +26 −0 src/providers/grass/qgsgrassprovidermodule.cpp
  2. +3 −0 src/providers/grass/qgsgrassprovidermodule.h
@@ -100,6 +100,7 @@ QList<QgsGrassImport*> QgsGrassMapsetItem::mImports;

QgsGrassMapsetItem::QgsGrassMapsetItem( QgsDataItem* parent, QString dirPath, QString path )
: QgsDirectoryItem( parent, "", dirPath, path )
, mMapsetFileSystemWatcher( 0 )
{
QDir dir( mDirPath );
mName = dir.dirName();
@@ -111,6 +112,31 @@ QgsGrassMapsetItem::QgsGrassMapsetItem( QgsDataItem* parent, QString dirPath, QS
mIconName = "grass_mapset.png";
}

void QgsGrassMapsetItem::setState( State state )
{
QgsDebugMsg( "Entered" );
QgsDirectoryItem::setState( state );

if ( state == Populated )
{
if ( !mMapsetFileSystemWatcher )
{
mMapsetFileSystemWatcher = new QFileSystemWatcher( this );
mMapsetFileSystemWatcher->addPath( mDirPath + "/vector" );
mMapsetFileSystemWatcher->addPath( mDirPath + "/cellhd" );
connect( mMapsetFileSystemWatcher, SIGNAL( directoryChanged( const QString & ) ), SLOT( directoryChanged() ) );
}
}
else if ( state == NotPopulated )
{
if ( mMapsetFileSystemWatcher )
{
delete mMapsetFileSystemWatcher;
mMapsetFileSystemWatcher = 0;
}
}
}

bool QgsGrassMapsetItem::objectInImports( QgsGrassObject grassObject )
{
foreach ( QgsGrassImport* import, mImports )
@@ -54,6 +54,8 @@ class QgsGrassMapsetItem : public QgsDirectoryItem
public:
QgsGrassMapsetItem( QgsDataItem* parent, QString dirPath, QString path );

virtual void setState( State state ) override;

QIcon icon() override { return QgsDataItem::icon(); }

QVector<QgsDataItem*> createChildren() override;
@@ -69,6 +71,7 @@ class QgsGrassMapsetItem : public QgsDirectoryItem
//void showImportError(const QString& error);
QString mLocation;
QString mGisdbase;
QFileSystemWatcher *mMapsetFileSystemWatcher;
// running imports
static QList<QgsGrassImport*> mImports;
};

0 comments on commit 91058aa

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