From 9a5cc5b8d2129f0f54846fdc65baec744f0797a4 Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Mon, 20 Aug 2012 13:32:52 +0300 Subject: [PATCH] SANKORE-909 Write text : Select the text --- src/domain/UBGraphicsTextItemDelegate.cpp | 17 +++++++++++++++++ src/domain/UBGraphicsTextItemDelegate.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/domain/UBGraphicsTextItemDelegate.cpp b/src/domain/UBGraphicsTextItemDelegate.cpp index 3ab8f973..03efa958 100644 --- a/src/domain/UBGraphicsTextItemDelegate.cpp +++ b/src/domain/UBGraphicsTextItemDelegate.cpp @@ -403,3 +403,20 @@ void UBGraphicsTextItemDelegate::scaleTextSize(qreal multiplyer) { ChangeTextSize(multiplyer, scaleSize); } + +QVariant UBGraphicsTextItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) +{ + if (change == QGraphicsItem::ItemSelectedChange) + { + if (delegated()->isSelected()) + { + QTextCursor c = delegated()->textCursor(); + if (c.hasSelection()) + { + c.clearSelection(); + delegated()->setTextCursor(c); + } + } + } + return UBGraphicsItemDelegate::itemChange(change, value); +} \ No newline at end of file diff --git a/src/domain/UBGraphicsTextItemDelegate.h b/src/domain/UBGraphicsTextItemDelegate.h index b01df4e2..26b3ba9b 100644 --- a/src/domain/UBGraphicsTextItemDelegate.h +++ b/src/domain/UBGraphicsTextItemDelegate.h @@ -40,6 +40,8 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate virtual ~UBGraphicsTextItemDelegate(); bool isEditable(); void scaleTextSize(qreal multiplyer); + virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value); + public slots: void contentsChanged();