CjdZddlmZmZmZmZddlmZmZm Z ddl m Z m Z m Z mZmZGddeZGddeZGd d eZGd d eZGd deZGddeZGddeZdS)uD Delegate per la griglia Linker. - MatchTriangleDelegate: disegna un triangolino nell'angolo in alto a destra: ROSSO → archivio ha sovrascritto il valore originale dell'utente VERDE → archivio ha confermato lo stesso valore dell'utente Il valore originale dell'utente è salvato in Qt.ItemDataRole.UserRole. )QStyledItemDelegateQStyleOptionViewItemQToolTipQStyle)QtQPointFQEvent)QPainterQBrushQColor QPolygonFQFontcLeZdZdZdZedZdeffd ZfdZ xZ S)RedTriangleDelegatez Disegna il triangolino sulle celle input toccate dall'archivio. - Verde: archivio ha confermato il valore originale (UserRole == DisplayRole) - Rosso: archivio ha sovrascritto il valore originale (UserRole != DisplayRole) z#CC0000painterc t||||tjj}|dSt |}|sdSt |tjjpd}||krdS|j }|j }|j } | |tjjd|tjj||j|t1t3||z | t3|| t3|| |zg|dS)NT)superpaintdatar ItemDataRoleUserRolestr DisplayRolelower TRIANGLE_SIZErectrighttopsave setRenderHintr RenderHint AntialiasingsetPenPenStyleNoPensetBrushCOLOR_OVERRIDE drawPolygonr rrestore) selfroptionindexuser_valuser_str display_valsxy __class__s =C:\PYTHON\MyICR_Suite\app\modules\linker\src\gui\delegates.pyrzRedTriangleDelegate.paints  gvu---::bo677   Fx==  F%**R_%@AAGRHH >>  {0022 2 2 F   K     KOO   h1>EEEr{())),---I AE1   AqMM Aq1u  '      cD|tjjkr|t jj}|rt|nd}t|t jj pd}|rT| | kr*tj | ||dStjdSt||||S)z:Tooltip sul triangolino rosso: mostra il valore originale.rT)typer TypeToolTiprrrrrrrrshowText globalPoshideTextr helpEvent) r,eventviewr-r.r/r0 display_strr5s r6r?zRedTriangleDelegate.helpEvent7s ::<<6;. . .zz"/":;;H(08s8}}}bHejj)DEEKLLK HNN,, 0A0A0C0CCC!%//"3"3XtDDDt     4ww  fe<< = = = = = = = = =r7rc"eZdZdZfdZxZS)CenteredDelegatez/Testo centrato orizzontalmente e verticalmente.cxt||tjj|_dSN)rinitStyleOptionr AlignmentFlag AlignCenterdisplayAlignmentr,r-r.r5s r6rMz CenteredDelegate.initStyleOptionHs1 ..."$"2">r7rCrDrErFrMrGrHs@r6rJrJEs>99?????????r7rJc"eZdZdZfdZxZS)RightAlignedDelegatez2Testo allineato a destra e verticalmente centrato.ct||tjjtjjz|_dSrL)rrMrrN AlignVCenter AlignRightrPrQs r6rMz$RightAlignedDelegate.initStyleOptionPs< ..."$"2"?"BRB]"]r7rRrHs@r6rTrTMsG<<^^^^^^^^^r7rTc"eZdZdZfdZxZS)ThousandsDelegatezPAllineato a destra, formatta il valore numerico con separatore migliaia (punto).cvt||t|tjjpd} tt|d dd|_ dS#ttf$rYdSwxYw)Nr,.)rrMrrrrrstripintfloatreplacetext ValueError TypeError)r,r-r.rar5s r6rMz!ThousandsDelegate.initStyleOptionXs ...5::bo9::@bAAGGII  t--1199#sCCFKKKI&    DD s*7B##B87B8rRrHs@r6rYrYUs>ZZr7rYc,eZdZdZdedeffd ZxZS)FlatBgDelegatezDipinge BackgroundRole come fillRect piatto, bypassando l'interferenza del CSS stylesheet. Usato per celle editabili con colore di sfondo fisso.rr-ct|jtjjz}|s|t jj}|| | |j || t|}t|_t!|||dSt!|||dSrL)boolstater StateFlagState_SelectedrrrBackgroundRoler!fillRectrr+rr backgroundBrushrr)r,rr-r.selectedbgoptr5s r6rzFlatBgDelegate.paintes v'7'FFGG BO:;;B~   b111!!!*622&,hh# gsE222  gvu-----r7)rCrDrErFr rrrGrHs@r6rereasV== .X ./C . . . . . . . . . .r7recTeZdZdZedZd dedeffd Zdeffd Z xZ S) RiferLinkDelegatezRende le celle come hyperlink (testo blu sottolineato). Parametro center=True per allineamento centrato (default: sinistra).z#0563C1NFcenterrcJt||r*tjjtjjz|_dS|r*tjjtjjz|_dStjjtjjz|_dSrL) r__init__rrNrVrW_align AlignHCenter AlignLeft)r,parentrsrr5s r6ruzRiferLinkDelegate.__init__zs     U*7":J:UUDKKK  U*7":J:WWDKKK*7":J:TTDKKKr7rcFt|tjjpd}|s%t |||dS|t|j tj j z}|r^||j|j|j}n{|tjj}|||j|n2||j|j|j}t/|j}|d||||||jdddd|j||dS)NrTr) rrrrrr]rrr!rgrhrrirjrlrpalette highlighthighlightedTextcolorrkbase LINK_COLORrfont setUnderlinesetFontr%drawTextadjustedrvr+) r,rr-r.rarnrrorr5s r6rzRiferLinkDelegate.paints5::bo9::@bAAGGII  GGMM'65 1 1 1 F  v'7'FFGG  $   V[&.*B*B*D*D E E EN2244::<X > > > > > >r7rN)rFPyQt6.QtWidgetsrrrr PyQt6.QtCorerrr PyQt6.QtGuir r r r rrrJrTrYrerrrrr7r6rsXWWWWWWWWWWW,,,,,,,,,,BBBBBBBBBBBBBB4=4=4=4=4=-4=4=4=n?????*???^^^^^.^^^     ,   .....(...&+++++++++\>>>>>(>>>>>r7