Skip to content

Commit

Permalink
use specific PyQt4/uic widget-plugins module for python compilation o…
Browse files Browse the repository at this point in the history
…f widgets
  • Loading branch information
3nids committed May 12, 2014
1 parent d83f3ec commit 38c694d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Expand Up @@ -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

Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion python/CMakeLists.txt
Expand Up @@ -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}")
Expand Down
3 changes: 0 additions & 3 deletions python/__init__.py
Expand Up @@ -24,7 +24,6 @@
__revision__ = '$Format:%H$'

import sip
from customwidgets import referenceCustomWidgets

try:
apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"]
Expand All @@ -36,8 +35,6 @@

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
Expand Up @@ -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",\
)
3 changes: 1 addition & 2 deletions src/gui/qgsmaplayercombobox.h
Expand Up @@ -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();
Expand All @@ -62,7 +62,6 @@ class GUI_EXPORT QgsMapLayerComboBox : public QComboBox

private:
QgsMapLayerProxyModel* mProxyModel;

};

#endif // QGSMAPLAYERCOMBOBOX_H

0 comments on commit 38c694d

Please sign in to comment.