Skip to content
Permalink
Browse files

regions added to browser

git-svn-id: http://svn.osgeo.org/qgis/trunk@5050 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek
rblazek committed Mar 17, 2006
1 parent fa9db4b commit 77d3c81b89b6d88d91234722cc5b8a020f50b511
Showing with 42 additions and 3 deletions.
  1. +13 −1 src/plugins/grass/qgsgrassbrowser.cpp
  2. +28 −1 src/plugins/grass/qgsgrassmodel.cpp
  3. +1 −1 src/plugins/grass/qgsgrassmodel.h
@@ -216,6 +216,7 @@ void QgsGrassBrowser::deleteMap()
QString typeName;
if ( type == QgsGrassModel::Raster ) typeName = "rast";
else if ( type == QgsGrassModel::Vector ) typeName = "vect";
else if ( type == QgsGrassModel::Region ) typeName = "region";

if ( mapset != QgsGrass::getDefaultMapset() )
{
@@ -304,6 +305,17 @@ void QgsGrassBrowser::setRegion()

Vect_close (&Map);
}
else if ( type == QgsGrassModel::Region )
{
if ( G__get_window (&window, "windows",
map.toLocal8Bit().data(),
mapset.toLocal8Bit().data() ) != NULL )
{
QMessageBox::warning( 0, "Warning",
"Cannot read region" );
return;
}
}
}

// Reset mapset (selected maps could be in a different one)
@@ -347,7 +359,7 @@ void QgsGrassBrowser::selectionChanged(const QItemSelection & selected, const QI
{
mActionAddMap->setEnabled(true);
}
if ( type == QgsGrassModel::Raster || type == QgsGrassModel::Vector )
if ( type == QgsGrassModel::Raster || type == QgsGrassModel::Vector || type == QgsGrassModel::Region )
{
mActionSetRegion->setEnabled(true);

@@ -424,8 +424,12 @@ QString QgsGrassModelItem::name()
case QgsGrassModel::Rasters:
return "raster";
break;
case QgsGrassModel::Regions:
return "region";
break;
case QgsGrassModel::Vector:
case QgsGrassModel::Raster:
case QgsGrassModel::Region:
return mMap;
break;
case QgsGrassModel::VectorLayer:
@@ -606,9 +610,11 @@ void QgsGrassModel::addItems(QgsGrassModelItem *item, QStringList list, int type
break;
case QgsGrassModel::Vectors:
case QgsGrassModel::Rasters:
case QgsGrassModel::Regions:
break;
case QgsGrassModel::Vector:
case QgsGrassModel::Raster:
case QgsGrassModel::Region:
newItem->mMap = name;
break;
case QgsGrassModel::VectorLayer:
@@ -643,10 +649,14 @@ void QgsGrassModel::refreshItem(QgsGrassModelItem *item)
item->mLocation, item->mMapset );
QStringList rasters = QgsGrass::rasters ( item->mGisbase,
item->mLocation, item->mMapset );
QStringList regions = QgsGrass::elements ( item->mGisbase,
item->mLocation, item->mMapset,
"windows" );

QStringList list;
if ( vectors.count() > 0 ) list.append("vector");
if ( rasters.count() > 0 ) list.append("raster");
if ( regions.count() > 0 ) list.append("region");

removeItems(item, list);

@@ -656,11 +666,15 @@ void QgsGrassModel::refreshItem(QgsGrassModelItem *item)
if ( rasters.count() > 0 )
addItems(item, QStringList("raster"), QgsGrassModel::Rasters );

if ( regions.count() > 0 )
addItems(item, QStringList("region"), QgsGrassModel::Regions );

}
break;

case QgsGrassModel::Vectors:
case QgsGrassModel::Rasters:
case QgsGrassModel::Regions:
{
QStringList list;
int type;
@@ -670,12 +684,18 @@ void QgsGrassModel::refreshItem(QgsGrassModelItem *item)
item->mMapset );
type = QgsGrassModel::Vector;
}
else
else if ( item->mType == QgsGrassModel::Rasters )
{
list = QgsGrass::rasters ( item->mGisbase, item->mLocation,
item->mMapset );
type = QgsGrassModel::Raster;
}
else if ( item->mType == QgsGrassModel::Regions )
{
list = QgsGrass::elements ( item->mGisbase, item->mLocation,
item->mMapset, "windows" );
type = QgsGrassModel::Region;
}

removeItems(item, list);
addItems(item, list, type );
@@ -698,6 +718,9 @@ void QgsGrassModel::refreshItem(QgsGrassModelItem *item)
case QgsGrassModel::Raster:
break;

case QgsGrassModel::Region:
break;

case QgsGrassModel::VectorLayer:
break;
}
@@ -801,6 +824,10 @@ QVariant QgsGrassModel::data ( const QModelIndex &index, int role ) const
return mIconRasterLayer;
break;

case QgsGrassModel::Region :
return mIconFile;
break;

case QgsGrassModel::VectorLayer :
if ( item->mLayer.contains("point") )
{
@@ -45,7 +45,7 @@ class QgsGrassModel: public QAbstractItemModel

//! Item types
enum ItemType { None, Gisbase, Location, Mapset, Rasters, Vectors, Raster,
Vector, VectorLayer };
Vector, VectorLayer, Regions, Region };

//! Set GISBASE and LOCATION_NAME
void setLocation ( const QString &gisbase, const QString &location );

0 comments on commit 77d3c81

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