QGIS API Documentation  2.99.0-Master (6a61179)
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 <QMimeData>
19 #include <QStringList>
20 
21 class QgsLayerItem;
22 class QgsLayerTreeNode;
23 
27 class CORE_EXPORT QgsMimeDataUtils
28 {
29  public:
30 
31  struct CORE_EXPORT Uri
32  {
34  Uri();
36  explicit Uri( QString& encData );
37 
40  bool isValid() const { return !layerType.isEmpty(); }
41 
43  QString data() const;
44 
46  QString layerType;
50  QString providerKey;
52  QString name;
54  QString uri;
55  QStringList supportedCrs;
56  QStringList supportedFormats;
57  };
58  typedef QList<Uri> UriList;
59 
60  static QMimeData* encodeUriList( const UriList& layers );
61 
62  static bool isUriList( const QMimeData* data );
63 
64  static UriList decodeUriList( const QMimeData* data );
65 
70  static QByteArray layerTreeNodesToUriList( const QList<QgsLayerTreeNode*>& nodes );
71 
72  private:
73  static QString encode( const QStringList& items );
74  static QStringList decode( const QString& encoded );
75  static QByteArray uriListToByteArray( const UriList& layers );
76 
77 };
78 
80 
81 #endif // QGSMIMEDATAUTILS_H
82 
QString layerType
Type of URI. Recognized types: "vector" / "raster" / "plugin" / "custom".
QString name
Human readable name to be used e.g. in layer tree.
Q_DECLARE_METATYPE(QgsMimeDataUtils::UriList)
QStringList supportedFormats
bool isValid() const
Returns whether the object contains valid data.
This class is a base class for nodes in a layer tree.
QString providerKey
For "vector" / "raster" type: provider id.
QString uri
Identifier of the data source recognized by its providerKey.
Item that represents a layer that can be opened with one of the providers.
Definition: qgsdataitem.h:321
QList< Uri > UriList