Skip to content
Permalink
Browse files
Dox, enum class
  • Loading branch information
nyalldawson committed May 20, 2021
1 parent a034668 commit 95c01cc93c0a3af305548e39911ae3de16499369
@@ -88,3 +88,14 @@
Qgis.VectorExportResult.__doc__ = 'Vector layer export result codes.\n\n.. versionadded:: 3.20\n\n' + '* ``NoError``: ' + Qgis.VectorExportResult.Success.__doc__ + '\n' + '* ``ErrCreateDataSource``: ' + Qgis.VectorExportResult.ErrorCreatingDataSource.__doc__ + '\n' + '* ``ErrCreateLayer``: ' + Qgis.VectorExportResult.ErrorCreatingLayer.__doc__ + '\n' + '* ``ErrAttributeTypeUnsupported``: ' + Qgis.VectorExportResult.ErrorAttributeTypeUnsupported.__doc__ + '\n' + '* ``ErrAttributeCreationFailed``: ' + Qgis.VectorExportResult.ErrorAttributeCreationFailed.__doc__ + '\n' + '* ``ErrProjection``: ' + Qgis.VectorExportResult.ErrorProjectingFeatures.__doc__ + '\n' + '* ``ErrFeatureWriteFailed``: ' + Qgis.VectorExportResult.ErrorFeatureWriteFailed.__doc__ + '\n' + '* ``ErrInvalidLayer``: ' + Qgis.VectorExportResult.ErrorInvalidLayer.__doc__ + '\n' + '* ``ErrInvalidProvider``: ' + Qgis.VectorExportResult.ErrorInvalidProvider.__doc__ + '\n' + '* ``ErrProviderUnsupportedFeature``: ' + Qgis.VectorExportResult.ErrorProviderUnsupportedFeature.__doc__ + '\n' + '* ``ErrConnectionFailed``: ' + Qgis.VectorExportResult.ErrorConnectionFailed.__doc__ + '\n' + '* ``ErrUserCanceled``: ' + Qgis.VectorExportResult.UserCanceled.__doc__
# --
Qgis.VectorExportResult.baseClass = Qgis
# monkey patching scoped based enum
Qgis.DriveType.Unknown.__doc__ = "Unknown type"
Qgis.DriveType.Invalid.__doc__ = "Invalid path"
Qgis.DriveType.Removable.__doc__ = "Removable drive"
Qgis.DriveType.Fixed.__doc__ = "Fixed drive"
Qgis.DriveType.Remote.__doc__ = "Remote drive"
Qgis.DriveType.CdRom.__doc__ = "CD-ROM"
Qgis.DriveType.RamDisk.__doc__ = "RAM disk"
Qgis.DriveType.__doc__ = 'Drive types\n\n.. versionadded:: 3.20\n\n' + '* ``Unknown``: ' + Qgis.DriveType.Unknown.__doc__ + '\n' + '* ``Invalid``: ' + Qgis.DriveType.Invalid.__doc__ + '\n' + '* ``Removable``: ' + Qgis.DriveType.Removable.__doc__ + '\n' + '* ``Fixed``: ' + Qgis.DriveType.Fixed.__doc__ + '\n' + '* ``Remote``: ' + Qgis.DriveType.Remote.__doc__ + '\n' + '* ``CdRom``: ' + Qgis.DriveType.CdRom.__doc__ + '\n' + '* ``RamDisk``: ' + Qgis.DriveType.RamDisk.__doc__
# --
Qgis.DriveType.baseClass = Qgis
@@ -161,6 +161,17 @@ The development version
UserCanceled,
};

enum class DriveType
{
Unknown,
Invalid,
Removable,
Fixed,
Remote,
CdRom,
RamDisk,
};

static const double DEFAULT_SEARCH_RADIUS_MM;

static const float DEFAULT_MAPTOPIXEL_THRESHOLD;
@@ -118,18 +118,7 @@ Will check ``basepath`` in an outward spiral up to ``maxClimbs`` levels to check
.. versionadded:: 3.12
%End

enum DriveType
{
Unknown,
Invalid,
Removable,
Fixed,
Remote,
CdRom,
RamDisk,
};

static DriveType driveType( const QString &path ) throw( QgsNotSupportedException );
static Qgis::DriveType driveType( const QString &path ) throw( QgsNotSupportedException );
%Docstring
Returns the drive type for the given ``path``.

@@ -140,7 +129,7 @@ Returns the drive type for the given ``path``.

static bool pathIsSlowDevice( const QString &path );
%Docstring
Returns ``True`` if the specified ``path`` is known to reside on a slow device, e.g. a remote
Returns ``True`` if the specified ``path`` is assumed to reside on a slow device, e.g. a remote
network drive or other non-fixed device.

.. versionadded:: 3.20
@@ -225,6 +225,22 @@ class CORE_EXPORT Qgis
};
Q_ENUM( VectorExportResult )

/**
* Drive types
* \since QGIS 3.20
*/
enum class DriveType : int
{
Unknown, //!< Unknown type
Invalid, //!< Invalid path
Removable, //!< Removable drive
Fixed, //!< Fixed drive
Remote, //!< Remote drive
CdRom, //!< CD-ROM
RamDisk, //!< RAM disk
};
Q_ENUM( DriveType )

/**
* Identify search radius in mm
* \since QGIS 2.3
@@ -281,7 +281,7 @@ std::unique_ptr< wchar_t[] > pathToWChar( const QString &path )
}
#endif

QgsFileUtils::DriveType QgsFileUtils::driveType( const QString &path )
Qgis::DriveType QgsFileUtils::driveType( const QString &path )
{
#ifdef MSVC
auto pathType = [ = ]( const QString & path ) -> DriveType
@@ -291,25 +291,25 @@ QgsFileUtils::DriveType QgsFileUtils::driveType( const QString &path )
switch ( type )
{
case DRIVE_UNKNOWN:
return Unknown;
return Qgis::DriveType::Unknown;

case DRIVE_NO_ROOT_DIR:
return Invalid;
return Qgis::DriveType::Invalid;

case DRIVE_REMOVABLE:
return Removable;
return Qgis::DriveType::Removable;

case DRIVE_FIXED:
return Fixed;
return Qgis::DriveType::Fixed;

case DRIVE_REMOTE:
return Remote;
return Qgis::DriveType::Remote;

case DRIVE_CDROM:
return CdRom;
return Qgis::DriveType::CdRom;

case DRIVE_RAMDISK:
return RamDisk;
return Qgis::DriveType::RamDisk;
}

return Unknown;
@@ -339,18 +339,18 @@ bool QgsFileUtils::pathIsSlowDevice( const QString &path )
{
try
{
const DriveType type = driveType( path );
const Qgis::DriveType type = driveType( path );
switch ( type )
{
case QgsFileUtils::Unknown:
case QgsFileUtils::Invalid:
case QgsFileUtils::Fixed:
case QgsFileUtils::RamDisk:
case Qgis::DriveType::Unknown:
case Qgis::DriveType::Invalid:
case Qgis::DriveType::Fixed:
case Qgis::DriveType::RamDisk:
return false;

case QgsFileUtils::Removable:
case QgsFileUtils::Remote:
case QgsFileUtils::CdRom:
case Qgis::DriveType::Removable:
case Qgis::DriveType::Remote:
case Qgis::DriveType::CdRom:
return true;
}
}
@@ -20,6 +20,7 @@

#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgis.h"
#include <QString>

/**
@@ -119,32 +120,17 @@ class CORE_EXPORT QgsFileUtils
*/
static QStringList findFile( const QString &file, const QString &basepath = QString(), int maxClimbs = 4, int searchCeiling = 4, const QString &currentDir = QString() );

/**
* Drive types
* \since QGIS 3.20
*/
enum DriveType
{
Unknown, //!< Unknown type
Invalid, //!< Invalid path
Removable, //!< Removable drive
Fixed, //!< Fixed drive
Remote, //!< Remote drive
CdRom, //!< CD-ROM
RamDisk, //!< RAM disk
};

/**
* Returns the drive type for the given \a path.
*
* \throws QgsNotSupportedException if determining the drive type is not supported on the current platform.
*
* \since QGIS 3.20
*/
static DriveType driveType( const QString &path ) SIP_THROW( QgsNotSupportedException );
static Qgis::DriveType driveType( const QString &path ) SIP_THROW( QgsNotSupportedException );

/**
* Returns TRUE if the specified \a path is known to reside on a slow device, e.g. a remote
* Returns TRUE if the specified \a path is assumed to reside on a slow device, e.g. a remote
* network drive or other non-fixed device.
*
* \since QGIS 3.20

0 comments on commit 95c01cc

Please sign in to comment.