Skip to content

Commit 6fb3268

Browse files
committedNov 17, 2014
[processing] remove MultipleFileInputPanel as it duplicates MultipleInputPanel
homogenize UI in FileSelectionPanel and RenderinStylePanel, remove inused imports
1 parent 28c03a1 commit 6fb3268

File tree

7 files changed

+66
-137
lines changed

7 files changed

+66
-137
lines changed
 

‎python/plugins/processing/gui/CrsSelectionPanel.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
__revision__ = '$Format:%H$'
2727

2828
from PyQt4.QtGui import *
29-
from PyQt4.QtCore import *
3029

3130
from qgis.gui import *
3231
from qgis.core import *

‎python/plugins/processing/gui/ExtentSelectionPanel.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
__revision__ = '$Format:%H$'
2727

28-
from PyQt4.QtCore import *
2928
from PyQt4.QtGui import *
3029

3130
from qgis.core import *

‎python/plugins/processing/gui/FileSelectionPanel.py

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,29 @@
2626
__revision__ = '$Format:%H$'
2727

2828
import os
29-
from PyQt4 import QtGui, QtCore
29+
30+
from PyQt4.QtGui import *
31+
3032
from processing.tools.system import *
3133

34+
from processing.ui.ui_widgetBaseSelector import Ui_Form
35+
3236

33-
class FileSelectionPanel(QtGui.QWidget):
37+
class FileSelectionPanel(QWidget, Ui_Form):
38+
39+
def __init__(self, isFolder, ext=None):
40+
QWidget.__init__(self)
41+
self.setupUi(self)
3442

35-
def __init__(self, isFolder, ext = None):
36-
super(FileSelectionPanel, self).__init__(None)
3743
self.ext = ext or '*'
3844
self.isFolder = isFolder
39-
self.horizontalLayout = QtGui.QHBoxLayout(self)
40-
self.horizontalLayout.setSpacing(2)
41-
self.horizontalLayout.setMargin(0)
42-
self.text = QtGui.QLineEdit()
43-
self.text.setSizePolicy(QtGui.QSizePolicy.Expanding,
44-
QtGui.QSizePolicy.Expanding)
45-
self.horizontalLayout.addWidget(self.text)
46-
self.pushButton = QtGui.QPushButton()
47-
self.pushButton.setText(self.tr('...'))
48-
self.pushButton.clicked.connect(self.showSelectionDialog)
49-
self.horizontalLayout.addWidget(self.pushButton)
50-
self.setLayout(self.horizontalLayout)
45+
46+
self.btnSelect.clicked.connect(self.showSelectionDialog)
5147

5248
def showSelectionDialog(self):
5349
# Find the file dialog's working directory
54-
settings = QtCore.QSettings()
55-
text = unicode(self.text.text())
50+
settings = QSettings()
51+
text = self.leText.text()
5652
if os.path.isdir(text):
5753
path = text
5854
elif os.path.isdir(os.path.dirname(text)):
@@ -63,25 +59,25 @@ def showSelectionDialog(self):
6359
path = ''
6460

6561
if self.isFolder:
66-
folder = QtGui.QFileDialog.getExistingDirectory(self,
62+
folder = QFileDialog.getExistingDirectory(self,
6763
self.tr('Select folder'), path)
6864
if folder:
69-
self.text.setText(str(folder))
65+
self.leText.setText(folder)
7066
settings.setValue('/Processing/LastInputPath',
71-
os.path.dirname(unicode(folder)))
67+
os.path.dirname(folder))
7268
else:
73-
filenames = QtGui.QFileDialog.getOpenFileNames(self, self.tr('Open file'),
74-
path, '*.' + self.ext)
69+
filenames = QFileDialog.getOpenFileNames(self,
70+
self.tr('Select file'), path, '*.' + self.ext)
7571
if filenames:
76-
self.text.setText(u';'.join(filenames))
72+
self.leText.setText(u';'.join(filenames))
7773
settings.setValue('/Processing/LastInputPath',
78-
os.path.dirname(unicode(filenames[0])))
74+
os.path.dirname(filenames[0]))
7975

8076
def getValue(self):
81-
s = unicode(self.text.text())
77+
s = self.leText.text()
8278
if isWindows():
8379
s = s.replace('\\', '/')
8480
return s
8581

8682
def setText(self, text):
87-
self.text.setText(text)
83+
self.leText.setText(text)

‎python/plugins/processing/gui/MultipleFileInputPanel.py

Lines changed: 0 additions & 61 deletions
This file was deleted.

‎python/plugins/processing/gui/MultipleInputPanel.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,41 @@
2525

2626
__revision__ = '$Format:%H$'
2727

28-
from PyQt4 import QtGui
28+
from PyQt4.QtGui import *
29+
2930
from processing.gui.MultipleInputDialog import MultipleInputDialog
31+
from processing.gui.MultipleFileInputDialog import MultipleFileInputDialog
32+
33+
from processing.ui.ui_widgetBaseSelector import Ui_Form
34+
35+
class MultipleInputPanel(QWidget, Ui_Form):
3036

37+
def __init__(self, options=None, datatype=None):
38+
QWidget.__init__(self)
39+
self.setupUi(self)
3140

32-
class MultipleInputPanel(QtGui.QWidget):
41+
self.leText.setEnabled(False)
42+
self.leText.setText(self.tr('0 elements selected'))
43+
44+
self.btnSelect.clicked.connect(self.showSelectionDialog)
3345

34-
def __init__(self, options, datatype=None, parent=None):
35-
super(MultipleInputPanel, self).__init__(parent)
3646
self.options = options
3747
self.datatype = datatype
3848
self.selectedoptions = []
39-
self.horizontalLayout = QtGui.QHBoxLayout(self)
40-
self.horizontalLayout.setSpacing(2)
41-
self.horizontalLayout.setMargin(0)
42-
self.label = QtGui.QLabel()
43-
self.label.setText('0 elements selected')
44-
self.label.setSizePolicy(QtGui.QSizePolicy.Expanding,
45-
QtGui.QSizePolicy.Expanding)
46-
self.horizontalLayout.addWidget(self.label)
47-
self.pushButton = QtGui.QPushButton()
48-
self.pushButton.setText('...')
49-
self.pushButton.clicked.connect(self.showSelectionDialog)
50-
self.horizontalLayout.addWidget(self.pushButton)
51-
self.setLayout(self.horizontalLayout)
5249

5350
def setSelectedItems(self, selected):
5451
# No checking is performed!
5552
self.selectedoptions = selected
56-
self.label.setText(str(len(self.selectedoptions))
57-
+ ' elements selected')
53+
self.leText.setText(
54+
self.tr('%d elements selected') % len(self.selectedoptions))
5855

5956
def showSelectionDialog(self):
60-
61-
dlg = MultipleInputDialog(self.options, self.selectedoptions)
57+
if self.datatype is None:
58+
dlg = MultipleInputDialog(self.options, self.selectedoptions)
59+
else:
60+
dlg = MultipleFileInputDialog(self.selectedoptions)
6261
dlg.exec_()
6362
if dlg.selectedoptions is not None:
6463
self.selectedoptions = dlg.selectedoptions
65-
self.label.setText(str(len(self.selectedoptions))
66-
+ ' elements selected')
64+
self.leText.setText(
65+
self.tr('%d elements selected') % len(self.selectedoptions))

‎python/plugins/processing/gui/ParametersPanel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
from processing.gui.ExtentSelectionPanel import ExtentSelectionPanel
4848
from processing.gui.FileSelectionPanel import FileSelectionPanel
4949
from processing.gui.CrsSelectionPanel import CrsSelectionPanel
50-
from processing.gui.MultipleFileInputPanel import MultipleFileInputPanel
5150
from processing.core.parameters import ParameterRaster
5251
from processing.core.parameters import ParameterVector
5352
from processing.core.parameters import ParameterTable
@@ -294,7 +293,7 @@ def getWidgetFromParameter(self, param):
294293
item = FileSelectionPanel(param.isFolder, param.ext)
295294
elif isinstance(param, ParameterMultipleInput):
296295
if param.datatype == ParameterMultipleInput.TYPE_FILE:
297-
item = MultipleFileInputPanel()
296+
item = MultipleInputPanel(datatype=ParameterMultipleInput.TYPE_FILE)
298297
else:
299298
if param.datatype == ParameterMultipleInput.TYPE_RASTER:
300299
options = dataobjects.getRasterLayers(sorting=False)

‎python/plugins/processing/gui/RenderingStyleFilePanel.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,35 @@
2525

2626
__revision__ = '$Format:%H$'
2727

28-
import os.path
29-
from PyQt4 import QtGui, QtCore
28+
from PyQt4.QtGui import *
29+
3030
from processing.core.ProcessingConfig import ProcessingConfig
31+
from processing.tools.system import *
32+
33+
from processing.ui.ui_widgetBaseSelector import Ui_Form
3134

3235

33-
class RenderingStyleFilePanel(QtGui.QWidget):
36+
class RenderingStyleFilePanel(QWidget, Ui_Form):
3437

3538
def __init__(self):
36-
super(RenderingStyleFilePanel, self).__init__(None)
37-
self.horizontalLayout = QtGui.QHBoxLayout(self)
38-
self.horizontalLayout.setSpacing(2)
39-
self.horizontalLayout.setMargin(0)
40-
self.text = QtGui.QLineEdit()
41-
self.text.setSizePolicy(QtGui.QSizePolicy.Expanding,
42-
QtGui.QSizePolicy.Expanding)
43-
self.horizontalLayout.addWidget(self.text)
44-
self.pushButton = QtGui.QPushButton()
45-
self.pushButton.setText('...')
46-
self.pushButton.clicked.connect(self.showSelectionDialog)
47-
self.horizontalLayout.addWidget(self.pushButton)
48-
self.setLayout(self.horizontalLayout)
39+
QWidget.__init__(self)
40+
self.setupUi(self)
41+
42+
self.btnSelect.clicked.connect(self.showSelectionDialog)
43+
4944

5045
def showSelectionDialog(self):
51-
filename = QtGui.QFileDialog.getOpenFileName(self,
52-
self.tr('Select style file'), '', self.tr('QGIS Layer Style File (*.qml *.QML)'))
46+
filename = QFileDialog.getOpenFileName(self,
47+
self.tr('Select style file'), '',
48+
self.tr('QGIS Layer Style File (*.qml *.QML)'))
5349
if filename:
54-
self.text.setText(unicode(filename))
50+
self.leText.setText(filename)
5551

5652
def setText(self, text):
57-
self.text.setText(unicode(text))
53+
self.leText.setText(text)
5854

5955
def getValue(self):
60-
filename = unicode(self.text.text())
61-
return filename
56+
s = self.leText.text()
57+
if isWindows():
58+
s = s.replace('\\', '/')
59+
return s

0 commit comments

Comments
 (0)
Please sign in to comment.