B
    Ý!†^È  ã               @   sl   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
mZmZmZmZ dZdaG dd„ deƒZdS )é    )ÚQGuiApplication)ÚQQmlApplicationEngineÚqmlRegisterType)ÚQUrlÚQTimerÚQAbstractListModelÚQModelIndex)ÚQObjectÚSignalÚSlotÚPropertyÚQtNc               @   sœ   e Zd Zejd Zejd Zejd Zejd Zejd Z	dd„ Z
dd	„ Zd
d„ Zdd„ Zdd„ Zeƒ dd„ ƒZeƒ dd„ ƒZddd„Zdd„ Zdd„ ZdS )ÚPatchBayModelr   é   é   é   é   c             C   s.   t  | ¡ t ¡ | _ttt ¡ ƒƒ| _| ad S )N)	r   Ú__init__Úlocal_effectsÚkeysZ_PatchBayModel__effect_idsÚdictÚ	enumerateÚ_PatchBayModel__orderÚpatch_bay_singleton)Úself© r   ú"/home/debian/UI/patch_bay_model.pyr      s    

zPatchBayModel.__init__c             C   s   |   tƒ |  ¡ |  ¡ ¡ d S )N)ÚbeginInsertRowsr   ÚrowCount)r   r   r   r   ÚstartInsert+   s    zPatchBayModel.startInsertc             C   s   t tt ¡ ƒƒ| _|  ¡  d S )N)r   r   r   r   r   ÚendInsertRows)r   r   r   r   Ú	endInsert/   s    zPatchBayModel.endInsertc             C   s&   t t ¡ ƒ |¡}|  tƒ ||¡ d S )N)Úlistr   r   ÚindexÚbeginRemoveRowsr   )r   Ú	effect_idÚcurrent_rowr   r   r   ÚstartRemove4   s    zPatchBayModel.startRemovec             C   s   |   ¡  d S )N)ÚendRemoveRows)r   r   r   r   Ú	endRemove9   s    zPatchBayModel.endRemovec             C   s*   | j  |  dd¡|  ttƒd d¡¡ d S )Nr   r   )ÚdataChangedÚemitr#   Úlenr   )r   r   r   r   Úitems_changed<   s    zPatchBayModel.items_changedc             C   s4   t t ¡ ƒ |¡}| j |  |d¡|  |d¡¡ d S )Nr   )r"   r   r   r#   r*   r+   )r   r%   r&   r   r   r   Úitem_changedA   s    zPatchBayModel.item_changedNc             C   s   t tƒS )N)r,   r   )r   Úparentr   r   r   r   G   s    zPatchBayModel.rowCountc             C   sÐ   |  ¡ stƒ S | ¡ }d|  kr.|  ¡ k rÊn n˜|tjkrJ| j| ¡  S |tjkrjt| j| ¡   d S |tj	krŠt| j| ¡   d S |tj
krªt| j| ¡   d S |tjkrÊt| j| ¡   d S tƒ S )Nr   Úeffect_typeÚ	highlightÚxÚy)ÚisValidZQVariantÚrowr   r   ÚEffectIDr   Ú
EffectTyper   ÚIsHighlightedÚXÚY)r   r#   Úroler5   r   r   r   ÚdataK   s    




zPatchBayModel.datac          
   C   s"   t jdt jdt jdt jdt jdiS )Ns   l_effect_ids   l_effect_types   l_highlights   cur_xs   cur_y)r   r6   r7   r8   r9   r:   )r   r   r   r   Ú	roleNames_   s
    zPatchBayModel.roleNames)N)Ú__name__Ú
__module__Ú__qualname__r   ÚUserRoler6   r7   r8   r9   r:   r   r   r!   r'   r)   r   r-   r.   r   r<   r=   r   r   r   r   r      s   





r   )ÚPySide2.QtGuir   ÚPySide2.QtQmlr   r   ÚPySide2.QtCorer   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   Ú<module>   s   