Skip to content

Commit

Permalink
Python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Dec 20, 2016
1 parent 82d1871 commit 826c440
Show file tree
Hide file tree
Showing 10 changed files with 276 additions and 0 deletions.
10 changes: 10 additions & 0 deletions python/core/core.sip
Expand Up @@ -61,6 +61,8 @@
%Include qgsfield.sip
%Include qgsfieldconstraints.sip
%Include qgsfields.sip
%Include qgsfieldkitregistry.sip
%Include qgsfieldkit.sip
%Include qgsgeometrysimplifier.sip
%Include qgsgeometryvalidator.sip
%Include qgsgml.sip
Expand Down Expand Up @@ -242,6 +244,14 @@
%Include gps/qgsnmeaconnection.sip
%Include gps/qgsqtlocationconnection.sip

%Include fieldkit/qgsdatetimefieldkit.sip
%Include fieldkit/qgsfallbackfieldkit.sip
%Include fieldkit/qgskeyvaluefieldkit.sip
%Include fieldkit/qgslistfieldkit.sip
%Include fieldkit/qgsrelationreferencefieldkit.sip
%Include fieldkit/qgsvaluemapfieldkit.sip
%Include fieldkit/qgsvaluerelationfieldkit.sip

%Include layertree/qgslayertree.sip
%Include layertree/qgslayertreegroup.sip
%Include layertree/qgslayertreelayer.sip
Expand Down
29 changes: 29 additions & 0 deletions python/core/fieldkit/qgsdatetimefieldkit.sip
@@ -0,0 +1,29 @@
/***************************************************************************
qgsdatetimefieldkit.sip - QgsDateTimeFieldKit

---------------------
begin : 2.12.2016
copyright : (C) 2016 by Matthias Kuhn
email : matthias@opengis.ch
***************************************************************************
* *
* 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. *
* *
***************************************************************************/
class QgsDateTimeFieldKit : QgsFieldKit
{
%TypeHeaderCode
#include "qgsdatetimefieldkit.h"
%End
public:
QgsDateTimeFieldKit();

QString id() const;

virtual QString representValue( QgsVectorLayer* layer, int fieldIndex, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;

static QString defaultFormat( const QVariant::Type type );
};
9 changes: 9 additions & 0 deletions python/core/fieldkit/qgsfallbackfieldkit.sip
@@ -0,0 +1,9 @@
class QgsFallbackFieldKit : QgsFieldKit
{
%TypeHeaderCode
#include "qgsfallbackfieldkit.h"
%End
public:
QgsFallbackFieldKit();
QString id() const;
};
25 changes: 25 additions & 0 deletions python/core/fieldkit/qgskeyvaluefieldkit.sip
@@ -0,0 +1,25 @@
/***************************************************************************
qgskeyvaluefieldkit.sip - QgsKeyValueFieldKit

---------------------
begin : 3.12.2016
copyright : (C) 2016 by Matthias Kuhn
email : matthias@opengis.ch
***************************************************************************
* *
* 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. *
* *
***************************************************************************/
class QgsKeyValueFieldKit : QgsFieldKit
{
%TypeHeaderCode
#include "qgskeyvaluefieldkit"
%End
public:
QgsKeyValueFieldKit();
QString id() const;
QString representValue( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;
};
28 changes: 28 additions & 0 deletions python/core/fieldkit/qgslistfieldkit.sip
@@ -0,0 +1,28 @@
/***************************************************************************
qgslistfieldkit.sip - QgsListFieldKit

---------------------
begin : 3.12.2016
copyright : (C) 2016 by Matthias Kuhn
email : matthias@opengis.ch
***************************************************************************
* *
* 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. *
* *
***************************************************************************/
class QgsListFieldKit : QgsFieldKit
{
%TypeHeaderCode
#include "qgslistfieldkit.h"
%End

public:
QgsListFieldKit();

QString id() const;

QString representValue( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;
};
30 changes: 30 additions & 0 deletions python/core/fieldkit/qgsrelationreferencefieldkit.sip
@@ -0,0 +1,30 @@
/***************************************************************************
qgsrelationreferencefieldkit.sip - QgsRelationReferenceFieldKit

---------------------
begin : 3.12.2016
copyright : (C) 2016 by Matthias Kuhn
email : matthias@opengis.ch
***************************************************************************
* *
* 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. *
* *
***************************************************************************/

class QgsRelationReferenceFieldKit : QgsFieldKit
{
%TypeHeaderCode
#include "qgsrelationreferencefieldkit"
%End
public:
QgsRelationReferenceFieldKit();

QString id() const;

virtual QString representValue( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const override;

virtual QVariant sortValue( QgsVectorLayer *vl, int fieldIdx, const QVariantMap&config, const QVariant& cache, const QVariant& value ) const override;
};
29 changes: 29 additions & 0 deletions python/core/fieldkit/qgsvaluemapfieldkit.sip
@@ -0,0 +1,29 @@
/***************************************************************************
qgsvaluemapfieldkit.sip - QgsValueMapFieldKit

---------------------
begin : 3.12.2016
copyright : (C) 2016 by Matthias Kuhn
email : matthias@opengis.ch
***************************************************************************
* *
* 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. *
* *
***************************************************************************/
class QgsValueMapFieldKit : QgsFieldKit
{
%TypeHeaderCode
#include "qgsvaluemapfieldkit.h"
%End
public:
QgsValueMapFieldKit();

QString id() const;

QString representValue( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;

QVariant sortValue( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;
};
45 changes: 45 additions & 0 deletions python/core/fieldkit/qgsvaluerelationfieldkit.sip
@@ -0,0 +1,45 @@
/***************************************************************************
qgsvaluerelationfieldkit.sip - QgsValueRelationFieldKit

---------------------
begin : 3.12.2016
copyright : (C) 2016 by Matthias Kuhn
email : matthias@opengis.ch
***************************************************************************
* *
* 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. *
* *
***************************************************************************/
class QgsValueRelationFieldKit : QgsFieldKit
{
%TypeHeaderCode
#include "qgsvaluerelationfieldkit"
%End

public:
struct ValueRelationItem
{
ValueRelationItem( const QVariant& key, const QString& value );

ValueRelationItem();

QVariant key;
QString value;
};

typedef QVector < ValueRelationItem > ValueRelationCache;

QgsValueRelationFieldKit();

QString id() const;
QString representValue( QgsVectorLayer *layer, int fieldIdx, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const;

QVariant sortValue( QgsVectorLayer *vl, int fieldIdx, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const;

QVariant createCache( QgsVectorLayer *vl, int fieldIdx, const QVariantMap &config ) const;

static ValueRelationCache createCache( const QVariantMap& config );
};
35 changes: 35 additions & 0 deletions python/core/qgsfieldkit.sip
@@ -0,0 +1,35 @@
/***************************************************************************
qgsfieldkit.sip - QgsFieldKit

---------------------
begin : 2.12.2016
copyright : (C) 2016 by Matthias Kuhn
email : matthias@opengis.ch
***************************************************************************
* *
* 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. *
* *
***************************************************************************/
class QgsFieldKit
{
%TypeHeaderCode
#include "qgsfieldkit.h"
%End
public:
QgsFieldKit();

virtual ~QgsFieldKit();

virtual QString id() const = 0;

virtual QString representValue( QgsVectorLayer* layer, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;

virtual QVariant sortValue( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;

virtual Qt::AlignmentFlag alignmentFlag( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config ) const;

virtual QVariant createCache( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config ) const;
};
36 changes: 36 additions & 0 deletions python/core/qgsfieldkitregistry.sip
@@ -0,0 +1,36 @@
/***************************************************************************
qgsfieldkitregistry.sip - QgsFieldKitRegistry

---------------------
begin : 2.12.2016
copyright : (C) 2016 by Matthias Kuhn
email : matthias@opengis.ch
***************************************************************************
* *
* 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. *
* *
***************************************************************************/
class QgsFieldKitRegistry : QObject
{
%TypeHeaderCode
#include "qgsfieldkitregistry.h"
%End
public:

QgsFieldKitRegistry();
~QgsFieldKitRegistry();

void addFieldKit( QgsFieldKit* kit /Transfer/ );

void removeFieldKit( QgsFieldKit* kit );

QgsFieldKit* fieldKit( const QString& id ) const;

signals:
void fieldKitAdded( QgsFieldKit* kit );

void fieldKitRemoved( QgsFieldKit* kit );
};

0 comments on commit 826c440

Please sign in to comment.