Skip to content

Commit

Permalink
redirect custom widget includes to qgis.gui
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed May 12, 2014
1 parent 196d7d8 commit ee522ec
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ ENDIF(WITH_QSCIAPI)
SET(PY_FILES
__init__.py
utils.py
customwidgets.py
)

ADD_CUSTOM_TARGET(pyutils ALL)
Expand Down
4 changes: 4 additions & 0 deletions python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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")
Expand Down
33 changes: 33 additions & 0 deletions python/customwidgets.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions src/customwidgets/qgiscustomwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit ee522ec

Please sign in to comment.