Skip to content

Commit 826c440

Browse files
committed
Python bindings
1 parent 82d1871 commit 826c440

10 files changed

+276
-0
lines changed

python/core/core.sip

+10
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
%Include qgsfield.sip
6262
%Include qgsfieldconstraints.sip
6363
%Include qgsfields.sip
64+
%Include qgsfieldkitregistry.sip
65+
%Include qgsfieldkit.sip
6466
%Include qgsgeometrysimplifier.sip
6567
%Include qgsgeometryvalidator.sip
6668
%Include qgsgml.sip
@@ -242,6 +244,14 @@
242244
%Include gps/qgsnmeaconnection.sip
243245
%Include gps/qgsqtlocationconnection.sip
244246

247+
%Include fieldkit/qgsdatetimefieldkit.sip
248+
%Include fieldkit/qgsfallbackfieldkit.sip
249+
%Include fieldkit/qgskeyvaluefieldkit.sip
250+
%Include fieldkit/qgslistfieldkit.sip
251+
%Include fieldkit/qgsrelationreferencefieldkit.sip
252+
%Include fieldkit/qgsvaluemapfieldkit.sip
253+
%Include fieldkit/qgsvaluerelationfieldkit.sip
254+
245255
%Include layertree/qgslayertree.sip
246256
%Include layertree/qgslayertreegroup.sip
247257
%Include layertree/qgslayertreelayer.sip
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/***************************************************************************
2+
qgsdatetimefieldkit.sip - QgsDateTimeFieldKit
3+
4+
---------------------
5+
begin : 2.12.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+
class QgsDateTimeFieldKit : QgsFieldKit
17+
{
18+
%TypeHeaderCode
19+
#include "qgsdatetimefieldkit.h"
20+
%End
21+
public:
22+
QgsDateTimeFieldKit();
23+
24+
QString id() const;
25+
26+
virtual QString representValue( QgsVectorLayer* layer, int fieldIndex, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;
27+
28+
static QString defaultFormat( const QVariant::Type type );
29+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class QgsFallbackFieldKit : QgsFieldKit
2+
{
3+
%TypeHeaderCode
4+
#include "qgsfallbackfieldkit.h"
5+
%End
6+
public:
7+
QgsFallbackFieldKit();
8+
QString id() const;
9+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/***************************************************************************
2+
qgskeyvaluefieldkit.sip - QgsKeyValueFieldKit
3+
4+
---------------------
5+
begin : 3.12.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+
class QgsKeyValueFieldKit : QgsFieldKit
17+
{
18+
%TypeHeaderCode
19+
#include "qgskeyvaluefieldkit"
20+
%End
21+
public:
22+
QgsKeyValueFieldKit();
23+
QString id() const;
24+
QString representValue( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;
25+
};
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/***************************************************************************
2+
qgslistfieldkit.sip - QgsListFieldKit
3+
4+
---------------------
5+
begin : 3.12.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+
class QgsListFieldKit : QgsFieldKit
17+
{
18+
%TypeHeaderCode
19+
#include "qgslistfieldkit.h"
20+
%End
21+
22+
public:
23+
QgsListFieldKit();
24+
25+
QString id() const;
26+
27+
QString representValue( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;
28+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/***************************************************************************
2+
qgsrelationreferencefieldkit.sip - QgsRelationReferenceFieldKit
3+
4+
---------------------
5+
begin : 3.12.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+
17+
class QgsRelationReferenceFieldKit : QgsFieldKit
18+
{
19+
%TypeHeaderCode
20+
#include "qgsrelationreferencefieldkit"
21+
%End
22+
public:
23+
QgsRelationReferenceFieldKit();
24+
25+
QString id() const;
26+
27+
virtual QString representValue( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const override;
28+
29+
virtual QVariant sortValue( QgsVectorLayer *vl, int fieldIdx, const QVariantMap&config, const QVariant& cache, const QVariant& value ) const override;
30+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/***************************************************************************
2+
qgsvaluemapfieldkit.sip - QgsValueMapFieldKit
3+
4+
---------------------
5+
begin : 3.12.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+
class QgsValueMapFieldKit : QgsFieldKit
17+
{
18+
%TypeHeaderCode
19+
#include "qgsvaluemapfieldkit.h"
20+
%End
21+
public:
22+
QgsValueMapFieldKit();
23+
24+
QString id() const;
25+
26+
QString representValue( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;
27+
28+
QVariant sortValue( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;
29+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/***************************************************************************
2+
qgsvaluerelationfieldkit.sip - QgsValueRelationFieldKit
3+
4+
---------------------
5+
begin : 3.12.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+
class QgsValueRelationFieldKit : QgsFieldKit
17+
{
18+
%TypeHeaderCode
19+
#include "qgsvaluerelationfieldkit"
20+
%End
21+
22+
public:
23+
struct ValueRelationItem
24+
{
25+
ValueRelationItem( const QVariant& key, const QString& value );
26+
27+
ValueRelationItem();
28+
29+
QVariant key;
30+
QString value;
31+
};
32+
33+
typedef QVector < ValueRelationItem > ValueRelationCache;
34+
35+
QgsValueRelationFieldKit();
36+
37+
QString id() const;
38+
QString representValue( QgsVectorLayer *layer, int fieldIdx, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const;
39+
40+
QVariant sortValue( QgsVectorLayer *vl, int fieldIdx, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const;
41+
42+
QVariant createCache( QgsVectorLayer *vl, int fieldIdx, const QVariantMap &config ) const;
43+
44+
static ValueRelationCache createCache( const QVariantMap& config );
45+
};

python/core/qgsfieldkit.sip

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/***************************************************************************
2+
qgsfieldkit.sip - QgsFieldKit
3+
4+
---------------------
5+
begin : 2.12.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+
class QgsFieldKit
17+
{
18+
%TypeHeaderCode
19+
#include "qgsfieldkit.h"
20+
%End
21+
public:
22+
QgsFieldKit();
23+
24+
virtual ~QgsFieldKit();
25+
26+
virtual QString id() const = 0;
27+
28+
virtual QString representValue( QgsVectorLayer* layer, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;
29+
30+
virtual QVariant sortValue( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;
31+
32+
virtual Qt::AlignmentFlag alignmentFlag( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config ) const;
33+
34+
virtual QVariant createCache( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config ) const;
35+
};

python/core/qgsfieldkitregistry.sip

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/***************************************************************************
2+
qgsfieldkitregistry.sip - QgsFieldKitRegistry
3+
4+
---------------------
5+
begin : 2.12.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+
class QgsFieldKitRegistry : QObject
17+
{
18+
%TypeHeaderCode
19+
#include "qgsfieldkitregistry.h"
20+
%End
21+
public:
22+
23+
QgsFieldKitRegistry();
24+
~QgsFieldKitRegistry();
25+
26+
void addFieldKit( QgsFieldKit* kit /Transfer/ );
27+
28+
void removeFieldKit( QgsFieldKit* kit );
29+
30+
QgsFieldKit* fieldKit( const QString& id ) const;
31+
32+
signals:
33+
void fieldKitAdded( QgsFieldKit* kit );
34+
35+
void fieldKitRemoved( QgsFieldKit* kit );
36+
};

0 commit comments

Comments
 (0)