Skip to content

Commit 38c694d

Browse files
committedMay 12, 2014
use specific PyQt4/uic widget-plugins module for python compilation of widgets
1 parent d83f3ec commit 38c694d

File tree

5 files changed

+25
-18
lines changed

5 files changed

+25
-18
lines changed
 

‎CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ IF (UNIX AND NOT APPLE)
558558
SET (QGIS_MANUAL_DIR ${CMAKE_INSTALL_PREFIX}/${QGIS_MANUAL_SUBDIR})
559559
ENDIF (UNIX AND NOT APPLE)
560560

561+
561562
#############################################################
562563
# Python bindings
563564

@@ -583,6 +584,10 @@ IF (WITH_BINDINGS)
583584
SET(PYTHON_SITE_PACKAGES_DIR ${QGIS_DATA_DIR}/python)
584585
ENDIF (NOT BINDINGS_GLOBAL_INSTALL)
585586

587+
IF (WITH_CUSTOM_WIDGETS)
588+
SET(PYUIC_WIDGET_PLUGIN_DIRECTORY ${PYQT4_MOD_DIR}/uic/widget-plugins/)
589+
ENDIF (WITH_CUSTOM_WIDGETS)
590+
586591
ENDIF (WITH_BINDINGS)
587592

588593
# Set QSCINTILLA_VERSION_STR to that of module, if no headers found

‎python/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,10 @@ ENDIF(WITH_QSCIAPI)
179179
SET(PY_FILES
180180
__init__.py
181181
utils.py
182-
customwidgets.py
183182
)
183+
IF(WITH_CUSTOM_WIDGETS)
184+
INSTALL(FILES custom_widgets/qgis_customwidgets.py DESTINATION "${PYUIC_WIDGET_PLUGIN_DIRECTORY}")
185+
ENDIF(WITH_CUSTOM_WIDGETS)
184186

185187
ADD_CUSTOM_TARGET(pyutils ALL)
186188
INSTALL(FILES ${PY_FILES} DESTINATION "${QGIS_PYTHON_DIR}")

‎python/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
__revision__ = '$Format:%H$'
2525

2626
import sip
27-
from customwidgets import referenceCustomWidgets
2827

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

3736
from qgis.core import QgsFeature, QgsGeometry
3837

39-
referenceCustomWidgets()
40-
4138
try:
4239
# Add a __nonzero__ method onto QPyNullVariant so we can check for null values easier.
4340
# >>> value = QPyNullVariant("int")

‎python/customwidgets.py renamed to ‎python/custom_widgets/qgis_customwidgets.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,21 @@
1717
***************************************************************************
1818
"""
1919

20-
import sys
21-
import qgis
22-
from qgis import gui
20+
# If pluginType is MODULE, the plugin loader will call moduleInformation. The
21+
# variable MODULE is inserted into the local namespace by the plugin loader.
22+
pluginType = MODULE
2323

24-
"""
25-
This allow to redirect the custom widget include header file to qgis.gui
26-
"""
2724

28-
def referenceCustomWidgets():
29-
sys.modules["qgscollapsiblegroupboxplugin"] = qgis.gui
30-
sys.modules["qgsfieldcomboboxplugin"] = qgis.gui
31-
sys.modules["qgsfieldexpressionwidgetplugin"] = qgis.gui
32-
sys.modules["qgsmaplayercomboboxplugin"] = qgis.gui
33-
sys.modules["qgsscalevisibilitywidgetplugin"] = qgis.gui
25+
# moduleInformation() must return a tuple (module, widget_list). If "module"
26+
# is "A" and any widget from this module is used, the code generator will write
27+
# "import A". If "module" is "A[.B].C", the code generator will write
28+
# "from A[.B] import C". Each entry in "widget_list" must be unique.
29+
def moduleInformation():
30+
return "qgis.gui", \
31+
("QgsCollapsibleGroupbox" ,\
32+
"QgsFieldComboBox" ,\
33+
"QgsFieldExpressionWidget",\
34+
"QgsMapLayerComboBox" ,\
35+
"QgsMapLayerProxyModel" ,\
36+
"QgsScalevisibilityWidget",\
37+
)

‎src/gui/qgsmaplayercombobox.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class GUI_EXPORT QgsMapLayerComboBox : public QComboBox
4444
void setFilters( QgsMapLayerProxyModel::Filters filters );
4545

4646
//! currently used filter on list layers
47-
QgsMapLayerProxyModel::Filters filters() {return mProxyModel->filters();}
47+
QgsMapLayerProxyModel::Filters filters() { return mProxyModel->filters(); }
4848

4949
//! currentLayer returns the current layer selected in the combo box
5050
QgsMapLayer* currentLayer();
@@ -62,7 +62,6 @@ class GUI_EXPORT QgsMapLayerComboBox : public QComboBox
6262

6363
private:
6464
QgsMapLayerProxyModel* mProxyModel;
65-
6665
};
6766

6867
#endif // QGSMAPLAYERCOMBOBOX_H

0 commit comments

Comments
 (0)
Please sign in to comment.