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

           Branch data     Line data    Source code
       1                 :            : /***************************************************************************
       2                 :            :   qgsdataitemprovider.h
       3                 :            :   --------------------------------------
       4                 :            :   Date                 : March 2015
       5                 :            :   Copyright            : (C) 2015 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                 :            : 
      16                 :            : #ifndef QGSDATAITEMPROVIDER_H
      17                 :            : #define QGSDATAITEMPROVIDER_H
      18                 :            : 
      19                 :            : #include "qgis_core.h"
      20                 :            : #include "qgis_sip.h"
      21                 :            : #include "qgsdataitem.h"
      22                 :            : 
      23                 :            : class QgsDataItem;
      24                 :            : 
      25                 :            : class QString;
      26                 :            : 
      27                 :            : //! handlesDirectoryPath function
      28                 :            : typedef bool handlesDirectoryPath_t( const QString &path ) SIP_SKIP;
      29                 :            : 
      30                 :            : 
      31                 :            : /**
      32                 :            :  * \ingroup core
      33                 :            :  * \brief This is the interface for those who want to add custom data items to the browser tree.
      34                 :            :  *
      35                 :            :  * The method createDataItem() is ever called only if capabilities() return non-zero value.
      36                 :            :  * There are two occasions when createDataItem() is called:
      37                 :            :  *
      38                 :            :  * # to create root items (passed path is empty, parent item is NULLPTR).
      39                 :            :  * # to create items in directory structure. For this capabilities have to return at least
      40                 :            :  *   of the following: QgsDataProvider::Dir or QgsDataProvider::File. Passed path is the file
      41                 :            :  *   or directory being inspected, parent item is a valid QgsDirectoryItem
      42                 :            :  *
      43                 :            :  * \since QGIS 2.10
      44                 :            :  */
      45                 :         15 : class CORE_EXPORT QgsDataItemProvider
      46                 :            : {
      47                 :            :   public:
      48                 :         15 :     virtual ~QgsDataItemProvider() = default;
      49                 :            : 
      50                 :            :     //! Human-readable name of the provider name
      51                 :            :     virtual QString name() = 0;
      52                 :            : 
      53                 :            :     /**
      54                 :            :      * Returns the data provider key (if the data item provider is associated with a data provider),
      55                 :            :      * the default implementation returns an empty string.
      56                 :            :      *
      57                 :            :      * \since QGIS 3.14
      58                 :            :      */
      59                 :          6 :     virtual QString dataProviderKey() const { return QString(); };
      60                 :            : 
      61                 :            :     //! Returns combination of flags from QgsDataProvider::DataCapabilities
      62                 :            :     virtual int capabilities() const = 0;
      63                 :            : 
      64                 :            :     /**
      65                 :            :      * Create a new instance of QgsDataItem (or NULLPTR) for given path and parent item.
      66                 :            :      * Caller takes responsibility of deleting created items.
      67                 :            :      */
      68                 :            :     virtual QgsDataItem *createDataItem( const QString &path, QgsDataItem *parentItem ) = 0 SIP_FACTORY;
      69                 :            : 
      70                 :            :     /**
      71                 :            :      * Create a vector of instances of QgsDataItem (or NULLPTR) for given path and parent item.
      72                 :            :      * Caller takes responsibility of deleting created items.
      73                 :            :      */
      74                 :            :     virtual QVector<QgsDataItem *> createDataItems( const QString &path, QgsDataItem *parentItem );
      75                 :            : 
      76                 :            :     /**
      77                 :            :      * Returns TRUE if the provider will handle the directory at the specified \a path.
      78                 :            :      *
      79                 :            :      * If the provider indicates that it will handle the directory, the default creation and
      80                 :            :      * population of directory items for the path will be avoided and it is left to the
      81                 :            :      * provider to correctly populate relevant entries for the path.
      82                 :            :      *
      83                 :            :      * The default implementation returns FALSE for all paths.
      84                 :            :      *
      85                 :            :      * \since QGIS 3.0
      86                 :            :      */
      87                 :            :     virtual bool handlesDirectoryPath( const QString &path );
      88                 :            : };
      89                 :            : 
      90                 :            : #endif // QGSDATAITEMPROVIDER_H

Generated by: LCOV version 1.14