Skip to content

Commit

Permalink
[processing] remove MultipleFileInputPanel as it duplicates MultipleI…
Browse files Browse the repository at this point in the history
…nputPanel

homogenize UI in FileSelectionPanel and RenderinStylePanel, remove inused imports
  • Loading branch information
alexbruy committed Nov 17, 2014
1 parent 28c03a1 commit 6fb3268
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 137 deletions.
1 change: 0 additions & 1 deletion python/plugins/processing/gui/CrsSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
__revision__ = '$Format:%H$'

from PyQt4.QtGui import *
from PyQt4.QtCore import *

from qgis.gui import *
from qgis.core import *
Expand Down
1 change: 0 additions & 1 deletion python/plugins/processing/gui/ExtentSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

__revision__ = '$Format:%H$'

from PyQt4.QtCore import *
from PyQt4.QtGui import *

from qgis.core import *
Expand Down
50 changes: 23 additions & 27 deletions python/plugins/processing/gui/FileSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,29 @@
__revision__ = '$Format:%H$'

import os
from PyQt4 import QtGui, QtCore

from PyQt4.QtGui import *

from processing.tools.system import *

from processing.ui.ui_widgetBaseSelector import Ui_Form


class FileSelectionPanel(QtGui.QWidget):
class FileSelectionPanel(QWidget, Ui_Form):

def __init__(self, isFolder, ext=None):
QWidget.__init__(self)
self.setupUi(self)

def __init__(self, isFolder, ext = None):
super(FileSelectionPanel, self).__init__(None)
self.ext = ext or '*'
self.isFolder = isFolder
self.horizontalLayout = QtGui.QHBoxLayout(self)
self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0)
self.text = QtGui.QLineEdit()
self.text.setSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.text)
self.pushButton = QtGui.QPushButton()
self.pushButton.setText(self.tr('...'))
self.pushButton.clicked.connect(self.showSelectionDialog)
self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout)

self.btnSelect.clicked.connect(self.showSelectionDialog)

def showSelectionDialog(self):
# Find the file dialog's working directory
settings = QtCore.QSettings()
text = unicode(self.text.text())
settings = QSettings()
text = self.leText.text()
if os.path.isdir(text):
path = text
elif os.path.isdir(os.path.dirname(text)):
Expand All @@ -63,25 +59,25 @@ def showSelectionDialog(self):
path = ''

if self.isFolder:
folder = QtGui.QFileDialog.getExistingDirectory(self,
folder = QFileDialog.getExistingDirectory(self,
self.tr('Select folder'), path)
if folder:
self.text.setText(str(folder))
self.leText.setText(folder)
settings.setValue('/Processing/LastInputPath',
os.path.dirname(unicode(folder)))
os.path.dirname(folder))
else:
filenames = QtGui.QFileDialog.getOpenFileNames(self, self.tr('Open file'),
path, '*.' + self.ext)
filenames = QFileDialog.getOpenFileNames(self,
self.tr('Select file'), path, '*.' + self.ext)
if filenames:
self.text.setText(u';'.join(filenames))
self.leText.setText(u';'.join(filenames))
settings.setValue('/Processing/LastInputPath',
os.path.dirname(unicode(filenames[0])))
os.path.dirname(filenames[0]))

def getValue(self):
s = unicode(self.text.text())
s = self.leText.text()
if isWindows():
s = s.replace('\\', '/')
return s

def setText(self, text):
self.text.setText(text)
self.leText.setText(text)
61 changes: 0 additions & 61 deletions python/plugins/processing/gui/MultipleFileInputPanel.py

This file was deleted.

45 changes: 22 additions & 23 deletions python/plugins/processing/gui/MultipleInputPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,41 @@

__revision__ = '$Format:%H$'

from PyQt4 import QtGui
from PyQt4.QtGui import *

from processing.gui.MultipleInputDialog import MultipleInputDialog
from processing.gui.MultipleFileInputDialog import MultipleFileInputDialog

from processing.ui.ui_widgetBaseSelector import Ui_Form

class MultipleInputPanel(QWidget, Ui_Form):

def __init__(self, options=None, datatype=None):
QWidget.__init__(self)
self.setupUi(self)

class MultipleInputPanel(QtGui.QWidget):
self.leText.setEnabled(False)
self.leText.setText(self.tr('0 elements selected'))

self.btnSelect.clicked.connect(self.showSelectionDialog)

def __init__(self, options, datatype=None, parent=None):
super(MultipleInputPanel, self).__init__(parent)
self.options = options
self.datatype = datatype
self.selectedoptions = []
self.horizontalLayout = QtGui.QHBoxLayout(self)
self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0)
self.label = QtGui.QLabel()
self.label.setText('0 elements selected')
self.label.setSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.label)
self.pushButton = QtGui.QPushButton()
self.pushButton.setText('...')
self.pushButton.clicked.connect(self.showSelectionDialog)
self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout)

def setSelectedItems(self, selected):
# No checking is performed!
self.selectedoptions = selected
self.label.setText(str(len(self.selectedoptions))
+ ' elements selected')
self.leText.setText(
self.tr('%d elements selected') % len(self.selectedoptions))

def showSelectionDialog(self):

dlg = MultipleInputDialog(self.options, self.selectedoptions)
if self.datatype is None:
dlg = MultipleInputDialog(self.options, self.selectedoptions)
else:
dlg = MultipleFileInputDialog(self.selectedoptions)
dlg.exec_()
if dlg.selectedoptions is not None:
self.selectedoptions = dlg.selectedoptions
self.label.setText(str(len(self.selectedoptions))
+ ' elements selected')
self.leText.setText(
self.tr('%d elements selected') % len(self.selectedoptions))
3 changes: 1 addition & 2 deletions python/plugins/processing/gui/ParametersPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
from processing.gui.ExtentSelectionPanel import ExtentSelectionPanel
from processing.gui.FileSelectionPanel import FileSelectionPanel
from processing.gui.CrsSelectionPanel import CrsSelectionPanel
from processing.gui.MultipleFileInputPanel import MultipleFileInputPanel
from processing.core.parameters import ParameterRaster
from processing.core.parameters import ParameterVector
from processing.core.parameters import ParameterTable
Expand Down Expand Up @@ -294,7 +293,7 @@ def getWidgetFromParameter(self, param):
item = FileSelectionPanel(param.isFolder, param.ext)
elif isinstance(param, ParameterMultipleInput):
if param.datatype == ParameterMultipleInput.TYPE_FILE:
item = MultipleFileInputPanel()
item = MultipleInputPanel(datatype=ParameterMultipleInput.TYPE_FILE)
else:
if param.datatype == ParameterMultipleInput.TYPE_RASTER:
options = dataobjects.getRasterLayers(sorting=False)
Expand Down
42 changes: 20 additions & 22 deletions python/plugins/processing/gui/RenderingStyleFilePanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,35 @@

__revision__ = '$Format:%H$'

import os.path
from PyQt4 import QtGui, QtCore
from PyQt4.QtGui import *

from processing.core.ProcessingConfig import ProcessingConfig
from processing.tools.system import *

from processing.ui.ui_widgetBaseSelector import Ui_Form


class RenderingStyleFilePanel(QtGui.QWidget):
class RenderingStyleFilePanel(QWidget, Ui_Form):

def __init__(self):
super(RenderingStyleFilePanel, self).__init__(None)
self.horizontalLayout = QtGui.QHBoxLayout(self)
self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0)
self.text = QtGui.QLineEdit()
self.text.setSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.text)
self.pushButton = QtGui.QPushButton()
self.pushButton.setText('...')
self.pushButton.clicked.connect(self.showSelectionDialog)
self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout)
QWidget.__init__(self)
self.setupUi(self)

self.btnSelect.clicked.connect(self.showSelectionDialog)


def showSelectionDialog(self):
filename = QtGui.QFileDialog.getOpenFileName(self,
self.tr('Select style file'), '', self.tr('QGIS Layer Style File (*.qml *.QML)'))
filename = QFileDialog.getOpenFileName(self,
self.tr('Select style file'), '',
self.tr('QGIS Layer Style File (*.qml *.QML)'))
if filename:
self.text.setText(unicode(filename))
self.leText.setText(filename)

def setText(self, text):
self.text.setText(unicode(text))
self.leText.setText(text)

def getValue(self):
filename = unicode(self.text.text())
return filename
s = self.leText.text()
if isWindows():
s = s.replace('\\', '/')
return s

0 comments on commit 6fb3268

Please sign in to comment.