ó
ÉÝ{Tc           @   s×   d  Z  d d l m Z m Z d d l Td d l Z d d l Z d d l Z d d g Z d e j	 f d „  ƒ  YZ
 d	 e j	 f d
 „  ƒ  YZ d e j	 f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j	 f d „  ƒ  YZ d S(   s•  
     qtgui/statusGui.py: CCP4MG Molecular Graphics Program
     Copyright (C) 2001-2008 University of York, CCLRC
     Copyright (C) 2009-2011 University of York
     Copyright (C) 2012 STFC

     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   *Ns   Status file (*.pkl)s-   Editable picture definition file (*.mgpic.py)t
   guiRestorec           B   sq   e  Z d  „  Z d „  Z d „  Z d „  Z d d „ Z d d „ Z d „  Z	 d d	 „ Z
 d i  d d d d
 „ Z RS(   c         C   s   |  j  j | ƒ d  S(   N(   t
   filedialogt
   addFilters(   t   selft   filters(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR   $   s    c         C   s   |  j  j | ƒ d  S(   N(   R   t	   addFilter(   R   t   filter(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR   '   s    c         C   s   |  j  j t ƒ S(   N(   R   R   (   R   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR   *   s    c         C   s   |  j  j | ƒ d  S(   N(   R   t   setNameFilters(   R   R   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR
   -   s    c         C   s!  t  t |  ƒ j | ƒ d d  l } |  j d ƒ |  j |  j d ƒ ƒ t j ƒ  } t j	 ƒ  } | j
 t j	 j ƒ t j ƒ  } t j ƒ  } | j t j d ƒ ƒ t j d |  ƒ |  _ | j |  j ƒ t j d |  ƒ |  _ | j |  j ƒ | j d ƒ t j ƒ  |  _ |  j j d ƒ |  j j d	 ƒ | j |  j ƒ | j | ƒ | j | ƒ | j | ƒ |  j j d
 ƒ |  j j d
 ƒ | j |  ƒ } | j | ƒ | j ƒ  |  _ |  j j |  j j ƒ |  j |  j t j  d ƒ |  j! ƒ |  j j" t# ƒ |  j | ƒ |  j |  j t j  d ƒ |  j$ ƒ d  S(   Niÿÿÿÿt   dialogRestores"   Restore status and/or view file(s)t   Restores   display statust   viewi   t   PREVIEWid   i   s   currentChanged(const QString)s"   filesSelected (const QStringList&)(%   t   superR   t   __init__t	   mgWidgetst   setObjectNamet   setWindowTitlet   trR    t   QVBoxLayoutt   QFramet   setFrameStylet   Boxt   QHBoxLayoutt	   addWidgett   QLabelt	   QCheckBoxt   restore_statust   restore_viewt
   addStretcht   preview_widgett   setTextt   setFixedHeightt	   addLayoutt	   setLayoutt
   setCheckedt   MGFileDialogt   getFileDialogR   t   setFileModet   ExistingFilest   connectR   t   SIGNALt   updatePreviewR
   t   nameFilterst   handleSelection(   R   t   parentR   t   layoutt   framet   frame_layoutt   line_layoutR   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR   1   s@    "t    c         C   s“   t  t | j ƒ  ƒ d ƒ } | j d ƒ r t j j | d  ƒ r t j | d  ƒ j	 d ƒ } |  j
 j d ƒ |  j
 j | ƒ n |  j
 j d ƒ d  S(   Ns   utf-8s   .pkliüÿÿÿid   R4   s   No preview available(   t   unicodet   strt   toUtf8t   endswitht   ost   patht   existsR    t   QPixmapt   scaledToHeightR    R!   t	   setPixmap(   R   t	   filename_t   filenamet   pixmap(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR,   c   s    %c         C   sR   t  |  j j ƒ  ƒ d k rN t j j |  j j ƒ  d ƒ sN |  j j ƒ  d Sn  d  S(   Ni    (   t   lenR   t   selectedFilesR9   R:   t   isdirt   None(   R   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyt   getFileNamen   s    iÿÿÿÿc         C   s9  | d k  r$ t  |  j j ƒ  ƒ } n  x| D]} t | j ƒ  ƒ |  _ | rt j j |  j ƒ d d k rt	 ƒ  j
 d |  j ƒ } | d d k  r° t j j |  d | d ƒ q1| d sá |  j |  j ƒ |  j ƒ  |  j ƒ  q1|  j ƒ  t |  |  j ƒ } | j ƒ  } | t j j k r1| j ƒ  \ } } t	 ƒ  j |  j d | | ƒ } |  j d | ƒ t j j |  d d t j j t j j Bƒ }	 |	 t j j k rœd  St |  ƒ }
 d	 t j j |  j ƒ d } |
 j | ƒ |
 j j |  j ƒ |
 j ƒ  } |  j ƒ  |  j ƒ  q1q+ |  j |  j ƒ } |  j ƒ  |  j ƒ  q+ Wd  S(
   Ni    i   s   .pklR@   s   Error reading status filet   statuss   Save status files*   Save the status with new data file names?
s   Save updated status from file: (    t   intR   t	   isCheckedR6   R7   t   status_fileR9   R:   t   splitextt   HISTORYt   get_status_data_filesR    t   QMessageBoxt   warningt   loadStatusFilet   acceptt   closet   hidet   lostFilesGuit   exec_t   QDialogt   Acceptedt   getFilest   edit_status_data_filest   questiont   Savet   Cancelt   guiSaveStatust   splitR   t
   fileDialogt
   selectFile(   R   RC   R   t   itemt   rvt   lostGuit   objListt   fileDefnRG   t   retvalt   saveGuit   title(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR.   w   sF     %


 

c         C   sq   | d k  r$ t  |  j j ƒ  ƒ } n  | d k  rH t  |  j j ƒ  ƒ } n  |  j t j d ƒ | | | | | ƒ d  S(   Ni    t   filesSelected(   RH   R   RI   R   t   emitR   R+   (   R   t   fileRG   R   R   t   remove(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyRP   ©   s
      N(   t   __name__t
   __module__R   R   R   R
   RE   R   R,   RF   R.   RP   (    (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR      s   				2		2R]   c           B   s)   e  Z d d d  „ Z d „  Z d „  Z RS(   c         C   s*   t  j j |  | ƒ | |  _ |  j ƒ  d  S(   N(   R    RV   R   t   saved_statust   draw(   R   R/   Ro   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR   ·   s    	c         C   sÞ   |  j  |  j d ƒ ƒ t j ƒ  } t j |  ƒ } | j ƒ  |  _ |  j j t j	 j
 ƒ |  j j t j	 j ƒ |  j j t ƒ g  } |  j j t ƒ |  j |  j t j d ƒ |  j ƒ | j | d d d d ƒ |  j | ƒ d  S(   Ns   Save current statuss   fileSelected(const QString&)i   i    i   (   R   R   R    t   QGridLayoutR   R&   R'   R_   R(   t   QFileDialogt   AnyFilet   setAcceptModet
   AcceptSavet   setConfirmOverwritet   FalseR
   R-   R*   R   R+   t   saveFileR   R$   (   R   R0   Rk   t   filter_list(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyRp   ¾   s    "c         C   sž  |  j  j ƒ  } | s d  St | d j ƒ  ƒ } t |  j  j ƒ  j ƒ  ƒ } |  j  j ƒ  } g  } xu | D]m } t | j ƒ  ƒ } d | k rf | | j d ƒ d } d | k rÓ | | j d ƒ  } | j | ƒ qÓ qf qf Wt	 } x& | D] } | j
 | ƒ rä t } qä qä W| rqd | k rq| | j d ƒ d } d | k rq| | j d ƒ  } | j
 | ƒ sn| | } qnqqn  |  j t j d ƒ | |  j ƒ |  j ƒ  d  S(   Ni    s   (*i   t   )Ri   (   R_   RC   R6   R7   t   selectedNameFilterR-   t   findt   rfindt   appendRw   R8   t   TrueRj   R   R+   Ro   RQ   (   R   Rk   t   filtt   filtsQtt   filtst   ft   _filtt	   hasSuffix(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyRx   ß   s4     N(   Rm   Rn   RE   R   Rp   Rx   (    (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR]   ²   s   	!RT   c           B   sV   e  Z d d  g  i  d „ Z d „  Z d „  Z d „  Z d  d „ Z d „  Z d „  Z	 RS(	   R4   c         C   sæ  t  j j |  | ƒ g  } | r? | j t j j | ƒ d ƒ n  | rT | } | } n! t ƒ  j | | ƒ \ } } } }	 |  j	 d t j j | ƒ d d ƒ t  j
 ƒ  }
 |
 j t  j d ƒ d d d d ƒ |
 j t  j d ƒ d d d d ƒ |
 j t  j d ƒ d	 d d d	 ƒ |
 j t  j d
 ƒ d	 d	 d d ƒ g  |  _ d	 } x™ | D]‘ } | j | ƒ rD| | \ } } } | d } |  j j t | | | |
 | ƒ ƒ |  j d j | ƒ |  j |  j d t j d ƒ |  j ƒ qDqDWt  j |  ƒ } | j t  j j ƒ } | j d ƒ |  j | t j d ƒ |  j ƒ | j d ƒ | j t  j j ƒ } | j d ƒ |  j | t j d ƒ |  t j d ƒ ƒ | j d ƒ |
 j | | d d d d ƒ |
 |  _ |  j |
 ƒ |  j t ƒ  t j d ƒ |  j ƒ d  S(   Ni    s   Find data files loading i   s   status files6   Cannot find all data files as specified in status filei   sA   Please give alternative files (or continue without missing files)s*   Saved project/directory alias and filenamei   s   File to be loadedi   iÿÿÿÿt   happys	   clicked()s-   Load the status file with selected data filess   reject()s   Cancel loading status filet   directoriesChanged(    R    RV   R   R~   R9   R:   R^   RL   RM   R   Rq   R   R   t   widgetst   has_keyt   lostFileWidgetR   R*   R   R+   t   handleHappyWidgett   QDialogButtonBoxt	   addButtont   Applyt   setAutoDefaultt
   setToolTipR\   t   SLOTt   gridR$   t   CCP4DATABASEt   handleChangedAlias(   R   R/   RJ   t   lostt   defnt   hintsRd   t   fileDeft   nLostt   nFoundR0   t   rowt   objnamet   aliast   filnR:   t   dialogt   button(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR     sH     	!%""""	
"-(	c         C   s»   d } xR |  j  D]G } t j j t | j j ƒ  ƒ ƒ s | t | j j ƒ  ƒ d } q q W| r­ t j j |  d d | d t j j	 t j j
 Bƒ } | t j j
 k r­ d  Sn  |  j ƒ  d  S(   NR4   s   
s    Lost data files restoring statuss,   The following data files can not be found..
s-   You can continue to load remaining data files(   Rˆ   R9   R:   R;   R6   t   textR    RN   RZ   RŽ   R\   RQ   (   R   R•   t   wwRf   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyRŽ   C  s    !$ c         C   sY   g  } i  } x@ |  j  D]5 } t | j ƒ  ƒ } | j | ƒ | j ƒ  | | <q W| | g S(   N(   Rˆ   R6   t
   objectNameR~   t   getFile(   R   Rd   Re   R¢   t   name(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyRX   W  s    c         C   s!   |  j  t j j ƒ |  j ƒ  d  S(   N(   t	   setResultR    RV   t   RejectedRR   (   R   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyt   Closeb  s    c         C   s%   x |  j  D] } | j | ƒ q
 Wd  S(   N(   Rˆ   R”   (   R   t   changed_aliast   w(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR”   j  s    c         C   s5   d d  l  } | j |  ƒ } | j ƒ  | j ƒ  } d  S(   Niÿÿÿÿ(   t   ccp4iGuit   ccp4iAliasGuit   loadAliasesRU   (   R   R«   t   editAliasGuiRb   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyt   editAliasesr  s    
c         C   s;   t  j j | ƒ d } x |  j D] } | j | ƒ q  Wd  S(   Ni    (   R9   R:   R^   Rˆ   t   tryHint(   R   t   new_pathR¢   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR‹   z  s    N(
   Rm   Rn   RE   R   RŽ   RX   R¨   R”   R¯   R‹   (    (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyRT     s   ;				RŠ   c           B   sk   e  Z d  Z d Z d Z d Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 d „ Z d „  Z RS(   i   i   i    i   c         C   sþ  t  j j |  ƒ t  j |  ƒ |  _ |  j j t j d ƒ ƒ | j |  j | t	 j
 d d ƒ t  j t j j | ƒ d |  ƒ |  _ |  j j d ƒ | j |  j | t	 j d d ƒ | d k rÃ d } n  t  j | |  ƒ |  _ |  j j d ƒ | j |  j | t	 j d d ƒ t  j |  ƒ |  _ |  j j d ƒ |  j j d ƒ |  j |  j t j d	 ƒ |  j ƒ | j |  j | t	 j d d ƒ |  j | ƒ t  j d
 |  ƒ |  _ |  j j d ƒ |  j j d ƒ |  j |  j t j d ƒ |  j ƒ | j |  j | d d d ƒ d  S(   NRZ   i   s   Name of filet   FULLPATHt    s   Project or directory aliass   Current full path name for fileiÈ   s   editingFinished()t   Browsers   Use browser to find filei    s	   clicked()i   (   R    t   QWidgetR   R   R†   R>   t   guiUtilst
   loadPixmapR   RŠ   t   HAPPYR9   R:   R^   Rž   R�   t   NAMER�   t   ALIASt	   QLineEditt   setMinimumWidthR*   R   R+   t   setHappyt   PATHt   setFilenamet   QPushButtont   browseR�   t   openBrowser(   R   R�   Rž   R:   R0   R›   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR   ‹  s.    % 	""c         C   s]   t  j j |  |  j d ƒ t |  j j ƒ  ƒ d d ƒ } | rY |  j t | j ƒ  ƒ ƒ n  d  S(   Ns
   Find file R4   (	   R    Rr   t   getOpenFileNameR   R6   Rž   R¡   R¿   t   toAscii(   R   Rž   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyRÂ   ¨  s    7 c         C   s1   | r  |  j  t | d ƒ ƒ n  |  j j ƒ  d  S(   Ni    (   R¿   R6   t   browserRR   (   R   Rž   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyt   handleBrowser¯  s     c         C   s   |  j  j | ƒ |  j ƒ  d  S(   N(   R:   R!   R½   (   R   Rž   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR¿   ¶  s    c         C   s‚   t  j j t |  j j ƒ  ƒ ƒ re |  j j t j d ƒ ƒ |  j	 t
 j d ƒ t |  j j ƒ  ƒ ƒ n |  j j t j d ƒ ƒ d  S(   NR†   RZ   (   R9   R:   R;   R6   R¡   R†   R>   R¶   R·   Rj   R   R+   (   R   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR½   ¼  s    !+c         C   sÛ   t  |  j j ƒ  ƒ } t j j | ƒ r• t ƒ  j t j j | ƒ d ƒ } | s| d d  l } | j	 t  |  j
 j ƒ  ƒ ƒ } n  t j j | ƒ d } n* t  |  j
 j ƒ  ƒ } t  |  j j ƒ  ƒ } | sÎ d } n  | | | g S(   Ni    iÿÿÿÿi   R²   (   R6   R:   R¡   R9   R;   R“   t   aliasForDirR^   t   stringt   stripR�   Rž   (   R   R:   R�   RÈ   Rž   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR¤   Å  s    "! 	R4   c         C   s�   t  |  j j ƒ  ƒ } t ƒ  j t  |  j j ƒ  ƒ ƒ } | rc t j j | t  |  j j ƒ  ƒ ƒ } n  |  j j	 | ƒ |  j
 ƒ  d  S(   N(   R6   R�   R¡   R“   t   get_project_dirR9   R:   t   joinRž   R!   R½   (   R   R©   R�   R:   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR”   Ø  s    !'c         C   so   t  j j t |  j j ƒ  ƒ ƒ r% d  St  j j | t |  j j ƒ  ƒ ƒ } t  j j | ƒ rk |  j | ƒ n  d  S(   N(   R9   R:   R;   R6   R¡   RË   Rž   R¿   (   R   R±   t	   test_path(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR°   ã  s
    ! $(   Rm   Rn   R¸   R¹   Rº   R¾   R   RÂ   RÆ   R¿   R½   R¤   R”   R°   (    (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyRŠ   ‚  s   							t
   recoverGUIc           B   s   e  Z d  „  Z d „  Z RS(   c         C   sO  t  j j |  | ƒ |  j d ƒ |  j d ƒ t  j ƒ  } | j t  j d ƒ ƒ t ƒ  j	 ƒ  } t  j
 |  ƒ |  _ x | D] } |  j j | ƒ qw W| j |  j ƒ t  j |  ƒ } | j t j j ƒ | j d t  j j ƒ } |  j | t j d ƒ |  j ƒ | j d t  j j ƒ } |  j | t j d ƒ |  j ƒ | j | ƒ |  j | ƒ d  S(   Ns   Recover statust   recovers   Recover program status fromt   Recovers	   clicked()R\   (   R    RV   R   R   R   R   R   R   RL   t   getRecoverFilest	   QComboBoxt   menut   addItemRŒ   t   setOrientationR   t   Qtt
   HorizontalR�   t	   ApplyRoleR*   R+   RÎ   t
   RejectRoleRR   R$   (   R   R/   R0   t   recover_filesRa   t	   buttonBoxR    (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyR   ô  s$    c         C   s…   |  j  ƒ  t |  j j ƒ  ƒ } t ƒ  j ƒ  t ƒ  j | ƒ } | r^ t j	 j
 |  d | ƒ n# t ƒ  j ƒ  d d  l } | j ƒ  d  S(   Ns   Error restoring status from iÿÿÿÿ(   RR   R6   RÒ   t   currentTextt   DISPLAYTABLEt   deleteAllDataObjRL   RÎ   R    RN   RO   t   loadAllDataObjt   rebuildt   UpdateDisplay(   R   t   status_labelt   retRß   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyRÎ     s    
(   Rm   Rn   R   RÎ   (    (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyRÍ   í  s   	(   t   __doc__t   PyQt4R    R   t   global_definitionsR   R¶   R9   R-   RV   R   R]   RT   Rµ   RŠ   RÍ   (    (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/statusGui.pyt   <module>   s   
“O�k