当前位置: 首页>>代码示例>>Python>>正文


Python TextBlockHelper.is_collapsed方法代码示例

本文整理汇总了Python中pyqode.core.api.TextBlockHelper.is_collapsed方法的典型用法代码示例。如果您正苦于以下问题:Python TextBlockHelper.is_collapsed方法的具体用法?Python TextBlockHelper.is_collapsed怎么用?Python TextBlockHelper.is_collapsed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyqode.core.api.TextBlockHelper的用法示例。


在下文中一共展示了TextBlockHelper.is_collapsed方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: convert

# 需要导入模块: from pyqode.core.api import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.TextBlockHelper import is_collapsed [as 别名]
        def convert(name, editor, to_collapse):
            ti = QtWidgets.QTreeWidgetItem()
            ti.setText(0, name.name)
            if isinstance(name.icon, list):
                icon = QtGui.QIcon.fromTheme(
                    name.icon[0], QtGui.QIcon(name.icon[1]))
            else:
                icon = QtGui.QIcon(name.icon)
            ti.setIcon(0, icon)
            name.block = editor.document().findBlockByNumber(name.line)
            ti.setData(0, QtCore.Qt.UserRole, name)
            ti.setToolTip(0, name.description)
            block_data = name.block.userData()
            if block_data is None:
                block_data = TextBlockUserData()
                name.block.setUserData(block_data)
            block_data.tree_item = ti

            if to_collapse is not None and \
                    TextBlockHelper.is_collapsed(name.block):
                to_collapse.append(ti)

            for ch in name.children:
                ti_ch, to_collapse = convert(ch, editor, to_collapse)
                if ti_ch:
                    ti.addChild(ti_ch)
            return ti, to_collapse
开发者ID:abdullahtahiriyo,项目名称:cadquery-freecad-module,代码行数:29,代码来源:outline.py

示例2: _on_key_pressed

# 需要导入模块: from pyqode.core.api import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.TextBlockHelper import is_collapsed [as 别名]
 def _on_key_pressed(self, event):
     """
     Override key press to select the current scope if the user wants
     to deleted a folded scope (without selecting it).
     """
     delete_request = event.key() in [QtCore.Qt.Key_Backspace,
                                      QtCore.Qt.Key_Delete]
     if event.text() or delete_request:
         cursor = self.editor.textCursor()
         if cursor.hasSelection():
             # change selection to encompass the whole scope.
             positions_to_check = cursor.selectionStart(), cursor.selectionEnd()
         else:
             positions_to_check = (cursor.position(), )
         for pos in positions_to_check:
             block = self.editor.document().findBlock(pos)
             th = TextBlockHelper()
             if th.is_fold_trigger(block) and th.is_collapsed(block):
                 self.toggle_fold_trigger(block)
                 if delete_request and cursor.hasSelection():
                     scope = FoldScope(self.find_parent_scope(block))
                     tc = TextHelper(self.editor).select_lines(*scope.get_range())
                     if tc.selectionStart() > cursor.selectionStart():
                         start = cursor.selectionStart()
                     else:
                         start = tc.selectionStart()
                     if tc.selectionEnd() < cursor.selectionEnd():
                         end = cursor.selectionEnd()
                     else:
                         end = tc.selectionEnd()
                     tc.setPosition(start)
                     tc.setPosition(end, tc.KeepAnchor)
                     self.editor.setTextCursor(tc)
开发者ID:must40,项目名称:pyqode.core,代码行数:35,代码来源:folding.py

示例3: _on_item_state_changed

# 需要导入模块: from pyqode.core.api import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.TextBlockHelper import is_collapsed [as 别名]
 def _on_item_state_changed(self, item):
     if self._updating:
         return
     block = item.data(0, QtCore.Qt.UserRole).block
     assert isinstance(item, QtWidgets.QTreeWidgetItem)
     item_state = not item.isExpanded()
     block_state = TextBlockHelper.is_collapsed(block)
     if item_state != block_state:
         self._updating = True
         self._folding_panel.toggle_fold_trigger(block)
         self._updating = False
开发者ID:abdullahtahiriyo,项目名称:cadquery-freecad-module,代码行数:13,代码来源:outline.py

示例4: test_expand_all

# 需要导入模块: from pyqode.core.api import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.TextBlockHelper import is_collapsed [as 别名]
def test_expand_all(editor):
    panel = get_panel(editor)
    QTest.qWait(1000)
    panel.collapse_all()
    QTest.qWait(1000)
    panel.expand_all()
    block = editor.document().firstBlock()
    while block.blockNumber() < editor.document().blockCount() - 1:
        assert block.isVisible()
        if TextBlockHelper.is_fold_trigger(block):
            assert TextBlockHelper.is_collapsed(block) is False
        block = block.next()
开发者ID:must40,项目名称:pyqode.core,代码行数:14,代码来源:test_folding.py

示例5: test_mouse_press

# 需要导入模块: from pyqode.core.api import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.TextBlockHelper import is_collapsed [as 别名]
def test_mouse_press(editor):
    panel = get_panel(editor)
    panel.highlight_caret_scope = False
    # fold child block
    toggle_fold_trigger(editor, 15, panel)
    block = editor.document().findBlockByNumber(14)
    assert TextBlockHelper.is_fold_trigger(block) is True
    assert TextBlockHelper.is_collapsed(block) is True
    block = block.next()
    while block.blockNumber() < 21:
        assert block.isVisible() is False
        block = block.next()
    # fold top level block
    toggle_fold_trigger(editor, 9, panel)
    block = editor.document().findBlockByNumber(8)
    assert TextBlockHelper.is_fold_trigger(block)
    block = block.next()
    while block.blockNumber() < 27:
        if block.blockNumber() == 14:
            assert TextBlockHelper.is_fold_trigger(block) is True
            assert TextBlockHelper.is_collapsed(block) is True
        assert block.isVisible() is False
        block = block.next()
    # unfold it top level block
    toggle_fold_trigger(editor, 9, panel)
    block = editor.document().findBlockByNumber(8)
    assert TextBlockHelper.is_fold_trigger(block)
    block = block.next()
    while block.blockNumber() < 27:
        if 14 < block.blockNumber() < 22:
            assert block.isVisible() is False
        else:
            assert block.isVisible() is True
        block = block.next()

    # cleanup
    QTest.mouseMove(panel, QtCore.QPoint(0, 0))
    panel.leaveEvent(None)
    editor.setFocus()
    panel.highlight_caret_scope = True
开发者ID:must40,项目名称:pyqode.core,代码行数:42,代码来源:test_folding.py

示例6: _highlight_surrounding_scopes

# 需要导入模块: from pyqode.core.api import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.TextBlockHelper import is_collapsed [as 别名]
    def _highlight_surrounding_scopes(self, block):
        """
        Highlights the scopes surrounding the current fold scope.

        :param block: Block that starts the current fold scope.
        """
        scope = FoldScope(block)
        if (self._current_scope is None or
                self._current_scope.get_range() != scope.get_range()):
            self._current_scope = scope
            self._clear_scope_decos()
            # highlight surrounding parent scopes with a darker color
            start, end = scope.get_range()
            if not TextBlockHelper.is_collapsed(block):
                self._add_scope_decorations(block, start, end)
开发者ID:must40,项目名称:pyqode.core,代码行数:17,代码来源:folding.py

示例7: test_collapse_all

# 需要导入模块: from pyqode.core.api import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.TextBlockHelper import is_collapsed [as 别名]
def test_collapse_all(editor):
    panel = get_panel(editor)
    QTest.qWait(1000)
    panel.collapse_all()
    QTest.qWait(1000)
    block = editor.document().firstBlock()
    while block.blockNumber() < editor.document().blockCount() - 1:
        blank_line = len(block.text().strip()) == 0
        if TextBlockHelper.get_fold_lvl(block) > 0:
            if not blank_line:
                assert block.isVisible() is False
        else:
            assert block.isVisible() is True
        if TextBlockHelper.is_fold_trigger(block):
            assert TextBlockHelper.is_collapsed(block) is True
        block = block.next()
开发者ID:must40,项目名称:pyqode.core,代码行数:18,代码来源:test_folding.py

示例8: paintEvent

# 需要导入模块: from pyqode.core.api import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.TextBlockHelper import is_collapsed [as 别名]
 def paintEvent(self, event):
     # Paints the fold indicators and the possible fold region background
     # on the folding panel.
     super(FoldingPanel, self).paintEvent(event)
     painter = QtGui.QPainter(self)
     # Draw background over the selected non collapsed fold region
     if self._mouse_over_line is not None:
         block = self.editor.document().findBlockByNumber(
             self._mouse_over_line)
         try:
             self._draw_fold_region_background(block, painter)
         except ValueError:
             pass
     # Draw fold triggers
     for top_position, line_number, block in self.editor.visible_blocks:
         if TextBlockHelper.is_fold_trigger(block):
             collapsed = TextBlockHelper.is_collapsed(block)
             mouse_over = self._mouse_over_line == line_number
             self._draw_fold_indicator(
                 top_position, mouse_over, collapsed, painter)
             if collapsed:
                 # check if the block already has a decoration, it might
                 # have been folded by the parent editor/document in the
                 # case of cloned editor
                 for deco in self._block_decos:
                     if deco.block == block:
                         # no need to add a deco, just go to the next block
                         break
                 else:
                     self._add_fold_decoration(block, FoldScope(block))
             else:
                 for deco in self._block_decos:
                     # check if the block decoration has been removed, it
                     # might have been unfolded by the parent
                     # editor/document in the case of cloned editor
                     if deco.block == block:
                         # remove it and
                         self._block_decos.remove(deco)
                         self.editor.decorations.remove(deco)
                         del deco
                         break
开发者ID:must40,项目名称:pyqode.core,代码行数:43,代码来源:folding.py


注:本文中的pyqode.core.api.TextBlockHelper.is_collapsed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。