Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[GRASS] mapset item refresh on file system change
  • Loading branch information
blazek committed Jun 25, 2015
1 parent 580ae03 commit 91058aa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/providers/grass/qgsgrassprovidermodule.cpp
Expand Up @@ -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();
Expand All @@ -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 )
Expand Down
3 changes: 3 additions & 0 deletions src/providers/grass/qgsgrassprovidermodule.h
Expand Up @@ -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;
Expand All @@ -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;
};
Expand Down

0 comments on commit 91058aa

Please sign in to comment.