2010-08-27 18:32 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/hbqt/qtgui/hbqt_hbqgraphicsitem.cpp
* contrib/hbqt/qtgui/hbqt_hbqgraphicsscene.cpp
* contrib/hbide/hbqreportsmanager.prg
+ Advanced: Report's save/load artifacts.
+ Context-menu on scene areas where no item is under cursor.
+ ObjectsTree without any item highlighted if no item is visible selected in the scene.
This commit is contained in:
@@ -16,6 +16,14 @@
|
||||
The license applies to all entries newer than 2009-04-28.
|
||||
*/
|
||||
|
||||
2010-08-27 18:32 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
|
||||
* contrib/hbqt/qtgui/hbqt_hbqgraphicsitem.cpp
|
||||
* contrib/hbqt/qtgui/hbqt_hbqgraphicsscene.cpp
|
||||
* contrib/hbide/hbqreportsmanager.prg
|
||||
+ Advanced: Report's save/load artifacts.
|
||||
+ Context-menu on scene areas where no item is under cursor.
|
||||
+ ObjectsTree without any item highlighted if no item is visible selected in the scene.
|
||||
|
||||
2010-08-27 12:49 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
|
||||
* contrib/hbqt/tests/demoqt.prg
|
||||
- Replaced: remaining old implementation code for Slots/Events.
|
||||
|
||||
@@ -73,6 +73,8 @@
|
||||
|
||||
#define INI_KEY( cKey, n ) cKey + "_" + hb_ntos( n ) + "="
|
||||
|
||||
STATIC hIDs := {=>}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
CLASS HbqReportsManager
|
||||
@@ -388,6 +390,12 @@ METHOD HbqReportsManager:execEvent( cEvent, p, p1, p2 )
|
||||
CASE p == 21105 // Context Menu Event
|
||||
::contextMenuScene( p1 )
|
||||
|
||||
CASE p == 21107 // Left button pressed nowhere on an item
|
||||
IF ! empty( ::qCurGraphicsItem )
|
||||
::qCurGraphicsItem := NIL
|
||||
::qTreeObjects:setCurrentItem( QTreeWidgetItem():new() )
|
||||
ENDIF
|
||||
|
||||
CASE p == QEvent_GraphicsSceneDragEnter
|
||||
qEvent:acceptProposedAction()
|
||||
|
||||
@@ -610,7 +618,7 @@ METHOD HbqReportsManager:toString()
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD HbqReportsManager:buildReportStream()
|
||||
LOCAL txt_:= {}, n, a_, s, oWidget, qPos
|
||||
LOCAL txt_:= {}, n, a_, s, oWidget, qPos, qTran
|
||||
|
||||
aadd( txt_, "[GENERAL]" )
|
||||
aadd( txt_, "" )
|
||||
@@ -642,9 +650,13 @@ METHOD HbqReportsManager:buildReportStream()
|
||||
n := a_:__enumIndex()
|
||||
IF hb_hHasKey( ::hItems, a_[ 3 ] )
|
||||
oWidget := ::hItems[ a_[ 3 ] ]
|
||||
qPos := QPointF():from( oWidget:scenePos() )
|
||||
qPos := QPointF():from( oWidget:scenePos() )
|
||||
qTran := QTransform():from( oWidget:transform() )
|
||||
|
||||
a_[ 5 ] := { { 0, 0, oWidget:width(), oWidget:height() }, { qPos:x(), qPos:y() } }
|
||||
a_[ 5 ] := { { 0, 0, oWidget:width(), oWidget:height() }, ;
|
||||
{ qPos:x(), qPos:y() }, ;
|
||||
{ qTran:m11(), qTran:m12(), qTran:m13(), qTran:m21(), qTran:m22(), qTran:m23(), qTran:m31(), qTran:m32(), qTran:m33() }, ;
|
||||
}
|
||||
|
||||
aadd( txt_, INI_KEY( "object", n ) + rmgr_a2arrayStr( a_ ) )
|
||||
ENDIF
|
||||
@@ -700,7 +712,7 @@ METHOD HbqReportsManager:parseBuffer( cBuffer )
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD HbqReportsManager:loadReport( xData )
|
||||
LOCAL cBuffer, a_, d_, n, cName, cAlias, cField
|
||||
LOCAL cBuffer, a_, d_, n, cName, cAlias, cField, oWidget, qTran
|
||||
|
||||
::clear()
|
||||
|
||||
@@ -729,16 +741,19 @@ METHOD HbqReportsManager:loadReport( xData )
|
||||
FOR EACH a_ IN ::aRptObjects
|
||||
SWITCH a_[ 1 ]
|
||||
CASE "Object"
|
||||
d_:= a_[ 5 ]
|
||||
::addObject( a_[ 4 ], QRectF():new( d_[ 1,1 ], d_[ 1,2 ], d_[ 1,3 ], d_[ 1,4 ] ), QPointF():new( d_[ 2,1 ], d_[ 2,2 ] ) )
|
||||
d_ := a_[ 5 ]
|
||||
oWidget := ::addObject( a_[ 4 ], QRectF():new( d_[ 1,1 ], d_[ 1,2 ], d_[ 1,3 ], d_[ 1,4 ] ), QPointF():new( d_[ 2,1 ], d_[ 2,2 ] ) )
|
||||
EXIT
|
||||
CASE "Field"
|
||||
d_:= a_[ 5 ]
|
||||
cName := a_[ 3 ] ; n := at( "...", cName ) ; cAlias := substr( cName, 1, n-1 )
|
||||
cField := substr( cName, n + 3 ) ; n := at( "_", cField ) ; cField := substr( cField, 1, n-1 )
|
||||
::addField( cAlias, cField, QRectF():new( d_[ 1,1 ], d_[ 1,2 ], d_[ 1,3 ], d_[ 1,4 ] ), QPointF():new( d_[ 2,1 ], d_[ 2,2 ] ) )
|
||||
d_ := a_[ 5 ]
|
||||
cName := a_[ 3 ] ; n := at( "...", cName ) ; cAlias := substr( cName, 1, n-1 )
|
||||
cField := substr( cName, n + 3 ) ; n := at( "_", cField ) ; cField := substr( cField, 1, n-1 )
|
||||
oWidget := ::addField( cAlias, cField, QRectF():new( d_[ 1,1 ], d_[ 1,2 ], d_[ 1,3 ], d_[ 1,4 ] ), QPointF():new( d_[ 2,1 ], d_[ 2,2 ] ) )
|
||||
EXIT
|
||||
ENDSWITCH
|
||||
qTran := QTransform():new()
|
||||
qTran : setMatrix( d_[ 3,1 ], d_[ 3,2 ], d_[ 3,3 ], d_[ 3,4 ], d_[ 3,5 ], d_[ 3,6 ], d_[ 3,7 ], d_[ 3,8 ], d_[ 3,9 ] )
|
||||
oWidget : setTransform( qTran )
|
||||
NEXT
|
||||
ENDIF
|
||||
|
||||
@@ -811,7 +826,7 @@ METHOD HbqReportsManager:addObject( cType, qGeo, qPos )
|
||||
::updateObjectsTree( "Object", "Page_1", cName, cType )
|
||||
aadd( ::aObjects, { "Object", "Page_1", cName, cType, {} } )
|
||||
|
||||
RETURN Self
|
||||
RETURN oWidget
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@@ -838,7 +853,7 @@ METHOD HbqReportsManager:addField( cAlias, cField, qGeo, qPos )
|
||||
::updateObjectsTree( "Field", "Page_1", cName, NIL )
|
||||
aadd( ::aObjects, { "Field", "Page_1", cName, NIL, {} } )
|
||||
|
||||
RETURN Self
|
||||
RETURN oWidget
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@@ -882,6 +897,10 @@ METHOD HbqReportsManager:clear()
|
||||
::aRptPages := {}
|
||||
::aRptSources := {}
|
||||
|
||||
hIDs := {=>}
|
||||
|
||||
::qScene:invalidate()
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
@@ -1056,8 +1075,6 @@ METHOD HbqReportsManager:getImageOfType( cType )
|
||||
|
||||
METHOD HbqReportsManager:getNextID( cType )
|
||||
|
||||
STATIC hIDs := {=>}
|
||||
|
||||
IF ! hb_hHasKey( hIDs, cType )
|
||||
hIDs[ cType ] := 0
|
||||
ENDIF
|
||||
|
||||
@@ -110,7 +110,7 @@ HBQGraphicsItem::HBQGraphicsItem( int type, QGraphicsItem * parent ) : QGraphics
|
||||
|
||||
m_barsIdentation = 1 / UNIT;
|
||||
m_showLabels = true;
|
||||
m_toColorFactor = 1.5;
|
||||
m_toColorFactor = 2.0;
|
||||
m_drawBorder = true;
|
||||
m_showGrid = true;
|
||||
m_legendColorRectWidth = 5 / UNIT;
|
||||
|
||||
@@ -133,7 +133,6 @@ void HBQGraphicsScene::setPageSize( int pageSize )
|
||||
updatePageRect();
|
||||
m_paperRect = sceneRect();
|
||||
setGeometry( QRect( 10 / UNIT, 10 / UNIT, sceneRect().width() - 10 / UNIT * 2, sceneRect().height()- 10 / UNIT * 2 ) );
|
||||
|
||||
}
|
||||
|
||||
QRectF HBQGraphicsScene::paperRect()
|
||||
@@ -236,6 +235,7 @@ void HBQGraphicsScene::mousePressEvent( QGraphicsSceneMouseEvent * event )
|
||||
mouseOldPos = movingItem->pos();
|
||||
|
||||
QGraphicsScene::mousePressEvent( event );
|
||||
|
||||
if( event->buttons() == Qt::LeftButton )
|
||||
{
|
||||
if( ! itemAt( event->scenePos() ) ){
|
||||
@@ -246,6 +246,15 @@ void HBQGraphicsScene::mousePressEvent( QGraphicsSceneMouseEvent * event )
|
||||
emit itemSelected( this, event->scenePos() );
|
||||
}
|
||||
}
|
||||
|
||||
HBQGraphicsItem * item = dynamic_cast< HBQGraphicsItem * >( itemAt( event->scenePos() ) );
|
||||
if( ! item ){
|
||||
if( block ){
|
||||
PHB_ITEM p1 = hb_itemPutNI( NULL, 21107 );
|
||||
hb_vmEvalBlockV( block, 1, p1 );
|
||||
hb_itemRelease( p1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +273,24 @@ void HBQGraphicsScene::mouseReleaseEvent( QGraphicsSceneMouseEvent * event )
|
||||
movingItem = 0;
|
||||
}
|
||||
QGraphicsScene::mouseReleaseEvent( event );
|
||||
|
||||
if( event->button() == Qt::RightButton )
|
||||
{
|
||||
HBQGraphicsItem * item = dynamic_cast< HBQGraphicsItem * >( itemAt( event->scenePos() ) );
|
||||
if( ! item ){
|
||||
if( block ){
|
||||
PHB_ITEM p1 = hb_itemPutNI( NULL, 21105 );
|
||||
PHB_ITEM p2 = hb_itemPutPtr( NULL, event );
|
||||
hb_vmEvalBlockV( block, 2, p1, p2 );
|
||||
hb_itemRelease( p1 );
|
||||
hb_itemRelease( p2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
// Key Events
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void HBQGraphicsScene::keyReleaseEvent( QKeyEvent * keyEvent )
|
||||
{
|
||||
@@ -381,15 +407,6 @@ void HBQGraphicsScene::keyPressEvent( QKeyEvent * keyEvent )
|
||||
|
||||
void HBQGraphicsScene::contextMenuEvent( QGraphicsSceneContextMenuEvent * event )
|
||||
{
|
||||
#if 0
|
||||
if( block ){
|
||||
PHB_ITEM p1 = hb_itemPutNI( NULL, 21105 );
|
||||
PHB_ITEM p2 = hb_itemPutPtr( NULL, event );
|
||||
hb_vmEvalBlockV( block, 2, p1, p2 );
|
||||
hb_itemRelease( p1 );
|
||||
hb_itemRelease( p2 );
|
||||
}
|
||||
#endif
|
||||
QGraphicsScene::contextMenuEvent( event );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user