2009-08-09 26:15 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)

* contrib/hbqt/hbqt_slots.cpp
  * contrib/hbxbp/xbpbrowse.prg
    + Implemented XbpColumn():type == XBPCOL_TYPE_ICONFILE.
      Now any image can be viewed as an icon in a column object of XbpBrowse()
   
  * contrib/hbxbp/tests/demoxbp.prg
    ! Updated to demonstrate XbpColumn():type == XBPCOL_TYPE_ICONFILE functionality.
This commit is contained in:
Pritpal Bedi
2009-08-09 23:19:55 +00:00
parent 8106523a59
commit 3add3fe6a9
4 changed files with 67 additions and 4 deletions

View File

@@ -17,6 +17,15 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-08-09 26:15 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* contrib/hbqt/hbqt_slots.cpp
* contrib/hbxbp/xbpbrowse.prg
+ Implemented XbpColumn():type == XBPCOL_TYPE_ICONFILE.
Now any image can be viewed as an icon in a column object of XbpBrowse()
* contrib/hbxbp/tests/demoxbp.prg
! Updated to demonstrate XbpColumn():type == XBPCOL_TYPE_ICONFILE functionality.
2009-08-09 21:42 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* config/global.cf
! Fixed 'sh' HB_SHELL detection. Problem experienced with

View File

@@ -1800,6 +1800,7 @@ Qt_WhatsThisRole 5 Qt_SizeHintRole 13
#define HBQT_BRW_COLHEIGHT 1011
#define HBQT_BRW_DATHEIGHT 1012
#define HBQT_BRW_DATALIGN 1013
#define HBQT_BRW_CELLDECORATION 1014
QVariant fetchRole( PHB_ITEM block, int what, int par1, int par2 )
{
@@ -1821,6 +1822,8 @@ QVariant fetchRole( PHB_ITEM block, int what, int par1, int par2 )
return( hb_itemGetND( ret ) );
else if( hb_itemType( ret ) & HB_IT_NUMERIC )
return( hb_itemGetNI( ret ) );
// else if( hb_itemType( ret ) & HB_IT_POINTER )
// return( hb_itemGetPtr( ret ) );
else
return QVariant();
@@ -1875,6 +1878,12 @@ QVariant HbDbfModel::data( const QModelIndex & index, int role ) const
else
return( QColor( ( QRgb ) iClr ) );
}
case Qt::DecorationRole:
{
QVariant image = fetchRole( block, HBQT_BRW_CELLDECORATION, index.row()+1, index.column()+1 );
return( QIcon( image.toString() ) );
//return( QPixmap( image.toString() ) );
}
case Qt::DisplayRole:
{
return( fetchRole( block, HBQT_BRW_CELLVALUE, index.row()+1, index.column()+1 ) );

View File

@@ -1576,11 +1576,11 @@ STATIC FUNCTION RtfApplyFont( oRTF )
FUNCTION Build_Browse( oWnd )
LOCAL aPresParam, oXbpBrowse, oXbpColumn
LOCAL cPath := hb_DirBase() + ".." + hb_osPathSeparator() + ".." + hb_osPathSeparator() + ".." + hb_osPathSeparator() + "tests" + hb_osPathSeparator()
Set( _SET_DATEFORMAT, "yyyy.mm.dd" ) /* ANSI */
USE ( hb_DirBase() + ".." + hb_osPathSeparator() + ".." + hb_osPathSeparator() + ".." + hb_osPathSeparator() + "tests" + hb_osPathSeparator() +;
"test.dbf" ) NEW SHARED VIA 'DBFCDX'
USE ( cPath + "test.dbf" ) NEW SHARED VIA 'DBFCDX'
DbGotop()
oXbpBrowse := XbpBrowse():new():create( oWnd, , { 10,10 }, { oWnd:currentSize()[1]-25,oWnd:currentSize()[2]-45 } )
@@ -1601,6 +1601,7 @@ FUNCTION Build_Browse( oWnd )
oXbpBrowse:headerRbDown := {|mp1, mp2, o| mp1 := mp1, xbp_debug( o:getColumn( mp2 ):heading ) }
aPresParam := {}
aadd( aPresParam, { XBP_PP_COL_HA_CAPTION , "Last" } )
aadd( aPresParam, { XBP_PP_COL_HA_FGCLR , XBPSYSCLR_WINDOWSTATICTEXT } )
@@ -1720,6 +1721,26 @@ FUNCTION Build_Browse( oWnd )
//
oXbpBrowse:addColumn( oXbpColumn )
aPresParam := {}
aadd( aPresParam, { XBP_PP_COL_HA_CAPTION , "Icons" } )
aadd( aPresParam, { XBP_PP_COL_HA_FGCLR , GRA_CLR_CYAN } )
aadd( aPresParam, { XBP_PP_COL_HA_BGCLR , GRA_CLR_BLUE } )
aadd( aPresParam, { XBP_PP_COL_HA_HEIGHT , 20 } )
aadd( aPresParam, { XBP_PP_COL_DA_FGCLR , GRA_CLR_BLACK } )
aadd( aPresParam, { XBP_PP_COL_DA_BGCLR , RGB( 5,240,210 ) } )
aadd( aPresParam, { XBP_PP_COL_DA_HILITE_FGCLR , GRA_CLR_WHITE } )
aadd( aPresParam, { XBP_PP_COL_DA_HILITE_BGCLR , GRA_CLR_DARKGRAY } )
aadd( aPresParam, { XBP_PP_COL_DA_ROWHEIGHT , 20 } )
aadd( aPresParam, { XBP_PP_COL_DA_ROWWIDTH , 40 } )
//
oXbpColumn := XbpColumn():new()
oXbpColumn:type := XBPCOL_TYPE_FILEICON
cPath := hb_DirBase() + hb_osPathSeparator()
oXbpColumn:dataLink := {|n| n := recno(), IF( n%3 == 0, cPath + "abs3.png", IF( n%5 == 0, cPath + "copy.png", cPath + "vr.png" ) ) }
oXbpColumn:create( , , , , aPresParam )
//
oXbpBrowse:addColumn( oXbpColumn )
RETURN nil
/*----------------------------------------------------------------------*/

View File

@@ -92,6 +92,7 @@
#define HBQT_BRW_COLHEIGHT 1011
#define HBQT_BRW_DATHEIGHT 1012
#define HBQT_BRW_DATALIGN 1013
#define HBQT_BRW_CELLDECORATION 1014
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
@@ -809,14 +810,31 @@ METHOD XbpBrowse:supplyInfo( nInfo, p2, p3 )
::forceStable()
RETURN IF( p3 > 0 .and. p3 <= ::colCount, ::columns[ p3 ]:dheight , 12 )
CASE HBQT_BRW_CELLVALUE
CASE HBQT_BRW_CELLDECORATION
IF ::lFirst
::lFirst := .f.
::forceStable()
::setVertScrollBarRange( .t. )
::setHorzScrollBarRange( .f. )
ENDIF
RETURN ::cellValue( p2, p3 )
IF ::columns[ p3 ]:type == XBPCOL_TYPE_FILEICON
RETURN trim( ::cellValue( p2, p3 ) )
ELSE
RETURN ""
ENDIF
CASE HBQT_BRW_CELLVALUE
IF ::columns[ p3 ]:type == XBPCOL_TYPE_TEXT
IF ::lFirst
::lFirst := .f.
::forceStable()
::setVertScrollBarRange( .t. )
::setHorzScrollBarRange( .f. )
ENDIF
RETURN ::cellValue( p2, p3 )
ELSE
RETURN ""
ENDIF
ENDSWITCH
@@ -974,6 +992,11 @@ METHOD doConfigure() CLASS XbpBrowse
cType := ValType( xValue )
nWidth := IIF( cType $ "CMNDTL", Len( Transform( xValue, oCol:picture ) ), 0 )
/* Control the picture spec of Bitmaps|Icon files */
IF oCol:type != XBPCOL_TYPE_TEXT
nWidth := 256
ENDIF
#if 0
cColSep := oCol:colSep
IF cColSep == NIL
@@ -3369,6 +3392,7 @@ CREATE CLASS XbpColumn INHERIT XbpWindow, XbpDataRef
DATA nColWidth
DATA valtype
DATA type INIT XBPCOL_TYPE_TEXT
DATA blankVariable
ENDCLASS