Changed code to better deal with project relative paths on Windows systems.

Fri, 14 May 2010 17:26:38 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 14 May 2010 17:26:38 +0200
changeset 248
f4561c24989a
parent 247
b3da30a52337
child 249
52df4455a035

Changed code to better deal with project relative paths on Windows systems.

Graphics/ApplicationDiagram.py file | annotate | diff | comparison | revisions
Plugins/DocumentationPlugins/Ericapi/EricapiConfigDialog.py file | annotate | diff | comparison | revisions
Plugins/DocumentationPlugins/Ericdoc/EricdocConfigDialog.py file | annotate | diff | comparison | revisions
Plugins/PluginEricapi.py file | annotate | diff | comparison | revisions
Plugins/PluginEricdoc.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/HgStatusMonitorThread.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/ProjectBrowserHelper.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/hg.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsPySvn/ProjectBrowserHelper.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsPySvn/SvnDiffDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsPySvn/SvnStatusMonitorThread.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsPySvn/SvnUrlSelectionDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsPySvn/subversion.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsSubversion/SvnDiffDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsSubversion/SvnStatusMonitorThread.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsSubversion/SvnUrlSelectionDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsSubversion/subversion.py file | annotate | diff | comparison | revisions
Plugins/ViewManagerPlugins/Tabview/Tabview.py file | annotate | diff | comparison | revisions
Project/Project.py file | annotate | diff | comparison | revisions
Project/ProjectBaseBrowser.py file | annotate | diff | comparison | revisions
Project/ProjectBrowserModel.py file | annotate | diff | comparison | revisions
Project/ProjectFormsBrowser.py file | annotate | diff | comparison | revisions
Project/ProjectInterfacesBrowser.py file | annotate | diff | comparison | revisions
Project/ProjectOthersBrowser.py file | annotate | diff | comparison | revisions
Project/ProjectResourcesBrowser.py file | annotate | diff | comparison | revisions
Project/ProjectSourcesBrowser.py file | annotate | diff | comparison | revisions
Project/ProjectTranslationsBrowser.py file | annotate | diff | comparison | revisions
Project/PropertiesDialog.py file | annotate | diff | comparison | revisions
Project/SpellingPropertiesDialog.py file | annotate | diff | comparison | revisions
Project/TranslationPropertiesDialog.py file | annotate | diff | comparison | revisions
Tasks/TaskViewer.py file | annotate | diff | comparison | revisions
UI/FindFileDialog.py file | annotate | diff | comparison | revisions
VCS/ProjectBrowserHelper.py file | annotate | diff | comparison | revisions
VCS/StatusMonitorThread.py file | annotate | diff | comparison | revisions
diff -r b3da30a52337 -r f4561c24989a Graphics/ApplicationDiagram.py
--- a/Graphics/ApplicationDiagram.py	Fri May 14 17:23:52 2010 +0200
+++ b/Graphics/ApplicationDiagram.py	Fri May 14 17:26:38 2010 +0200
@@ -85,7 +85,8 @@
         """
         Private method to build the packages shapes of the diagram.
         """
-        project = os.path.splitdrive(self.project.ppath)[1].replace(os.sep, '.')[1:]
+        project = os.path.splitdrive(self.project.getProjectPath())[1]\
+            .replace(os.sep, '.')[1:]
         packages = {}
         shapes = {}
         p = 10
diff -r b3da30a52337 -r f4561c24989a Plugins/DocumentationPlugins/Ericapi/EricapiConfigDialog.py
--- a/Plugins/DocumentationPlugins/Ericapi/EricapiConfigDialog.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/DocumentationPlugins/Ericapi/EricapiConfigDialog.py	Fri May 14 17:26:38 2010 +0200
@@ -173,7 +173,7 @@
         if filename:
             # make it relative, if it is in a subdirectory of the project path 
             fn = Utilities.toNativeSeparators(filename)
-            fn = fn.replace(self.ppath + os.sep, '')
+            fn = self.project.getRelativePath(fn)
             self.outputFileEdit.setText(fn)
 
     def on_outputFileEdit_textChanged(self, filename):
@@ -204,7 +204,7 @@
         if directory:
             # make it relative, if it is a subdirectory of the project path 
             dn = Utilities.toNativeSeparators(directory)
-            dn = dn.replace(self.ppath + os.sep, '')
+            dn = self.project.getRelativePath(dn)
             while dn.endswith(os.sep):
                 dn = dn[:-1]
             self.ignoreDirEdit.setText(dn)
diff -r b3da30a52337 -r f4561c24989a Plugins/DocumentationPlugins/Ericdoc/EricdocConfigDialog.py
--- a/Plugins/DocumentationPlugins/Ericdoc/EricdocConfigDialog.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/DocumentationPlugins/Ericdoc/EricdocConfigDialog.py	Fri May 14 17:26:38 2010 +0200
@@ -26,11 +26,11 @@
     """
     Class implementing a dialog to enter the parameters for eric5-doc.
     """
-    def __init__(self, ppath, parms = None, parent = None):
+    def __init__(self, project, parms = None, parent = None):
         """
         Constructor
         
-        @param ppath project path of the current project (string)
+        @param project reference to the project object (Project.Project)
         @param parms parameters to set in the dialog
         @param parent parent widget of this dialog
         """
@@ -72,7 +72,8 @@
                 else:
                     self.parameters[key] = parms[key]
         
-        self.ppath = ppath
+        self.ppath = project.getProjectPath()
+        self.project = project
         
         self.outputDirCompleter = E5DirCompleter(self.outputDirEdit)
         self.ignoreDirCompleter = E5DirCompleter(self.ignoreDirEdit)
@@ -247,7 +248,7 @@
         if directory:
             # make it relative, if it is a subdirectory of the project path 
             dn = Utilities.toNativeSeparators(directory)
-            dn = dn.replace(self.ppath + os.sep, '')
+            dn = self.project.getRelativePath(dn)
             while dn.endswith(os.sep):
                 dn = dn[:-1]
             self.outputDirEdit.setText(dn)
@@ -272,7 +273,7 @@
         if directory:
             # make it relative, if it is a subdirectory of the project path 
             dn = Utilities.toNativeSeparators(directory)
-            dn = dn.replace(self.ppath + os.sep, '')
+            dn = self.project.getRelativePath(dn)
             while dn.endswith(os.sep):
                 dn = dn[:-1]
             self.ignoreDirEdit.setText(dn)
@@ -310,7 +311,7 @@
         if cssFile:
             # make it relative, if it is in a subdirectory of the project path 
             cf = Utilities.toNativeSeparators(cssFile)
-            cf = cf.replace(self.ppath + os.sep, '')
+            cf = self.project.getRelativePath(cf)
             self.cssEdit.setText(cf)
 
     def __selectColor(self, colorKey):
@@ -458,7 +459,7 @@
         if directory:
             # make it relative, if it is a subdirectory of the project path 
             dn = Utilities.toNativeSeparators(directory)
-            dn = dn.replace(self.ppath + os.sep, '')
+            dn = self.project.getRelativePath(dn)
             while dn.endswith(os.sep):
                 dn = dn[:-1]
             self.qtHelpDirEdit.setText(dn)
diff -r b3da30a52337 -r f4561c24989a Plugins/PluginEricapi.py
--- a/Plugins/PluginEricapi.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/PluginEricapi.py	Fri May 14 17:26:38 2010 +0200
@@ -165,8 +165,8 @@
                         root, ext = os.path.splitext(outputFileName)
                         outfile = "%s-%s%s" % (root, progLanguage.lower(), ext)
                 
-                outfile = outfile.replace(project.ppath+os.sep, '')
+                outfile = project.getRelativePath(outfile)
                 if outfile not in project.pdata['OTHERS']:
                     project.pdata['OTHERS'].append(outfile)
                     project.setDirty(True)
-                    project.othersAdded(outfile)
+                    project.othersAdded(outfile)
\ No newline at end of file
diff -r b3da30a52337 -r f4561c24989a Plugins/PluginEricdoc.py
--- a/Plugins/PluginEricdoc.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/PluginEricdoc.py	Fri May 14 17:26:38 2010 +0200
@@ -7,8 +7,6 @@
 Module implementing the Ericdoc plugin.
 """
 
-import os
-
 from PyQt4.QtCore import QObject, SIGNAL
 from PyQt4.QtGui import QDialog, QApplication
 
@@ -143,7 +141,7 @@
         """
         project = e5App().getObject("Project")
         parms = project.getData('DOCUMENTATIONPARMS', "ERIC4DOC")
-        dlg = EricdocConfigDialog(project.getProjectPath(), parms)
+        dlg = EricdocConfigDialog(project, parms)
         if dlg.exec_() == QDialog.Accepted:
             args, parms = dlg.generateParameters()
             project.setData('DOCUMENTATIONPARMS', "ERIC4DOC", parms)
@@ -159,7 +157,7 @@
                 outdir = 'doc'      # that is eric5-docs default output dir
                 
             # add it to the project data, if it isn't in already
-            outdir = outdir.replace(project.ppath+os.sep, '')
+            outdir = project.getRelativePath(outdir)
             if outdir not in project.pdata['OTHERS']:
                 project.pdata['OTHERS'].append(outdir)
                 project.setDirty(True)
@@ -171,8 +169,8 @@
                     outdir = 'help'      # that is eric5-docs default QtHelp output dir
                     
                 # add it to the project data, if it isn't in already
-                outdir = outdir.replace(project.ppath+os.sep, '')
+                outdir = project.getRelativePath(outdir)
                 if outdir not in project.pdata['OTHERS']:
                     project.pdata['OTHERS'].append(outdir)
                     project.setDirty(True)
-                    project.othersAdded(outdir)
+                    project.othersAdded(outdir)
\ No newline at end of file
diff -r b3da30a52337 -r f4561c24989a Plugins/VcsPlugins/vcsMercurial/HgStatusMonitorThread.py
--- a/Plugins/VcsPlugins/vcsMercurial/HgStatusMonitorThread.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/HgStatusMonitorThread.py	Fri May 14 17:26:38 2010 +0200
@@ -17,16 +17,16 @@
     """
     Class implementing the VCS status monitor thread class for Mercurial.
     """
-    def __init__(self, interval, projectDir, vcs, parent = None):
+    def __init__(self, interval, project, vcs, parent = None):
         """
         Constructor
         
         @param interval new interval in seconds (integer)
-        @param projectDir project directory to monitor (string)
+        @param project reference to the project object (Project)
         @param vcs reference to the version control object
         @param parent reference to the parent object (QObject)
         """
-        VcsStatusMonitorThread.__init__(self, interval, projectDir, vcs, parent)
+        VcsStatusMonitorThread.__init__(self, interval, project, vcs, parent)
         
         self.__ioEncoding = Preferences.getSystem("IOEncoding")
     
diff -r b3da30a52337 -r f4561c24989a Plugins/VcsPlugins/vcsMercurial/ProjectBrowserHelper.py
--- a/Plugins/VcsPlugins/vcsMercurial/ProjectBrowserHelper.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/ProjectBrowserHelper.py	Fri May 14 17:26:38 2010 +0200
@@ -620,7 +620,7 @@
         else:
             items = self.browser.getSelectedItems()
             names = [itm.fileName() for itm in items]
-            files = [name.replace(self.browser.project.ppath + os.sep, '') \
+            files = [self.browser.project.getRelativePath(name) \
                 for name in names]
             
             dlg = DeleteFilesConfirmationDialog(self.parent(),
@@ -630,4 +630,4 @@
                 files)
         
         if dlg.exec_() == QDialog.Accepted:
-            self.vcs.hgForget(names)
+            self.vcs.hgForget(names)
\ No newline at end of file
diff -r b3da30a52337 -r f4561c24989a Plugins/VcsPlugins/vcsMercurial/hg.py
--- a/Plugins/VcsPlugins/vcsMercurial/hg.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/hg.py	Fri May 14 17:26:38 2010 +0200
@@ -2007,8 +2007,8 @@
         """
         Protected method to create an instance of the VCS status monitor thread.
         
-        @param project reference to the project object
+        @param project reference to the project object (Project)
         @param interval check interval for the monitor thread in seconds (integer)
         @return reference to the monitor thread (QThread)
         """
-        return HgStatusMonitorThread(interval, project.ppath, self)
+        return HgStatusMonitorThread(interval, project, self)
diff -r b3da30a52337 -r f4561c24989a Plugins/VcsPlugins/vcsPySvn/ProjectBrowserHelper.py
--- a/Plugins/VcsPlugins/vcsPySvn/ProjectBrowserHelper.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/VcsPlugins/vcsPySvn/ProjectBrowserHelper.py	Fri May 14 17:26:38 2010 +0200
@@ -861,7 +861,7 @@
             name = self.browser.currentItem().fileName()
         except AttributeError:
             name = self.browser.currentItem().dirName()
-        name = name.replace(self.project.ppath+os.sep, "")
+        name = self.project.getRelativePath(name)
         self.vcs.svnInfo(self.project.ppath, name)
         
     def __SVNConfigure(self):
@@ -908,4 +908,4 @@
         for itm in items:
             if isinstance(itm, ProjectBrowserFileItem):
                 return True
-        return False
+        return False
\ No newline at end of file
diff -r b3da30a52337 -r f4561c24989a Plugins/VcsPlugins/vcsPySvn/SvnDiffDialog.py
--- a/Plugins/VcsPlugins/vcsPySvn/SvnDiffDialog.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/VcsPlugins/vcsPySvn/SvnDiffDialog.py	Fri May 14 17:26:38 2010 +0200
@@ -184,8 +184,7 @@
         cwd = os.getcwd()
         os.chdir(dname)
         try:
-            ppath = e5App().getObject('Project').getProjectPath()
-            dname = dname.replace(ppath, '')
+            dname = e5App().getObject('Project').getRelativePath(dname)
             if dname:
                 dname += "/"
             for name in fnames:
@@ -360,4 +359,4 @@
         """
         self.errorGroup.show()
         self.errors.insertPlainText(msg)
-        self.errors.ensureCursorVisible()
+        self.errors.ensureCursorVisible()
\ No newline at end of file
diff -r b3da30a52337 -r f4561c24989a Plugins/VcsPlugins/vcsPySvn/SvnStatusMonitorThread.py
--- a/Plugins/VcsPlugins/vcsPySvn/SvnStatusMonitorThread.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/VcsPlugins/vcsPySvn/SvnStatusMonitorThread.py	Fri May 14 17:26:38 2010 +0200
@@ -19,16 +19,16 @@
     """
     Class implementing the VCS status monitor thread class for Subversion.
     """
-    def __init__(self, interval, projectDir, vcs, parent = None):
+    def __init__(self, interval, project, vcs, parent = None):
         """
         Constructor
         
         @param interval new interval in seconds (integer)
-        @param projectDir project directory to monitor (string)
+        @param project reference to the project object (Project)
         @param vcs reference to the version control object
         @param parent reference to the parent object (QObject)
         """
-        VcsStatusMonitorThread.__init__(self, interval, projectDir, vcs, parent)
+        VcsStatusMonitorThread.__init__(self, interval, project, vcs, parent)
     
     def _performMonitor(self):
         """
diff -r b3da30a52337 -r f4561c24989a Plugins/VcsPlugins/vcsPySvn/SvnUrlSelectionDialog.py
--- a/Plugins/VcsPlugins/vcsPySvn/SvnUrlSelectionDialog.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/VcsPlugins/vcsPySvn/SvnUrlSelectionDialog.py	Fri May 14 17:26:38 2010 +0200
@@ -71,9 +71,10 @@
             self.repoRootLabel1.setText(reposRoot)
             self.repoRootLabel2.setText(reposRoot)
         else:
-            ppath = e5App().getObject('Project').getProjectPath()
-            if path != ppath:
-                path = path.replace(ppath, '')
+            project = e5App().getObject('Project')
+            if Utilities.normcasepath(path) != \
+               Utilities.normcasepath(project.getProjectPath()):
+                path = project.getRelativePath(path)
                 reposURL = reposURL.replace(path, '')
             self.repoRootLabel1.hide()
             self.typeCombo1.hide()
diff -r b3da30a52337 -r f4561c24989a Plugins/VcsPlugins/vcsPySvn/subversion.py
--- a/Plugins/VcsPlugins/vcsPySvn/subversion.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/VcsPlugins/vcsPySvn/subversion.py	Fri May 14 17:26:38 2010 +0200
@@ -2039,4 +2039,4 @@
         @param interval check interval for the monitor thread in seconds (integer)
         @return reference to the monitor thread (QThread)
         """
-        return SvnStatusMonitorThread(interval, project.ppath, self)
+        return SvnStatusMonitorThread(interval, project, self)
diff -r b3da30a52337 -r f4561c24989a Plugins/VcsPlugins/vcsSubversion/SvnDiffDialog.py
--- a/Plugins/VcsPlugins/vcsSubversion/SvnDiffDialog.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/VcsPlugins/vcsSubversion/SvnDiffDialog.py	Fri May 14 17:26:38 2010 +0200
@@ -141,11 +141,11 @@
             else:
                 dname, fname = self.vcs.splitPath(fn)
                 fnames = [fname]
-            ppath = e5App().getObject('Project').getProjectPath()
-            if dname == ppath:
+            project = e5App().getObject('Project')
+            if dname == project.getProjectPath():
                 path = ""
             else:
-                path = dname.replace(ppath + os.sep, '')
+                path = project.getRelativePath(dname)
             if path:
                 path += "/"
             for fname in fnames:
@@ -362,4 +362,4 @@
             self.intercept = False
             evt.accept()
             return
-        QWidget.keyPressEvent(self, evt)
+        QWidget.keyPressEvent(self, evt)
\ No newline at end of file
diff -r b3da30a52337 -r f4561c24989a Plugins/VcsPlugins/vcsSubversion/SvnStatusMonitorThread.py
--- a/Plugins/VcsPlugins/vcsSubversion/SvnStatusMonitorThread.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/VcsPlugins/vcsSubversion/SvnStatusMonitorThread.py	Fri May 14 17:26:38 2010 +0200
@@ -17,16 +17,16 @@
     """
     Class implementing the VCS status monitor thread class for Subversion.
     """
-    def __init__(self, interval, projectDir, vcs, parent = None):
+    def __init__(self, interval, project, vcs, parent = None):
         """
         Constructor
         
         @param interval new interval in seconds (integer)
-        @param projectDir project directory to monitor (string)
+        @param project reference to the project object (Project)
         @param vcs reference to the version control object
         @param parent reference to the parent object (QObject)
         """
-        VcsStatusMonitorThread.__init__(self, interval, projectDir, vcs, parent)
+        VcsStatusMonitorThread.__init__(self, interval, project, vcs, parent)
         
         self.__ioEncoding = Preferences.getSystem("IOEncoding")
         
diff -r b3da30a52337 -r f4561c24989a Plugins/VcsPlugins/vcsSubversion/SvnUrlSelectionDialog.py
--- a/Plugins/VcsPlugins/vcsSubversion/SvnUrlSelectionDialog.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/VcsPlugins/vcsSubversion/SvnUrlSelectionDialog.py	Fri May 14 17:26:38 2010 +0200
@@ -69,9 +69,10 @@
             self.repoRootLabel1.setText(reposRoot)
             self.repoRootLabel2.setText(reposRoot)
         else:
-            ppath = e5App().getObject('Project').getProjectPath()
-            if path != ppath:
-                path = path.replace(ppath, '')
+            project = e5App().getObject('Project')
+            if Utilities.normcasepath(path) != \
+               Utilities.normcasepath(project.getProjectPath()):
+                path = project.getRelativePath(path)
                 reposURL = reposURL.replace(path, '')
             self.repoRootLabel1.hide()
             self.typeCombo1.hide()
diff -r b3da30a52337 -r f4561c24989a Plugins/VcsPlugins/vcsSubversion/subversion.py
--- a/Plugins/VcsPlugins/vcsSubversion/subversion.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/VcsPlugins/vcsSubversion/subversion.py	Fri May 14 17:26:38 2010 +0200
@@ -1821,4 +1821,4 @@
         @param interval check interval for the monitor thread in seconds (integer)
         @return reference to the monitor thread (QThread)
         """
-        return SvnStatusMonitorThread(interval, project.ppath, self)
+        return SvnStatusMonitorThread(interval, project, self)
diff -r b3da30a52337 -r f4561c24989a Plugins/ViewManagerPlugins/Tabview/Tabview.py
--- a/Plugins/ViewManagerPlugins/Tabview/Tabview.py	Fri May 14 17:23:52 2010 +0200
+++ b/Plugins/ViewManagerPlugins/Tabview/Tabview.py	Fri May 14 17:26:38 2010 +0200
@@ -373,10 +373,7 @@
             if Preferences.getUI("TabViewManagerFilenameOnly"):
                 txt = os.path.basename(fn)
             else:
-                txt = fn
-                ppath = e5App().getObject("Project").getProjectPath()
-                if ppath:
-                    txt = txt.replace(ppath + os.sep, "")
+                txt = e5App().getObject("Project").getRelativePath(fn)
             
             maxFileNameChars = Preferences.getUI("TabViewManagerFilenameLength")
             if len(txt) > maxFileNameChars:
@@ -734,10 +731,7 @@
             if self.filenameOnly:
                 txt = os.path.basename(fn)
             else:
-                txt = fn
-                ppath = e5App().getObject("Project").getProjectPath()
-                if ppath:
-                    txt = txt.replace(ppath + os.sep, "")
+                txt = e5App().getObject("Project").getRelativePath(fn)
             if len(txt) > self.maxFileNameChars:
                 txt = "...%s" % txt[-self.maxFileNameChars:]
             if not QFileInfo(fn).isWritable():
@@ -774,10 +768,7 @@
             if self.filenameOnly:
                 txt = os.path.basename(fn)
             else:
-                txt = fn
-                ppath = e5App().getObject("Project").getProjectPath()
-                if ppath:
-                    txt = txt.replace(ppath + os.sep, "")
+                txt = e5App().getObject("Project").getRelativePath(fn)
             if len(txt) > self.maxFileNameChars:
                 txt = "...%s" % txt[-self.maxFileNameChars:]
             if not QFileInfo(fn).isWritable():
@@ -845,10 +836,7 @@
         if self.filenameOnly:
             tabName = os.path.basename(newName)
         else:
-            tabName = newName
-            ppath = e5App().getObject("Project").getProjectPath()
-            if ppath:
-                tabName = tabName.replace(ppath + os.sep, "")
+            tabName = e5App().getObject("Project").getRelativePath(newName)
         if len(tabName) > self.maxFileNameChars:
             tabName = "...%s" % tabName[-self.maxFileNameChars:]
         index = self.currentTabWidget.indexOf(editor)
@@ -1079,10 +1067,7 @@
                         if self.filenameOnly:
                             txt = os.path.basename(fn)
                         else:
-                            txt = fn
-                            ppath = e5App().getObject("Project").getProjectPath()
-                            if ppath:
-                                txt = txt.replace(ppath + os.sep, "")
+                            txt = e5App().getObject("Project").getRelativePath(fn)
                         if len(txt) > self.maxFileNameChars:
                             txt = "...%s" % txt[-self.maxFileNameChars:]
                         if not QFileInfo(fn).isWritable():
@@ -1099,4 +1084,4 @@
         for tw in self.tabWidgets:
             if id(tw) == id_:
                 return tw
-        return None
+        return None
\ No newline at end of file
diff -r b3da30a52337 -r f4561c24989a Project/Project.py
--- a/Project/Project.py	Fri May 14 17:23:52 2010 +0200
+++ b/Project/Project.py	Fri May 14 17:26:38 2010 +0200
@@ -15,6 +15,7 @@
 import copy
 import zipfile
 import io
+import re
 
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
@@ -280,6 +281,7 @@
         self.dirty = False      # dirty flag
         self.pfile = ""         # name of the project file
         self.ppath = ""         # name of the project directory
+        self.ppathRe = None
         self.translationsRoot = ""  # the translations prefix
         self.name = ""
         self.opened = False
@@ -571,6 +573,10 @@
             
         self.pfile = os.path.abspath(fn)
         self.ppath = os.path.abspath(os.path.dirname(fn))
+        if Utilities.isWindowsPlatform():
+            self.ppathRe = re.compile(re.escape(self.ppath + os.sep), re.IGNORECASE )
+        else:
+            self.ppathRe = re.compile(re.escape(self.ppath + os.sep))
         
         # insert filename into list of recently opened projects
         self.__syncRecent()
@@ -726,6 +732,10 @@
         if res:
             self.pfile = os.path.abspath(fn)
             self.ppath = os.path.abspath(os.path.dirname(fn))
+            if Utilities.isWindowsPlatform():
+                self.ppathRe = re.compile(re.escape(self.ppath + os.sep), re.IGNORECASE )
+            else:
+                self.ppathRe = re.compile(re.escape(self.ppath + os.sep))
             self.name = os.path.splitext(os.path.basename(fn))[0]
             self.setDirty(False)
             
@@ -1542,15 +1552,16 @@
         
         @param langFile the translation file to be removed (string)
         """
-        langFile = langFile.replace(self.ppath + os.sep, '')
+        langFile = self.getRelativePath(langFile)
         qmFile = self.__binaryTranslationFile(langFile)
         self.pdata["TRANSLATIONS"].remove(langFile)
         self.__model.removeItem(langFile)
         if qmFile:
             try:
                 if self.pdata["TRANSLATIONSBINPATH"]:
-                    qmFile = os.path.join(self.pdata["TRANSLATIONSBINPATH"][0],
-                        os.path.basename(qmFile)).replace(self.ppath + os.sep, '')
+                    qmFile = self.getRelativePath(
+                        os.path.join(self.pdata["TRANSLATIONSBINPATH"][0],
+                        os.path.basename(qmFile)))
                 self.pdata["TRANSLATIONS"].remove(qmFile)
                 self.__model.removeItem(qmFile)
             except ValueError:
@@ -1563,7 +1574,7 @@
         
         @param langFile the translation file to be removed (string)
         """
-        langFile = langFile.replace(self.ppath + os.sep, '')
+        langFile = self.getRelativePath(langFile)
         qmFile = self.__binaryTranslationFile(langFile)
         
         try:
@@ -1583,8 +1594,9 @@
         if qmFile:
             try:
                 if self.pdata["TRANSLATIONSBINPATH"]:
-                    qmFile = os.path.join(self.pdata["TRANSLATIONSBINPATH"][0],
-                        os.path.basename(qmFile)).replace(self.ppath + os.sep, '')
+                    qmFile = self.getRelativePath(
+                        os.path.join(self.pdata["TRANSLATIONSBINPATH"][0],
+                        os.path.basename(qmFile)))
                 fn = os.path.join(self.ppath, qmFile)
                 if os.path.exists(fn):
                     os.remove(fn)
@@ -1608,7 +1620,7 @@
         
         if os.path.isabs(fn):
             # make it relative to the project root, if it starts with that path
-            newfn = fn.replace(self.ppath + os.sep, '')
+            newfn = self.getRelativePath(fn)
         else:
             # assume relative paths are relative to the project root
             newfn = fn
@@ -1876,7 +1888,7 @@
         """
         if fn:
             # if it is below the project directory, make it relative to that
-            fn = fn.replace(self.ppath + os.sep, '')
+            fn = self.getRelativePath(fn)
             
             # if it ends with the directory separator character, remove it
             if fn.endswith(os.sep):
@@ -1958,11 +1970,11 @@
         @param newfn new filename of the main script (string)
         """
         if self.pdata["MAINSCRIPT"]:
-            ofn = oldfn.replace(self.ppath + os.sep, '')
+            ofn = self.getRelativePath(oldfn)
             if ofn != self.pdata["MAINSCRIPT"][0]:
                 return
             
-            fn = newfn.replace(self.ppath + os.sep, '')
+            fn = self.getRelativePath(newfn)
             self.pdata["MAINSCRIPT"] = [fn]
             self.setDirty(True)
         
@@ -1974,7 +1986,7 @@
         @param newfn new filename of the file (string)
         @return flag indicating success
         """
-        fn = oldfn.replace(self.ppath + os.sep, '')
+        fn = self.getRelativePath(oldfn)
         isSourceFile = fn in self.pdata["SOURCES"]
         
         if newfn is None:
@@ -2028,7 +2040,7 @@
         @param isSourceFile flag indicating that this is a source file
                 even if it doesn't have the source extension (boolean)
         """
-        fn = oldname.replace(self.ppath + os.sep, '')
+        fn = self.getRelativePath(oldname)
         if os.path.dirname(oldname) == os.path.dirname(newname):
             self.removeFile(oldname, False)
             self.appendFile(newname, isSourceFile, False)
@@ -2047,7 +2059,7 @@
         @param start prefix (string)
         """
         filelist = []
-        start = start.replace(self.ppath + os.sep, '')
+        start = self.getRelativePath(start)
         for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES", "OTHERS"]:
             for entry in self.pdata[key][:]:
                 if entry.startswith(start):
@@ -2061,8 +2073,8 @@
         @param olddn original directory name (string)
         @param newdn new directory name (string)
         """
-        olddn = olddn.replace(self.ppath + os.sep, '')
-        newdn = newdn.replace(self.ppath + os.sep, '')
+        olddn = self.getRelativePath(olddn)
+        newdn = self.getRelativePath(newdn)
         for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES", "OTHERS"]:
             for entry in self.pdata[key][:]:
                 if entry.startswith(olddn):
@@ -2077,8 +2089,8 @@
         @param olddn old directory name (string)
         @param newdn new directory name (string)
         """
-        olddn = olddn.replace(self.ppath + os.sep, '')
-        newdn = newdn.replace(self.ppath + os.sep, '')
+        olddn = self.getRelativePath(olddn)
+        newdn = self.getRelativePath(newdn)
         typeStrings = []
         for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES", "OTHERS"]:
             for entry in self.pdata[key][:]:
@@ -2110,7 +2122,7 @@
         @param fn filename to be removed from the project
         @param updateModel flag indicating an update of the model is requested (boolean)
         """
-        fn = fn.replace(self.ppath + os.sep, '')
+        fn = self.getRelativePath(fn)
         dirty = True
         if fn in self.pdata["SOURCES"]:
             self.pdata["SOURCES"].remove(fn)
@@ -2139,7 +2151,7 @@
         @param dn directory name to be removed from the project
         """
         dirty = False
-        dn = dn.replace(self.ppath + os.sep, '')
+        dn = self.getRelativePath(dn)
         for entry in self.pdata["OTHERS"][:]:
             if entry.startswith(dn):
                 self.pdata["OTHERS"].remove(entry)
@@ -2212,7 +2224,7 @@
         @param fn filename to be checked (string)
         @return flag indicating, if the project contains the file (boolean)
         """
-        fn = fn.replace(self.ppath + os.sep, '')
+        fn = self.getRelativePath(fn)
         if fn in self.pdata["SOURCES"] or \
            fn in self.pdata["FORMS"] or \
            fn in self.pdata["INTERFACES"] or \
@@ -2511,7 +2523,7 @@
                 if not pattern.isEmpty:
                     self.pdata["TRANSLATIONPATTERN"] = [pattern]
             self.pdata["TRANSLATIONPATTERN"][0] = \
-                self.pdata["TRANSLATIONPATTERN"][0].replace(self.ppath + os.sep, "")
+                self.getRelativePath(self.pdata["TRANSLATIONPATTERN"][0])
             pattern = self.pdata["TRANSLATIONPATTERN"][0].replace("%language%", "*")
             for ts in tslist:
                 if fnmatch.fnmatch(ts, pattern):
@@ -3032,7 +3044,7 @@
         success = True
         filesWithSyntaxErrors = 0
         for fn in vm.getOpenFilenames():
-            rfn = fn.replace(self.ppath + os.sep, '') # make relativ to project
+            rfn = self.getRelativePath(fn)
             if rfn in self.pdata["SOURCES"] or rfn in self.pdata["OTHERS"]:
                 editor = vm.getOpenEditor(fn)
                 success &= vm.saveEditorEd(editor)
@@ -3137,6 +3149,17 @@
         """
         return self.ppath
         
+    def startswithProjectPath(self, path):
+        """
+        Public method to check, if a path starts with the project path.
+        
+        @param path path to be checked (string)
+        """
+        if self.ppathRe:
+            return self.ppathRe.match(path) is not None
+        else:
+            return False
+        
     def getProjectFile(self):
         """
         Public method to get the path of the project file.
@@ -3164,27 +3187,30 @@
         """
         return self.pdata["HASH"][0]
         
-    def getRelativePath(self, fn):
+    def getRelativePath(self, path):
         """
         Public method to convert a file path to a project relative
         file path.
         
-        @param fn file or directory name to convert (string)
-        @return project relative path or unchanged path, if fn doesn't
+        @param path file or directory name to convert (string)
+        @return project relative path or unchanged path, if path doesn't
             belong to the project (string)
         """
-        return fn.replace(self.ppath + os.sep, "")
-        
-    def getRelativeUniversalPath(self, fn):
+        if self.startswithProjectPath(path):
+            return self.ppathRe.sub("", path, 1)
+        else:
+            return path
+        
+    def getRelativeUniversalPath(self, path):
         """
         Public method to convert a file path to a project relative
         file path with universal separators.
         
-        @param fn file or directory name to convert (string)
-        @return project relative path or unchanged path, if fn doesn't
+        @param path file or directory name to convert (string)
+        @return project relative path or unchanged path, if path doesn't
             belong to the project (string)
         """
-        return Utilities.fromNativeSeparators(fn.replace(self.ppath + os.sep, ""))
+        return Utilities.fromNativeSeparators(self.getRelativePath(path))
         
     def getAbsoluteUniversalPath(self, fn):
         """
@@ -3206,7 +3232,7 @@
         @return flag indicating membership (boolean)
         """
         newfn = os.path.abspath(fn)
-        newfn = newfn.replace(self.ppath + os.sep, '')
+        newfn = self.getRelativePath(newfn)
         if newfn in self.pdata["SOURCES"] or \
            newfn in self.pdata["FORMS"] or \
            newfn in self.pdata["INTERFACES"] or \
@@ -3229,7 +3255,7 @@
         @return flag indicating membership (boolean)
         """
         newfn = os.path.abspath(fn)
-        newfn = newfn.replace(self.ppath + os.sep, '')
+        newfn = self.getRelativePath(newfn)
         return newfn in self.pdata["SOURCES"]
         
     def isProjectForm(self, fn):
@@ -3241,7 +3267,7 @@
         @return flag indicating membership (boolean)
         """
         newfn = os.path.abspath(fn)
-        newfn = newfn.replace(self.ppath + os.sep, '')
+        newfn = self.getRelativePath(newfn)
         return newfn in self.pdata["FORMS"]
         
     def isProjectInterface(self, fn):
@@ -3253,7 +3279,7 @@
         @return flag indicating membership (boolean)
         """
         newfn = os.path.abspath(fn)
-        newfn = newfn.replace(self.ppath + os.sep, '')
+        newfn = self.getRelativePath(newfn)
         return newfn in self.pdata["INTERFACES"]
         
     def isProjectResource(self, fn):
@@ -3265,7 +3291,7 @@
         @return flag indicating membership (boolean)
         """
         newfn = os.path.abspath(fn)
-        newfn = newfn.replace(self.ppath + os.sep, '')
+        newfn = self.getRelativePath(newfn)
         return newfn in self.pdata["RESOURCES"]
         
     def initActions(self):
@@ -3925,7 +3951,7 @@
                 # do not bother with dirs here...
                 if os.path.isdir(ns):
                     if recursiveSearch:
-                        d = ns.replace(self.ppath + os.sep, '')
+                        d = self.getRelativePath(ns)
                         if d not in dirs:
                             dirs.append(d)
                     continue
@@ -4039,7 +4065,7 @@
         if not self.isOpen():
             return
         
-        name = fullname.replace(self.ppath + os.sep, "")
+        name = self.getRelativePath(fullname)
         self.emit(SIGNAL("prepareRepopulateItem"), name)
         self.__model.repopulateItem(name)
         self.emit(SIGNAL("completeRepopulateItem"), name)
diff -r b3da30a52337 -r f4561c24989a Project/ProjectBaseBrowser.py
--- a/Project/ProjectBaseBrowser.py	Fri May 14 17:23:52 2010 +0200
+++ b/Project/ProjectBaseBrowser.py	Fri May 14 17:26:38 2010 +0200
@@ -304,7 +304,7 @@
         @param fn filename of file to be highlighted (string)
         """
         newfn = os.path.abspath(fn)
-        newfn = newfn.replace(self.project.ppath + os.sep, '')
+        newfn = self.project.getRelativePath(newfn)
         sindex = self._model.itemIndexByName(newfn)
         if sindex.isValid():
             index = self.model().mapFromSource(sindex)
diff -r b3da30a52337 -r f4561c24989a Project/ProjectBrowserModel.py
--- a/Project/ProjectBrowserModel.py	Fri May 14 17:23:52 2010 +0200
+++ b/Project/ProjectBrowserModel.py	Fri May 14 17:26:38 2010 +0200
@@ -552,7 +552,7 @@
         @return reference to the item found
         """
         if QDir.isAbsolutePath(name):
-            name = name.replace(self.project.ppath + os.sep, "")
+            name = self.project.getRelativePath(name)
         pathlist = re.split(r'/|\\', name)
         if len(pathlist) > 0:
             olditem = self.rootItem
diff -r b3da30a52337 -r f4561c24989a Project/ProjectFormsBrowser.py
--- a/Project/ProjectFormsBrowser.py	Fri May 14 17:23:52 2010 +0200
+++ b/Project/ProjectFormsBrowser.py	Fri May 14 17:26:38 2010 +0200
@@ -550,7 +550,7 @@
         for itm in itmList:
             fn2 = itm.fileName()
             fullNames.append(fn2)
-            fn = fn2.replace(self.project.ppath + os.sep, '')
+            fn = self.project.getRelativePath(fn2)
             files.append(fn)
         
         dlg = DeleteFilesConfirmationDialog(self.parent(),
@@ -744,7 +744,7 @@
         """
         itm = self.model().item(self.currentIndex())
         fn2 = itm.fileName()
-        fn = fn2.replace(self.project.ppath + os.sep, '')
+        fn = self.project.getRelativePath(fn2)
         if self.hooks["compileForm"] is not None:
             self.hooks["compileForm"](fn)
         else:
@@ -786,7 +786,7 @@
         Private method to compile selected forms to source files.
         """
         items = self.getSelectedItems()
-        files = [itm.fileName().replace(self.project.ppath + os.sep, '') \
+        files = [self.project.getRelativePath(itm.fileName()) \
                  for itm in items]
         
         if self.hooks["compileSelectedForms"] is not None:
diff -r b3da30a52337 -r f4561c24989a Project/ProjectInterfacesBrowser.py
--- a/Project/ProjectInterfacesBrowser.py	Fri May 14 17:23:52 2010 +0200
+++ b/Project/ProjectInterfacesBrowser.py	Fri May 14 17:26:38 2010 +0200
@@ -382,7 +382,7 @@
         for itm in itmList:
             fn2 = itm.fileName()
             fullNames.append(fn2)
-            fn = fn2.replace(self.project.ppath+os.sep, '')
+            fn = self.project.getRelativePath(fn2)
             files.append(fn)
         
         dlg = DeleteFilesConfirmationDialog(self.parent(),
@@ -512,7 +512,7 @@
         if self.omniidl is not None:
             itm = self.model().item(self.currentIndex())
             fn2 = itm.fileName()
-            fn = fn2.replace(self.project.ppath+os.sep, '')
+            fn = self.project.getRelativePath(fn2)
             self.__compileIDL(fn)
         
     def __compileAllInterfaces(self):
@@ -550,7 +550,7 @@
         if self.omniidl is not None:
             items = self.getSelectedItems()
             
-            files = [itm.fileName().replace(self.project.ppath+os.sep, '') \
+            files = [self.project.getRelativePath(itm.fileName()) \
                      for itm in items]
             numIDLs = len(files)
             progress = QProgressDialog(self.trUtf8("Compiling interfaces..."), 
diff -r b3da30a52337 -r f4561c24989a Project/ProjectOthersBrowser.py
--- a/Project/ProjectOthersBrowser.py	Fri May 14 17:23:52 2010 +0200
+++ b/Project/ProjectOthersBrowser.py	Fri May 14 17:26:38 2010 +0200
@@ -269,13 +269,13 @@
         for itm in itmList:
             if isinstance(itm, ProjectBrowserFileItem):
                 fn2 = itm.fileName()
-                fn = fn2.replace(self.project.ppath+os.sep, '')
+                fn = self.project.getRelativePath(fn2)
                 items.append(itm)
                 fullNames.append(fn2)
                 names.append(fn)
             else:
                 dn2 = itm.dirName()
-                dn = dn2.replace(self.project.ppath+os.sep, '')
+                dn = self.project.getRelativePath(dn2)
                 dirItems.append(itm)
                 dirFullNames.append(dn2)
                 dirNames.append(dn)
diff -r b3da30a52337 -r f4561c24989a Project/ProjectResourcesBrowser.py
--- a/Project/ProjectResourcesBrowser.py	Fri May 14 17:23:52 2010 +0200
+++ b/Project/ProjectResourcesBrowser.py	Fri May 14 17:26:38 2010 +0200
@@ -444,7 +444,7 @@
         for itm in itmList:
             fn2 = itm.fileName()
             fullNames.append(fn2)
-            fn = fn2.replace(self.project.ppath+os.sep, '')
+            fn = self.project.getRelativePath(fn2)
             files.append(fn)
         
         dlg = DeleteFilesConfirmationDialog(self.parent(),
@@ -614,7 +614,7 @@
         """
         itm = self.model().item(self.currentIndex())
         fn2 = itm.fileName()
-        fn = fn2.replace(self.project.ppath+os.sep, '')
+        fn = self.project.getRelativePath(fn2)
         if self.hooks["compileResource"] is not None:
             self.hooks["compileResource"](fn)
         else:
@@ -655,7 +655,7 @@
         Private method to compile selected resources to source files.
         """
         items = self.getSelectedItems()
-        files = [itm.fileName().replace(self.project.ppath+os.sep, '') \
+        files = [self.project.getRelativePath(itm.fileName()) \
                  for itm in items]
         
         if self.hooks["compileSelectedResources"] is not None:
diff -r b3da30a52337 -r f4561c24989a Project/ProjectSourcesBrowser.py
--- a/Project/ProjectSourcesBrowser.py	Fri May 14 17:23:52 2010 +0200
+++ b/Project/ProjectSourcesBrowser.py	Fri May 14 17:26:38 2010 +0200
@@ -565,7 +565,7 @@
         else:
             dn = ""
         
-        dn = dn.replace(self.project.ppath, "")
+        dn = self.project.getRelativePath(dn)
         if dn.startswith(os.sep):
             dn = dn[1:]
         dlg = NewPythonPackageDialog(dn, self)
@@ -651,7 +651,7 @@
         for itm in itmList:
             fn2 = itm.fileName()
             fullNames.append(fn2)
-            fn = fn2.replace(self.project.ppath+os.sep, '')
+            fn = self.project.getRelativePath(fn2)
             files.append(fn)
         
         dlg = DeleteFilesConfirmationDialog(self.parent(),
diff -r b3da30a52337 -r f4561c24989a Project/ProjectTranslationsBrowser.py
--- a/Project/ProjectTranslationsBrowser.py	Fri May 14 17:23:52 2010 +0200
+++ b/Project/ProjectTranslationsBrowser.py	Fri May 14 17:26:38 2010 +0200
@@ -617,7 +617,7 @@
         if itmList and not previewAll:
             for itm in itmList:
                 if isinstance(itm, ProjectBrowserSimpleDirectoryItem):
-                    dname = itm.dirName().replace(self.project.ppath+os.sep, '')
+                    dname = self.project.getRelativePath(itm.dirName())
                     trfiles = sorted(self.project.pdata["TRANSLATIONS"][:])
                     for trfile in trfiles:
                         if trfile.startswith(dname):
@@ -686,7 +686,7 @@
         sections.append(("FORMS", forms))
         
         if langs:
-            l = [lang.fileName().replace(self.project.ppath + os.sep, '') \
+            l = [self.project.getRelativePath(lang.fileName()) \
                  for lang in langs if lang.fileName().endswith('.ts')]
         else:
             try:
@@ -873,13 +873,13 @@
         else:
             if noobsolete:
                 if self.hooks["generateSelected"] is not None:
-                    l = [lang.fileName().replace(self.project.ppath + os.sep, '') \
+                    l = [self.project.getRelativePath(lang.fileName()) \
                          for lang in langs]
                     self.hooks["generateSelected"](l)
                     return
             else:
                 if self.hooks["generateSelectedWithObsolete"] is not None:
-                    l = [lang.fileName().replace(self.project.ppath + os.sep, '') \
+                    l = [self.project.getRelativePath(lang.fileName()) \
                          for lang in langs]
                     self.hooks["generateSelectedWithObsolete"](l)
                     return
@@ -1015,7 +1015,7 @@
                 return
         else:
             if self.hooks["releaseSelected"] is not None:
-                l = [lang.fileName().replace(self.project.ppath+os.sep, '') \
+                l = [self.project.getRelativePath(lang.fileName()) \
                      for lang in langs]
                 self.hooks["releaseSelected"](l)
                 return
diff -r b3da30a52337 -r f4561c24989a Project/PropertiesDialog.py
--- a/Project/PropertiesDialog.py	Fri May 14 17:23:52 2010 +0200
+++ b/Project/PropertiesDialog.py	Fri May 14 17:26:38 2010 +0200
@@ -236,7 +236,7 @@
         self.project.pdata["VERSION"] = [self.versionEdit.text()]
         fn = self.mainscriptEdit.text()
         if fn:
-            fn = fn.replace(self.project.ppath+os.sep, "")
+            fn = self.project.getRelativePath(fn2)
             self.project.pdata["MAINSCRIPT"] = [fn]
             self.project.translationsRoot = os.path.splitext(fn)[0]
         else:
diff -r b3da30a52337 -r f4561c24989a Project/SpellingPropertiesDialog.py
--- a/Project/SpellingPropertiesDialog.py	Fri May 14 17:23:52 2010 +0200
+++ b/Project/SpellingPropertiesDialog.py	Fri May 14 17:26:38 2010 +0200
@@ -108,6 +108,6 @@
             self.project.pdata["SPELLLANGUAGE"] = \
                 [self.spellingComboBox.currentText()]
         self.project.pdata["SPELLWORDS"] = \
-            [self.pwlEdit.text().replace(self.project.ppath + os.sep, "")]
+            [self.project.getRelativePath(self.pwlEdit.text())]
         self.project.pdata["SPELLEXCLUDES"] = \
-            [self.pelEdit.text().replace(self.project.ppath + os.sep, "")]
\ No newline at end of file
+            [self.project.getRelativePath(self.pelEdit.text())]
diff -r b3da30a52337 -r f4561c24989a Project/TranslationPropertiesDialog.py
--- a/Project/TranslationPropertiesDialog.py	Fri May 14 17:23:52 2010 +0200
+++ b/Project/TranslationPropertiesDialog.py	Fri May 14 17:26:38 2010 +0200
@@ -139,12 +139,11 @@
         """
         Private slot to add the shown exception to the listwidget.
         """
+        texcept = self.exceptionEdit.text()
         if self.project.ppath == '':
-            ppath = self.parent.getPPath()
+            texcept = texcept.replace(self.parent.getPPath() + os.sep, "")
         else:
-            ppath = self.project.ppath
-        texcept = self.exceptionEdit.text()
-        texcept = texcept.replace(ppath + os.sep, "")
+            texcept = self.project.getRelativePath(texcept)
         if texcept.endswith(os.sep):
             texcept = texcept[:-1]
         if texcept:
@@ -204,18 +203,18 @@
         """
         tp = Utilities.toNativeSeparators(self.transPatternEdit.text())
         if tp:
-            tp = tp.replace(self.project.ppath + os.sep, "")
+            tp = self.project.getRelativePath(tp)
             self.project.pdata["TRANSLATIONPATTERN"] = [tp]
             self.project.translationsRoot = tp.split("%language%")[0]
         else:
             self.project.pdata["TRANSLATIONPATTERN"] = []
         tp = Utilities.toNativeSeparators(self.transBinPathEdit.text())
         if tp:
-            tp = tp.replace(self.project.ppath + os.sep, "")
+            tp = self.project.getRelativePath(tp)
             self.project.pdata["TRANSLATIONSBINPATH"] = [tp]
         else:
             self.project.pdata["TRANSLATIONSBINPATH"] = []
         exceptList = []
         for i in range(self.exceptionsList.count()):
             exceptList.append(self.exceptionsList.item(i).text())
-        self.project.pdata["TRANSLATIONEXCEPTIONS"] = exceptList[:]
\ No newline at end of file
+        self.project.pdata["TRANSLATIONEXCEPTIONS"] = exceptList[:]
diff -r b3da30a52337 -r f4561c24989a Tasks/TaskViewer.py
--- a/Tasks/TaskViewer.py	Fri May 14 17:23:52 2010 +0200
+++ b/Tasks/TaskViewer.py	Fri May 14 17:26:38 2010 +0200
@@ -33,7 +33,7 @@
     """
     def __init__(self, description, priority = 1, filename = "", lineno = 0, 
                  completed = False, _time = 0, isProjectTask = False, 
-                 isBugfixTask = False, ppath = "", longtext = ""):
+                 isBugfixTask = False, project = None, longtext = ""):
         """
         Constructor
         
@@ -47,7 +47,7 @@
         @param isProjectTask flag indicating a task related to the current project
             (boolean)
         @param isBugfixTask flag indicating a bugfix task (boolean)
-        @param ppath the project path (string)
+        @param project reference to the project object (Project)
         @param longtext explanatory text of the task (string)
         """
         self.description = description
@@ -62,10 +62,10 @@
         self.created = _time and _time or time.time()
         self._isProjectTask = isProjectTask
         self.isBugfixTask = isBugfixTask
-        self.ppath = ppath
+        self.project = project
         
         if isProjectTask:
-            self.filename = self.filename.replace(self.ppath + os.sep, "")
+            self.filename = self.project.getRelativePath(self.filename)
             
         QTreeWidgetItem.__init__(self, ["", "", self.description, self.filename, 
             (self.lineno and "%6d" % self.lineno or "")])
@@ -165,7 +165,7 @@
         @return filename (string)
         """
         if self._isProjectTask and self.filename:
-            return os.path.join(self.ppath, self.filename)
+            return os.path.join(self.project.getProjectPath(), self.filename)
         else:
             return self.filename
     
@@ -531,8 +531,7 @@
         """
         task = Task(description, priority, filename, lineno, completed, 
                    _time, isProjectTask, isBugfixTask, 
-                   self.project and self.project.ppath or "", 
-                   longtext)
+                   self.project, longtext)
         self.tasks.append(task)
         if self.taskFilter.showTask(task):
             self.addTopLevelItem(task)
diff -r b3da30a52337 -r f4561c24989a UI/FindFileDialog.py
--- a/UI/FindFileDialog.py	Fri May 14 17:23:52 2010 +0200
+++ b/UI/FindFileDialog.py	Fri May 14 17:26:38 2010 +0200
@@ -267,8 +267,9 @@
         
         if self.projectButton.isChecked():
             if self.filterCheckBox.isChecked():
-                files = [file.replace(self.project.ppath + os.sep, "") \
-                         for file in self.__getFileList(self.project.ppath, filterRe)]
+                files = [self.project.getRelativePath(file) \
+                         for file in \
+                         self.__getFileList(self.project.getProjectPath(), filterRe)]
             else:
                 files = []
                 if self.sourcesCheckBox.isChecked():
diff -r b3da30a52337 -r f4561c24989a VCS/ProjectBrowserHelper.py
--- a/VCS/ProjectBrowserHelper.py	Fri May 14 17:23:52 2010 +0200
+++ b/VCS/ProjectBrowserHelper.py	Fri May 14 17:26:38 2010 +0200
@@ -267,8 +267,7 @@
                 names = [itm.dirName() for itm in items]
             else:
                 names = [itm.fileName() for itm in items]
-            files = [
-                name.replace(self.browser.project.ppath+os.sep, '') \
+            files = [self.browser.project.getRelativePath(name) \
                 for name in names]
             
             dlg = DeleteFilesConfirmationDialog(self.parent(),
diff -r b3da30a52337 -r f4561c24989a VCS/StatusMonitorThread.py
--- a/VCS/StatusMonitorThread.py	Fri May 14 17:23:52 2010 +0200
+++ b/VCS/StatusMonitorThread.py	Fri May 14 17:26:38 2010 +0200
@@ -7,8 +7,6 @@
 Module implementing the VCS status monitor thread base class.
 """
 
-import os
-
 from PyQt4.QtCore import QThread, QMutex, QWaitCondition, SIGNAL
 
 class VcsStatusMonitorThread(QThread):
@@ -19,12 +17,12 @@
     @signal vcsStatusMonitorStatus(QString, QString) emitted to signal the status of the
         monitoring thread (ok, nok, op) and a status message
     """
-    def __init__(self, interval, projectDir, vcs, parent = None):
+    def __init__(self, interval, project, vcs, parent = None):
         """
         Constructor
         
         @param interval new interval in seconds (integer)
-        @param projectDir project directory to monitor (string)
+        @param project reference to the project object (Project)
         @param vcs reference to the version control object
         @param parent reference to the parent object (QObject)
         """
@@ -33,7 +31,8 @@
         
         self.setTerminationEnabled(True)
         
-        self.projectDir = projectDir
+        self.projectDir = project.getProjectPath()
+        self.project = project
         self.vcs = vcs
         
         self.interval = interval
@@ -158,7 +157,7 @@
         
         @param name name of the entry to be cleared (string)
         """
-        key = name.replace(self.projectDir + os.sep, '')
+        key = self.project.getRelativePath(name)
         try:
             del self.reportedStates[key]
         except KeyError:

eric ide

mercurial