diff --git a/CMakeLists.txt b/CMakeLists.txt index b14716e5183..36e6b3c7cb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -558,6 +558,7 @@ IF (UNIX AND NOT APPLE) SET (QGIS_MANUAL_DIR ${CMAKE_INSTALL_PREFIX}/${QGIS_MANUAL_SUBDIR}) ENDIF (UNIX AND NOT APPLE) + ############################################################# # Python bindings @@ -583,6 +584,10 @@ IF (WITH_BINDINGS) SET(PYTHON_SITE_PACKAGES_DIR ${QGIS_DATA_DIR}/python) ENDIF (NOT BINDINGS_GLOBAL_INSTALL) + IF (WITH_CUSTOM_WIDGETS) + SET(PYUIC_WIDGET_PLUGIN_DIRECTORY ${PYQT4_MOD_DIR}/uic/widget-plugins/) + ENDIF (WITH_CUSTOM_WIDGETS) + ENDIF (WITH_BINDINGS) # Set QSCINTILLA_VERSION_STR to that of module, if no headers found diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index e218f3e770b..9b079b061d9 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -179,8 +179,10 @@ ENDIF(WITH_QSCIAPI) SET(PY_FILES __init__.py utils.py - customwidgets.py ) +IF(WITH_CUSTOM_WIDGETS) + INSTALL(FILES custom_widgets/qgis_customwidgets.py DESTINATION "${PYUIC_WIDGET_PLUGIN_DIRECTORY}") +ENDIF(WITH_CUSTOM_WIDGETS) ADD_CUSTOM_TARGET(pyutils ALL) INSTALL(FILES ${PY_FILES} DESTINATION "${QGIS_PYTHON_DIR}") diff --git a/python/__init__.py b/python/__init__.py index 37e0b29064a..d89d7aead34 100755 --- a/python/__init__.py +++ b/python/__init__.py @@ -24,7 +24,6 @@ __copyright__ = '(C) 2007, Martin Dobias' __revision__ = '$Format:%H$' import sip -from customwidgets import referenceCustomWidgets try: apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"] @@ -36,8 +35,6 @@ except ValueError: 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") diff --git a/python/customwidgets.py b/python/custom_widgets/qgis_customwidgets.py similarity index 54% rename from python/customwidgets.py rename to python/custom_widgets/qgis_customwidgets.py index 45836d91b1e..e95a9ce9d9c 100644 --- a/python/customwidgets.py +++ b/python/custom_widgets/qgis_customwidgets.py @@ -17,17 +17,21 @@ *************************************************************************** """ -import sys -import qgis -from qgis import gui +# If pluginType is MODULE, the plugin loader will call moduleInformation. The +# variable MODULE is inserted into the local namespace by the plugin loader. +pluginType = MODULE -""" - 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 +# moduleInformation() must return a tuple (module, widget_list). If "module" +# is "A" and any widget from this module is used, the code generator will write +# "import A". If "module" is "A[.B].C", the code generator will write +# "from A[.B] import C". Each entry in "widget_list" must be unique. +def moduleInformation(): + return "qgis.gui", \ + ("QgsCollapsibleGroupbox" ,\ + "QgsFieldComboBox" ,\ + "QgsFieldExpressionWidget",\ + "QgsMapLayerComboBox" ,\ + "QgsMapLayerProxyModel" ,\ + "QgsScalevisibilityWidget",\ + ) diff --git a/src/gui/qgsmaplayercombobox.h b/src/gui/qgsmaplayercombobox.h index 483a6499efa..b2b160b718f 100644 --- a/src/gui/qgsmaplayercombobox.h +++ b/src/gui/qgsmaplayercombobox.h @@ -44,7 +44,7 @@ class GUI_EXPORT QgsMapLayerComboBox : public QComboBox void setFilters( QgsMapLayerProxyModel::Filters filters ); //! currently used filter on list layers - QgsMapLayerProxyModel::Filters filters() {return mProxyModel->filters();} + QgsMapLayerProxyModel::Filters filters() { return mProxyModel->filters(); } //! currentLayer returns the current layer selected in the combo box QgsMapLayer* currentLayer(); @@ -62,7 +62,6 @@ class GUI_EXPORT QgsMapLayerComboBox : public QComboBox private: QgsMapLayerProxyModel* mProxyModel; - }; #endif // QGSMAPLAYERCOMBOBOX_H