Skip to content
Permalink
Browse files
redirect custom widget includes to qgis.gui
  • Loading branch information
3nids committed May 12, 2014
1 parent 196d7d8 commit ee522ec5001e387ed553b04e0b7b7669dc38cb72
Showing with 44 additions and 0 deletions.
  1. +1 −0 python/CMakeLists.txt
  2. +4 −0 python/__init__.py
  3. +33 −0 python/customwidgets.py
  4. +6 −0 src/customwidgets/qgiscustomwidgets.cpp
@@ -179,6 +179,7 @@ ENDIF(WITH_QSCIAPI)
SET(PY_FILES
__init__.py
utils.py
customwidgets.py
)

ADD_CUSTOM_TARGET(pyutils ALL)
@@ -24,6 +24,8 @@
__revision__ = '$Format:%H$'

import sip
from customwidgets import referenceCustomWidgets

try:
apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"]
for api in apis:
@@ -34,6 +36,8 @@

from qgis.core import QgsFeature, QgsGeometry

referenceCustomWidgets()

try:
# Add a __nonzero__ method onto QPyNullVariant so we can check for null values easier.
# >>> value = QPyNullVariant("int")
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
customwidgets.py
---------------------
Date : May 2014
Copyright : (C) 2014 by Denis Rouzaud
Email : denis.rouzaud@gmail.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. *
* *
***************************************************************************
"""

import sys
import qgis
from qgis import gui

"""
This allow to redirect the custom widget include header file to qgis.gui
"""

def referenceCustomWidgets():
sys.modules["qgscollapsiblegroupboxplugin"] = qgis.gui
sys.modules["qgsfieldcomboboxplugin"] = qgis.gui
sys.modules["qgsfieldexpressionwidgetplugin"] = qgis.gui
sys.modules["qgsmaplayercomboboxplugin"] = qgis.gui
sys.modules["qgsscalevisibilitywidgetplugin"] = qgis.gui
@@ -27,6 +27,12 @@
QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
: QObject( parent )
{

// !!!!!!!!!!!!!!!!!!!!!
// do not forget to add the corresponding line in python/customwidgets.py
// to make the custom widget available from python
// !!!!!!!!!!!!!!!!!!!!!

mWidgets.append( new QgsCollapsibleGroupBoxPlugin );
mWidgets.append( new QgsFieldComboBoxPlugin );
mWidgets.append( new QgsFieldExpressionWidgetPlugin );

0 comments on commit ee522ec

Please sign in to comment.