@ -31,16 +31,17 @@
QColor UBGraphicsTextItem : : lastUsedTextColor ;
UBGraphicsTextItem : : UBGraphicsTextItem ( QGraphicsItem * parent )
: QGraphicsTextItem ( parent )
: UBGraphicsItem ( )
, QGraphicsTextItem ( parent )
, mMultiClickState ( 0 )
, mLastMousePressTime ( QTime : : currentTime ( ) )
{
mDelegate = new UBGraphicsTextItemDelegate ( this , 0 ) ;
m Delegate- > init ( ) ;
setDelegate ( new UBGraphicsTextItemDelegate ( this , 0 ) ) ;
Delegate ( ) - > init ( ) ;
m Delegate- > frame ( ) - > setOperationMode ( UBGraphicsDelegateFrame : : Resizing ) ;
m Delegate- > setFlippable ( false ) ;
m Delegate- > setRotatable ( true ) ;
Delegate ( ) - > frame ( ) - > setOperationMode ( UBGraphicsDelegateFrame : : Resizing ) ;
Delegate ( ) - > setFlippable ( false ) ;
Delegate ( ) - > setRotatable ( true ) ;
mTypeTextHereLabel = tr ( " <Type Text Here> " ) ;
@ -58,7 +59,7 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
setUuid ( QUuid : : createUuid ( ) ) ;
connect ( document ( ) , SIGNAL ( contentsChanged ( ) ) , m Delegate, SLOT ( contentsChanged ( ) ) ) ;
connect ( document ( ) , SIGNAL ( contentsChanged ( ) ) , Delegate ( ) , SLOT ( contentsChanged ( ) ) ) ;
connect ( document ( ) , SIGNAL ( undoCommandAdded ( ) ) , this , SLOT ( undoCommandAdded ( ) ) ) ;
connect ( document ( ) - > documentLayout ( ) , SIGNAL ( documentSizeChanged ( const QSizeF & ) ) ,
@ -68,18 +69,14 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
UBGraphicsTextItem : : ~ UBGraphicsTextItem ( )
{
if ( mDelegate )
{
delete mDelegate ;
}
}
QVariant UBGraphicsTextItem : : itemChange ( GraphicsItemChange change , const QVariant & value )
{
QVariant newValue = value ;
if ( m Delegate)
newValue = m Delegate- > itemChange ( change , value ) ;
if ( Delegate ( ) )
newValue = Delegate ( ) - > itemChange ( change , value ) ;
return QGraphicsTextItem : : itemChange ( change , newValue ) ;
}
@ -95,10 +92,10 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
return ;
}
if ( m Delegate)
if ( Delegate ( ) )
{
m Delegate- > mousePressEvent ( event ) ;
if ( m Delegate & & parentItem ( ) & & UBGraphicsGroupContainerItem : : Type = = parentItem ( ) - > type ( ) )
Delegate ( ) - > mousePressEvent ( event ) ;
if ( Delegate ( ) & & parentItem ( ) & & UBGraphicsGroupContainerItem : : Type = = parentItem ( ) - > type ( ) )
{
UBGraphicsGroupContainerItem * group = qgraphicsitem_cast < UBGraphicsGroupContainerItem * > ( parentItem ( ) ) ;
if ( group )
@ -110,13 +107,13 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
group - > setCurrentItem ( this ) ;
this - > setSelected ( true ) ;
m Delegate- > positionHandles ( ) ;
Delegate ( ) - > positionHandles ( ) ;
}
}
else
{
m Delegate- > getToolBarItem ( ) - > show ( ) ;
Delegate ( ) - > getToolBarItem ( ) - > show ( ) ;
}
}
@ -165,7 +162,7 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsTextItem : : mouseMoveEvent ( QGraphicsSceneMouseEvent * event )
{
if ( ! m Delegate | | ! m Delegate- > mouseMoveEvent ( event ) )
if ( ! Delegate ( ) | | ! Delegate ( ) - > mouseMoveEvent ( event ) )
{
QGraphicsTextItem : : mouseMoveEvent ( event ) ;
}
@ -184,8 +181,8 @@ void UBGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if ( mMultiClickState = = 1 )
{
if ( m Delegate)
m Delegate- > mouseReleaseEvent ( event ) ;
if ( Delegate ( ) )
Delegate ( ) - > mouseReleaseEvent ( event ) ;
QGraphicsTextItem : : mouseReleaseEvent ( event ) ;
}
@ -324,8 +321,8 @@ void UBGraphicsTextItem::resize(qreal w, qreal h)
setTextWidth ( w ) ;
setTextHeight ( h ) ;
if ( m Delegate)
m Delegate- > positionHandles ( ) ;
if ( Delegate ( ) )
Delegate ( ) - > positionHandles ( ) ;
}
@ -347,12 +344,6 @@ void UBGraphicsTextItem::undoCommandAdded()
}
void UBGraphicsTextItem : : remove ( )
{
if ( mDelegate )
mDelegate - > remove ( true ) ;
}
void UBGraphicsTextItem : : documentSizeChanged ( const QSizeF & newSize )
{
resize ( newSize . width ( ) , newSize . height ( ) ) ;