B
    nôb\ë  ã               @   sb   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z ddlmZ G dd	„ d	eeƒZd
S )zäOutline Explorer Plugin

Data for outline are provided by method .get_outlineexplorer_data() of
highlighter of assigned editor. For example, for Python files code editor uses
highlighter spyder.utils.syntaxhighlighters.PythonSH
é    )ÚSignal)Ú_)ÚSpyderPluginMixin)Úis_text_string)Úicon_manager)ÚOutlineExplorerWidgetc               @   s~   e Zd ZdZeeeƒZddd„Zdd„ Z	dd„ Z
d	d
„ Zdd„ Zdd„ Zdd„ Zddd„Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚOutlineExplorerÚoutline_explorerNc             C   s`   |   d¡}|   d¡}|   d¡}tj| ||||d t | |¡ |  ¡  | j ¡  ¡  |  ¡  d S )NÚshow_fullpathÚshow_all_filesÚshow_comments)Úparentr
   r   r   )	Ú
get_optionr   Ú__init__r   Zinitialize_pluginÚ
treewidgetÚheaderZhideÚload_config)Úselfr   r
   r   r   © r   ú=lib/python3.7/site-packages/spyder/plugins/outlineexplorer.pyr      s    


zOutlineExplorer.__init__c             C   s   t dƒS )zReturn widget titleZOutline)r   )r   r   r   r   Úget_plugin_title.   s    z OutlineExplorer.get_plugin_titlec             C   s
   t  d¡S )zReturn widget iconr	   )ÚimaZicon)r   r   r   r   Úget_plugin_icon2   s    zOutlineExplorer.get_plugin_iconc             C   s   | j S )zq
        Return the widget to give focus to when
        this plugin's dockwidget is raised on top-level
        )r   )r   r   r   r   Úget_focus_widget6   s    z OutlineExplorer.get_focus_widgetc             C   s   g S )z*Return a list of actions related to pluginr   )r   r   r   r   Úget_plugin_actions=   s    z"OutlineExplorer.get_plugin_actionsc             C   s    | j j | j¡ | j  | ¡ dS )z'Register plugin in Spyder's main windowN)ÚmainÚrestore_scrollbar_positionZconnectZadd_dockwidget)r   r   r   r   Úregister_pluginA   s    zOutlineExplorer.register_pluginc             C   s   dS )zRefresh project explorer widgetNr   )r   r   r   r   Úrefresh_pluginG   s    zOutlineExplorer.refresh_pluginFc             C   s   |   ¡  dS )z3Perform actions before parent main window is closedT)Úsave_config)r   Z
cancelabler   r   r   Úclosing_pluginK   s    zOutlineExplorer.closing_pluginc             C   s   t  | |¡ |r| j ¡  dS )z!DockWidget visibility has changedN)r   Úvisibility_changedZoutlineexplorer_is_visibleÚemit)r   Úenabler   r   r   r!   Q   s    z"OutlineExplorer.visibility_changedc             C   s$   |   dd¡}|dk	r | j |¡ dS )z9Restoring scrollbar position after main window is visibleÚscrollbar_positionN)r   r   Zset_scrollbar_position)r   Zscrollbar_posr   r   r   r   X   s    z*OutlineExplorer.restore_scrollbar_positionc             C   sR   x(t |  ¡  ¡ ƒD ]\}}|  ||¡ qW |  d| j ¡ ¡ |  d| j ¡ ¡ dS )z%Save configuration: tree widget stateÚexpanded_stater$   N)ÚlistZget_optionsÚitemsZ
set_optionr   Zget_expanded_stateZget_scrollbar_position)r   ZoptionÚvaluer   r   r   r   ^   s
    zOutlineExplorer.save_configc             C   s0   |   dd¡}t|ƒrd}|dk	r,| j |¡ dS )z%Load configuration: tree widget stater%   N)r   r   r   Zset_expanded_state)r   r%   r   r   r   r   f   s
    zOutlineExplorer.load_config)N)F)Ú__name__Ú
__module__Ú__qualname__ZCONF_SECTIONr   ÚstrÚobjectZsig_option_changedr   r   r   r   r   r   r   r    r!   r   r   r   r   r   r   r   r      s   


r   N)Ú__doc__Zqtpy.QtCorer   Zspyder.config.baser   Zspyder.pluginsr   Zspyder.py3compatr   Zspyder.utilsr   r   Zspyder.widgets.editortoolsr   r   r   r   r   r   Ú<module>   s   