Skip to content
Permalink
Browse files

common methods for vector layer name and add all vector layers

git-svn-id: http://svn.osgeo.org/qgis/trunk@5023 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek
rblazek committed Mar 15, 2006
1 parent a091d4a commit 028f8808e671cd11119509348dfda436234c3bfa
Showing with 22 additions and 24 deletions.
  1. +18 −8 src/plugins/grass/qgsgrassbrowser.cpp
  2. +4 −16 src/plugins/grass/qgsgrassedit.cpp
@@ -40,6 +40,7 @@

#include "qgis.h"
#include "qgsapplication.h"
#include "qgsrasterlayer.h"

extern "C" {
#include <grass/gis.h>
@@ -50,6 +51,7 @@ extern "C" {
#include "qgsgrassmodel.h"
#include "qgsgrassbrowser.h"
#include "qgsgrassselect.h"
#include "qgsgrassutils.h"

QgsGrassBrowser::QgsGrassBrowser ( QgisIface *iface,
QWidget * parent, Qt::WFlags f )
@@ -141,16 +143,24 @@ void QgsGrassBrowser::addMap()
{
int type = mModel->itemType(*it);
QString uri = mModel->uri(*it);
QString mapset = mModel->itemMapset(*it);
QString map = mModel->itemMap(*it);
if ( type == QgsGrassModel::Raster )
{
std::cerr << "add raster: " << uri.ascii() << std::endl;
mIface->addRasterLayer( uri );
QgsRasterLayer *layer = new QgsRasterLayer( uri, map );
mIface->addRasterLayer(layer);
mapSelected = true;
}
else if ( type == QgsGrassModel::Vector )
{
QgsGrassUtils::addVectorLayers ( mIface,
QgsGrass::getDefaultGisdbase(),
QgsGrass::getDefaultLocation(),
mapset, map );
}
else if ( type == QgsGrassModel::VectorLayer )
{
QString map = mModel->itemMap(*it);
QString name = map;

QStringList list = QgsGrassSelect::vectorLayers(
QgsGrass::getDefaultGisdbase(),
@@ -161,10 +171,8 @@ void QgsGrassBrowser::addMap()
QStringList split = QStringList::split ( '/', uri );
QString layer = split.last();

if ( list.size() > 1 )
{
name += " " + layer;
}
QString name = QgsGrassUtils::vectorLayerName (
map, layer, list.size() );

mIface->addVectorLayer( uri, name, "grass");
mapSelected = true;
@@ -250,7 +258,9 @@ void QgsGrassBrowser::selectionChanged(const QItemSelection & selected, const QI
mTextBrowser->verticalScrollBar()->setValue(0);

int type = mModel->itemType(*it);
if ( type == QgsGrassModel::Raster || type == QgsGrassModel::VectorLayer )
if ( type == QgsGrassModel::Raster ||
type == QgsGrassModel::Vector ||
type == QgsGrassModel::VectorLayer )
{
mActionAddMap->setEnabled(true);
}
@@ -66,6 +66,7 @@ extern "C" {
#include "../../src/providers/grass/qgsgrassprovider.h"
#include "qgsgrassattributes.h"
#include "qgsgrassedit.h"
#include "qgsgrassutils.h"

#include "qgsmapcanvasitem.h"

@@ -923,22 +924,9 @@ void QgsGrassEdit::closeEdit(void)
split.pop_back(); // map
QString mapset = split.last();

QStringList layers = QgsGrassSelect::vectorLayers (
QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation(),
mapset, map );

for ( int i = 0; i < layers.count(); i++ )
{
uri = QgsGrass::getDefaultGisdbase() + "/"
+ QgsGrass::getDefaultLocation() + "/"
+ mapset + "/" + map + "/" + layers[i];

#ifdef QGISDEBUG
std::cerr << "layer = " << layers[i].local8Bit().data() << std::endl;
std::cerr << "uri = " << uri.local8Bit().data() << std::endl;
#endif
mIface->addVectorLayer( uri, layers[i], "grass");
}
QgsGrassUtils::addVectorLayers ( mIface, QgsGrass::getDefaultGisdbase(),
QgsGrass::getDefaultLocation(),
mapset, map );
}

delete this;

0 comments on commit 028f880

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