Skip to content

Commit

Permalink
[GRASS] change canceled import item icon / label
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Jun 25, 2015
1 parent 7ce4edf commit 580ae03
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/providers/grass/qgis.v.in.cpp
Expand Up @@ -165,6 +165,7 @@ int main( int argc, char **argv )
if ( isPolygon )
{
tmpMap = QgsGrass::vectNewMapStruct();
// TODO: use Vect_open_tmp_new with GRASS 7
Vect_open_new( tmpMap, tmpName.toUtf8().data(), 0 );
map = tmpMap;
}
Expand Down
18 changes: 18 additions & 0 deletions src/providers/grass/qgsgrass.cpp
Expand Up @@ -21,6 +21,13 @@

#include <setjmp.h>

// for Sleep / usleep for debugging
#ifdef Q_OS_WIN
#include <windows.h>
#else
#include <time.h>
#endif

#include "qgsgrass.h"

#include "qgslogger.h"
Expand Down Expand Up @@ -2258,3 +2265,14 @@ void GRASS_LIB_EXPORT QgsGrass::vectDestroyMapStruct( struct Map_info *map )
qgsFree( map );
map = 0;
}

void GRASS_LIB_EXPORT QgsGrass::sleep( int ms )
{
// Stolen from QTest::qSleep
#ifdef Q_OS_WIN
Sleep( uint( ms ) );
#else
struct timespec ts = { ms / 1000, ( ms % 1000 ) * 1000 * 1000 };
nanosleep( &ts, NULL );
#endif
}
3 changes: 3 additions & 0 deletions src/providers/grass/qgsgrass.h
Expand Up @@ -421,6 +421,9 @@ class QgsGrass
// Free struct Map_info
static GRASS_LIB_EXPORT void vectDestroyMapStruct( struct Map_info *map );

// Sleep miliseconds (for debugging)
static GRASS_LIB_EXPORT void sleep( int ms );

private:
static int initialized; // Set to 1 after initialization
static bool active; // is active mode
Expand Down
19 changes: 17 additions & 2 deletions src/providers/grass/qgsgrassprovidermodule.cpp
Expand Up @@ -833,7 +833,7 @@ QgsGrassImportItem::QgsGrassImportItem( QgsDataItem* parent, const QString& name
, mImport( import )
{
setCapabilities( QgsDataItem::NoCapabilities ); // disable fertility
setState( Populating );
setState( Populated );

QgsGrassImportIcon::instance()->connectFrameChanged( this, SLOT( emitDataChanged() ) );
}
Expand Down Expand Up @@ -862,12 +862,27 @@ void QgsGrassImportItem::cancel()
QgsDebugMsg( "mImport is null" );
return;
}
if ( mImport->isCanceled() )
{
return;
}
mImport->cancel();
QgsGrassImportIcon::instance()->disconnectFrameChanged( this, SLOT( emitDataChanged() ) );
setName( name() + " : " + tr( "cancelling" ) );
emitDataChanged();
}

QIcon QgsGrassImportItem::icon()
{
return QgsGrassImportIcon::instance()->icon();
if ( mImport && mImport->isCanceled() )
{
setIconName( "/mIconDelete.png" );
return QgsDataItem::icon();
}
else
{
return QgsGrassImportIcon::instance()->icon();
}
}

//-------------------------------------------------------------------------
Expand Down

0 comments on commit 580ae03

Please sign in to comment.