示例#1
0
 def keyPressEvent(self, event):
     """Reimplement Qt method"""
     if event == QKeySequence.Copy:
         self.copy()
         event.accept()
     else:
         QTableView.keyPressEvent(self, event)
示例#2
0
 def _songKeyPressEvent(self, event):
     if event.matches(QKeySequence.Delete):
         self._removeSongs()
     elif event.key() == Qt.Key_Escape:
         self.songList.setCurrentIndex(QModelIndex())
     else:
         QTableView.keyPressEvent(self.songList, event)
示例#3
0
    def keyPressEvent(self, event):
        """Capture certain types of keypress events and handle them different ways."""
        # When data has been edited, move to the next row in the column and continue editing.
        currentIndex = self.currentIndex()

        #print "row: " + str(currentIndex.row()) + ", col: " + str(currentIndex.column())
        
        if currentIndex.isValid():
            if self.state() == QAbstractItemView.EditingState:
                if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
                    Util.debug(3, "DataTableView.keyPressEvent", "Enter key pressed in table")
                    newIndex = self.model().createIndex(currentIndex.row() + 1, currentIndex.column())
                    self.setCurrentIndex(newIndex)
                    self.edit(newIndex)
                    self.setCurrentIndex(newIndex)
                    return
                elif event.key() == Qt.Key_Up:
                    Util.debug(3, "DataTableView.keyPressEvent", "Up key pressed in table")
                    newIndex = self.model().createIndex(currentIndex.row() - 1, currentIndex.column())
                    #print "nrow: " + str(newIndex.row()) + ", ncol: " + str(newIndex.column())
                    #self.setCurrentIndex(newIndex)
                    self.setState(QAbstractItemView.NoState)
                elif event.key() == Qt.Key_Down:
                    Util.debug(3, "DataTableView.keyPressEvent", "Down key pressed in table")
                    newIndex = self.model().createIndex(currentIndex.row() + 1, currentIndex.column())
                    #print "nrow: " + str(newIndex.row()) + ", ncol: " + str(newIndex.column())
                    #self.setCurrentIndex(newIndex)
                    self.setState(QAbstractItemView.NoState)
        
        # Nothing found, so resort to default behavior
        QTableView.keyPressEvent(self, event)
示例#4
0
 def keyPressEvent(self, event):
     """Reimplement Qt method"""
     if event == QKeySequence.Copy:
         self.copy()
         event.accept()
     else:
         QTableView.keyPressEvent(self, event)
	def keyPressEvent(self, key_event):
		"""Redefining the QTableView required key press events

		Params:
		- key_event: receives the key press event
		"""
		QTableView.keyPressEvent(self, key_event)

		#According to the item selection status it's selected/unselected
		#with the space bar
		if key_event.key() == Qt.Key_Space:
			self.update_selected_items()

		#With the following ifs are capture the F4 key events execute the
		#corresponding actions
		if key_event.key() == Qt.Key_F4 and len(self.selectedIndexes()) == 1:
			#When there is only one selected item, the selected item will be renamed
			self.rename_dialog(self.selectedIndexes()[0])

		if key_event.key() == Qt.Key_F4 and len(self.selectedIndexes()) == 0:
			#When there is no selected item, the item that has the cursor over will be renamed
			self.rename_dialog(self.currentIndex())

		if key_event.key() == Qt.Key_F4 and len(self.selectedIndexes()) > 1:
			#When there are more than one selected item, all of them will be unselected
			#and the item where the cursor is over will be renamed
			self.selectionModel().clearSelection()
			self.rename_dialog(self.currentIndex())
示例#6
0
    def cell_key_pressed(self, q_key_event):
        """
        Handles the event of pressing a keyboard key while on the table.
        """
        logging.warning("A key was pressed!!!")
        key = q_key_event.key()
        logging.info("Key = {}".format(key))

        if(Qt.ControlModifier == (int(q_key_event.modifiers()) & (Qt.ControlModifier))):
            if key == Qt.Key_Delete:
                logging.info("Delete key pressed while in the table. Clear all filters")
                self.clear_all_filters()
            elif key == Qt.Key_H:
                self.hide_rows_based_on_selected_cells()
            elif key == Qt.Key_O:
                self.show_rows_based_on_selected_cells()
            elif key == Qt.Key_Up: # Jump to previous match
                selected_indexes = self.get_selected_indexes()
                if(len(selected_indexes) == 1):
                    self.go_to_prev_match(selected_indexes[0])
            elif key == Qt.Key_Down: # Jump to next match
                selected_indexes = self.get_selected_indexes()
                if(len(selected_indexes) == 1):
                    self.go_to_next_match(selected_indexes[0])           
            elif key == Qt.Key_PageUp:
                selected_indexes = self.get_selected_indexes()
                if(len(selected_indexes) == 1):
                    prev_bookmark_index = self.table_model.getPrevBookmarkIndex(selected_indexes[0])
                    if(prev_bookmark_index is not None):
                        self.select_cell_by_index(prev_bookmark_index)
            elif key == Qt.Key_PageDown:
                selected_indexes = self.get_selected_indexes()
                if(len(selected_indexes) == 1):
                    next_bookmark_index = self.table_model.getNextBookmarkIndex(selected_indexes[0])
                    if(next_bookmark_index is not None):
                        self.select_cell_by_index(next_bookmark_index)
            elif key == Qt.Key_C:
                selected_indexes = self.get_selected_indexes()
                self.prepare_clipboard_text()
            elif key == Qt.Key_B:
                if(Qt.ShiftModifier == (int(q_key_event.modifiers()) & (Qt.ShiftModifier))):
                    self.table_model.clearAllBookmarks()
                else:
                    selected_indexes = self.get_selected_indexes()
                    self.table_model.toggleBookmarks(selected_indexes)
            elif key == Qt.Key_Left:
                self.select_search_match(is_forward=False)
            elif key == Qt.Key_Right:
                self.select_search_match(is_forward=True)
            elif key == Qt.Key_Home:
                self.select_cell_by_row_and_column(0, 0);
            elif key == Qt.Key_End:
                self.select_cell_by_row_and_column(self.table_model.rowCount(None) - 1, 0);               
        elif key == Qt.Key_F5:
            self.load_log_file(self.log_file_full_path)
        
        else:
            QTableView.keyPressEvent(self.user_interface.tblLogData, q_key_event)
        self.update_graph_markers()
 def keyPressEvent(self, event):
     if event.key() == Qt.Key_Return and self.state() != QAbstractItemView.EditingState:
         selected = self.selectionModel().selectedIndexes()
         if selected:
             selected = selected[0]
             self.setCurrentIndex(selected)
             self.edit(selected)
     else:
         QTableView.keyPressEvent(self, event)
 def keyPressEvent(self, evt):
     """
     Protected method implementing special key handling.
     
     @param evt reference to the event (QKeyEvent)
     """
     if evt.key() in [Qt.Key_Delete, Qt.Key_Backspace] and \
        self.model() is not None:
         self.removeSelected()
         evt.setAccepted(True)
     else:
         QTableView.keyPressEvent(self, evt)
示例#9
0
 def keyPressEvent(self, event):
     if event.key() == Qt.Key_Tab:
         index = self.currentIndex()
         model = index.model()
         if index.column() == WORD:
             self.setCurrentIndex(index.sibling(index.row(),MEANINGS))
         elif index.column() == MEANINGS:
             self.setCurrentIndex(index.sibling(index.row(),CONTEXT))
         elif index.column() == CONTEXT and index.row() != model.rowCount()-1:
             self.setCurrentIndex(index.sibling(index.row()+1,WORD))
     else:
         QTableView.keyPressEvent(self, event)
示例#10
0
    def keyPressEvent(self, event):
        if event.key() == QtCore.Qt.Key_Delete:
            if len(self.selectedIndexes()) > 0:
                indexes = self.selectedIndexes()
                rowIndexes = []

                for i in range(0, len(indexes), 4):
                    index = indexes[i]
                    rowIndexes.append(index.row())
                self.emit(QtCore.SIGNAL("requestDeleted"), rowIndexes)
        else:
            QTableView.keyPressEvent(self, event)
示例#11
0
 def keyPressEvent(self, event):
     """Reimplement Qt methods"""
     if event.key() == Qt.Key_Delete:
         self.remove_item()
         event.accept()
     elif event.key() == Qt.Key_F2:
         self.rename_item()
         event.accept()
     elif event == QKeySequence.Paste:
         self.paste()
         event.accept()
     else:
         QTableView.keyPressEvent(self, event)
示例#12
0
 def keyPressEvent(self, event):
     """Reimplement Qt methods"""
     if event.key() == Qt.Key_Delete:
         self.remove_item()
         event.accept()
     elif event.key() == Qt.Key_F2:
         self.rename_item()
         event.accept()
     elif event == QKeySequence.Paste:
         self.paste()
         event.accept()
     else:
         QTableView.keyPressEvent(self, event)
示例#13
0
 def keyPressEvent(self, event):
     """
     Reimplemented from tableview
     """
     if event.key() == Qt.Key_Delete:
         self.removeItem()
     return QTableView.keyPressEvent(self, event)
示例#14
0
	def keyPressEvent(self, event):
		if event.key() == Qt.Key_Delete:
			index = self.selectedIndexes()[0]
			row = index.model().itemFromIndex(index).row()

			childIndex=self.model().index(row+1,0)
			childIndex2=self.model().index(row+1,self.model().columnCount()-1)
			self.selectionModel().clearSelection()
			self.selectionModel().select(QItemSelection(childIndex,childIndex2), QItemSelectionModel.Select)
			self.selectionModel().setCurrentIndex(childIndex,QItemSelectionModel.Rows)
			if self.playingId == row:
				self.runAction.emit('stop')
			self.model().removeRow(row)
		elif event.key() == Qt.Key_Return:
			self.runAction.emit('play')
		QTableView.keyPressEvent(self, event)
示例#15
0
	def keyPressEvent(self, event):
		if event.key() == Qt.Key_Delete:
			index = self.selectedIndexes()[0]
			row = index.model().itemFromIndex(index).row()

			childIndex=self.model().index(row+1,0)
			childIndex2=self.model().index(row+1,self.model().columnCount()-1)
			self.selectionModel().clearSelection()
			self.selectionModel().select(QItemSelection(childIndex,childIndex2), QItemSelectionModel.Select)
			self.selectionModel().setCurrentIndex(childIndex,QItemSelectionModel.Rows)
			if self.playingId == row:
				self.runAction.emit('stop')
			self.model().removeRow(row)
		elif event.key() == Qt.Key_Return:
			self.runAction.emit('play')
		QTableView.keyPressEvent(self, event)
示例#16
0
 def keyPressEvent(self, event):
     if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Delete:
         row = self.currentIndex().row()
         task = self.get_task_by_row(row)
         if task:
             self.delete_task_by_id(task.id)
     elif event.type() == QEvent.KeyPress and (event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return):
         Global.event.task_selected.emit(self.get_task_by_row(self.currentIndex().row()))
     else:
         return QTableView.keyPressEvent(self, event)
示例#17
0
 def keyPressEvent(self, event):
     """
     Reimplemented from tableview
     """ 
     return QTableView.keyPressEvent(self, event)
示例#18
0
	def keyPressEvent(self, event):
		if event.key() == Qt.Key_Return:
			self.runAction.emit('play')
		QTableView.keyPressEvent(self, event)
示例#19
0
def main(icon_spec):
    app = QApplication(sys.argv)

    main_window = QMainWindow()

    def sigint_handler(*args):
        main_window.close()
    signal.signal(signal.SIGINT, sigint_handler)
    # the timer enables triggering the sigint_handler
    signal_timer = QTimer()
    signal_timer.start(100)
    signal_timer.timeout.connect(lambda: None)

    tool_bar = QToolBar()
    main_window.addToolBar(Qt.TopToolBarArea, tool_bar)

    table_view = QTableView()
    table_view.setSelectionBehavior(QAbstractItemView.SelectRows)
    table_view.setSelectionMode(QAbstractItemView.SingleSelection)
    table_view.setSortingEnabled(True)
    main_window.setCentralWidget(table_view)

    proxy_model = QSortFilterProxyModel()
    proxy_model.setFilterCaseSensitivity(Qt.CaseInsensitive)
    proxy_model.setFilterKeyColumn(1)
    table_view.setModel(proxy_model)
    proxy_model.layoutChanged.connect(table_view.resizeRowsToContents)

    item_model = QStandardItemModel()
    proxy_model.setSourceModel(item_model)

    # get all icons and their available sizes
    QIcon.setThemeName("gnome")
    icons = []
    all_sizes = set([])
    for context, icon_names in icon_spec:
        for icon_name in icon_names:
            icon = QIcon.fromTheme(icon_name)
            sizes = []
            for size in icon.availableSizes():
                size = (size.width(), size.height())
                sizes.append(size)
                all_sizes.add(size)
            sizes.sort()
            icons.append({
                'context': context,
                'icon_name': icon_name,
                'icon': icon,
                'sizes': sizes,
            })
    all_sizes = list(all_sizes)
    all_sizes.sort()

    # input field for filter
    def filter_changed(value):
        proxy_model.setFilterRegExp(value)
        table_view.resizeRowsToContents()
    filter_line_edit = QLineEdit()
    filter_line_edit.setMaximumWidth(200)
    filter_line_edit.setPlaceholderText('Filter name')
    filter_line_edit.setToolTip('Filter name optionally using regular expressions (' + QKeySequence(QKeySequence.Find).toString() + ')')
    filter_line_edit.textChanged.connect(filter_changed)
    tool_bar.addWidget(filter_line_edit)

    # actions to toggle visibility of available sizes/columns 
    def action_toggled(index):
        column = 2 + index
        table_view.setColumnHidden(column, not table_view.isColumnHidden(column))
        table_view.resizeColumnsToContents()
        table_view.resizeRowsToContents()
    signal_mapper = QSignalMapper()
    for i, size in enumerate(all_sizes):
        action = QAction('%dx%d' % size, tool_bar)
        action.setCheckable(True)
        action.setChecked(True)
        tool_bar.addAction(action)
        action.toggled.connect(signal_mapper.map)
        signal_mapper.setMapping(action, i)
        # set tool tip and handle key sequence
        tool_tip = 'Toggle visibility of column'
        if i < 10:
            digit = ('%d' % (i + 1))[-1]
            tool_tip += ' (%s)' % QKeySequence('Ctrl+%s' % digit).toString()
        action.setToolTip(tool_tip)
    signal_mapper.mapped.connect(action_toggled)

    # label columns
    header_labels = ['context', 'name']
    for width, height in all_sizes:
        header_labels.append('%dx%d' % (width, height))
    item_model.setColumnCount(len(header_labels))
    item_model.setHorizontalHeaderLabels(header_labels)

    # fill rows
    item_model.setRowCount(len(icons))
    for row, icon_data in enumerate(icons):
        # context
        item = QStandardItem(icon_data['context'])
        item.setFlags(item.flags() ^ Qt.ItemIsEditable)
        item_model.setItem(row, 0, item)
        # icon name
        item = QStandardItem(icon_data['icon_name'])
        item.setFlags(item.flags() ^ Qt.ItemIsEditable)
        item_model.setItem(row, 1, item)
        for index_in_all_sizes, size in enumerate(all_sizes):
            column = 2 + index_in_all_sizes
            if size in icon_data['sizes']:
                # icon as pixmap to keep specific size
                item = QStandardItem('')
                pixmap = icon_data['icon'].pixmap(size[0], size[1])
                item.setData(pixmap, Qt.DecorationRole)
                item.setFlags(item.flags() ^ Qt.ItemIsEditable)
                item_model.setItem(row, column, item)
            else:
                # single space to be sortable against icons
                item = QStandardItem(' ')
                item.setFlags(item.flags() ^ Qt.ItemIsEditable)
                item_model.setItem(row, column, item)

    table_view.resizeColumnsToContents()
    # manually set row heights because resizeRowsToContents is not working properly
    for row, icon_data in enumerate(icons):
        if len(icon_data['sizes']) > 0:
            max_size = icon_data['sizes'][-1]
            table_view.setRowHeight(row, max_size[1])

    # enable focus find (ctrl+f) and toggle columns (ctrl+NUM)
    def main_window_keyPressEvent(self, event, old_keyPressEvent=QMainWindow.keyPressEvent):
        if event.matches(QKeySequence.Find):
            filter_line_edit.setFocus()
            return
        if event.modifiers() == Qt.ControlModifier and event.key() >= Qt.Key_0 and event.key() <= Qt.Key_9:
            index = event.key() - Qt.Key_1
            if event.key() == Qt.Key_0:
                index += 10
            action = signal_mapper.mapping(index)
            if action:
                action.toggle()
                return
        old_keyPressEvent(self, event)
    main_window.keyPressEvent = new.instancemethod(main_window_keyPressEvent, table_view, None)

    # enable copy (ctrl+c) name of icon to clipboard
    def table_view_keyPressEvent(self, event, old_keyPressEvent=QTableView.keyPressEvent):
        if event.matches(QKeySequence.Copy):
            selection_model = self.selectionModel()
            if selection_model.hasSelection():
                index = selection_model.selectedRows()[0]
                source_index = self.model().mapToSource(index)
                item = self.model().sourceModel().item(source_index.row(), 1)
                icon_name = item.data(Qt.EditRole)
                app.clipboard().setText(icon_name.toString())
                return
        old_keyPressEvent(self, event)
    table_view.keyPressEvent = new.instancemethod(table_view_keyPressEvent, table_view, None)
    print 'Icon Theme: ', QIcon.themeName()

    print 'Theme Search Paths:'
    for item in QIcon.themeSearchPaths():
        print item
    main_window.showMaximized()
    return app.exec_()
示例#20
0
def main(icon_spec):
    app = QApplication(sys.argv)

    main_window = QMainWindow()

    def sigint_handler(*args):
        main_window.close()

    signal.signal(signal.SIGINT, sigint_handler)
    # the timer enables triggering the sigint_handler
    signal_timer = QTimer()
    signal_timer.start(100)
    signal_timer.timeout.connect(lambda: None)

    tool_bar = QToolBar()
    main_window.addToolBar(Qt.TopToolBarArea, tool_bar)

    table_view = QTableView()
    table_view.setSelectionBehavior(QAbstractItemView.SelectRows)
    table_view.setSelectionMode(QAbstractItemView.SingleSelection)
    table_view.setSortingEnabled(True)
    main_window.setCentralWidget(table_view)

    proxy_model = QSortFilterProxyModel()
    proxy_model.setFilterCaseSensitivity(Qt.CaseInsensitive)
    proxy_model.setFilterKeyColumn(1)
    table_view.setModel(proxy_model)
    proxy_model.layoutChanged.connect(table_view.resizeRowsToContents)

    item_model = QStandardItemModel()
    proxy_model.setSourceModel(item_model)

    # get all icons and their available sizes
    QIcon.setThemeName("gnome")
    icons = []
    all_sizes = set([])
    for context, icon_names in icon_spec:
        for icon_name in icon_names:
            icon = QIcon.fromTheme(icon_name)
            sizes = []
            for size in icon.availableSizes():
                size = (size.width(), size.height())
                sizes.append(size)
                all_sizes.add(size)
            sizes.sort()
            icons.append({
                'context': context,
                'icon_name': icon_name,
                'icon': icon,
                'sizes': sizes,
            })
    all_sizes = list(all_sizes)
    all_sizes.sort()

    # input field for filter
    def filter_changed(value):
        proxy_model.setFilterRegExp(value)
        table_view.resizeRowsToContents()

    filter_line_edit = QLineEdit()
    filter_line_edit.setMaximumWidth(200)
    filter_line_edit.setPlaceholderText('Filter name')
    filter_line_edit.setToolTip(
        'Filter name optionally using regular expressions (' +
        QKeySequence(QKeySequence.Find).toString() + ')')
    filter_line_edit.textChanged.connect(filter_changed)
    tool_bar.addWidget(filter_line_edit)

    # actions to toggle visibility of available sizes/columns
    def action_toggled(index):
        column = 2 + index
        table_view.setColumnHidden(column,
                                   not table_view.isColumnHidden(column))
        table_view.resizeColumnsToContents()
        table_view.resizeRowsToContents()

    signal_mapper = QSignalMapper()
    for i, size in enumerate(all_sizes):
        action = QAction('%dx%d' % size, tool_bar)
        action.setCheckable(True)
        action.setChecked(True)
        tool_bar.addAction(action)
        action.toggled.connect(signal_mapper.map)
        signal_mapper.setMapping(action, i)
        # set tool tip and handle key sequence
        tool_tip = 'Toggle visibility of column'
        if i < 10:
            digit = ('%d' % (i + 1))[-1]
            tool_tip += ' (%s)' % QKeySequence('Ctrl+%s' % digit).toString()
        action.setToolTip(tool_tip)
    signal_mapper.mapped.connect(action_toggled)

    # label columns
    header_labels = ['context', 'name']
    for width, height in all_sizes:
        header_labels.append('%dx%d' % (width, height))
    item_model.setColumnCount(len(header_labels))
    item_model.setHorizontalHeaderLabels(header_labels)

    # fill rows
    item_model.setRowCount(len(icons))
    for row, icon_data in enumerate(icons):
        # context
        item = QStandardItem(icon_data['context'])
        item.setFlags(item.flags() ^ Qt.ItemIsEditable)
        item_model.setItem(row, 0, item)
        # icon name
        item = QStandardItem(icon_data['icon_name'])
        item.setFlags(item.flags() ^ Qt.ItemIsEditable)
        item_model.setItem(row, 1, item)
        for index_in_all_sizes, size in enumerate(all_sizes):
            column = 2 + index_in_all_sizes
            if size in icon_data['sizes']:
                # icon as pixmap to keep specific size
                item = QStandardItem('')
                pixmap = icon_data['icon'].pixmap(size[0], size[1])
                item.setData(pixmap, Qt.DecorationRole)
                item.setFlags(item.flags() ^ Qt.ItemIsEditable)
                item_model.setItem(row, column, item)
            else:
                # single space to be sortable against icons
                item = QStandardItem(' ')
                item.setFlags(item.flags() ^ Qt.ItemIsEditable)
                item_model.setItem(row, column, item)

    table_view.resizeColumnsToContents()
    # manually set row heights because resizeRowsToContents is not working properly
    for row, icon_data in enumerate(icons):
        if len(icon_data['sizes']) > 0:
            max_size = icon_data['sizes'][-1]
            table_view.setRowHeight(row, max_size[1])

    # enable focus find (ctrl+f) and toggle columns (ctrl+NUM)
    def main_window_keyPressEvent(self,
                                  event,
                                  old_keyPressEvent=QMainWindow.keyPressEvent):
        if event.matches(QKeySequence.Find):
            filter_line_edit.setFocus()
            return
        if event.modifiers() == Qt.ControlModifier and event.key(
        ) >= Qt.Key_0 and event.key() <= Qt.Key_9:
            index = event.key() - Qt.Key_1
            if event.key() == Qt.Key_0:
                index += 10
            action = signal_mapper.mapping(index)
            if action:
                action.toggle()
                return
        old_keyPressEvent(self, event)

    main_window.keyPressEvent = new.instancemethod(main_window_keyPressEvent,
                                                   table_view, None)

    # enable copy (ctrl+c) name of icon to clipboard
    def table_view_keyPressEvent(self,
                                 event,
                                 old_keyPressEvent=QTableView.keyPressEvent):
        if event.matches(QKeySequence.Copy):
            selection_model = self.selectionModel()
            if selection_model.hasSelection():
                index = selection_model.selectedRows()[0]
                source_index = self.model().mapToSource(index)
                item = self.model().sourceModel().item(source_index.row(), 1)
                icon_name = item.data(Qt.EditRole)
                app.clipboard().setText(icon_name.toString())
                return
        old_keyPressEvent(self, event)

    table_view.keyPressEvent = new.instancemethod(table_view_keyPressEvent,
                                                  table_view, None)
    print 'Icon Theme: ', QIcon.themeName()

    print 'Theme Search Paths:'
    for item in QIcon.themeSearchPaths():
        print item
    main_window.showMaximized()
    return app.exec_()
示例#21
0
    def cell_key_pressed(self, q_key_event):
        """
        Handles the event of pressing a keyboard key while on the table.
        """
        logging.warning("A key was pressed!!!")
        key = q_key_event.key()
        logging.info("Key = {}".format(key))

        if (Qt.ControlModifier == (int(q_key_event.modifiers()) &
                                   (Qt.ControlModifier))):
            if key == Qt.Key_Delete:
                logging.info(
                    "Delete key pressed while in the table. Clear all filters")
                self.clear_all_filters()
            elif key == Qt.Key_H:
                self.hide_rows_based_on_selected_cells()
            elif key == Qt.Key_O:
                self.show_rows_based_on_selected_cells()
            elif key == Qt.Key_Up:  # Jump to previous match
                selected_indexes = self.get_selected_indexes()
                if (len(selected_indexes) == 1):
                    self.go_to_prev_match(selected_indexes[0])
            elif key == Qt.Key_Down:  # Jump to next match
                selected_indexes = self.get_selected_indexes()
                if (len(selected_indexes) == 1):
                    self.go_to_next_match(selected_indexes[0])
            elif key == Qt.Key_PageUp:
                selected_indexes = self.get_selected_indexes()
                if (len(selected_indexes) == 1):
                    prev_bookmark_index = self.table_model.getPrevBookmarkIndex(
                        selected_indexes[0])
                    if (prev_bookmark_index is not None):
                        self.select_cell_by_index(prev_bookmark_index)
            elif key == Qt.Key_PageDown:
                selected_indexes = self.get_selected_indexes()
                if (len(selected_indexes) == 1):
                    next_bookmark_index = self.table_model.getNextBookmarkIndex(
                        selected_indexes[0])
                    if (next_bookmark_index is not None):
                        self.select_cell_by_index(next_bookmark_index)
            elif key == Qt.Key_C:
                selected_indexes = self.get_selected_indexes()
                self.prepare_clipboard_text()
            elif key == Qt.Key_B:
                if (Qt.ShiftModifier == (int(q_key_event.modifiers()) &
                                         (Qt.ShiftModifier))):
                    self.table_model.clearAllBookmarks()
                else:
                    selected_indexes = self.get_selected_indexes()
                    self.table_model.toggleBookmarks(selected_indexes)
            elif key == Qt.Key_Left:
                self.select_search_match(is_forward=False)
            elif key == Qt.Key_Right:
                self.select_search_match(is_forward=True)
            elif key == Qt.Key_Home:
                self.select_cell_by_row_and_column(0, 0)
            elif key == Qt.Key_End:
                self.select_cell_by_row_and_column(
                    self.table_model.rowCount(None) - 1, 0)
        elif key == Qt.Key_F5:
            self.load_log_file(self.log_file_full_path)

        else:
            QTableView.keyPressEvent(self.user_interface.tblLogData,
                                     q_key_event)
        self.update_graph_markers()
示例#22
0
 def keyPressEvent(self, event):
     if event.text() == " ":
         self.spacePressed.emit()
         return
     QTableView.keyPressEvent(self, event)
示例#23
0
 def keyPressEvent(self, event):
     if event.text() == ' ':
         self.spacePressed.emit()
         return
     QTableView.keyPressEvent(self, event)
示例#24
0
 def keyPressEvent(self, event):
     if event.key() == Qt.Key_Delete:
         # override delete to delete the cell contents
         self.menuClear()
     else:
         return QTableView.keyPressEvent(self, event)
示例#25
0
文件: xeb.py 项目: rorydog1/epics
 def keyPressEvent(self, event):
     if event.key() == Qt.Key_Delete:
         # override delete to delete the cell contents
         self.menuClear()
     else:
         return QTableView.keyPressEvent(self, event)
示例#26
0
 def keyPressEvent(self, event):
     if event.key() == Qt.Key_Return:
         self.runAction.emit('play')
     QTableView.keyPressEvent(self, event)