82 self.__fileManager.rsyncProgressMessage.connect( |
83 self.__fileManager.rsyncProgressMessage.connect( |
83 self.__handleRsyncProgressMessage) |
84 self.__handleRsyncProgressMessage) |
84 self.__fileManager.removeDirectoryDone.connect(self.__newDeviceList) |
85 self.__fileManager.removeDirectoryDone.connect(self.__newDeviceList) |
85 self.__fileManager.createDirectoryDone.connect(self.__newDeviceList) |
86 self.__fileManager.createDirectoryDone.connect(self.__newDeviceList) |
86 self.__fileManager.deleteFileDone.connect(self.__newDeviceList) |
87 self.__fileManager.deleteFileDone.connect(self.__newDeviceList) |
|
88 self.__fileManager.fsinfoDone.connect(self.__shownFsInfoResult) |
87 self.__fileManager.synchTimeDone.connect(self.__timeSynchronized) |
89 self.__fileManager.synchTimeDone.connect(self.__timeSynchronized) |
88 self.__fileManager.showTimeDone.connect(self.__deviceTimeReceived) |
90 self.__fileManager.showTimeDone.connect(self.__deviceTimeReceived) |
89 self.__fileManager.showVersionDone.connect( |
91 self.__fileManager.showVersionDone.connect( |
90 self.__deviceVersionReceived) |
92 self.__deviceVersionReceived) |
|
93 self.__fileManager.showImplementationDone.connect( |
|
94 self.__deviceImplementationReceived) |
91 |
95 |
92 self.__fileManager.error.connect(self.__handleError) |
96 self.__fileManager.error.connect(self.__handleError) |
93 |
97 |
94 self.localFileTreeWidget.customContextMenuRequested.connect( |
98 self.localFileTreeWidget.customContextMenuRequested.connect( |
95 self.__showLocalContextMenu) |
99 self.__showLocalContextMenu) |
122 self.__deviceMenu.addSeparator() |
126 self.__deviceMenu.addSeparator() |
123 self.__devDelFileAct = self.__deviceMenu.addAction( |
127 self.__devDelFileAct = self.__deviceMenu.addAction( |
124 self.tr("Delete File"), self.__deleteDeviceFile) |
128 self.tr("Delete File"), self.__deleteDeviceFile) |
125 self.__deviceMenu.addSeparator() |
129 self.__deviceMenu.addSeparator() |
126 self.__deviceMenu.addAction( |
130 self.__deviceMenu.addAction( |
|
131 self.tr("Show Filesystem Info"), self.__showFileSystemInfo) |
|
132 self.__deviceMenu.addSeparator() |
|
133 self.__deviceMenu.addAction( |
127 self.tr("Synchronize Time"), self.__synchronizeTime) |
134 self.tr("Synchronize Time"), self.__synchronizeTime) |
128 self.__deviceMenu.addAction( |
135 self.__deviceMenu.addAction( |
129 self.tr("Show Time"), self.__showDeviceTime) |
136 self.tr("Show Time"), self.__showDeviceTime) |
130 self.__deviceMenu.addSeparator() |
137 self.__deviceMenu.addSeparator() |
131 self.__deviceMenu.addAction( |
138 self.__deviceMenu.addAction( |
132 self.tr("Show Version"), self.__showDeviceVersion) |
139 self.tr("Show Version"), self.__showDeviceVersion) |
|
140 self.__deviceMenu.addAction( |
|
141 self.tr("Show Implementation"), self.__showImplementation) |
133 |
142 |
134 def start(self): |
143 def start(self): |
135 """ |
144 """ |
136 Public method to start the widget. |
145 Public method to start the widget. |
137 """ |
146 """ |
138 self.__fileManager.connect() |
147 ui = e5App().getObject("UserInterface") |
|
148 vm = e5App().getObject("ViewManager") |
|
149 |
|
150 ui.preferencesChanged.connect( |
|
151 self.__fileManager.handlePreferencesChanged) |
|
152 |
|
153 self.__fileManager.connectToDevice() |
139 |
154 |
140 dirname = "" |
155 dirname = "" |
141 vm = e5App().getObject("ViewManager") |
|
142 aw = vm.activeWindow() |
156 aw = vm.activeWindow() |
143 if aw: |
157 if aw: |
144 dirname = os.path.dirname(aw.getFileName()) |
158 dirname = os.path.dirname(aw.getFileName()) |
145 if not dirname: |
159 if not dirname: |
146 dirname = (Preferences.getMultiProject("Workspace") or |
160 dirname = (Preferences.getMultiProject("Workspace") or |
151 |
165 |
152 def stop(self): |
166 def stop(self): |
153 """ |
167 """ |
154 Public method to stop the widget. |
168 Public method to stop the widget. |
155 """ |
169 """ |
156 self.__fileManager.disconnect() |
170 ui = e5App().getObject("UserInterface") |
|
171 ui.preferencesChanged.disconnect( |
|
172 self.__fileManager.handlePreferencesChanged) |
|
173 |
|
174 self.__fileManager.disconnectFromDevice() |
157 |
175 |
158 @pyqtSlot(str, str) |
176 @pyqtSlot(str, str) |
159 def __handleError(self, method, error): |
177 def __handleError(self, method, error): |
160 """ |
178 """ |
161 Private slot to handle errors. |
179 Private slot to handle errors. |
520 if not os.path.isabs(dirPath): |
538 if not os.path.isabs(dirPath): |
521 dirPath = os.path.join(self.localCwd.text(), dirPath) |
539 dirPath = os.path.join(self.localCwd.text(), dirPath) |
522 self.localCwd.setText(dirPath) |
540 self.localCwd.setText(dirPath) |
523 self.__listLocalFiles(dirPath) |
541 self.__listLocalFiles(dirPath) |
524 |
542 |
525 # TODO: test this |
|
526 @pyqtSlot() |
543 @pyqtSlot() |
527 def __createLocalDirectory(self): |
544 def __createLocalDirectory(self): |
528 """ |
545 """ |
529 Private slot to create a local directory. |
546 Private slot to create a local directory. |
530 """ |
547 """ |
535 QLineEdit.Normal) |
552 QLineEdit.Normal) |
536 if ok and dirPath: |
553 if ok and dirPath: |
537 dirPath = os.path.join(self.localCwd.text(), dirPath) |
554 dirPath = os.path.join(self.localCwd.text(), dirPath) |
538 try: |
555 try: |
539 os.mkdir(dirPath) |
556 os.mkdir(dirPath) |
|
557 self.__listLocalFiles(self.localCwd.text()) |
540 except (OSError, IOError) as exc: |
558 except (OSError, IOError) as exc: |
541 E5MessageBox.critical( |
559 E5MessageBox.critical( |
542 self, |
560 self, |
543 self.tr("Create Directory"), |
561 self.tr("Create Directory"), |
544 self.tr("""<p>The directory <b>{0}</b> could not be""" |
562 self.tr("""<p>The directory <b>{0}</b> could not be""" |
545 """ created.</p><p>Reason: {1}</p>""").format( |
563 """ created.</p><p>Reason: {1}</p>""").format( |
546 dirPath, str(exc)) |
564 dirPath, str(exc)) |
547 ) |
565 ) |
548 |
566 |
549 # TODO: test this |
|
550 @pyqtSlot() |
567 @pyqtSlot() |
551 def __deleteLocalDirectoryTree(self): |
568 def __deleteLocalDirectoryTree(self): |
552 """ |
569 """ |
553 Private slot to delete a local directory tree. |
570 Private slot to delete a local directory tree. |
554 """ |
571 """ |
562 "Do you really want to delete this directory tree?"), |
579 "Do you really want to delete this directory tree?"), |
563 [dirname]) |
580 [dirname]) |
564 if dlg.exec_() == QDialog.Accepted: |
581 if dlg.exec_() == QDialog.Accepted: |
565 try: |
582 try: |
566 shutil.rmtree(dirname) |
583 shutil.rmtree(dirname) |
|
584 self.__listLocalFiles(self.localCwd.text()) |
567 except Exception as exc: |
585 except Exception as exc: |
568 E5MessageBox.critical( |
586 E5MessageBox.critical( |
569 self, |
587 self, |
570 self.tr("Delete Directory Tree"), |
588 self.tr("Delete Directory Tree"), |
571 self.tr("""<p>The directory <b>{0}</b> could not be""" |
589 self.tr("""<p>The directory <b>{0}</b> could not be""" |
572 """ deleted.</p><p>Reason: {1}</p>""").format( |
590 """ deleted.</p><p>Reason: {1}</p>""").format( |
573 dirname, str(exc)) |
591 dirname, str(exc)) |
574 ) |
592 ) |
575 |
593 |
576 # TODO: test this |
|
577 @pyqtSlot() |
594 @pyqtSlot() |
578 def __deleteLocalFile(self): |
595 def __deleteLocalFile(self): |
579 """ |
596 """ |
580 Private slot to delete a local file. |
597 Private slot to delete a local file. |
581 """ |
598 """ |
589 "Do you really want to delete this file?"), |
606 "Do you really want to delete this file?"), |
590 [filename]) |
607 [filename]) |
591 if dlg.exec_() == QDialog.Accepted: |
608 if dlg.exec_() == QDialog.Accepted: |
592 try: |
609 try: |
593 os.remove(filename) |
610 os.remove(filename) |
|
611 self.__listLocalFiles(self.localCwd.text()) |
594 except (OSError, IOError) as exc: |
612 except (OSError, IOError) as exc: |
595 E5MessageBox.critical( |
613 E5MessageBox.critical( |
596 self, |
614 self, |
597 self.tr("Delete File"), |
615 self.tr("Delete File"), |
598 self.tr("""<p>The file <b>{0}</b> could not be""" |
616 self.tr("""<p>The file <b>{0}</b> could not be""" |
599 """ deleted.</p><p>Reason: {1}</p>""").format( |
617 """ deleted.</p><p>Reason: {1}</p>""").format( |
600 filename, str(exc)) |
618 filename, str(exc)) |
601 ) |
619 ) |
602 |
620 |
603 # TODO: test this |
|
604 @pyqtSlot() |
621 @pyqtSlot() |
605 def __showLocalTime(self): |
622 def __showLocalTime(self): |
606 """ |
623 """ |
607 Private slot to show the local date and time. |
624 Private slot to show the local date and time. |
608 """ |
625 """ |
663 if ok and dirPath: |
680 if ok and dirPath: |
664 if not dirPath.startswith("/"): |
681 if not dirPath.startswith("/"): |
665 dirPath = self.deviceCwd.text() + "/" + dirPath |
682 dirPath = self.deviceCwd.text() + "/" + dirPath |
666 self.__fileManager.cd(dirPath) |
683 self.__fileManager.cd(dirPath) |
667 |
684 |
668 # TODO: test this |
|
669 @pyqtSlot() |
685 @pyqtSlot() |
670 def __createDeviceDirectory(self): |
686 def __createDeviceDirectory(self): |
671 """ |
687 """ |
672 Private slot to create a directory on the device. |
688 Private slot to create a directory on the device. |
673 """ |
689 """ |
729 self.tr( |
744 self.tr( |
730 "Do you really want to delete this file?"), |
745 "Do you really want to delete this file?"), |
731 [filename]) |
746 [filename]) |
732 if dlg.exec_() == QDialog.Accepted: |
747 if dlg.exec_() == QDialog.Accepted: |
733 self.__fileManager.delete(filename) |
748 self.__fileManager.delete(filename) |
|
749 |
|
750 @pyqtSlot() |
|
751 def __showFileSystemInfo(self): |
|
752 """ |
|
753 Private slot to show some file system information. |
|
754 """ |
|
755 self.__fileManager.fileSystemInfo() |
|
756 |
|
757 @pyqtSlot(tuple) |
|
758 def __shownFsInfoResult(self, fsinfo): |
|
759 """ |
|
760 Private slot to show the file systom information of the device. |
|
761 |
|
762 @param fsinfo tuple of tuples containing the file system name, the |
|
763 total size, the used size and the free size |
|
764 @type tuple of tuples of (str, int, int, int) |
|
765 """ |
|
766 msg = self.tr("<h3>Filesystem Information</h3>") |
|
767 for name, totalSize, usedSize, freeSize in fsinfo: |
|
768 msg += self.tr( |
|
769 "<h4>{0}</h4" |
|
770 "<table>" |
|
771 "<tr><td>Total Size: </td><td align='right'>{1}</td></tr>" |
|
772 "<tr><td>Used Size: </td><td align='right'>{2}</td></tr>" |
|
773 "<tr><td>Free Size: </td><td align='right'>{3}</td></tr>" |
|
774 "</table>" |
|
775 ).format(name, |
|
776 Globals.dataString(totalSize), |
|
777 Globals.dataString(usedSize), |
|
778 Globals.dataString(freeSize), |
|
779 ) |
|
780 E5MessageBox.information( |
|
781 self, |
|
782 self.tr("Filesystem Information"), |
|
783 msg) |
734 |
784 |
735 @pyqtSlot() |
785 @pyqtSlot() |
736 def __synchronizeTime(self): |
786 def __synchronizeTime(self): |
737 """ |
787 """ |
738 Private slot to synchronize the local time to the device. |
788 Private slot to synchronize the local time to the device. |
812 msg = self.tr("No version information available.") |
862 msg = self.tr("No version information available.") |
813 E5MessageBox.information( |
863 E5MessageBox.information( |
814 self, |
864 self, |
815 self.tr("Device Version Information"), |
865 self.tr("Device Version Information"), |
816 msg) |
866 msg) |
|
867 |
|
868 @pyqtSlot() |
|
869 def __showImplementation(self): |
|
870 """ |
|
871 Private slot to show some implementation related information. |
|
872 """ |
|
873 self.__fileManager.showImplementation() |
|
874 |
|
875 @pyqtSlot(str, str) |
|
876 def __deviceImplementationReceived(self, name, version): |
|
877 """ |
|
878 Privat slot handling the receipt of implementation info. |
|
879 |
|
880 @param name name of the implementation |
|
881 @type str |
|
882 @param version version string of the implementation |
|
883 @type str |
|
884 """ |
|
885 E5MessageBox.information( |
|
886 self, |
|
887 self.tr("Device Implementation Information"), |
|
888 self.tr( |
|
889 "<h3>Device Implementation Information</h3>" |
|
890 "<p>This device contains <b>{0} {1}</b>.</p>" |
|
891 ).format(name, version) |
|
892 ) |