QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
qgsmimedatautils.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsmimedatautils.h
3
---------------------
4
begin : November 2011
5
copyright : (C) 2011 by Martin Dobias
6
email : wonder dot sk at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
#ifndef QGSMIMEDATAUTILS_H
16
#define QGSMIMEDATAUTILS_H
17
18
#include "qgis_core.h"
19
#include "
qgis_sip.h
"
20
#include "
qgswkbtypes.h
"
21
22
#include <QMimeData>
23
#include <QString>
24
#include <QStringList>
25
26
using namespace
Qt::StringLiterals;
27
28
class
QgsLayerItem
;
29
class
QgsLayerTreeNode
;
30
class
QgsVectorLayer
;
31
class
QgsRasterLayer
;
32
class
QgsMeshLayer
;
33
class
QgsMapLayer
;
34
class
QgsProject
;
35
41
class
CORE_EXPORT
QgsMimeDataUtils
42
{
43
public
:
44
struct
CORE_EXPORT
Uri
45
{
47
Uri
() =
default
;
49
explicit
Uri
(
const
QString &encData );
50
56
explicit
Uri
(
QgsMapLayer
*layer );
57
61
bool
isValid
()
const
{
return
!
layerType
.isEmpty(); }
62
64
QString data()
const
;
65
66
// TODO QGIS 5.0 -- remove this version of function in favor of the one with explicit project parameter
76
Q_DECL_DEPRECATED
QgsVectorLayer
*vectorLayer(
bool
&owner
SIP_OUT
, QString &error
SIP_OUT
)
const
SIP_DEPRECATED
;
77
88
QgsVectorLayer
*vectorLayer(
bool
&owner
SIP_OUT
, QString &error
SIP_OUT
,
QgsProject
*project )
const
;
89
90
// TODO QGIS 5.0 -- remove this version of function in favor of the one with explicit project parameter
100
Q_DECL_DEPRECATED
QgsRasterLayer
*rasterLayer(
bool
&owner
SIP_OUT
, QString &error
SIP_OUT
)
const
SIP_DEPRECATED
;
101
112
QgsRasterLayer
*rasterLayer(
bool
&owner
SIP_OUT
, QString &error
SIP_OUT
,
QgsProject
*project )
const
;
113
114
// TODO QGIS 5.0 -- remove this version of function in favor of the one with explicit project parameter
124
Q_DECL_DEPRECATED
QgsMeshLayer
*meshLayer(
bool
&owner
SIP_OUT
, QString &error
SIP_OUT
)
const
SIP_DEPRECATED
;
125
136
QgsMeshLayer
*meshLayer(
bool
&owner
SIP_OUT
, QString &error
SIP_OUT
,
QgsProject
*project )
const
;
137
138
// TODO QGIS 5.0 -- remove this version of function in favor of the one with explicit project parameter
151
Q_DECL_DEPRECATED
QgsMapLayer
*mapLayer() const
SIP_DEPRECATED
;
152
166
QgsMapLayer
*mapLayer(
QgsProject
*project ) const;
167
192
QString
layerType
;
193
200
QString
providerKey
;
201
203
QString
name
;
205
QString
uri
;
206
QStringList
supportedCrs
;
207
QStringList
supportedFormats
;
208
213
QString
layerId
;
214
220
QString
pId
;
221
228
Qgis
::WkbType
wkbType
=
Qgis
::WkbType::Unknown;
229
234
QString
filePath
;
235
236
#ifdef SIP_RUN
237
// clang-format off
238
SIP_PYOBJECT __repr__();
239
% MethodCode
240
QString str = u
"<QgsMimeDataUtils::Uri (%1): %2>"
_s.arg( sipCpp->providerKey, sipCpp->uri );
241
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
242
% End
243
// clang-format on
244
#endif
245
};
246
typedef
QList<QgsMimeDataUtils::Uri>
UriList
;
247
251
static
QMimeData *
encodeUriList
(
const
UriList
&layers )
SIP_FACTORY
;
252
253
static
bool
isUriList
(
const
QMimeData *data );
254
255
static
UriList
decodeUriList
(
const
QMimeData *data );
256
260
static
QByteArray
layerTreeNodesToUriList
(
const
QList<QgsLayerTreeNode *> &nodes );
261
268
static
bool
hasOriginatedFromCurrentAppInstance
(
const
QgsMimeDataUtils::Uri
&uri );
269
270
private
:
271
static
QString encode(
const
QStringList &items );
272
static
QStringList decode(
const
QString &encoded );
273
static
QByteArray uriListToByteArray(
const
UriList
&layers );
274
275
276
friend
class
TestQgsMimeDataUtils
;
277
};
278
279
Q_DECLARE_METATYPE
(
QgsMimeDataUtils::UriList
)
280
281
#endif
// QGSMIMEDATAUTILS_H
Qgis
Provides global constants and enumerations for use throughout the application.
Definition
qgis.h:62
QgsLayerItem
A browser item that represents a layer that can be opened with one of the providers.
Definition
qgslayeritem.h:35
QgsLayerTreeNode
Base class for nodes in a layer tree.
Definition
qgslayertreenode.h:81
QgsMapLayer
Base class for all map layer types.
Definition
qgsmaplayer.h:83
QgsMeshLayer
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition
qgsmeshlayer.h:105
QgsMimeDataUtils
Contains utility functions for working with MIME data.
Definition
qgsmimedatautils.h:42
QgsMimeDataUtils::layerTreeNodesToUriList
static QByteArray layerTreeNodesToUriList(const QList< QgsLayerTreeNode * > &nodes)
Returns encoded URI list from a list of layer tree nodes.
Definition
qgsmimedatautils.cpp:261
QgsMimeDataUtils::isUriList
static bool isUriList(const QMimeData *data)
Definition
qgsmimedatautils.cpp:209
QgsMimeDataUtils::UriList
QList< QgsMimeDataUtils::Uri > UriList
Definition
qgsmimedatautils.h:246
QgsMimeDataUtils::TestQgsMimeDataUtils
friend class TestQgsMimeDataUtils
Definition
qgsmimedatautils.h:276
QgsMimeDataUtils::encodeUriList
static QMimeData * encodeUriList(const UriList &layers)
Encodes a URI list to a new QMimeData object.
Definition
qgsmimedatautils.cpp:214
QgsMimeDataUtils::decodeUriList
static UriList decodeUriList(const QMimeData *data)
Definition
qgsmimedatautils.cpp:223
QgsMimeDataUtils::hasOriginatedFromCurrentAppInstance
static bool hasOriginatedFromCurrentAppInstance(const QgsMimeDataUtils::Uri &uri)
Returns true if uri originated from the current QGIS application instance.
Definition
qgsmimedatautils.cpp:270
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition
qgsproject.h:114
QgsRasterLayer
Represents a raster layer.
Definition
qgsrasterlayer.h:82
QgsVectorLayer
Represents a vector layer which manages a vector based dataset.
Definition
qgsvectorlayer.h:414
qgis_sip.h
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition
qgis_sip.h:113
SIP_OUT
#define SIP_OUT
Definition
qgis_sip.h:57
SIP_FACTORY
#define SIP_FACTORY
Definition
qgis_sip.h:83
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
qgswkbtypes.h
QgsMimeDataUtils::Uri
Definition
qgsmimedatautils.h:45
QgsMimeDataUtils::Uri::wkbType
Qgis::WkbType wkbType
WKB type, if associated with a vector layer, or QgsWkbTypes::Unknown if not yet known.
Definition
qgsmimedatautils.h:228
QgsMimeDataUtils::Uri::filePath
QString filePath
Path to file, if uri is associated with a file.
Definition
qgsmimedatautils.h:234
QgsMimeDataUtils::Uri::supportedCrs
QStringList supportedCrs
Definition
qgsmimedatautils.h:206
QgsMimeDataUtils::Uri::uri
QString uri
Identifier of the data source recognized by its providerKey.
Definition
qgsmimedatautils.h:205
QgsMimeDataUtils::Uri::name
QString name
Human readable name to be used e.g. in layer tree.
Definition
qgsmimedatautils.h:203
QgsMimeDataUtils::Uri::pId
QString pId
Unique ID associated with application instance.
Definition
qgsmimedatautils.h:220
QgsMimeDataUtils::Uri::providerKey
QString providerKey
For "vector" / "raster" type: provider id.
Definition
qgsmimedatautils.h:200
QgsMimeDataUtils::Uri::layerId
QString layerId
Layer ID, if uri is associated with a layer from a QgsProject.
Definition
qgsmimedatautils.h:213
QgsMimeDataUtils::Uri::Uri
Uri()=default
Constructs invalid URI.
QgsMimeDataUtils::Uri::supportedFormats
QStringList supportedFormats
Definition
qgsmimedatautils.h:207
QgsMimeDataUtils::Uri::layerType
QString layerType
Type of URI.
Definition
qgsmimedatautils.h:192
QgsMimeDataUtils::Uri::isValid
bool isValid() const
Returns whether the object contains valid data.
Definition
qgsmimedatautils.h:61
Generated on
for QGIS API Documentation by
1.17.0