Skip to content

Commit

Permalink
[processing] load UI files dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed May 19, 2015
1 parent 30dbd8f commit d8e1cf3
Show file tree
Hide file tree
Showing 60 changed files with 253 additions and 2,034 deletions.
5 changes: 1 addition & 4 deletions python/plugins/processing/CMakeLists.txt
Expand Up @@ -8,12 +8,9 @@ ADD_SUBDIRECTORY(modeler)
ADD_SUBDIRECTORY(script)
ADD_SUBDIRECTORY(tools)
ADD_SUBDIRECTORY(tests)

FILE(GLOB UI_FILES ui/*.ui)
PYQT4_WRAP_UI(PYUI_FILES ${UI_FILES})
ADD_SUBDIRECTORY(ui)

FILE(GLOB OTHER_FILES metadata.txt)
FILE(GLOB PY_FILES *.py)

PLUGIN_INSTALL(processing . ${PY_FILES} ${OTHER_FILES})
PLUGIN_INSTALL(processing ui ${PYUI_FILES} ui/__init__.py)
4 changes: 1 addition & 3 deletions python/plugins/processing/algs/qgis/ui/CMakeLists.txt
@@ -1,6 +1,4 @@
FILE(GLOB PY_FILES *.py)

FILE(GLOB UI_FILES *.ui)
PYQT4_WRAP_UI(PYUI_FILES ${UI_FILES})

PLUGIN_INSTALL(processing ./algs/qgis/ui ${PY_FILES} ${PYUI_FILES})
PLUGIN_INSTALL(processing ./algs/qgis/ui ${PY_FILES} ${UI_FILES})
Expand Up @@ -28,6 +28,7 @@
import os
import re

from PyQt4 import uic
from PyQt4.QtCore import Qt, QSettings
from PyQt4.QtGui import QDialog, QFileDialog, QApplication, QCursor, QMessageBox
from qgis.gui import QgsEncodingFileDialog
Expand All @@ -38,12 +39,14 @@
from processing.tools import dataobjects
from processing.gui.Postprocessing import handleAlgorithmResults

from ui_DlgFieldsCalculator import Ui_FieldsCalculator
pluginPath = os.path.dirname(__file__)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'DlgFieldsCalculator.ui'))


class FieldsCalculatorDialog(QDialog, Ui_FieldsCalculator):
class FieldsCalculatorDialog(BASE, WIDGET):
def __init__(self, alg):
QDialog.__init__(self)
super(FieldsCalculatorDialog, self).__init__(None)
self.setupUi(self)

self.executed = False
Expand Down
12 changes: 8 additions & 4 deletions python/plugins/processing/algs/qgis/ui/FieldsMappingPanel.py
Expand Up @@ -25,17 +25,21 @@

__revision__ = '$Format:%H$'

import os

from collections import OrderedDict

from PyQt4 import uic
from PyQt4 import QtCore, QtGui

from qgis.core import QgsExpression
from qgis.gui import QgsFieldExpressionWidget

from processing.tools import dataobjects

from .ui_widgetFieldsMapping import Ui_Form
pluginPath = os.path.dirname(__file__)
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'widgetFieldsMapping.ui'))


class FieldsMappingModel(QtCore.QAbstractTableModel):
Expand All @@ -45,7 +49,7 @@ class FieldsMappingModel(QtCore.QAbstractTableModel):
(QtCore.QVariant.Double, "Double"),
(QtCore.QVariant.String, "String"),
(QtCore.QVariant.DateTime, "Date"),
(QtCore.QVariant.LongLong, "Double"),
(QtCore.QVariant.LongLong, "Double"),
(QtCore.QVariant.Date, "Date")])

columns = [
Expand Down Expand Up @@ -297,10 +301,10 @@ def on_expression_fieldChange(self, fieldName):
self.commitData.emit(self.sender())


class FieldsMappingPanel(QtGui.QWidget, Ui_Form):
class FieldsMappingPanel(BASE, WIDGET):

def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
super(FieldsMappingPanel, self).__init__(parent)
self.setupUi(self)

self.addButton.setIcon(
Expand Down
148 changes: 0 additions & 148 deletions python/plugins/processing/algs/qgis/ui/ui_DlgFieldsCalculator.py

This file was deleted.

107 changes: 0 additions & 107 deletions python/plugins/processing/algs/qgis/ui/ui_widgetFieldsMapping.py

This file was deleted.

14 changes: 10 additions & 4 deletions python/plugins/processing/gui/AlgorithmDialogBase.py
Expand Up @@ -25,16 +25,22 @@

__revision__ = '$Format:%H$'

import os

from PyQt4 import uic
from PyQt4.QtCore import QCoreApplication, QUrl
from PyQt4.QtGui import QDialog, QApplication, QDialogButtonBox
from PyQt4.QtGui import QApplication, QDialogButtonBox

from qgis.utils import iface

from processing.core.ProcessingConfig import ProcessingConfig
from processing.ui.ui_DlgAlgorithmBase import Ui_Dialog

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
os.path.join(pluginPath, 'ui', 'DlgAlgorithmBase.ui'))


class AlgorithmDialogBase(QDialog, Ui_Dialog):
class AlgorithmDialogBase(BASE, WIDGET):

class InvalidParameterValue(Exception):

Expand All @@ -43,7 +49,7 @@ def __init__(self, param, widget):


def __init__(self, alg):
QDialog.__init__(self, iface.mainWindow())
super(AlgorithmDialogBase, self).__init__(iface.mainWindow())
self.setupUi(self)

self.executed = False
Expand Down

0 comments on commit d8e1cf3

Please sign in to comment.