[processing] remove MultipleFileInputPanel as it duplicates MultipleInputPanel

homogenize UI in FileSelectionPanel and RenderinStylePanel, remove inused imports
This commit is contained in:
Alexander Bruy 2014-11-06 15:50:12 +02:00
parent 28c03a1cd9
commit 6fb32687c4
7 changed files with 66 additions and 137 deletions

View File

@ -26,7 +26,6 @@ __copyright__ = '(C) 2012, Victor Olaya'
__revision__ = '$Format:%H$'
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from qgis.gui import *
from qgis.core import *

View File

@ -25,7 +25,6 @@ __copyright__ = '(C) 2012, Victor Olaya'
__revision__ = '$Format:%H$'
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *

View File

@ -26,33 +26,29 @@ __copyright__ = '(C) 2012, Victor Olaya'
__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):
def __init__(self, isFolder, ext = None):
super(FileSelectionPanel, self).__init__(None)
class FileSelectionPanel(QWidget, Ui_Form):
def __init__(self, isFolder, ext=None):
QWidget.__init__(self)
self.setupUi(self)
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)):
@ -63,25 +59,25 @@ class FileSelectionPanel(QtGui.QWidget):
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)

View File

@ -1,61 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
MultipleFileInputPanel.py
---------------------
Date : August 2012
Copyright : (C) 2012 by Victor Olaya
(C) 2013 by CS Systemes d'information (CS SI)
Email : volayaf at gmail dot com
otb at c-s dot fr (CS SI)
Contributors : Victor Olaya - basis from MultipleInputPanel
Alexia Mondot (CS SI) - adapt for a new parameter
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4 import QtGui
from processing.gui.MultipleFileInputDialog import MultipleFileInputDialog
class MultipleFileInputPanel(QtGui.QWidget):
def __init__(self, parent = None):
super(MultipleFileInputPanel, self).__init__(parent)
self.selectedoptions = []
self.horizontalLayout = QtGui.QHBoxLayout(self)
self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0)
self.label = QtGui.QLabel()
self.label.setText(self.tr('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.tr('...'))
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(self.tr('%d elements selected') % len(self.selectedoptions))
def showSelectionDialog(self):
dlg = MultipleFileInputDialog(self.selectedoptions)
dlg.exec_()
if dlg.selectedoptions != None:
self.selectedoptions = dlg.selectedoptions
self.label.setText(self.tr('%d elements selected') % len(self.selectedoptions))

View File

@ -25,42 +25,41 @@ __copyright__ = '(C) 2012, Victor Olaya'
__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(QtGui.QWidget):
class MultipleInputPanel(QWidget, Ui_Form):
def __init__(self, options=None, datatype=None):
QWidget.__init__(self)
self.setupUi(self)
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))

View File

@ -47,7 +47,6 @@ from processing.gui.NumberInputPanel import NumberInputPanel
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
@ -294,7 +293,7 @@ class ParametersPanel(QWidget):
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)

View File

@ -25,37 +25,35 @@ __copyright__ = '(C) 2012, Victor Olaya'
__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