ó
ÉÝ{Tc           @   sL   d  Z  d d l m Z m Z d d l Td „  Z d e j f d „  ƒ  YZ d S(   sr  
     qtgui/ccp4iGui.py: CCP4MG Molecular Graphics Program
     Copyright (C) 2001-2008 University of York, CCLRC
     Copyright (C) 2009 University of York

     This library is free software: you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public License
     version 3, modified in accordance with the provisions of the 
     license to address the requirements of UK law.
 
     You should have received a copy of the modified GNU Lesser General 
     Public License along with this library.  If not, copies may be 
     downloaded from http://www.ccp4.ac.uk/ccp4license.php
 
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU Lesser General Public License for more details.
iÿÿÿÿ(   t   QtGuit   QtCore(   t   *c           C   s[   t  j s t  t ƒ  ƒ t  _ n  t  j j ƒ  sJ t  j j ƒ  t  j j ƒ  n t  j j ƒ  d  S(   N(   t   ccp4iAliasGuit   instst
   MAINWINDOWt	   isVisiblet   loadAliasest   showt   raise_(    (    (    s;   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ccp4iGui.pyt   openGui   s    	R   c           B   sY   e  Z d Z d d  „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(	   c         C   s	  t  j j |  | ƒ t  j ƒ  } t  j ƒ  } | j t  j d |  ƒ ƒ | j t  j d |  ƒ ƒ | j | ƒ t  j ƒ  } | j t  j d |  ƒ d d d d ƒ t  j	 |  ƒ |  _
 |  j
 j d ƒ |  j
 j d ƒ | j |  j
 d d d d ƒ | j t  j d |  ƒ d d d d ƒ t  j |  ƒ |  _ |  j j d ƒ |  j j d	 ƒ | j |  j d d d d ƒ t  j d
 |  ƒ } | j d ƒ |  j | t j d ƒ |  j ƒ | j | d d d d ƒ | j | ƒ t  j |  ƒ } | j t  j j ƒ } |  j | t j d ƒ |  j ƒ | j t  j j ƒ } |  j | t j d ƒ |  j ƒ | j d ƒ | j t  j j ƒ } |  j | t j d ƒ |  j ƒ | j d ƒ | j d t  j j ƒ } |  j | t j d ƒ |  j ƒ | j d ƒ |  j |  j
 t j d ƒ |  j ƒ | j | ƒ |  j | ƒ d  S(   Ns9   In CCP4mg you can add and change CCP4i directory aliases.s0   Please user CCP4i to change project directories.t   Aliasi    i   s3   Choose a directory alias to edit or enter a new ones   Directory pathiÈ   s,   Choose a directory to be linked to the aliast   Browsers   Use browser to find directorys	   clicked()i   s)   Save the current alias and directory paths'   Close window without saving any changess   Remove aliassT   Remove the current alias from the directory database - does NOT delete the directorys   currentIndexChanged(int)(    R    t   QDialogt   __init__t   QVBoxLayoutt   QHBoxLayoutt	   addWidgett   QLabelt	   addLayoutt   QGridLayoutt	   QComboBoxt   aliast   setEditablet
   setToolTipt	   QLineEditt   patht   setMinimumWidtht   QPushButtont   connectR   t   SIGNALt   openBrowsert   QDialogButtonBoxt	   addButtont   Helpt   helpt   Applyt   Cancelt   closet
   ActionRolet   deleteAliast   changedAliast	   setLayout(   t   selft   parentt   layoutt   line_layoutt   grid_layoutt   browsert   dialogt   button(    (    s;   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ccp4iGui.pyR   (   sJ    %%"c         C   sc   |  j  j ƒ  t ƒ  j d d d d ƒ \ } } x | D] } |  j  j | ƒ q5 W|  j j d ƒ d  S(   Nt   projectsi    t   aliasesi   t    (   R   t   cleart   CCP4DATABASEt   getProjectsListt   addItemR   t   setText(   R+   R3   R4   t   proj(    (    s;   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ccp4iGui.pyR   Z   s
    ! c         C   sm   d G| G|  j  GH| d k r/ |  j  j d ƒ n: t ƒ  j t |  j j ƒ  ƒ ƒ } | ri |  j  j | ƒ n  d  S(   NR)   i    R5   (   R   R:   R7   t   get_project_dirt   strR   t   currentText(   R+   t   iAliast   new_path(    (    s;   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ccp4iGui.pyR)   e   s    ! c         C   sä   t  |  j j ƒ  ƒ } | s5 t j j |  d d ƒ d  St ƒ  j | ƒ se t j j |  d | d ƒ d  St ƒ  j | ƒ } | d rŸ t j j |  d | d ƒ d  St ƒ  j	 ƒ  } | d rÖ t j j |  d | d ƒ d  S|  j
 ƒ  d  S(   Ns   Error removing directory aliass   No directory alias is givens)    is not saved in the directories databasei    i   s   Error creating directory alias(   R=   R   R>   R    t   QMessageBoxt   warningR7   R<   t   delete_aliast   write_ccp4i_directoriesR   (   R+   R   t   rv(    (    s;   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ccp4iGui.pyR(   n   s     

c         C   s   t  ƒ  j d d ƒ d  S(   Nt   files   projects.html(   t   HELPBROWSERt
   loadMgHelp(   R+   (    (    s;   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ccp4iGui.pyR#   ‚   s    c         C   s  t  |  j j ƒ  ƒ } | s5 t j j |  d d ƒ d  St  |  j j ƒ  ƒ } d d  l } | j j	 | ƒ s‚ t j j |  d d ƒ d  St
 ƒ  j | | ƒ } | d r¿ t j j |  d | d ƒ d  St
 ƒ  j ƒ  } | d rö t j j |  d | d ƒ d  S|  j ƒ  d  S(   Ns   Error creating directory aliass   No directory alias is giveniÿÿÿÿs   Directory path is not validi    i   (   R=   R   R>   R    RA   RB   R   t   textt   ost   existsR7   t   edit_dir_aliasRD   R&   (   R+   R   R   RJ   RE   (    (    s;   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ccp4iGui.pyR$   …   s$    

c         C   sŽ   t  j |  ƒ |  _ |  j j t  j j ƒ |  j j d t |  j j ƒ  ƒ ƒ |  j j	 t
 ƒ |  j |  j t j d ƒ |  j ƒ |  j j ƒ  d  S(   Ns   Directory with CCP4i alias s"   filesSelected (const QStringList&)(   R    t   QFileDialogR0   t   setFileModet	   Directoryt   setWindowTitleR=   R   R>   t   setModalt   TrueR   R   R   t   handleBrowserR   (   R+   (    (    s;   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ccp4iGui.pyR   �   s    #"c         C   s‹   d d  l  } | rj t | d ƒ } | j j | ƒ rj | j j | ƒ rj |  j j | ƒ |  j j ƒ  d  Sn  |  j j ƒ  |  j j d ƒ d  S(   Niÿÿÿÿi    R5   (   RJ   R=   R   RK   t   isdirR:   R0   R&   (   R+   t   dirnRJ   (    (    s;   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ccp4iGui.pyRS   ¥   s    $N(   t   __name__t
   __module__t   NoneR   R   R   R)   R(   R#   R$   R   RS   (    (    (    s;   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ccp4iGui.pyR   $   s   2							N(   t   __doc__t   PyQt4R    R   t   global_definitionsR
   R   R   (    (    (    s;   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ccp4iGui.pyt   <module>   s   
	
