def keyPressEvent(self, event): TypeAHeadMixin.keyPressEvent(self, event) key = event.key() if key == Qt.Key_Backspace: idx = self.model().index(0, 0, QModelIndex()) self.on_item_doubleclick(idx) elif key == Qt.Key_Return: print self.state() if self.state() != self.EditingState: try: index, = self.selectedIndexes() except ValueError: pass else: self.on_item_doubleclick(index)
def __init__(self, directory): TypeAHeadMixin.__init__(self) self.menu = None self.directory = directory self.buddies = {} self.sort_actions = [] self._last_selected = {} self.doubleClicked.connect(self.on_item_doubleclick) self.setEditTriggers(self.EditKeyPressed) self.action_rethumb = create_action(self, text="Refresh thumbnail", triggered=self.rethumb_action ) self.action_customthumb = create_action(self, text="Set custom thumbnail", triggered=self.custom_thumb_action ) self.action_nothumb = create_action(self, text="Remove thumbnail", triggered=self.nothumb_action ) self.action_refresh = create_action(self, text="Refresh", icon='gfx/reload.png', shortcut="F5", shortcut_context=Qt.WidgetShortcut, triggered=lambda: self.model().changeDirectory() ) self.action_rename = create_action(self, text="Rename", triggered=self.edit_wrapper ) self.action_delete = create_action(self, text="Delete", shortcut="Del", shortcut_context=Qt.WidgetShortcut, triggered=self.delete_action ) self.action_mkdir = create_action(self, text="Mkdir", shortcut="Ins", shortcut_context=Qt.WidgetShortcut, triggered=self.mkdir_action ) self.addActions([ self.action_rethumb, self.action_refresh, self.action_delete, self.action_mkdir, ])