//=======================================================================
GraphicsView_ViewPort::GraphicsView_ViewPort( QWidget* theParent )
: QGraphicsView( theParent ),
+ myNameLabel( 0 ),
myForegroundItem( 0 ),
myIsTransforming( false ),
myHighlightedObject( 0 ),
myScene = new GraphicsView_Scene( this );
setScene( myScene );
- // view name
- myNameLabel = new NameLabel( viewport() );
- myNameLabel->setVisible( false );
-
- QBoxLayout* aLayout = new QVBoxLayout( viewport() );
- aLayout->addStretch();
- aLayout->addWidget( myNameLabel );
-
// background
setBackgroundBrush( QBrush( Qt::white ) );
}
//================================================================
-// Function : setViewName
+// Function : setViewNameEnabled
// Purpose :
//================================================================
-void GraphicsView_ViewPort::setViewName( const QString& theName )
+void GraphicsView_ViewPort::setViewNameEnabled( bool theState,
+ bool theIsForced )
{
- myNameLabel->setText( theName );
+ if( theIsForced && !myNameLabel )
+ {
+ myNameLabel = new NameLabel( viewport() );
+
+ QBoxLayout* aLayout = new QVBoxLayout( viewport() );
+ aLayout->setMargin( 10 );
+ aLayout->setSpacing( 0 );
+ aLayout->addStretch();
+ aLayout->addWidget( myNameLabel );
+ }
+
+ if( myNameLabel )
+ myNameLabel->setVisible( theState );
}
//================================================================
-// Function : setViewNameEnabled
+// Function : setViewName
// Purpose :
//================================================================
-void GraphicsView_ViewPort::setViewNameEnabled( bool theState )
+void GraphicsView_ViewPort::setViewName( const QString& theName )
{
- myNameLabel->setVisible( theState );
+ if( myNameLabel )
+ myNameLabel->setText( theName );
}
//================================================================
{
myIsTransforming = true;
- myNameLabel->setAcceptMoveEvents( false );
+ if( myNameLabel )
+ myNameLabel->setAcceptMoveEvents( false );
if( QScrollBar* aHBar = horizontalScrollBar() )
aHBar->setValue( aHBar->value() - theDX );
if( QScrollBar* aVBar = verticalScrollBar() )
aVBar->setValue( aVBar->value() + theDY );
- myNameLabel->setAcceptMoveEvents( true );
+ if( myNameLabel )
+ myNameLabel->setAcceptMoveEvents( true );
myIsTransforming = false;
}