a
     ³Ša€  ã                   @   sÄ   d Z ddlmZ ddlmZ ddlmZmZ ddl	m
Z
mZmZmZ ddlmZ ddlmZ ddlmZ dd	lmZ ed
ƒZG dd„ dƒZG dd„ deƒZG dd„ deƒZdd„ ZedkrÀeƒ  dS )úProject Exploreré    )Úprint_functionN)ÚQtÚSignal)ÚQHBoxLayoutÚQLabelÚQVBoxLayoutÚQWidget)ÚPluginMainWidget)Úget_translation)ÚDirViewActions)ÚProjectExplorerTreeWidgetZspyderc                   @   s   e Zd ZdZdS )Ú"ProjectExplorerOptionsMenuSectionsÚmainN)Ú__name__Ú
__module__Ú__qualname__ÚMain© r   r   úJlib/python3.9/site-packages/spyder/plugins/projects/widgets/main_widget.pyr      s   r   c                       sZ   e Zd ZdZeeƒZd‡ fdd„	Zdd„ Zdd„ Z	d	d
„ Z
dd„ Zdd„ Zdd„ Z‡  ZS )ÚProjectExplorerWidgetr   Nc                    s¦   t ƒ j|||d |  d¡| _|  d¡| _t| | jƒ| _| j ¡  | j ¡  | j 	¡  | jj
 | j
¡ t| ƒ| _tƒ }| | j¡ | | j¡ |  |¡ |  d¡ d S )N)ÚpluginÚparentÚname_filtersÚshow_hscrollbaréÈ   )ÚsuperÚ__init__Zget_confr   r   r   Ú
treewidgetÚsetupZ
setup_viewÚhideÚsig_open_file_requestedÚconnectÚemptywidgetr   Ú	addWidgetÚ	setLayoutZsetMinimumWidth)ÚselfÚnamer   r   Zlayout©Ú	__class__r   r   r   0   s     


ÿ

zProjectExplorerWidget.__init__c                 C   sD   |   ¡ }|  tj¡}|  tj¡}||fD ]}| j||tjd q(dS )zSetup the widget.)ÚmenuZsectionN)Zget_options_menuZ
get_actionr   ZToggleHiddenFilesZToggleSingleClickZadd_item_to_menur   r   )r&   r*   Zhidden_actionZsingle_click_actionÚactionr   r   r   r   D   s    ýzProjectExplorerWidget.setupc                 C   s   d S )Nr   ©r&   r   r   r   Úupdate_actionsQ   s    z$ProjectExplorerWidget.update_actionsc                 C   s   t dƒS )NZProject)Ú_r,   r   r   r   Ú	get_titleT   s    zProjectExplorerWidget.get_titlec                 C   sj   |dur.| j  t |¡¡ | j  t |¡g¡ | j  ¡  z| j  | j  |¡d¡ W n t	yd   Y n0 dS )zSet the project directoryNT)
r   Zset_root_pathÚospÚdirnameZset_folder_namesÚbasenameZsetup_project_viewZsetExpandedZ	get_indexÚ	TypeError©r&   Ú	directoryr   r   r   Úset_project_dirW   s    
ÿz%ProjectExplorerWidget.set_project_dirc                 C   s   | j  ¡  | j ¡  dS )zShow an empty viewN)r   r    r#   Úshowr,   r   r   r   Úclearc   s    
zProjectExplorerWidget.clearc                 C   s"   | j  ¡  | j ¡  |  |¡ dS )zSetup projectN)r#   r    r   r7   r6   r4   r   r   r   Úsetup_projecth   s    

z#ProjectExplorerWidget.setup_project)N)r   r   r   Ú__doc__r   Ústrr!   r   r   r-   r/   r6   r8   r9   Ú__classcell__r   r   r(   r   r   #   s   
r   c                   @   s   e Zd Zddd„ZdS )ÚProjectExplorerTestNc                 C   s  t  | ¡ d| _tƒ }|  |¡ td | | ƒ| _|d ur>|| _nt 	t 
t¡¡| _| j | j¡ | | j¡ tƒ }| |¡ tdƒ}| tj¡ | |¡ tƒ | _| | j¡ | jj | jj¡ tƒ }| |¡ tdƒ}| tj¡ | |¡ tƒ | _| | j¡ d S )NZproject_explorerz<b>Open file:</b>z<b>Option changed:</b>)r	   r   ZCONF_SECTIONr   r%   r   Zexplorerr5   r0   r1   ÚabspathÚ__file__r9   r$   r   Z	addLayoutr   ZsetAlignmentr   Z
AlignRightZlabel1r!   r"   ZsetTextZlabel3)r&   r5   ZvlayoutZhlayout1ZlabelZhlayout3r   r   r   r   u   s2    





zProjectExplorerTest.__init__)N)r   r   r   r   r   r   r   r   r=   t   s   r=   c                  C   s8   ddl m}  | ƒ }tƒ }| dd¡ | ¡  | ¡  d S )Nr   )Úqapplicationéú   ià  )Zspyder.utils.qthelpersr@   r=   Zresizer7   Zexec_)r@   ZappÚtestr   r   r   rB   •   s    rB   Ú__main__)r:   Z
__future__r   Úos.pathÚpathr0   Zqtpy.QtCorer   r   Zqtpy.QtWidgetsr   r   r   r	   Zspyder.api.widgets.main_widgetr
   Zspyder.api.translationsr   Zspyder.plugins.explorer.apir   Z/spyder.plugins.projects.widgets.projectexplorerr   r.   r   r   r=   rB   r   r   r   r   r   Ú<module>   s   Q!	