QGIS API Documentation  2.99.0-Master (cb63e82)
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 #include "qgis_core.h"
22 
23 class QgsLayerItem;
24 class QgsLayerTreeNode;
25 
29 class CORE_EXPORT QgsMimeDataUtils
30 {
31  public:
32 
33  struct CORE_EXPORT Uri
34  {
36  Uri();
38  explicit Uri( QString &encData );
39 
42  bool isValid() const { return !layerType.isEmpty(); }
43 
45  QString data() const;
46 
48  QString layerType;
52  QString providerKey;
54  QString name;
56  QString uri;
57  QStringList supportedCrs;
58  QStringList supportedFormats;
59  };
60  typedef QList<Uri> UriList;
61 
62  static QMimeData *encodeUriList( const UriList &layers );
63 
64  static bool isUriList( const QMimeData *data );
65 
66  static UriList decodeUriList( const QMimeData *data );
67 
72  static QByteArray layerTreeNodesToUriList( const QList<QgsLayerTreeNode *> &nodes );
73 
74  private:
75  static QString encode( const QStringList &items );
76  static QStringList decode( const QString &encoded );
77  static QByteArray uriListToByteArray( const UriList &layers );
78 
79 };
80 
82 
83 #endif // QGSMIMEDATAUTILS_H
84 
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:296
QList< Uri > UriList