|
|
|
@ -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); |
|
|
|
|
mDelegate->init(); |
|
|
|
|
setDelegate(new UBGraphicsTextItemDelegate(this, 0)); |
|
|
|
|
Delegate()->init(); |
|
|
|
|
|
|
|
|
|
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing); |
|
|
|
|
mDelegate->setFlippable(false); |
|
|
|
|
mDelegate->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()), mDelegate, 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(mDelegate) |
|
|
|
|
newValue = mDelegate->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 (mDelegate) |
|
|
|
|
if (Delegate()) |
|
|
|
|
{ |
|
|
|
|
mDelegate->mousePressEvent(event); |
|
|
|
|
if (mDelegate && 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); |
|
|
|
|
mDelegate->positionHandles(); |
|
|
|
|
Delegate()->positionHandles(); |
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
mDelegate->getToolBarItem()->show(); |
|
|
|
|
Delegate()->getToolBarItem()->show(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -165,7 +162,7 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
|
|
|
|
|
|
void UBGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
|
{ |
|
|
|
|
if (!mDelegate || !mDelegate->mouseMoveEvent(event)) |
|
|
|
|
if (!Delegate() || !Delegate()->mouseMoveEvent(event)) |
|
|
|
|
{ |
|
|
|
|
QGraphicsTextItem::mouseMoveEvent(event); |
|
|
|
|
} |
|
|
|
@ -184,8 +181,8 @@ void UBGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
|
|
|
|
|
|
if (mMultiClickState == 1) |
|
|
|
|
{ |
|
|
|
|
if (mDelegate) |
|
|
|
|
mDelegate->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 (mDelegate) |
|
|
|
|
mDelegate->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()); |
|
|
|
|