/
qgsprocessingprovider.cpp
106 lines (87 loc) · 3.18 KB
/
qgsprocessingprovider.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/***************************************************************************
qgsprocessingprovider.cpp
--------------------------
begin : December 2016
copyright : (C) 2016 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsprocessingprovider.h"
#include "qgsapplication.h"
#include "qgsvectorfilewriter.h"
#include "qgssettings.h"
QgsProcessingProvider::QgsProcessingProvider( QObject *parent SIP_TRANSFERTHIS )
: QObject( parent )
{}
QgsProcessingProvider::~QgsProcessingProvider()
{
qDeleteAll( mAlgorithms );
}
QIcon QgsProcessingProvider::icon() const
{
return QgsApplication::getThemeIcon( "/processingAlgorithm.svg" );
}
QString QgsProcessingProvider::svgIconPath() const
{
return QgsApplication::iconPath( QStringLiteral( "processingAlgorithm.svg" ) );
}
QString QgsProcessingProvider::longName() const
{
return name();
}
void QgsProcessingProvider::refreshAlgorithms()
{
qDeleteAll( mAlgorithms );
mAlgorithms.clear();
loadAlgorithms();
emit algorithmsLoaded();
}
QList<const QgsProcessingAlgorithm *> QgsProcessingProvider::algorithms() const
{
return mAlgorithms.values();
}
const QgsProcessingAlgorithm *QgsProcessingProvider::algorithm( const QString &name ) const
{
return mAlgorithms.value( name );
}
bool QgsProcessingProvider::addAlgorithm( QgsProcessingAlgorithm *algorithm )
{
if ( !algorithm )
return false;
if ( mAlgorithms.contains( algorithm->name() ) )
return false;
// init the algorithm - this allows direct querying of the algorithm's parameters
// and outputs from the provider's copy
algorithm->initAlgorithm( QVariantMap() );
algorithm->setProvider( this );
mAlgorithms.insert( algorithm->name(), algorithm );
return true;
}
QStringList QgsProcessingProvider::supportedOutputVectorLayerExtensions() const
{
return QgsVectorFileWriter::supportedFormatExtensions();
}
QString QgsProcessingProvider::defaultVectorFileExtension( bool hasGeometry ) const
{
QgsSettings settings;
if ( hasGeometry )
{
return settings.value( QStringLiteral( "Processing/DefaultOutputVectorLayerExt" ), QStringLiteral( "shp" ), QgsSettings::Core ).toString();
}
else
{
return QStringLiteral( "dbf" );
}
}
QString QgsProcessingProvider::defaultRasterFileExtension() const
{
QgsSettings settings;
return settings.value( QStringLiteral( "Processing/DefaultOutputRasterLayerExt" ), QStringLiteral( "tif" ), QgsSettings::Core ).toString();
}