mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
QgsLayerItem::layerInfo replaced by mapLayerType, providerKey and uri methods
This commit is contained in:
parent
022be6e7a4
commit
b4fde40163
@ -193,11 +193,12 @@ bool QgsBrowser::layerClicked(QgsLayerItem* ptr)
|
||||
{
|
||||
mActionSetProjection->setEnabled ( ptr->capabilities() & QgsLayerItem::SetCrs );
|
||||
|
||||
QgsMapLayer::LayerType type;
|
||||
QString providerKey;
|
||||
QString uri;
|
||||
if ( ptr->layerInfo(type, providerKey, uri) )
|
||||
QString uri = ptr->uri();
|
||||
if ( !uri.isEmpty() )
|
||||
{
|
||||
QgsMapLayer::LayerType type = ptr->mapLayerType();
|
||||
QString providerKey = ptr->providerKey();
|
||||
|
||||
QgsDebugMsg ( providerKey + " : " + uri );
|
||||
if ( type == QgsMapLayer::VectorLayer )
|
||||
{
|
||||
@ -214,15 +215,15 @@ bool QgsBrowser::layerClicked(QgsLayerItem* ptr)
|
||||
QString crs;
|
||||
for ( int i = 1 ; i < URIParts.size(); i++ )
|
||||
{
|
||||
QString part = URIParts.at( i );
|
||||
int pos = part.indexOf( "=" );
|
||||
QString field = part.left( pos );
|
||||
QString value = part.mid( pos + 1 );
|
||||
QString part = URIParts.at( i );
|
||||
int pos = part.indexOf( "=" );
|
||||
QString field = part.left( pos );
|
||||
QString value = part.mid( pos + 1 );
|
||||
|
||||
if ( field == "layers" ) layers = value.split(",");
|
||||
if ( field == "styles" ) styles = value.split(",");
|
||||
if ( field == "format" ) format = value;
|
||||
if ( field == "crs" ) crs = value;
|
||||
if ( field == "layers" ) layers = value.split(",");
|
||||
if ( field == "styles" ) styles = value.split(",");
|
||||
if ( field == "format" ) format = value;
|
||||
if ( field == "crs" ) crs = value;
|
||||
}
|
||||
QgsDebugMsg ( "rasterLayerPath = " + rasterLayerPath );
|
||||
QgsDebugMsg ( "layers = " + layers.join(" " ) );
|
||||
|
@ -123,6 +123,7 @@ class CORE_EXPORT QgsLayerItem : public QgsDataItem
|
||||
public:
|
||||
enum LayerType
|
||||
{
|
||||
NoType,
|
||||
Vector,
|
||||
Raster,
|
||||
Point,
|
||||
@ -147,10 +148,14 @@ public:
|
||||
|
||||
// --- New virtual methods for layer item derived classes ---
|
||||
|
||||
// Sets info about layer which can be created for this item
|
||||
// returns true if layer can be created
|
||||
virtual bool layerInfo ( QgsMapLayer::LayerType & type,
|
||||
QString & providerKey, QString & uri ) { return false; }
|
||||
// Returns QgsMapLayer::LayerType
|
||||
virtual QgsMapLayer::LayerType mapLayerType() { return QgsMapLayer::VectorLayer; }
|
||||
|
||||
// Returns layer uri or empty string if layer cannot be created
|
||||
virtual QString uri() { return QString(); }
|
||||
|
||||
// Returns provider key
|
||||
virtual QString providerKey() { return QString(); }
|
||||
|
||||
// This will _write_ selected crs in data source
|
||||
virtual bool setCrs ( QgsCoordinateReferenceSystem crs ) { return false; }
|
||||
|
@ -1884,14 +1884,9 @@ QgsGdalLayerItem::~QgsGdalLayerItem ()
|
||||
{
|
||||
}
|
||||
|
||||
bool QgsGdalLayerItem::layerInfo(QgsMapLayer::LayerType & type,
|
||||
QString & providerKey, QString & uri )
|
||||
QString QgsGdalLayerItem::uri()
|
||||
{
|
||||
QgsDebugMsg ( "Entered" );
|
||||
type = QgsMapLayer::RasterLayer;
|
||||
providerKey = "gdal";
|
||||
uri = mUri;
|
||||
return true;
|
||||
return mUri;
|
||||
}
|
||||
|
||||
QgsLayerItem::Capability QgsGdalLayerItem::capabilities()
|
||||
|
@ -293,8 +293,10 @@ class QgsGdalLayerItem : public QgsLayerItem
|
||||
QString name, QString path, QString uri );
|
||||
~QgsGdalLayerItem ();
|
||||
|
||||
bool layerInfo ( QgsMapLayer::LayerType & type,
|
||||
QString & providerKey, QString & uri );
|
||||
QgsMapLayer::LayerType mapLayerType() { return QgsMapLayer::RasterLayer; }
|
||||
QString uri();
|
||||
QString providerKey() { return "gdal"; }
|
||||
|
||||
bool setCrs ( QgsCoordinateReferenceSystem crs );
|
||||
Capability capabilities();
|
||||
};
|
||||
|
@ -2140,14 +2140,9 @@ QgsOgrLayerItem::~QgsOgrLayerItem ()
|
||||
{
|
||||
}
|
||||
|
||||
bool QgsOgrLayerItem::layerInfo ( QgsMapLayer::LayerType & type,
|
||||
QString & providerKey, QString & uri )
|
||||
QString QgsOgrLayerItem::uri()
|
||||
{
|
||||
QgsDebugMsg ( "Entered" );
|
||||
type = QgsMapLayer::VectorLayer;
|
||||
providerKey = "ogr";
|
||||
uri = mUri;
|
||||
return true;
|
||||
return mUri;
|
||||
}
|
||||
|
||||
QgsLayerItem::Capability QgsOgrLayerItem::capabilities()
|
||||
|
@ -312,8 +312,9 @@ class QgsOgrLayerItem : public QgsLayerItem
|
||||
QgsOgrLayerItem ( QgsDataItem* parent, QString name, QString path, QString uri, LayerType layerType );
|
||||
~QgsOgrLayerItem ();
|
||||
|
||||
bool layerInfo ( QgsMapLayer::LayerType & type,
|
||||
QString & providerKey, QString & uri );
|
||||
QgsMapLayer::LayerType mapLayerType() { return QgsMapLayer::VectorLayer; }
|
||||
QString uri();
|
||||
QString providerKey() { return "ogr"; }
|
||||
bool setCrs ( QgsCoordinateReferenceSystem crs );
|
||||
Capability capabilities();
|
||||
};
|
||||
|
@ -3133,13 +3133,10 @@ QgsWMSLayerItem::~QgsWMSLayerItem ()
|
||||
{
|
||||
}
|
||||
|
||||
bool QgsWMSLayerItem::layerInfo(QgsMapLayer::LayerType & type,
|
||||
QString & providerKey, QString & uri )
|
||||
QString QgsWMSLayerItem::uri()
|
||||
{
|
||||
if ( mLayerProperty.name.isEmpty() ) return false; // layer collection
|
||||
|
||||
type = QgsMapLayer::RasterLayer;
|
||||
providerKey = "wms";
|
||||
QString uri;
|
||||
if ( mLayerProperty.name.isEmpty() ) return uri; // layer collection
|
||||
|
||||
QString rasterLayerPath = mConnInfo;
|
||||
QString baseName = mLayerProperty.name;
|
||||
@ -3186,7 +3183,7 @@ bool QgsWMSLayerItem::layerInfo(QgsMapLayer::LayerType & type,
|
||||
}
|
||||
uri = rasterLayerPath + "|layers=" + layers.join(",") + "|styles=" + styles.join(",") + "|format=" + format + "|crs=" + crs;
|
||||
|
||||
return true;
|
||||
return uri;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -990,8 +990,9 @@ class QgsWMSLayerItem : public QgsLayerItem
|
||||
QgsWmsCapabilitiesProperty capabilitiesProperty, QString connInfo, QgsWmsLayerProperty layerProperties );
|
||||
~QgsWMSLayerItem ();
|
||||
|
||||
bool layerInfo ( QgsMapLayer::LayerType & type,
|
||||
QString & providerKey, QString & uri );
|
||||
QgsMapLayer::LayerType mapLayerType() { return QgsMapLayer::RasterLayer; }
|
||||
QString uri();
|
||||
QString providerKey() { return "wms"; }
|
||||
|
||||
QgsWmsCapabilitiesProperty mCapabilitiesProperty;
|
||||
QString mConnInfo;
|
||||
|
Loading…
x
Reference in New Issue
Block a user