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