15 from PyQt4.QtCore import * |
15 from PyQt4.QtCore import * |
16 from PyQt4.QtGui import * |
16 from PyQt4.QtGui import * |
17 |
17 |
18 from E4Gui.E4Application import e4App |
18 from E4Gui.E4Application import e4App |
19 |
19 |
20 from ProjectBrowserModel import ProjectBrowserFileItem, \ |
20 from .ProjectBrowserModel import ProjectBrowserFileItem, \ |
21 ProjectBrowserSimpleDirectoryItem, ProjectBrowserDirectoryItem, \ |
21 ProjectBrowserSimpleDirectoryItem, ProjectBrowserDirectoryItem, \ |
22 ProjectBrowserTranslationType |
22 ProjectBrowserTranslationType |
23 from ProjectBaseBrowser import ProjectBaseBrowser |
23 from .ProjectBaseBrowser import ProjectBaseBrowser |
24 |
24 |
25 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
25 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
26 import UI.PixmapCache |
26 import UI.PixmapCache |
27 |
27 |
28 import Preferences |
28 import Preferences |
412 self._selectSingleItem(index) |
412 self._selectSingleItem(index) |
413 categories = self.getSelectedItemsCountCategorized(\ |
413 categories = self.getSelectedItemsCountCategorized(\ |
414 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]) |
414 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]) |
415 cnt = categories["sum"] |
415 cnt = categories["sum"] |
416 |
416 |
417 bfcnt = categories[unicode(ProjectBrowserFileItem)] |
417 bfcnt = categories[str(ProjectBrowserFileItem)] |
418 sdcnt = categories[unicode(ProjectBrowserSimpleDirectoryItem)] |
418 sdcnt = categories[str(ProjectBrowserSimpleDirectoryItem)] |
419 if cnt > 1 and cnt == bfcnt: |
419 if cnt > 1 and cnt == bfcnt: |
420 self.multiMenu.popup(self.mapToGlobal(coord)) |
420 self.multiMenu.popup(self.mapToGlobal(coord)) |
421 else: |
421 else: |
422 index = self.indexAt(coord) |
422 index = self.indexAt(coord) |
423 if cnt == 1 and index.isValid(): |
423 if cnt == 1 and index.isValid(): |
620 itmList = self.getSelectedItems() |
620 itmList = self.getSelectedItems() |
621 if itmList and not previewAll: |
621 if itmList and not previewAll: |
622 for itm in itmList: |
622 for itm in itmList: |
623 if isinstance(itm, ProjectBrowserSimpleDirectoryItem): |
623 if isinstance(itm, ProjectBrowserSimpleDirectoryItem): |
624 dname = itm.dirName().replace(self.project.ppath+os.sep, '') |
624 dname = itm.dirName().replace(self.project.ppath+os.sep, '') |
625 trfiles = self.project.pdata["TRANSLATIONS"][:] |
625 trfiles = sorted(self.project.pdata["TRANSLATIONS"][:]) |
626 trfiles.sort() |
|
627 for trfile in trfiles: |
626 for trfile in trfiles: |
628 if trfile.startswith(dname): |
627 if trfile.startswith(dname): |
629 if trfile not in fileNames: |
628 if trfile not in fileNames: |
630 fileNames.append(os.path.join(self.project.ppath, trfile)) |
629 fileNames.append(os.path.join(self.project.ppath, trfile)) |
631 else: |
630 else: |
632 fn = itm.fileName() |
631 fn = itm.fileName() |
633 if fn not in fileNames: |
632 if fn not in fileNames: |
634 fileNames.append(os.path.join(self.project.ppath, fn)) |
633 fileNames.append(os.path.join(self.project.ppath, fn)) |
635 else: |
634 else: |
636 trfiles = self.project.pdata["TRANSLATIONS"][:] |
635 trfiles = sorted(self.project.pdata["TRANSLATIONS"][:]) |
637 trfiles.sort() |
|
638 fileNames.extend([os.path.join(self.project.ppath, trfile) \ |
636 fileNames.extend([os.path.join(self.project.ppath, trfile) \ |
639 for trfile in trfiles \ |
637 for trfile in trfiles \ |
640 if trfile.endswith('.qm')]) |
638 if trfile.endswith('.qm')]) |
641 self.emit(SIGNAL('trpreview'), fileNames, True) |
639 self.emit(SIGNAL('trpreview'), fileNames, True) |
642 |
640 |
768 Private method to read from a process' stdout channel. |
766 Private method to read from a process' stdout channel. |
769 |
767 |
770 @param proc process to read from (QProcess) |
768 @param proc process to read from (QProcess) |
771 @param ps prompt string (string) |
769 @param ps prompt string (string) |
772 """ |
770 """ |
773 ioEncoding = str(Preferences.getSystem("IOEncoding")) |
771 ioEncoding = Preferences.getSystem("IOEncoding") |
774 |
772 |
775 proc.setReadChannel(QProcess.StandardOutput) |
773 proc.setReadChannel(QProcess.StandardOutput) |
776 while proc and proc.canReadLine(): |
774 while proc and proc.canReadLine(): |
777 s = ps |
775 s = ps |
778 output = unicode(proc.readLine(), ioEncoding, 'replace') |
776 output = str(proc.readLine(), ioEncoding, 'replace') |
779 s += output |
777 s += output |
780 self.emit(SIGNAL('appendStdout'), s) |
778 self.emit(SIGNAL('appendStdout'), s) |
781 |
779 |
782 def __readStderrLupdate(self): |
780 def __readStderrLupdate(self): |
783 """ |
781 """ |
804 Private method to read from a process' stderr channel. |
802 Private method to read from a process' stderr channel. |
805 |
803 |
806 @param proc process to read from (QProcess) |
804 @param proc process to read from (QProcess) |
807 @param ps propmt string (string) |
805 @param ps propmt string (string) |
808 """ |
806 """ |
809 ioEncoding = str(Preferences.getSystem("IOEncoding")) |
807 ioEncoding = Preferences.getSystem("IOEncoding") |
810 |
808 |
811 proc.setReadChannel(QProcess.StandardError) |
809 proc.setReadChannel(QProcess.StandardError) |
812 while proc and proc.canReadLine(): |
810 while proc and proc.canReadLine(): |
813 s = ps |
811 s = ps |
814 error = unicode(proc.readLine(), ioEncoding, 'replace') |
812 error = str(proc.readLine(), ioEncoding, 'replace') |
815 s += error |
813 s += error |
816 self.emit(SIGNAL('appendStderr'), s) |
814 self.emit(SIGNAL('appendStderr'), s) |
817 |
815 |
818 ############################################################################ |
816 ############################################################################ |
819 ## Methods for the generation commands |
817 ## Methods for the generation commands |