use specific PyQt4/uic widget-plugins module for python compilation of widgets

This commit is contained in:
Denis Rouzaud 2014-05-07 16:41:59 +02:00
parent d83f3ec4e6
commit 38c694d9ad
5 changed files with 25 additions and 18 deletions

View File

@ -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

View File

@ -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}")

View File

@ -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")

View File

@ -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",\
)

View File

@ -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