Skip to content
Permalink
Browse files

[processing] remove similar widgets (use generic one instead)

  • Loading branch information
alexbruy committed Nov 6, 2014
1 parent c3d230c commit 28c03a1cd9fca98c3c643eae3cc8c2899c0fa904
@@ -31,7 +31,7 @@
from PyQt4.QtGui import *
from qgis.utils import iface
from processing.core.Processing import Processing
from processing.gui.MissingDependencyDialog import MissingDependencyDialog
from processing.gui.MessageDialog import MessageDialog
from processing.gui.ParametersDialog import ParametersDialog
from processing.tools import dataobjects
from processing.tools.system import *
@@ -205,7 +205,9 @@ def runAlgorithm(self, alg):
alg = alg.getCopy()
message = alg.checkBeforeOpeningParametersDialog()
if message:
dlg = MissingDependencyDialog(message)
dlg = MessageDialog()
dlg.setTitle(self.tr('Missing dependency'))
dlg.setMessage(msg)
dlg.exec_()
return
dlg = alg.getCustomParametersDialog()
@@ -31,15 +31,17 @@
from qgis.gui import *
from qgis.core import *

from processing.ui.ui_widgetCRSSelector import Ui_widgetCRSSelector
from processing.ui.ui_widgetBaseSelector import Ui_Form

class CrsSelectionPanel(QWidget, Ui_widgetCRSSelector):
class CrsSelectionPanel(QWidget, Ui_Form):

def __init__(self, default):
QWidget.__init__(self)
self.setupUi(self)

self.btnBrowse.clicked.connect(self.browseCRS)
self.leText.setEnabled(False)

self.btnBSelect.clicked.connect(self.browseCRS)
self.authId = QgsCoordinateReferenceSystem(default).authid()
self.updateText()

@@ -56,7 +58,7 @@ def browseCRS(self):

def updateText(self):
if self.authId is not None:
self.leCRS.setText(self.authId)
self.leText.setText(self.authId)

def getValue(self):
return self.authId
@@ -37,7 +37,7 @@
from processing.core.parameters import ParameterMultipleInput
from processing.tools import dataobjects

from processing.ui.ui_widgetExtentSelector import Ui_Form
from processing.ui.ui_widgetBaseSelector import Ui_Form

class ExtentSelectionPanel(QWidget, Ui_Form):

@@ -48,8 +48,8 @@ def __init__(self, dialog, alg, default):
self.dialog = dialog
self.params = alg.parameters
if self.canUseAutoExtent():
if hasattr(self.leExtent, 'setPlaceholderText'):
self.leExtent.setPlaceholderText(
if hasattr(self.leText, 'setPlaceholderText'):
self.leText.setPlaceholderText(
self.tr('[Leave blank to use min covering extent]'))

self.btnSelect.clicked.connect(self.selectExtent)
@@ -92,7 +92,7 @@ def selectExtent(self):
popupmenu.exec_(QCursor.pos())

def useMinCoveringExtent(self):
self.leExtent.setText('')
self.leText.setText('')

def getMinCoveringExtent(self):
first = True
@@ -165,7 +165,7 @@ def setValueFromRect(self, r):
s = '{},{},{},{}'.format(
r.xMinimum(), r.xMaximum(), r.yMinimum(), r.yMaximum())

self.leExtent.setText(s)
self.leText.setText(s)
self.tool.reset()
canvas = iface.mapCanvas()
canvas.setMapTool(self.prevMapTool)
@@ -174,7 +174,7 @@ def setValueFromRect(self, r):
self.dialog.activateWindow()

def getValue(self):
if str(self.leExtent.text()).strip() != '':
return str(self.leExtent.text())
if str(self.leText.text()).strip() != '':
return unicode(self.leText.text())
else:
return self.getMinCoveringExtent()
@@ -37,9 +37,9 @@
from processing.core.outputs import OutputVector
from processing.core.outputs import OutputDirectory

from processing.ui.ui_widgetOutputSelect import Ui_widgetOutputSelect
from processing.ui.ui_widgetBaseSelector import Ui_Form

class OutputSelectionPanel(QWidget, Ui_widgetOutputSelect):
class OutputSelectionPanel(QWidget, Ui_Form):

SAVE_TO_TEMP_FILE = QCoreApplication.translate(
'OutputSelectionPanel', '[Save to temporary file]')
@@ -51,10 +51,10 @@ def __init__(self, output, alg):
self.output = output
self.alg = alg

if hasattr(self.text, 'setPlaceholderText'):
self.text.setPlaceholderText(self.SAVE_TO_TEMP_FILE)
if hasattr(self.leText, 'setPlaceholderText'):
self.leText.setPlaceholderText(self.SAVE_TO_TEMP_FILE)

self.btnBrowse.clicked.connect(self.selectOutput)
self.btnSelect.clicked.connect(self.selectOutput)

def selectOutput(self):
if isinstance(self.output, OutputDirectory):
@@ -63,29 +63,29 @@ def selectOutput(self):
popupMenu = QMenu()

actionSaveToTempFile = QAction(
self.tr('Save to a temporary file'), self.btnBrowse)
self.tr('Save to a temporary file'), self.btnSelect)
actionSaveToTempFile.triggered.connect(self.saveToTemporaryFile)
popupMenu.addAction(actionSaveToTempFile)

actionSaveToFile = QAction(
self.tr('Save to file...'), self.btnBrowse)
self.tr('Save to file...'), self.btnSelect)
actionSaveToFile.triggered.connect(self.selectFile)
popupMenu.addAction(actionSaveToFile)

if isinstance(self.output, OutputVector) \
and self.alg.provider.supportsNonFileBasedOutput():
actionSaveToMemory = QAction(
self.tr('Save to memory layer'), self.btnBrowse)
self.tr('Save to memory layer'), self.btnSelect)
actionSaveToMemory.triggered.connect(self.saveToMemory)
popupMenu.addAction(actionSaveToMemory)

popupMenu.exec_(QCursor.pos())

def saveToTemporaryFile(self):
self.text.setText('')
self.leText.setText('')

def saveToMemory(self):
self.text.setText('memory:')
self.leText.setText('memory:')

def selectFile(self):
fileFilter = self.output.getFileFilter(self.alg)
@@ -114,7 +114,7 @@ def selectFile(self):
ext = re.search("\*(\.[a-z]{1,5})", selectedFileFilter)
if ext:
fileName += ext.group(1)
self.text.setText(fileName)
self.leText.setText(fileName)
settings.setValue('/Processing/LastOutputPath',
os.path.dirname(fileName))
settings.setValue('/Processing/encoding', encoding)
@@ -125,10 +125,10 @@ def selectDirectory(self):
dirName = QFileDialog.getExistingDirectory(self,
self.tr('Select directory'), lastDir, QFileDialog.ShowDirsOnly)

self.text.setText(dirName)
self.leText.setText(dirName)

def getValue(self):
fileName = unicode(self.text.text())
fileName = unicode(self.leText.text())
if fileName.strip() in ['', self.SAVE_TO_TEMP_FILE]:
value = None
elif fileName.startswith('memory:'):
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<width>249</width>
<height>23</height>
</rect>
</property>
@@ -21,7 +21,7 @@
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="leExtent"/>
<widget class="QLineEdit" name="leText"/>
</item>
<item>
<widget class="QToolButton" name="btnSelect">

This file was deleted.

@@ -7,13 +7,16 @@
<x>0</x>
<y>0</y>
<width>251</width>
<height>24</height>
<height>23</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>0</number>
</property>

This file was deleted.

0 comments on commit 28c03a1

Please sign in to comment.
You can’t perform that action at this time.