Пример #1
0
def outline_explorer_bot2(qtbot):
    editor = CodeEditor()
    editor = CodeEditor(None)
    editor.set_language('py', 'test_file.py')
    editor.set_text(dedent(code))

    outline_explorer = OutlineExplorerWidget()
    outline_explorer.set_current_editor(editor, 'test_file.py', False, False)

    qtbot.addWidget(outline_explorer)

    return outline_explorer, qtbot
Пример #2
0
def outline_explorer_bot(qtbot):
    editor = CodeEditor()
    editor = CodeEditor(None)
    editor.set_language('py', 'test_outline_explorer.py')
    editor.set_text(text)

    outline_explorer = OutlineExplorerWidget()
    outline_explorer.set_current_editor(
            editor, 'test_outline_explorer.py', False, False)

    qtbot.addWidget(outline_explorer)

    return outline_explorer, qtbot
Пример #3
0
    def __init__(self, parent=None, fullpath_sorting=True):
        show_fullpath = self.get_option('show_fullpath')
        show_all_files = self.get_option('show_all_files')
        show_comments = self.get_option('show_comments')
        OutlineExplorerWidget.__init__(self, parent=parent,
                                       show_fullpath=show_fullpath,
                                       fullpath_sorting=fullpath_sorting,
                                       show_all_files=show_all_files,
                                       show_comments=show_comments)
        SpyderPluginMixin.__init__(self, parent)

        # Initialize plugin
        self.initialize_plugin()
        
        self.treewidget.header().hide()
        self.load_config()
Пример #4
0
    def __init__(self, parent=None, fullpath_sorting=True):
        SpyderPluginWidget.__init__(self, parent)

        show_fullpath = self.get_option('show_fullpath')
        show_all_files = self.get_option('show_all_files')
        show_comments = self.get_option('show_comments')
        self.explorer = OutlineExplorerWidget(
            self,
            show_fullpath=show_fullpath,
            fullpath_sorting=fullpath_sorting,
            show_all_files=show_all_files,
            show_comments=show_comments)

        layout = QVBoxLayout()
        layout.addWidget(self.explorer)
        self.setLayout(layout)

        # Initialize plugin
        self.initialize_plugin()

        self.explorer.treewidget.header().hide()
        self.load_config()
Пример #5
0
    def __init__(self, parent=None):
        SpyderPluginWidget.__init__(self, parent)

        show_fullpath = self.get_option('show_fullpath')
        show_all_files = self.get_option('show_all_files')
        show_comments = self.get_option('show_comments')

        # Initialize plugin
        self.initialize_plugin()
        self.explorer = OutlineExplorerWidget(
            self,
            show_fullpath=show_fullpath,
            show_all_files=show_all_files,
            show_comments=show_comments,
            options_button=self.options_button)

        layout = QVBoxLayout()
        layout.addWidget(self.explorer)
        self.setLayout(layout)

        # Menu as corner widget
        self.explorer.treewidget.header().hide()
        self.load_config()
Пример #6
0
    def __init__(self, parent=None, fullpath_sorting=True):
        SpyderPluginWidget.__init__(self, parent)

        show_fullpath = self.get_option('show_fullpath')
        show_all_files = self.get_option('show_all_files')
        show_comments = self.get_option('show_comments')
        self.explorer = OutlineExplorerWidget(
                                       self,
                                       show_fullpath=show_fullpath,
                                       fullpath_sorting=fullpath_sorting,
                                       show_all_files=show_all_files,
                                       show_comments=show_comments)

        layout = QVBoxLayout()
        layout.addWidget(self.explorer)
        self.setLayout(layout)

        # Initialize plugin
        self.initialize_plugin()
        
        self.explorer.treewidget.header().hide()
        self.load_config()
Пример #7
0
    def __init__(self, parent=None):
        Qt.QSplitter.__init__(self, parent)

        self.editorstacks = []
        self.editorwindows = []

        self.menu_actions, self.io_actions = self.createMenuActions()

        self.find_widget = FindReplace(self, enable_replace=True)
        self.outlineexplorer = OutlineExplorerWidget(self, show_fullpath=False,
                                                     show_all_files=False)
        self.outlineexplorer.edit_goto.connect(self.go_to_file)
        self.editor_splitter = EditorSplitter(self, self, self.menu_actions,
                                              first=True)

        editor_widgets = Qt.QWidget(self)
        editor_layout = Qt.QVBoxLayout()
        editor_layout.setContentsMargins(0, 0, 0, 0)
        editor_widgets.setLayout(editor_layout)
        editor_layout.addWidget(self.editor_splitter)
        editor_layout.addWidget(self.find_widget)

        self.setContentsMargins(0, 0, 0, 0)
        self.addWidget(editor_widgets)
        self.addWidget(self.outlineexplorer)

        self.setStretchFactor(0, 5)
        self.setStretchFactor(1, 1)

        self.toolbar_list = None
        self.menu_list = None
        self.setup_window([], [])

        # Set introspector
        introspector = IntrospectionManager()
        editorstack = self.editor_splitter.editorstack
        editorstack.set_introspector(introspector)
        introspector.set_editor_widget(editorstack)
Пример #8
0
class OutlineExplorer(SpyderPluginWidget):
    """Outline Explorer plugin."""

    CONF_SECTION = 'outline_explorer'

    def __init__(self, parent=None, fullpath_sorting=True):
        SpyderPluginWidget.__init__(self, parent)

        show_fullpath = self.get_option('show_fullpath')
        show_all_files = self.get_option('show_all_files')
        show_comments = self.get_option('show_comments')
        self.explorer = OutlineExplorerWidget(
                                       self,
                                       show_fullpath=show_fullpath,
                                       fullpath_sorting=fullpath_sorting,
                                       show_all_files=show_all_files,
                                       show_comments=show_comments)

        layout = QVBoxLayout()
        layout.addWidget(self.explorer)
        self.setLayout(layout)

        # Initialize plugin
        self.initialize_plugin()
        
        self.explorer.treewidget.header().hide()
        self.load_config()
        
    #------ SpyderPluginWidget API ---------------------------------------------    
    def get_plugin_title(self):
        """Return widget title"""
        return _("Outline")

    def get_plugin_icon(self):
        """Return widget icon"""
        return ima.icon('outline_explorer')
    
    def get_focus_widget(self):
        """
        Return the widget to give focus to when
        this plugin's dockwidget is raised on top-level
        """
        return self.explorer.treewidget
    
    def get_plugin_actions(self):
        """Return a list of actions related to plugin"""
        return []
    
    def register_plugin(self):
        """Register plugin in Spyder's main window"""
        self.main.restore_scrollbar_position.connect(
                                               self.restore_scrollbar_position)
        self.main.add_dockwidget(self)
        
    def refresh_plugin(self):
        """Refresh project explorer widget"""
        pass
        
    def closing_plugin(self, cancelable=False):
        """Perform actions before parent main window is closed"""
        self.save_config()
        return True

    #------ SpyderPluginMixin API ---------------------------------------------
    def visibility_changed(self, enable):
        """DockWidget visibility has changed"""
        super(SpyderPluginWidget, self).visibility_changed(enable)
        if enable:
            self.explorer.is_visible.emit()
            
    #------ Public API ---------------------------------------------------------
    def restore_scrollbar_position(self):
        """Restoring scrollbar position after main window is visible"""
        scrollbar_pos = self.get_option('scrollbar_position', None)
        if scrollbar_pos is not None:
            self.explorer.treewidget.set_scrollbar_position(scrollbar_pos)

    def save_config(self):
        """Save configuration: tree widget state"""
        for option, value in list(self.explorer.get_options().items()):
            self.set_option(option, value)
        self.set_option('expanded_state',
                        self.explorer.treewidget.get_expanded_state())
        self.set_option('scrollbar_position',
                        self.explorer.treewidget.get_scrollbar_position())
        
    def load_config(self):
        """Load configuration: tree widget state"""
        expanded_state = self.get_option('expanded_state', None)
        # Sometimes the expanded state option may be truncated in .ini file
        # (for an unknown reason), in this case it would be converted to a
        # string by 'userconfig':
        if is_text_string(expanded_state):
            expanded_state = None
        if expanded_state is not None:
            self.explorer.treewidget.set_expanded_state(expanded_state)
Пример #9
0
class OutlineExplorer(SpyderPluginWidget):
    """Outline Explorer plugin."""

    CONF_SECTION = 'outline_explorer'

    def __init__(self, parent=None, fullpath_sorting=True):
        SpyderPluginWidget.__init__(self, parent)

        show_fullpath = self.get_option('show_fullpath')
        show_all_files = self.get_option('show_all_files')
        show_comments = self.get_option('show_comments')
        self.explorer = OutlineExplorerWidget(
            self,
            show_fullpath=show_fullpath,
            fullpath_sorting=fullpath_sorting,
            show_all_files=show_all_files,
            show_comments=show_comments)

        layout = QVBoxLayout()
        layout.addWidget(self.explorer)
        self.setLayout(layout)

        # Initialize plugin
        self.initialize_plugin()

        self.explorer.treewidget.header().hide()
        self.load_config()

    #------ SpyderPluginWidget API ---------------------------------------------
    def get_plugin_title(self):
        """Return widget title"""
        return _("Outline")

    def get_plugin_icon(self):
        """Return widget icon"""
        return ima.icon('outline_explorer')

    def get_focus_widget(self):
        """
        Return the widget to give focus to when
        this plugin's dockwidget is raised on top-level
        """
        return self.explorer.treewidget

    def get_plugin_actions(self):
        """Return a list of actions related to plugin"""
        return []

    def register_plugin(self):
        """Register plugin in Spyder's main window"""
        self.main.restore_scrollbar_position.connect(
            self.restore_scrollbar_position)
        self.main.add_dockwidget(self)

    def refresh_plugin(self):
        """Refresh project explorer widget"""
        pass

    def closing_plugin(self, cancelable=False):
        """Perform actions before parent main window is closed"""
        self.save_config()
        return True

    #------ SpyderPluginMixin API ---------------------------------------------
    def visibility_changed(self, enable):
        """DockWidget visibility has changed"""
        super(SpyderPluginWidget, self).visibility_changed(enable)
        if enable:
            self.explorer.is_visible.emit()

    #------ Public API ---------------------------------------------------------
    def restore_scrollbar_position(self):
        """Restoring scrollbar position after main window is visible"""
        scrollbar_pos = self.get_option('scrollbar_position', None)
        if scrollbar_pos is not None:
            self.explorer.treewidget.set_scrollbar_position(scrollbar_pos)

    def save_config(self):
        """Save configuration: tree widget state"""
        for option, value in list(self.explorer.get_options().items()):
            self.set_option(option, value)
        self.set_option('expanded_state',
                        self.explorer.treewidget.get_expanded_state())
        self.set_option('scrollbar_position',
                        self.explorer.treewidget.get_scrollbar_position())

    def load_config(self):
        """Load configuration: tree widget state"""
        expanded_state = self.get_option('expanded_state', None)
        # Sometimes the expanded state option may be truncated in .ini file
        # (for an unknown reason), in this case it would be converted to a
        # string by 'userconfig':
        if is_text_string(expanded_state):
            expanded_state = None
        if expanded_state is not None:
            self.explorer.treewidget.set_expanded_state(expanded_state)