Plugins/VcsPlugins/vcsMercurial/HgCopyDialog.py

changeset 1885
e51a12f1f404
parent 1884
0a7ef7f4d09e
child 2302
f29e9405c851
--- a/Plugins/VcsPlugins/vcsMercurial/HgCopyDialog.py	Sat Jun 02 15:27:03 2012 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/HgCopyDialog.py	Sat Jun 02 16:36:16 2012 +0200
@@ -10,7 +10,7 @@
 import os.path
 
 from PyQt4.QtCore import pyqtSlot
-from PyQt4.QtGui import QDialog
+from PyQt4.QtGui import QDialog, QDialogButtonBox
 
 from E5Gui.E5Completers import E5FileCompleter, E5DirCompleter
 from E5Gui import E5FileDialog
@@ -28,7 +28,7 @@
         
         @param source name of the source file/directory (string)
         @param parent parent widget (QWidget)
-        @param move flag indicating a move operation
+        @param move flag indicating a move operation (boolean)
         @param force flag indicating a forced operation (boolean)
         """
         super().__init__(parent)
@@ -47,6 +47,8 @@
         self.forceCheckBox.setChecked(force)
         
         self.sourceEdit.setText(source)
+        
+        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
     
     def getData(self):
         """
@@ -55,8 +57,11 @@
         @return the target name (string) and a flag indicating
             the operation should be enforced (boolean)
         """
-        # TODO: check if target is an absolute path. If not make it relative to source.
-        return self.targetEdit.text(), self.forceCheckBox.isChecked()
+        target = self.targetEdit.text()
+        if not os.path.isabs(target):
+            sourceDir = os.path.dirname(self.sourceEdit.text())
+            target = os.path.join(sourceDir, target)
+        return target, self.forceCheckBox.isChecked()
     
     @pyqtSlot()
     def on_dirButton_clicked(self):
@@ -80,3 +85,13 @@
         
         if target:
             self.targetEdit.setText(target)
+    
+    @pyqtSlot(str)
+    def on_targetEdit_textChanged(self, txt):
+        """
+        Private slot to handle changes of the target.
+        
+        @param txt contents of the target edit (string)
+        """
+        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
+            os.path.isabs(txt) or os.path.dirname(txt) == "")

eric ide

mercurial