Little enhancement to the path picker widget to allow to disable the conversion of path separators.

Fri, 29 Jan 2016 19:11:27 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 29 Jan 2016 19:11:27 +0100
changeset 4700
dfdcc542198f
parent 4699
65c6256a669d
child 4701
562b3567cf91

Little enhancement to the path picker widget to allow to disable the conversion of path separators.

APIs/Python3/eric6.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Source/eric6.E5Gui.E5PathPicker.html file | annotate | diff | comparison | revisions
E5Gui/E5PathPicker.py file | annotate | diff | comparison | revisions
Preferences/ConfigurationPages/HelpDocumentationPage.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric6.api	Mon Jan 25 19:11:36 2016 +0100
+++ b/APIs/Python3/eric6.api	Fri Jan 29 19:11:27 2016 +0100
@@ -1421,37 +1421,37 @@
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.buttonToolTip?4()
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.clear?4()
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.clearEditText?4()
-eric6.E5Gui.E5PathPicker.E5PathPickerBase.currentText?4()
+eric6.E5Gui.E5PathPicker.E5PathPickerBase.currentText?4(toNative=True)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.defaultDirectory?4()
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.editTextChanged?7
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.editorEnabled?4()
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.editorToolTip?4()
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.filters?4()
-eric6.E5Gui.E5PathPicker.E5PathPickerBase.firstPath?4()
+eric6.E5Gui.E5PathPicker.E5PathPickerBase.firstPath?4(toNative=True)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.isPickerEnabled?4()
-eric6.E5Gui.E5PathPicker.E5PathPickerBase.lastPath?4()
+eric6.E5Gui.E5PathPicker.E5PathPickerBase.lastPath?4(toNative=True)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.mode?4()
-eric6.E5Gui.E5PathPicker.E5PathPickerBase.path?4()
+eric6.E5Gui.E5PathPicker.E5PathPickerBase.path?4(toNative=True)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.pathSelected?7
-eric6.E5Gui.E5PathPicker.E5PathPickerBase.paths?4()
+eric6.E5Gui.E5PathPicker.E5PathPickerBase.paths?4(toNative=True)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.pickerButtonClicked?7
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.setButtonToolTip?4(tooltip)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.setCurrentIndex?4(index)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.setDefaultDirectory?4(directory)
-eric6.E5Gui.E5PathPicker.E5PathPickerBase.setEditText?4(path)
+eric6.E5Gui.E5PathPicker.E5PathPickerBase.setEditText?4(path, toNative=True)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.setEditorEnabled?4(enable)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.setEditorToolTip?4(tooltip)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.setFilters?4(filters)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.setInsertPolicy?4(policy)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.setMode?4(mode)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.setNameFilters?4(filters)
-eric6.E5Gui.E5PathPicker.E5PathPickerBase.setPath?4(path)
+eric6.E5Gui.E5PathPicker.E5PathPickerBase.setPath?4(path, toNative=True)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.setPathsList?4(pathsList)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.setPickerEnabled?4(enable)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.setSizeAdjustPolicy?4(policy)
-eric6.E5Gui.E5PathPicker.E5PathPickerBase.setText?4(path)
+eric6.E5Gui.E5PathPicker.E5PathPickerBase.setText?4(path, toNative=True)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.setWindowTitle?4(title)
-eric6.E5Gui.E5PathPicker.E5PathPickerBase.text?4()
+eric6.E5Gui.E5PathPicker.E5PathPickerBase.text?4(toNative=True)
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.textChanged?7
 eric6.E5Gui.E5PathPicker.E5PathPickerBase.windowTitle?4()
 eric6.E5Gui.E5PathPicker.E5PathPickerBase?1(parent=None, useLineEdit=True)
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Source/eric6.E5Gui.E5PathPicker.html	Mon Jan 25 19:11:36 2016 +0100
+++ b/Documentation/Source/eric6.E5Gui.E5PathPicker.html	Fri Jan 29 19:11:27 2016 +0100
@@ -425,10 +425,16 @@
         Public method to clear the current path.
 </p><a NAME="E5PathPickerBase.currentText" ID="E5PathPickerBase.currentText"></a>
 <h4>E5PathPickerBase.currentText</h4>
-<b>currentText</b>(<i></i>)
+<b>currentText</b>(<i>toNative=True</i>)
 <p>
         Public method to get the current path.
 </p><dl>
+<dt><i>toNative</i> (bool)</dt>
+<dd>
+flag indicating to convert the path into
+            a native format
+</dd>
+</dl><dl>
 <dt>Returns:</dt>
 <dd>
 current path
@@ -500,10 +506,16 @@
 </dd>
 </dl><a NAME="E5PathPickerBase.firstPath" ID="E5PathPickerBase.firstPath"></a>
 <h4>E5PathPickerBase.firstPath</h4>
-<b>firstPath</b>(<i></i>)
+<b>firstPath</b>(<i>toNative=True</i>)
 <p>
         Public method to get the first path of a list of entered paths.
 </p><dl>
+<dt><i>toNative</i> (bool)</dt>
+<dd>
+flag indicating to convert the path into
+            a native format
+</dd>
+</dl><dl>
 <dt>Returns:</dt>
 <dd>
 first path
@@ -530,10 +542,16 @@
 </dd>
 </dl><a NAME="E5PathPickerBase.lastPath" ID="E5PathPickerBase.lastPath"></a>
 <h4>E5PathPickerBase.lastPath</h4>
-<b>lastPath</b>(<i></i>)
+<b>lastPath</b>(<i>toNative=True</i>)
 <p>
         Public method to get the last path of a list of entered paths.
 </p><dl>
+<dt><i>toNative</i> (bool)</dt>
+<dd>
+flag indicating to convert the path into
+            a native format
+</dd>
+</dl><dl>
 <dt>Returns:</dt>
 <dd>
 last path
@@ -560,10 +578,16 @@
 </dd>
 </dl><a NAME="E5PathPickerBase.path" ID="E5PathPickerBase.path"></a>
 <h4>E5PathPickerBase.path</h4>
-<b>path</b>(<i></i>)
+<b>path</b>(<i>toNative=True</i>)
 <p>
         Public method to get the current path.
 </p><dl>
+<dt><i>toNative</i> (bool)</dt>
+<dd>
+flag indicating to convert the path into
+            a native format
+</dd>
+</dl><dl>
 <dt>Returns:</dt>
 <dd>
 current path
@@ -575,10 +599,16 @@
 </dd>
 </dl><a NAME="E5PathPickerBase.paths" ID="E5PathPickerBase.paths"></a>
 <h4>E5PathPickerBase.paths</h4>
-<b>paths</b>(<i></i>)
+<b>paths</b>(<i>toNative=True</i>)
 <p>
         Public method to get the list of entered paths.
 </p><dl>
+<dt><i>toNative</i> (bool)</dt>
+<dd>
+flag indicating to convert the path into
+            a native format
+</dd>
+</dl><dl>
 <dt>Returns:</dt>
 <dd>
 entered paths
@@ -620,13 +650,17 @@
 </dd>
 </dl><a NAME="E5PathPickerBase.setEditText" ID="E5PathPickerBase.setEditText"></a>
 <h4>E5PathPickerBase.setEditText</h4>
-<b>setEditText</b>(<i>path</i>)
+<b>setEditText</b>(<i>path, toNative=True</i>)
 <p>
         Public method to set the current path.
 </p><dl>
 <dt><i>path</i> (str)</dt>
 <dd>
 path to be set
+</dd><dt><i>toNative</i> (bool)</dt>
+<dd>
+flag indicating to convert the path into
+            a native format
 </dd>
 </dl><a NAME="E5PathPickerBase.setEditorEnabled" ID="E5PathPickerBase.setEditorEnabled"></a>
 <h4>E5PathPickerBase.setEditorEnabled</h4>
@@ -692,13 +726,17 @@
 </dd>
 </dl><a NAME="E5PathPickerBase.setPath" ID="E5PathPickerBase.setPath"></a>
 <h4>E5PathPickerBase.setPath</h4>
-<b>setPath</b>(<i>path</i>)
+<b>setPath</b>(<i>path, toNative=True</i>)
 <p>
         Public method to set the current path.
 </p><dl>
 <dt><i>path</i> (str)</dt>
 <dd>
 path to be set
+</dd><dt><i>toNative</i> (bool)</dt>
+<dd>
+flag indicating to convert the path into
+            a native format
 </dd>
 </dl><a NAME="E5PathPickerBase.setPathsList" ID="E5PathPickerBase.setPathsList"></a>
 <h4>E5PathPickerBase.setPathsList</h4>
@@ -732,13 +770,17 @@
 </dd>
 </dl><a NAME="E5PathPickerBase.setText" ID="E5PathPickerBase.setText"></a>
 <h4>E5PathPickerBase.setText</h4>
-<b>setText</b>(<i>path</i>)
+<b>setText</b>(<i>path, toNative=True</i>)
 <p>
         Public method to set the current path.
 </p><dl>
 <dt><i>path</i> (str)</dt>
 <dd>
 path to be set
+</dd><dt><i>toNative</i> (bool)</dt>
+<dd>
+flag indicating to convert the path into
+            a native format
 </dd>
 </dl><a NAME="E5PathPickerBase.setWindowTitle" ID="E5PathPickerBase.setWindowTitle"></a>
 <h4>E5PathPickerBase.setWindowTitle</h4>
@@ -752,10 +794,16 @@
 </dd>
 </dl><a NAME="E5PathPickerBase.text" ID="E5PathPickerBase.text"></a>
 <h4>E5PathPickerBase.text</h4>
-<b>text</b>(<i></i>)
+<b>text</b>(<i>toNative=True</i>)
 <p>
         Public method to get the current path.
 </p><dl>
+<dt><i>toNative</i> (bool)</dt>
+<dd>
+flag indicating to convert the path into
+            a native format
+</dd>
+</dl><dl>
 <dt>Returns:</dt>
 <dd>
 current path
--- a/E5Gui/E5PathPicker.py	Mon Jan 25 19:11:36 2016 +0100
+++ b/E5Gui/E5PathPicker.py	Fri Jan 29 19:11:27 2016 +0100
@@ -226,101 +226,135 @@
         else:
             return self._editor.currentText()
     
-    def setText(self, path):
+    def setText(self, path, toNative=True):
         """
         Public method to set the current path.
         
         @param path path to be set
         @type str
+        @param toNative flag indicating to convert the path into
+            a native format
+        @type bool
         """
         if self.__mode == E5PathPickerModes.OpenFilesMode:
             self._setEditorText(path)
         else:
-            path = Utilities.toNativeSeparators(path)
+            if toNative:
+                path = Utilities.toNativeSeparators(path)
             self._setEditorText(path)
             if self._completer:
                 self._completer.setRootPath(path)
     
-    def text(self):
+    def text(self, toNative=True):
         """
         Public method to get the current path.
         
+        @param toNative flag indicating to convert the path into
+            a native format
+        @type bool
         @return current path
         @rtype str
         """
         if self.__mode == E5PathPickerModes.OpenFilesMode:
-            return ";".join(
-                [Utilities.toNativeSeparators(path)
-                 for path in self._editorText().split(";")])
+            if toNative:
+                return ";".join(
+                    [Utilities.toNativeSeparators(path)
+                     for path in self._editorText().split(";")])
+            else:
+                return self._editorText()
         else:
-            return os.path.expanduser(
-                Utilities.toNativeSeparators(self._editorText()))
+            if toNative:
+                return os.path.expanduser(
+                    Utilities.toNativeSeparators(self._editorText()))
+            else:
+                return os.path.expanduser(self._editorText())
     
-    def setEditText(self, path):
+    def setEditText(self, path, toNative=True):
         """
         Public method to set the current path.
         
         @param path path to be set
         @type str
+        @param toNative flag indicating to convert the path into
+            a native format
+        @type bool
         """
-        self.setText(path)
+        self.setText(path, toNative=toNative)
     
-    def currentText(self):
+    def currentText(self, toNative=True):
         """
         Public method to get the current path.
         
+        @param toNative flag indicating to convert the path into
+            a native format
+        @type bool
         @return current path
         @rtype str
         """
-        return self.text()
+        return self.text(toNative=toNative)
     
-    def setPath(self, path):
+    def setPath(self, path, toNative=True):
         """
         Public method to set the current path.
         
         @param path path to be set
         @type str
+        @param toNative flag indicating to convert the path into
+            a native format
+        @type bool
         """
-        self.setText(path)
+        self.setText(path, toNative=toNative)
     
-    def path(self):
+    def path(self, toNative=True):
         """
         Public method to get the current path.
         
+        @param toNative flag indicating to convert the path into
+            a native format
+        @type bool
         @return current path
         @rtype str
         """
-        return self.text()
+        return self.text(toNative=toNative)
     
-    def paths(self):
+    def paths(self, toNative=True):
         """
         Public method to get the list of entered paths.
         
+        @param toNative flag indicating to convert the path into
+            a native format
+        @type bool
         @return entered paths
         @rtype list of str
         """
         if self.__mode == E5PathPickerModes.OpenFilesMode:
-            return self.path().split(";")
+            return self.path(toNative=toNative).split(";")
         else:
-            return [self.path()]
+            return [self.path(toNative=toNative)]
     
-    def firstPath(self):
+    def firstPath(self, toNative=True):
         """
         Public method to get the first path of a list of entered paths.
         
+        @param toNative flag indicating to convert the path into
+            a native format
+        @type bool
         @return first path
         @rtype str
         """
-        return self.paths()[0]
+        return self.paths(toNative=toNative)[0]
     
-    def lastPath(self):
+    def lastPath(self, toNative=True):
         """
         Public method to get the last path of a list of entered paths.
         
+        @param toNative flag indicating to convert the path into
+            a native format
+        @type bool
         @return last path
         @rtype str
         """
-        return self.paths()[-1]
+        return self.paths(toNative=toNative)[-1]
     
     def setEditorEnabled(self, enable):
         """
--- a/Preferences/ConfigurationPages/HelpDocumentationPage.py	Mon Jan 25 19:11:36 2016 +0100
+++ b/Preferences/ConfigurationPages/HelpDocumentationPage.py	Fri Jan 29 19:11:27 2016 +0100
@@ -72,21 +72,21 @@
         
         # set initial values
         self.ericDocDirPicker.setText(
-            Preferences.getHelp("EricDocDir"))
+            Preferences.getHelp("EricDocDir"), toNative=False)
         self.python2DocDirPicker.setText(
-            Preferences.getHelp("Python2DocDir"))
+            Preferences.getHelp("Python2DocDir"), toNative=False)
         self.pythonDocDirPicker.setText(
-            Preferences.getHelp("PythonDocDir"))
+            Preferences.getHelp("PythonDocDir"), toNative=False)
         self.qt4DocDirPicker.setText(
-            Preferences.getHelp("Qt4DocDir"))
+            Preferences.getHelp("Qt4DocDir"), toNative=False)
         self.qt5DocDirPicker.setText(
-            Preferences.getHelp("Qt5DocDir"))
+            Preferences.getHelp("Qt5DocDir"), toNative=False)
         self.pyqt4DocDirPicker.setText(
-            Preferences.getHelp("PyQt4DocDir"))
+            Preferences.getHelp("PyQt4DocDir"), toNative=False)
         self.pyqt5DocDirPicker.setText(
-            Preferences.getHelp("PyQt5DocDir"))
+            Preferences.getHelp("PyQt5DocDir"), toNative=False)
         self.pysideDocDirPicker.setText(
-            Preferences.getHelp("PySideDocDir"))
+            Preferences.getHelp("PySideDocDir"), toNative=False)
         
     def save(self):
         """
@@ -94,28 +94,28 @@
         """
         Preferences.setHelp(
             "EricDocDir",
-            self.ericDocDirPicker.text())
+            self.ericDocDirPicker.text(toNative=False))
         Preferences.setHelp(
             "Python2DocDir",
-            self.python2DocDirPicker.text())
+            self.python2DocDirPicker.text(toNative=False))
         Preferences.setHelp(
             "PythonDocDir",
-            self.pythonDocDirPicker.text())
+            self.pythonDocDirPicker.text(toNative=False))
         Preferences.setHelp(
             "Qt4DocDir",
-            self.qt4DocDirPicker.text())
+            self.qt4DocDirPicker.text(toNative=False))
         Preferences.setHelp(
             "Qt5DocDir",
-            self.qt5DocDirPicker.text())
+            self.qt5DocDirPicker.text(toNative=False))
         Preferences.setHelp(
             "PyQt4DocDir",
-            self.pyqt4DocDirPicker.text())
+            self.pyqt4DocDirPicker.text(toNative=False))
         Preferences.setHelp(
             "PyQt5DocDir",
-            self.pyqt5DocDirPicker.text())
+            self.pyqt5DocDirPicker.text(toNative=False))
         Preferences.setHelp(
             "PySideDocDir",
-            self.pysideDocDirPicker.text())
+            self.pysideDocDirPicker.text(toNative=False))
     
 
 def create(dlg):

eric ide

mercurial