:type parent: QTableView
        :type undo_stack: QUndoStack
420290
def get_action(self, parent, undo_stack: QUndoStack, sel_range, protocol, view: int):
        
        self.command = ZeroHideAction(protocol, self.following_zeros, view, self.zero_hide_offsets)
        action = QAction(self.command.text(), parent)
        action.triggered.connect(self.action_triggered)
        self.undo_stack = undo_stack
        return action
1138779
def qteAbort(self, msgObj):
        
        self.qteWidget.setCursorPosition(*self.cursorPosOrig)
        try:
            self.qteMain.qtesigAbort.disconnect(self.qteAbort)
        except TypeError:
            pass
        try:
            self.qteText.textChanged.disconnect(self.qteTextChanged)
        except TypeError:
            pass
        self.qteWidget.qteSetLexer(self.originalLexer)
758939
def accept(self):
        """"""
        for index in range(self.stack.count()):
            self.stack.widget(index).accept_changes()
        QDialog.accept(self)
1152707
def reset(self):
        """"""
        self.data_stack = stack.Stack()
        self.return_stack = stack.Stack()
        self.instruction_pointer = 0
        return self
212323
def rowsAboutToBeRemoved(self, parent, start, end):
        """"""
        self._viewIsDirty = True
        super(StimulusView, self).rowsAboutToBeRemoved(parent, start, end)
488691
function(ctx) {
			var i,
				n,
				$row,
				$tbody,
				tree = ctx.tree,
				opts = ctx.options,
				tableOpts = opts.table,
				$table = tree.widget.element;

			if (tableOpts.customStatus != null) {
				if (opts.renderStatusColumns != null) {
					$.error(
						"The 'customStatus' option is deprecated since v2.15.0. Use 'renderStatusColumns' only instead."
					);
				} else {
					tree.warn(
						"The 'customStatus' option is deprecated since v2.15.0. Use 'renderStatusColumns' instead."
					);
					opts.renderStatusColumns = tableOpts.customStatus;
				}
			}
			if (opts.renderStatusColumns) {
				if (opts.renderStatusColumns === true) {
					opts.renderStatusColumns = opts.renderColumns;
					// } else if( opts.renderStatusColumns === "wide" ) {
					// 	opts.renderStatusColumns = _renderStatusNodeWide;
				}
			}

			$table.addClass("fancytree-container fancytree-ext-table");
			$tbody = $table.find(">tbody");
			if (!$tbody.length) {
				// TODO: not sure if we can rely on browsers to insert missing <tbody> before <tr>s:
				if ($table.find(">tr").length) {
					$.error(
						"Expected table > tbody > tr. If you see this please open an issue."
					);
				}
				$tbody = $("<tbody>").appendTo($table);
			}

			tree.tbody = $tbody[0];

			// Prepare row templates:
			// Determine column count from table header if any
			tree.columnCount = $("thead >tr:last >th", $table).length;
			// Read TR templates from tbody if any
			$row = $tbody.children("tr:first");
			if ($row.length) {
				n = $row.children("td").length;
				if (tree.columnCount && n !== tree.columnCount) {
					tree.warn(
						"Column count mismatch between thead (" +
							tree.columnCount +
							") and tbody (" +
							n +
							"): using tbody."
					);
					tree.columnCount = n;
				}
				$row = $row.clone();
			} else {
				// Only thead is defined: create default row markup
				_assert(
					tree.columnCount >= 1,
					"Need either <thead> or <tbody> with <td> elements to determine column count."
				);
				$row = $("<tr />");
				for (i = 0; i < tree.columnCount; i++) {
					$row.append("<td />");
				}
			}
			$row.find(">td")
				.eq(tableOpts.nodeColumnIdx)
				.html("<span class='fancytree-node' />");
			if (opts.aria) {
				$row.attr("role", "row");
				$row.find("td").attr("role", "gridcell");
			}
			tree.rowFragment = document.createDocumentFragment();
			tree.rowFragment.appendChild($row.get(0));

			// // If tbody contains a second row, use this as status node template
			// $row = $tbody.children("tr:eq(1)");
			// if( $row.length === 0 ) {
			// 	tree.statusRowFragment = tree.rowFragment;
			// } else {
			// 	$row = $row.clone();
			// 	tree.statusRowFragment = document.createDocumentFragment();
			// 	tree.statusRowFragment.appendChild($row.get(0));
			// }
			//
			$tbody.empty();

			// Make sure that status classes are set on the node's <tr> elements
			tree.statusClassPropName = "tr";
			tree.ariaPropName = "tr";
			this.nodeContainerAttrName = "tr";

			// #489: make sure $container is set to <table>, even if ext-dnd is listed before ext-table
			tree.$container = $table;

			this._superApply(arguments);

			// standard Fancytree created a root UL
			$(tree.rootNode.ul).remove();
			tree.rootNode.ul = null;

			// Add container to the TAB chain
			// #577: Allow to set tabindex to "0", "-1" and ""
			this.$container.attr("tabindex", opts.tabindex);
			// this.$container.attr("tabindex", opts.tabbable ? "0" : "-1");
			if (opts.aria) {
				tree.$container
					.attr("role", "treegrid")
					.attr("aria-readonly", true);
			}
		}
169678
def keyPressEvent(self, keyEvent):
        
        undoObj = UndoSelfInsert(self, keyEvent.text())
        self.qteUndoStack.push(undoObj)
1316530
def __updateStack(self, key):
        
        #if self.lastMenu is not None:
        #    if not ConfigManager.SETTINGS[MENU_TAKES_FOCUS]:
        #        self.app.hide_menu()
        #
        #    self.lastMenu = None

        if key == Key.ENTER:
            # Special case - map Enter to \n
            key = '\n'
        if key == Key.TAB:
            # Special case - map Tab to \t
            key = '\t'

        if key == Key.BACKSPACE:
            if ConfigManager.SETTINGS[UNDO_USING_BACKSPACE] and self.phraseRunner.can_undo():
                self.phraseRunner.undo_expansion()
            else:
                # handle backspace by dropping the last saved character
                try:
                    self.inputStack.pop()
                except IndexError:
                    # in case self.inputStack is empty
                    pass

            return False

        elif len(key) > 1:
            # non-simple key
            self.inputStack.clear()
            self.phraseRunner.clear_last()
            return False
        else:
            # Key is a character
            self.phraseRunner.clear_last()
            # if len(self.inputStack) == MAX_STACK_LENGTH, front items will removed for appending new items.
            self.inputStack.append(key)
            return True
397863
def keyPressEvent(self, event):
        """"""
        if event == QKeySequence.Copy:
            self.copy()
        else:
            QTableView.keyPressEvent(self, event)
1370746
def mousePressEvent(self, event):
        """"""
        index = self.indexAt(event.pos())
        if index.isValid():
            if index.column() == 0:
                self.edit(index, QtGui.QAbstractItemView.DoubleClicked, event)
            else:
                super(ProtocolView, self).mousePressEvent(event)
110165
def setup_editorstack(self, parent, layout):
        """"""
        layout.setSpacing(1)

        self.fname_label = QLabel()
        self.fname_label.setStyleSheet(
            "QLabel {margin: 0px; padding: 3px;}")
        layout.addWidget(self.fname_label)

        menu_btn = create_toolbutton(self, icon=ima.icon('tooloptions'),
                                     tip=_('Options'))
        # Don't show menu arrow and remove padding
        if is_dark_interface():
            menu_btn.setStyleSheet(
                ("QToolButton::menu-indicator{image: none;}\n"
                 "QToolButton{margin: 1px; padding: 3px;}"))
        else:
            menu_btn.setStyleSheet(
                "QToolButton::menu-indicator{image: none;}")
        self.menu = QMenu(self)
        menu_btn.setMenu(self.menu)
        menu_btn.setPopupMode(menu_btn.InstantPopup)
        self.menu.aboutToShow.connect(self.__setup_menu)

        corner_widgets = {Qt.TopRightCorner: [menu_btn]}
        self.tabs = BaseTabs(self, menu=self.menu, menu_use_tooltips=True,
                             corner_widgets=corner_widgets)
        self.tabs.tabBar().setObjectName('plugin-tab')
        self.tabs.set_close_function(self.close_file)
        self.tabs.tabBar().tabMoved.connect(self.move_editorstack_data)
        self.tabs.setMovable(True)

        self.stack_history.refresh()

        if hasattr(self.tabs, 'setDocumentMode') \
           and not sys.platform == 'darwin':
            # Don't set document mode to true on OSX because it generates
            # a crash when the editor is detached from the main window
            # Fixes Issue 561
            self.tabs.setDocumentMode(True)
        self.tabs.currentChanged.connect(self.current_changed)

        if sys.platform == 'darwin':
            tab_container = QWidget()
            tab_container.setObjectName('tab-container')
            tab_layout = QHBoxLayout(tab_container)
            tab_layout.setContentsMargins(0, 0, 0, 0)
            tab_layout.addWidget(self.tabs)
            layout.addWidget(tab_container)
        else:
            layout.addWidget(self.tabs)
1919
def parent(self):
        
        if TextBlockHelper.get_fold_lvl(self._trigger) > 0 and \
                self._trigger.blockNumber():
            block = self._trigger.previous()
            ref_lvl = self.trigger_level - 1
            while (block.blockNumber() and
                    (not TextBlockHelper.is_fold_trigger(block) or
                     TextBlockHelper.get_fold_lvl(block) > ref_lvl)):
                block = block.previous()
            try:
                return FoldScope(block)
            except ValueError:
                return None
        return None
1337882
def parent(self, index):
        
        if not index.isValid():
            return QtCore.QModelIndex()

        childItem = index.internalPointer()
        # the only place where the parent item is queried
        parentItem = childItem.getParent()

        if parentItem == self.root:
            return QtCore.QModelIndex()

        return self.createIndex(parentItem.row(), 0, parentItem)
1324155
def eventFilter(self, widget, event):
        """"""
        if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Delete:
            index = self.view().currentIndex().row()
            if index >= EXTERNAL_PATHS:
                # Remove item and update the view.
                self.removeItem(index)
                self.showPopup()
                # Set the view selection so that it doesn't bounce around.
                new_index = min(self.count() - 1, index)
                new_index = 0 if new_index < EXTERNAL_PATHS else new_index
                self.view().setCurrentIndex(self.model().index(new_index, 0))
                self.setCurrentIndex(new_index)
            return True
        return QComboBox.eventFilter(self, widget, event)
857342
def sort(self, column, order=Qt.DescendingOrder):
        """"""
        if column == 0:
            self.breakpoints.sort(
                key=lambda breakpoint: breakpoint[1])
            self.breakpoints.sort(
                key=lambda breakpoint: osp.basename(breakpoint[0]))
        elif column == 1:
            pass
        elif column == 2:
            pass
        elif column == 3:
            pass
        self.reset()
609443
function UndoManager (maxItems) {
    this.maxItems  = maxItems || 50;
    this.state = NORMAL_STATE;
    this.dontCompose = false;
    this.undoStack = [];
    this.redoStack = [];
  }
792156
def move_node(self, parent, from_index, to_index):
        

        # TODO: Should be refactored once this ticket is fixed:
        # https://bugreports.qt-project.org/browse/PYSIDE-78
        if not from_index >= 0 or \
                not from_index < parent.children_count() or \
                not to_index >= 0 or \
                not to_index < parent.children_count():
            return False

        parent_index = self.get_node_index(parent)
        self.beginRemoveRows(parent_index, from_index, from_index)
        child = parent.remove_child(from_index)
        self.endRemoveRows()

        start_index = parent.children_count() - 1
        end_index = to_index - 1

        tail = []
        for i in range(start_index, end_index, -1):
            self.beginRemoveRows(parent_index, i, i)
            tail.append(parent.remove_child(i))
            self.endRemoveRows()
        tail = list(reversed(tail))
        tail.insert(0, child)

        for node in tail:
            row = parent.children_count()
            self.beginInsertRows(parent_index, row, row)
            parent.add_child(node)
            self.endInsertRows()

        return True