LCOV - code coverage report
Current view: top level - core/project - qgsprojectbadlayerhandler.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 2 2 100.0 %
Date: 2021-03-26 12:19:53 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /***************************************************************************
       2                 :            :   qgsprojectbadlayerhandler.h - QgsProjectBadLayerHandler
       3                 :            : 
       4                 :            :  ---------------------
       5                 :            :  begin                : 22.10.2016
       6                 :            :  copyright            : (C) 2016 by Matthias Kuhn
       7                 :            :  email                : matthias@opengis.ch
       8                 :            :  ***************************************************************************
       9                 :            :  *                                                                         *
      10                 :            :  *   This program is free software; you can redistribute it and/or modify  *
      11                 :            :  *   it under the terms of the GNU General Public License as published by  *
      12                 :            :  *   the Free Software Foundation; either version 2 of the License, or     *
      13                 :            :  *   (at your option) any later version.                                   *
      14                 :            :  *                                                                         *
      15                 :            :  ***************************************************************************/
      16                 :            : #ifndef QGSPROJECTBADLAYERHANDLER_H
      17                 :            : #define QGSPROJECTBADLAYERHANDLER_H
      18                 :            : 
      19                 :            : #include <QDomNode>
      20                 :            : 
      21                 :            : #include "qgis_core.h"
      22                 :            : 
      23                 :            : /**
      24                 :            :  * \ingroup core
      25                 :            :  * \brief Interface for classes that handle missing layer files when reading project file.
      26                 :            :  */
      27                 :          5 : class CORE_EXPORT QgsProjectBadLayerHandler
      28                 :            : {
      29                 :            :   public:
      30                 :            : 
      31                 :            :     /**
      32                 :            :      * This method will be called whenever the project tries to load layers which
      33                 :            :      * cannot be accessed. It should inform the user about this and if possible offer
      34                 :            :      * to fix the unavailable layers by setting a valid datasource, e.g. by showing a file
      35                 :            :      * dialog.
      36                 :            :      *
      37                 :            :      * The default implementation will dismiss all bad layers and write information to the
      38                 :            :      * log.
      39                 :            :      *
      40                 :            :      * \since QGIS 3.0
      41                 :            :      */
      42                 :            :     virtual void handleBadLayers( const QList<QDomNode> &layers );
      43                 :          6 :     virtual ~QgsProjectBadLayerHandler() = default;
      44                 :            : 
      45                 :            : 
      46                 :            :   protected:
      47                 :            : 
      48                 :            :     //! file data representation
      49                 :            :     enum DataType
      50                 :            :     {
      51                 :            :       IS_VECTOR, //!< Vector data
      52                 :            :       IS_RASTER, //!< Raster data
      53                 :            :       IS_BOGUS   //!< Bogus data
      54                 :            :     };
      55                 :            : 
      56                 :            :     //! the flavors for data storage
      57                 :            :     enum ProviderType
      58                 :            :     {
      59                 :            :       IS_FILE,     //!< Saved in a file
      60                 :            :       IS_DATABASE, //!< Saved in a database
      61                 :            :       IS_URL,      //!< Retrieved from a URL
      62                 :            :       IS_Unknown   //!< Unknown type
      63                 :            :     };
      64                 :            : 
      65                 :            : 
      66                 :            :     /**
      67                 :            :      * Returns data type associated with the given QgsProject file Dom node
      68                 :            :      *
      69                 :            :      * The Dom node should represent the state associated with a specific layer.
      70                 :            :      *
      71                 :            :      * \since QGIS 3.0
      72                 :            :      */
      73                 :            :     DataType dataType( const QDomNode &layerNode );
      74                 :            : 
      75                 :            :     /**
      76                 :            :      * Returns the data source for the given layer
      77                 :            :      *
      78                 :            :      * The QDomNode is a QgsProject Dom node corresponding to a map layer state.
      79                 :            :      *
      80                 :            :      * Essentially dumps datasource tag.
      81                 :            :      *
      82                 :            :      * \since QGIS 3.0
      83                 :            :      */
      84                 :            :     QString dataSource( const QDomNode &layerNode );
      85                 :            : 
      86                 :            :     /**
      87                 :            :      * Returns the physical storage type associated with the given layer
      88                 :            :      *
      89                 :            :      * The QDomNode is a QgsProject Dom node corresponding to a map layer state.
      90                 :            :      *
      91                 :            :      * If the provider tag is "ogr", then it's a file type.
      92                 :            :      *
      93                 :            :      * However, if the layer is a raster, then there won't be a
      94                 :            :      * provider tag.  It will always have an associated file.
      95                 :            :      *
      96                 :            :      * If the layer doesn't fall into either of the previous two categories, then
      97                 :            :      * it's either a database or URL.  If the datasource tag has "url=", then it's
      98                 :            :      * URL based and if it has "dbname=">, then the layer data is in a database.
      99                 :            :      *
     100                 :            :      * \since QGIS 3.0
     101                 :            :      */
     102                 :            :     ProviderType providerType( const QDomNode &layerNode );
     103                 :            : 
     104                 :            :     /**
     105                 :            :      * Set the datasource element to the new value
     106                 :            :      *
     107                 :            :      * \since QGIS 3.0
     108                 :            :      */
     109                 :            :     void setDataSource( QDomNode &layerNode, const QString &dataSource );
     110                 :            : };
     111                 :            : 
     112                 :            : #endif // QGSPROJECTBADLAYERHANDLER_H

Generated by: LCOV version 1.14