Browse text multirow with icons and other possibilities for the displayed data

25 views
Skip to first unread message

Zoran Sibinovic

unread,
May 9, 2023, 4:50:46 AM5/9/23
to QtContribs
Hi to all,
in the past days Pritpal improves hbqtbrowse.prg with a multirow possibility for the browse header. I haven't already compared it to mine solution but wanted just to show my work that I used in the past several years since the solution is asked for.
The new: and init: is used according the previous qtcontribs version.

If it is usefull for someone to improve its code everybody is welcome with questions.
There are lot other things that I had also adapted: the frozen columns become editable when you navigate or click on them; there is no more empty columns if the browse frame that is larger than the width sum of the columns; there is no more cutted rows to be displayed if the top/bottom frame size is not exactly calculated; the vertical and horizontal slidebar moves exact to the first and the last  row and it did it smoothly row by row, etc. 
 
Regards 
Zoran


Cmybrwclass.prg

Zoran Sibinovic

unread,
May 10, 2023, 6:37:11 AM5/10/23
to QtContribs
Hi Pritpal,
I integrateg your browse header text multirow code. 
The changes I made affects only the METHOD MyHbQtBrowse:doConfigure() and your code works without my additions, but since I use also, sometimes, icons in front of the header text,
I had to add little line code to expand the header width in this case, otherwise the text with the icon inside is not fully displayed.


/*--------------------------------------------------*/
METHOD MyHbQtBrowse:doConfigure()     /* Overloaded */
 ...
   nHdrRows := 1
   FOR i := 1 TO Len( ::columns )
      xVal := Transform( Eval( ::columns[ i ]:block ), ::columns[ i ]:picture )
      nwVal := oSZ:width() * Len( xVal )
      nHdrLen := __calcHdrColumnRows( ::columns[ i ]:heading(), @nHdrRows )

      nwHead := oSZ:width() * nHdrLen
       ::columns[ i ]:nColWidth := Max( nwVal, nwHead ) + nPadding + IF( ::aHeadingIconList[i] <> "", 16, 0 )  //  ::aHeadingIconList, array with column header icons if any ( png, transparent background, 128x128dpi )

      ::oHeaderView:resizeSection( i-1, ::columns[ i ]:nColWidth )
      ::oFooterView:resizeSection( i-1, ::columns[ i ]:nColWidth )
   NEXT
...

The display of the icons in the header is managed in 
/*------------------------------------------------------------------*/
METHOD MyHbQtBrowse:fetchColumnInfo( nCall, nRole, nArea, nRow, nCol )

   ...

   CASE HBQT_QAIM_headerData
      IF nArea == 0                               /* Header Area */
         SWITCH nRole
         CASE Qt_SizeHintRole      ; RETURN ::oDefaultCellSize
         CASE Qt_DisplayRole       ; RETURN ::columns[ nCol ]:heading
         CASE Qt_DecorationRole    ; RETURN ::compatIcon( ::aHeadingIconList[nCol] )
         CASE Qt_TextAlignmentRole ; RETURN ::columns[ nCol ]:hAlignment 
         CASE Qt_ForegroundRole    ; RETURN QColor( Qt_darkBlue ) 
         CASE Qt_BackgroundRole    ; RETURN ::compatColor( ::columns[ nCol ]:hBgColor ) 

         ENDSWITCH
 ...

Regards 
Zoran
Reply all
Reply to author
Forward
0 new messages