ó
ø`9Sc           @   sG   d  d l  Td  d l Td  d l m Z d g Z d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   *(   t   guit   StatusLabelWidgetc           B   s€   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 e d „ Z d	 „  Z d
 „  Z d „  Z d „  Z RS(   s@   A rich text label with an icon for various information messages.c         C   sÂ   t  j |  | ƒ t ƒ  } t ƒ  |  _ |  j j t j t j Bƒ | j	 |  j ƒ t ƒ  |  _
 |  j
 j t j ƒ |  j
 j t ƒ | j	 |  j
 d ƒ | j ƒ  | j d d d d ƒ |  j | ƒ d  S(   Ni   i    (   t   QWidgett   __init__t   QHBoxLayoutt   QLabelt	   iconLabelt   setAlignmentt   Qtt	   AlignLeftt   AlignTopt	   addWidgett   messageLabelt   setTextFormatt   RichTextt   setWordWrapt   Truet
   addStretcht   setContentsMarginst	   setLayout(   t   selft   parentt   layout(    (    s    code\common\StatusLabelWidget.pyR      s    	
c         C   s   |  j  j t ƒ d S(   sX   Disable word wrapping for the label text (by default, word wrapping
        is enabled).N(   R   R   t   False(   R   (    (    s    code\common\StatusLabelWidget.pyt   disableWordWrapping6   s    c         C   s   |  j  j ƒ  |  j j ƒ  d  S(   N(   R   t   clearR   (   R   (    (    s    code\common\StatusLabelWidget.pyR   <   s    c         C   s   |  j  t j d ƒ | ƒ d  S(   Nt	   completed(   t   setIconAndTextR   t   loadIcon(   R   t   message(    (    s    code\common\StatusLabelWidget.pyt   setCompleted@   s    c         C   s   |  j  t j d ƒ | ƒ d  S(   Nt   info(   R   R   R   (   R   R   (    (    s    code\common\StatusLabelWidget.pyt   setInfoC   s    c         C   s   |  j  t j d ƒ | ƒ d  S(   Nt   warning(   R   R   R   (   R   R   (    (    s    code\common\StatusLabelWidget.pyt
   setWarningF   s    c         C   s   |  j  t j d ƒ | ƒ d  S(   Nt   error(   R   R   R   (   R   R   (    (    s    code\common\StatusLabelWidget.pyt   setErrorI   s    c         C   s0   |  j  t j d ƒ | ƒ | r, |  j ƒ  n  d S(   sv   Set a progress status message and then call 'repaintParentWindow'
        method if 'requestRepaint' is set to 'True'.t   progressN(   R   R   R   t   repaintParentWindow(   R   R   t   requestRepaint(    (    s    code\common\StatusLabelWidget.pyt   setProgressL   s    c         C   sÎ   | d k r |  j ƒ  d S| j ƒ  } | j ƒ  } | d k rN |  j | ƒ n  | d k rj |  j | ƒ n` | d k r† |  j | ƒ nD | d k r¢ |  j | ƒ n( | d k r¾ |  j | ƒ n t	 sÊ t
 ‚ d S(   s…   Set icon and text according to a 'StatusMessage' instance, as
        returned by 'StatusSignalingWidget's 'getStatusMessage' method.NR   R    R"   R$   R&   (   t   NoneR   t	   getStatust   getTextR   R!   R#   R%   R)   R   t   AssertionError(   R   t   statusMessaget   statust   text(    (    s    code\common\StatusLabelWidget.pyt   setStatusMessageU   s     
c         C   sm   d } d } xM | D]E } | d k	 r | d k sC | j ƒ  | k r | } | j ƒ  } q q W|  j | ƒ d S(   sï   Same as 'setStatusMessage', but take a list of 'StatusMessage'
        instances and select the most relevant message out of it.

        The most relevant message is the first message in the list with the
        greatest status severity.N(   R*   t   getSeverityR1   (   R   t   statusMessageListt   mostSevereMessaget   greatestSeverityR   (    (    s    code\common\StatusLabelWidget.pyt   setMostSevereStatusMessagem   s    c         C   s:   |  j  ƒ  } |  j ƒ  j ƒ  | j ƒ  j ƒ  | j ƒ  d S(   sÈ  Update this widget's layout and repaint the window it is contained
        in, so that any changes made to the displayed message would be
        immediately visible to the user.

        This is useful in combination with 'setProgress' when an action that
        may take noticeable amount of time is about to start in the main
        application thread. This may also be used as a handler for
        'StatusSignalingWidget's 'repaintRequested' signal.N(   t   windowR   t   activatet   repaint(   R   R   (    (    s    code\common\StatusLabelWidget.pyR'   ‚   s    
c         C   sH   t  |  j j ƒ  ƒ j ƒ  } |  j j | j | ƒ ƒ |  j j | ƒ d  S(   N(   t   QFontMetricsR   t   fontt   heightR   t	   setPixmapt   pixmapt   setText(   R   t   iconR   t
   iconHeight(    (    s    code\common\StatusLabelWidget.pyR   ™   s    N(   t   __name__t
   __module__t   __doc__R*   R   R   R   R   R!   R#   R%   R   R)   R1   R6   R'   R   (    (    (    s    code\common\StatusLabelWidget.pyR      s   										N(   t   PyQt4.QtCoret   PyQt4.QtGuit   common.utilsR   t   __all__R   R   (    (    (    s    code\common\StatusLabelWidget.pyt   <module>   s   

	