def keyPressEvent(self, event):
     '''
     Defines some of shortcuts for navigation/management in launch
     list view or topics view.
     '''
     key_mod = QApplication.keyboardModifiers()
     if not self.xmlFileView.state() == QAbstractItemView.EditingState:
         # remove history file from list by pressing DEL
         if event == QKeySequence.Delete:
             selected = self._launchItemsFromIndexes(self.xmlFileView.selectionModel().selectedIndexes(), False)
             for item in selected:
                 nm.settings().launch_history_remove(item.path)
                 self.launchlist_model.reloadCurrentPath()
         elif not key_mod and event.key() == Qt.Key_F4 and self.editXmlButton.isEnabled():
             # open selected launch file in xml editor by F4
             self.on_edit_xml_clicked()
         elif event == QKeySequence.Find:
             # set focus to filter box for packages
             self.searchPackageLine.setFocus(Qt.ActiveWindowFocusReason)
         elif event == QKeySequence.Paste:
             # paste files from clipboard
             self.launchlist_model.paste_from_clipboard()
         elif event == QKeySequence.Copy:
             # copy the selected items as file paths into clipboard
             selected = self.xmlFileView.selectionModel().selectedIndexes()
             indexes = []
             for s in selected:
                 indexes.append(self.launchlist_proxyModel.mapToSource(s))
             self.launchlist_model.copy_to_clipboard(indexes)
     if self.searchPackageLine.hasFocus() and event.key() == Qt.Key_Escape:
         # cancel package filtering on pressing ESC
         self.launchlist_model.show_packages(False)
         self.searchPackageLine.setText('')
         self.xmlFileView.setFocus(Qt.ActiveWindowFocusReason)
     QDockWidget.keyReleaseEvent(self, event)
Exemple #2
0
 def keyPressEvent(self, event):
     '''
     Defines some of shortcuts for navigation/management in launch
     list view or topics view.
     '''
     key_mod = QApplication.keyboardModifiers()
     if not self.xmlFileView.state() == QAbstractItemView.EditingState:
         # remove history file from list by pressing DEL
         if event == QKeySequence.Delete:
             selected = self._launchItemsFromIndexes(self.xmlFileView.selectionModel().selectedIndexes(), False)
             for item in selected:
                 nm.settings().launch_history_remove(item.path)
                 self.launchlist_model.reloadCurrentPath()
         elif not key_mod and event.key() == Qt.Key_F4 and self.editXmlButton.isEnabled():
             # open selected launch file in xml editor by F4
             self.on_edit_xml_clicked()
         elif event == QKeySequence.Find:
             # set focus to filter box for packages
             self.searchPackageLine.setFocus(Qt.ActiveWindowFocusReason)
         elif event == QKeySequence.Paste:
             # paste files from clipboard
             self.launchlist_model.paste_from_clipboard()
         elif event == QKeySequence.Copy:
             # copy the selected items as file paths into clipboard
             selected = self.xmlFileView.selectionModel().selectedIndexes()
             indexes = []
             for s in selected:
                 indexes.append(self.launchlist_proxyModel.mapToSource(s))
             self.launchlist_model.copy_to_clipboard(indexes)
     if self.searchPackageLine.hasFocus() and event.key() == Qt.Key_Escape:
         # cancel package filtering on pressing ESC
         self.launchlist_model.show_packages(False)
         self.searchPackageLine.setText('')
         self.xmlFileView.setFocus(Qt.ActiveWindowFocusReason)
     QDockWidget.keyReleaseEvent(self, event)
Exemple #3
0
 def keyPressEvent(self, event):
     '''
     Defines some of shortcuts for navigation/management in launch
     list view or topics view.
     '''
     key_mod = QApplication.keyboardModifiers()
     if not self.ui_file_view.state() == QAbstractItemView.EditingState:
         # remove history file from list by pressing DEL
         if event == QKeySequence.Delete or (event.key() == Qt.Key_Delete
                                             and
                                             key_mod & Qt.ShiftModifier):
             selected = self._pathItemsFromIndexes(
                 self.ui_file_view.selectionModel().selectedIndexes(),
                 False)
             for item in selected:
                 if item in nm.settings().launch_history:
                     nm.settings().launch_history_remove(item.path)
                     self.launchlist_model.reload_current_path()
                 elif not self.launchlist_model.is_in_root:
                     if key_mod & Qt.ShiftModifier:
                         rem_uri, rem_path = nmdurl.split(item.path)
                         host = rem_uri.split(':')
                         result = MessageBox.question(
                             self,
                             "Delete Question",
                             "Delete %s\n@ %s" % (rem_path, host[0]),
                             buttons=MessageBox.No | MessageBox.Yes)
                         if result == MessageBox.Yes:
                             try:
                                 nm.nmd().file.delete(item.path)
                                 self.launchlist_model.reload_current_path(
                                     clear_cache=True)
                             except Exception as e:
                                 rospy.logwarn("Error while delete %s: %s" %
                                               (item.path, utf8(e)))
                                 MessageBox.warning(
                                     self, "Delete error",
                                     'Error while delete:\n%s' % item.name,
                                     "%s" % utf8(e))
                     else:
                         MessageBox.information(
                             self,
                             "Delete Info",
                             "Use Shift+Del to delete files or directories",
                             buttons=MessageBox.Ok)
         elif not key_mod and event.key(
         ) == Qt.Key_F4 and self.ui_button_edit.isEnabled():
             # open selected launch file in xml editor by F4
             self.on_edit_xml_clicked()
         elif event == QKeySequence.Find:
             # set focus to filter box for packages
             self.ui_search_line.setFocus(Qt.ActiveWindowFocusReason)
         elif event == QKeySequence.Paste:
             # paste files from clipboard
             self.launchlist_model.paste_from_clipboard()
         elif event == QKeySequence.Copy:
             # copy the selected items as file paths into clipboard
             selected = self.ui_file_view.selectionModel().selectedIndexes()
             indexes = []
             for s in selected:
                 indexes.append(self.launchlist_proxy_model.mapToSource(s))
             self.launchlist_model.copy_to_clipboard(indexes)
     if self.ui_search_line.hasFocus() and event.key() == Qt.Key_Escape:
         # cancel package filtering on pressing ESC
         self.launchlist_model.reload_current_path()
         self.ui_search_line.setText('')
         self.ui_file_view.setFocus(Qt.ActiveWindowFocusReason)
     QDockWidget.keyReleaseEvent(self, event)