Extended the file completers to set the root directory of the model.

Tue, 01 Dec 2015 19:01:17 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 01 Dec 2015 19:01:17 +0100
changeset 4598
a5fba000224f
parent 4597
46be8d9c4dd8
child 4599
960d1e63f802

Extended the file completers to set the root directory of the model.

E5Gui/E5Completers.py file | annotate | diff | comparison | revisions
--- a/E5Gui/E5Completers.py	Mon Nov 30 19:52:30 2015 +0100
+++ b/E5Gui/E5Completers.py	Tue Dec 01 19:01:17 2015 +0100
@@ -9,6 +9,8 @@
 
 from __future__ import unicode_literals
 
+import os
+
 from PyQt5.QtCore import QDir, Qt, QStringListModel
 from PyQt5.QtWidgets import QCompleter, QFileSystemModel
 
@@ -48,6 +50,26 @@
             self.setCaseSensitivity(Qt.CaseInsensitive)
         if parent:
             parent.setCompleter(self)
+    
+    def setRootPath(self, path):
+        """
+        Public method to set the root path of the model.
+        
+        @param path root path for the model
+        @type str
+        """
+        if not os.path.isdir(path):
+            path = os.path.dirname(path)
+        self.__model.setRootPath(path)
+    
+    def rootPath(self):
+        """
+        Public method to get the root path of the model.
+        
+        @return root path of the model
+        @rtype str
+        """
+        return self.__model.rootPath()
 
 
 class E5DirCompleter(QCompleter):
@@ -82,6 +104,26 @@
             self.setCaseSensitivity(Qt.CaseInsensitive)
         if parent:
             parent.setCompleter(self)
+    
+    def setRootPath(self, path):
+        """
+        Public method to set the root path of the model.
+        
+        @param path root path for the model
+        @type str
+        """
+        if not os.path.isdir(path):
+            path = os.path.dirname(path)
+        self.__model.setRootPath(path)
+    
+    def rootPath(self):
+        """
+        Public method to get the root path of the model.
+        
+        @return root path of the model
+        @rtype str
+        """
+        return self.__model.rootPath()
 
 
 class E5StringListCompleter(QCompleter):

eric ide

mercurial