|
@@ -3,6 +3,7 @@
|
|
|
#include <QKeyEvent>
|
|
|
#include <QGraphicsSceneMouseEvent>
|
|
|
#include <QTextDocument>
|
|
|
+#include <QPainter>
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
@@ -46,6 +47,7 @@ void CTextItem::beginEditing()
|
|
|
void CTextItem::endEditing()
|
|
|
{
|
|
|
setTextInteractionFlags(Qt::NoTextInteraction);
|
|
|
+
|
|
|
setSelected(false);
|
|
|
clearFocus();
|
|
|
|
|
@@ -53,6 +55,9 @@ void CTextItem::endEditing()
|
|
|
emit sigTextChanged();
|
|
|
m_textChanged = false;
|
|
|
}
|
|
|
+
|
|
|
+ // 没找到取消文字选中状态的方法, 暂且用这个吧, 这回触发数据库保存操作
|
|
|
+ setPlainText(toPlainText());
|
|
|
}
|
|
|
|
|
|
bool CTextItem::isEditing() const
|
|
@@ -86,6 +91,11 @@ QSizeF CTextItem::textSize(const QString t, qreal width)
|
|
|
return i->document()->size();
|
|
|
}
|
|
|
|
|
|
+void CTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
|
+{
|
|
|
+ QGraphicsTextItem::paint(painter, option, widget);
|
|
|
+}
|
|
|
+
|
|
|
void CTextItem::slotTextChanged()
|
|
|
{
|
|
|
m_textChanged = true;
|