WindowAppBlockComment.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. #include "WindowAppBlockComment.h"
  2. #include "DialogEditComment.h"
  3. #include <QAbstractTextDocumentLayout>
  4. WindowAppBlockComment::WindowAppBlockComment(QGraphicsItem* parent)
  5. : QGraphicsTextItem(parent)
  6. , m_bSel(false)
  7. , m_strComment(COMM_DEFAULT_TEXT)
  8. , resizing(false)
  9. {
  10. // 初始化UI风格
  11. this->initStyle();
  12. // 设置注释控件的默认宽度
  13. blockRect.setRect(
  14. 0,
  15. 0,
  16. COMM_BASIC_WIDTH,
  17. COMM_BASIC_HEIGHT
  18. );
  19. // 更新矩形区域的尺寸
  20. this->updateRect();
  21. reDirection = ResizeNone;
  22. }
  23. WindowAppBlockComment::~WindowAppBlockComment()
  24. {
  25. }
  26. /// <summary>
  27. /// 初始化UI风格
  28. /// </summary>
  29. void WindowAppBlockComment::initStyle()
  30. {
  31. // 允许移动
  32. setFlag(QGraphicsItem::ItemIsMovable);
  33. // 允许选中
  34. setFlag(QGraphicsItem::ItemIsSelectable);
  35. // 允许发送尺寸变更通知
  36. setFlag(QGraphicsItem::ItemSendsGeometryChanges);
  37. // 设置字体
  38. this->setFont(FONT_COMM);
  39. // 设置文字颜色
  40. this->setDefaultTextColor(COLOR_COMM_TEXT);
  41. // 允许文字交互
  42. this->setTextInteractionFlags(Qt::TextEditorInteraction);
  43. // 置于最底层
  44. this->setZValue(1000.0);
  45. // 设置默认注释文本
  46. this->setPlainText(m_strComment);
  47. // 设置其他参数(左上角对齐,文字最大宽度等等)
  48. auto document = this->document();
  49. auto option = document->defaultTextOption();
  50. option.setAlignment(Qt::AlignLeft | Qt::AlignTop);
  51. document->setDefaultTextOption(option);
  52. //this->setTextWidth(110);
  53. // 绑定文本变更信号,自动调整边距
  54. connect(this->document(), SIGNAL(contentsChanged()), this, SLOT(onContentsChanged()));
  55. }
  56. ///// <summary>
  57. ///// 设置注释的文字
  58. ///// </summary>
  59. ///// <param name="strComm"></param>
  60. //void WindowAppBlockComment::setComment(const QString& strComm)
  61. //{
  62. // this->m_strComment = strComm;
  63. //}
  64. /// <summary>
  65. /// 绘制注释功能块
  66. /// </summary>
  67. /// <param name="painter"></param>
  68. /// <param name="option"></param>
  69. /// <param name="widget"></param>
  70. void WindowAppBlockComment::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
  71. {
  72. m_bSel = isSelected();
  73. painter->setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing);
  74. painter->save();
  75. // 绘制边框
  76. this->drawFrame(painter);
  77. paintSelected(painter, 1);
  78. //// 绘制文字
  79. //this->drawContent(painter);
  80. painter->restore();
  81. // 去掉黑色虚线框
  82. //QStyleOptionGraphicsItem op(*option);
  83. //op.state = QStyle::State_None;
  84. //QGraphicsTextItem::paint(painter, &op, widget);
  85. //// 编辑状态按原来的执行
  86. //if (hasFocus())
  87. //{
  88. // QItem::paint(painter, option, widget);
  89. //}
  90. //// 选中状态去掉虚线
  91. //else
  92. //{
  93. // // 原来什么属性就要什么属性,只不过去掉多余的选中状态
  94. // QStyleOptionGraphicsItem optionx(*option);
  95. // optionx.state &= ~QStyle::State_Selected;
  96. // QItem::paint(painter, &optionx, widget);
  97. //}
  98. QGraphicsTextItem::paint(painter, option, widget);
  99. }
  100. QVariant WindowAppBlockComment::itemChange(GraphicsItemChange change,
  101. const QVariant& value)
  102. {
  103. if (change == QGraphicsItem::ItemSelectedHasChanged)
  104. {
  105. emit selectedChange(this);
  106. }
  107. return value;
  108. }
  109. void WindowAppBlockComment::focusOutEvent(QFocusEvent* event)
  110. {
  111. setTextInteractionFlags(Qt::NoTextInteraction);
  112. emit lostFocus(this);
  113. QGraphicsTextItem::focusOutEvent(event);
  114. }
  115. /// <summary>
  116. /// 在文本内容变更时触发,自动更新边距
  117. /// </summary>
  118. void WindowAppBlockComment::onContentsChanged()
  119. {
  120. // 有内容变更时,更新一下外边界
  121. this->updateRect();
  122. this->update();
  123. }
  124. /// <summary>
  125. /// 响应双击事件,激活文本编辑模式
  126. /// </summary>
  127. /// <param name="event"></param>
  128. void WindowAppBlockComment::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
  129. {
  130. if (event->button() == Qt::LeftButton && textInteractionFlags() == Qt::NoTextInteraction)
  131. {
  132. setTextInteractionFlags(Qt::TextEditorInteraction);
  133. }
  134. QGraphicsTextItem::mouseDoubleClickEvent(event);
  135. }
  136. /// <summary>
  137. /// 绘制边框
  138. /// </summary>
  139. /// <param name="painter"></param>
  140. void WindowAppBlockComment::drawFrame(QPainter* painter)
  141. {
  142. //if (!m_bSel)
  143. //{
  144. // painter->setPen(QPen(COLOR_TBD_FRAME1, PEN_LINE_WIDTH));
  145. //}
  146. //else
  147. //{
  148. // painter->setPen(QPen(COLOR_TBD_FRAME1, PEN_LINE_WIDTH_SEL));
  149. //}
  150. // 设置画笔
  151. painter->setPen(QPen(COLOR_COMM_FRAME, PEN_WIDTH_FRAME));
  152. // 设置透明
  153. //painter->setBrush(Qt::transparent);
  154. // 绘制边框
  155. painter->drawRoundedRect(blockRect, 10, 10);
  156. }
  157. /// <summary>
  158. /// 更新矩形区域的尺寸
  159. /// </summary>
  160. void WindowAppBlockComment::updateRect()
  161. {
  162. m_strComment = this->toPlainText();
  163. // Reason:由于将 boundingRect 强制设定成了和 blockRect 一样的大小(方便做拉伸),
  164. // 所以在有文字内容变动的时候,需要手动扩大一下矩形区域
  165. QRectF textRect = QFontMetrics(FONT_COMM).boundingRect(m_strComment);
  166. float xFix = textRect.width() - blockRect.width();
  167. float yFix = textRect.height() - blockRect.width();
  168. if (xFix > 0.0)
  169. {
  170. blockRect.setRight(blockRect.right() + xFix);
  171. }
  172. if (yFix > 0.0)
  173. {
  174. blockRect.setBottom(blockRect.bottom() + yFix);
  175. }
  176. //blockBoundingRect = boundingRect();
  177. //if (blockBoundingRect.width() > blockRect.width())
  178. //{
  179. // blockRect.setWidth(blockBoundingRect.width());
  180. // // 然后微调一下外边框,方便拖放操作
  181. // blockRect.adjust(0, 0, 2, 0);
  182. //}
  183. //if (blockBoundingRect.height() > blockRect.height())
  184. //{
  185. // blockRect.setHeight(blockBoundingRect.height());
  186. // // 然后微调一下外边框,方便拖放操作
  187. // blockRect.adjust(0, 0, 0, 2);
  188. //}
  189. }
  190. //void WindowAppBlockComment::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
  191. //{
  192. // update();
  193. // QGraphicsObject::hoverEnterEvent(event);
  194. //}
  195. //
  196. //
  197. //void WindowAppBlockComment::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
  198. //{
  199. // setCursor(QCursor(Qt::ArrowCursor));
  200. // scene()->update(sceneBoundingRect());
  201. // update();
  202. // QGraphicsObject::hoverLeaveEvent(event);
  203. //}
  204. void WindowAppBlockComment::hoverMoveEvent(QGraphicsSceneHoverEvent* event)
  205. {
  206. if (this->isSelected())
  207. {
  208. QPointF mousePoint = event->pos();
  209. QPointF mouseHandler = QPointF(5, 5);
  210. QPointF topLeft = blockRect.topLeft();
  211. QPointF topRight = blockRect.topRight();
  212. QPointF bottomLeft = blockRect.bottomLeft();
  213. QPointF bottomRight = blockRect.bottomRight();
  214. // resize top
  215. if (mousePoint.x() >= (topLeft.x() + mouseHandler.x()) &&
  216. mousePoint.x() <= (topRight.x() - mouseHandler.x()) &&
  217. mousePoint.y() >= (topLeft.y() - mouseHandler.y()) &&
  218. mousePoint.y() <= (topLeft.y() + mouseHandler.y())) {
  219. setCursor(Qt::SizeVerCursor);
  220. }
  221. // resize bottom
  222. else if (mousePoint.x() >= (bottomLeft.x() + mouseHandler.x()) &&
  223. mousePoint.x() <= (bottomRight.x() - mouseHandler.x()) &&
  224. mousePoint.y() >= (bottomLeft.y() - mouseHandler.y()) &&
  225. mousePoint.y() <= (bottomLeft.y() + mouseHandler.y())) {
  226. setCursor(Qt::SizeVerCursor);
  227. }
  228. // resize left
  229. else if (mousePoint.x() >= (topLeft.x() - mouseHandler.x()) &&
  230. mousePoint.x() <= (topLeft.x() + mouseHandler.x()) &&
  231. mousePoint.y() >= (topLeft.y() + mouseHandler.y()) &&
  232. mousePoint.y() <= (bottomLeft.y() - mouseHandler.y())) {
  233. setCursor(Qt::SizeHorCursor);
  234. }
  235. // resize right
  236. else if (mousePoint.x() >= (topRight.x() - mouseHandler.x()) &&
  237. mousePoint.x() <= (topRight.x() + mouseHandler.x()) &&
  238. mousePoint.y() >= (topRight.y() + mouseHandler.y()) &&
  239. mousePoint.y() <= (bottomRight.y() - mouseHandler.y())) {
  240. setCursor(Qt::SizeHorCursor);
  241. }
  242. // resize top left
  243. else if (mousePoint.x() <= (topLeft.x() + mouseHandler.x()) &&
  244. mousePoint.x() >= (topLeft.x() - mouseHandler.x()) &&
  245. mousePoint.y() <= (topLeft.y() + mouseHandler.y()) &&
  246. mousePoint.y() >= (topLeft.y() - mouseHandler.y())) {
  247. setCursor(Qt::SizeFDiagCursor);
  248. }
  249. // resize bottom right
  250. else if (mousePoint.x() <= (bottomRight.x() + mouseHandler.x()) &&
  251. mousePoint.x() >= (bottomRight.x() - mouseHandler.x()) &&
  252. mousePoint.y() <= (bottomRight.y() + mouseHandler.y()) &&
  253. mousePoint.y() >= (bottomRight.y() - mouseHandler.y())) {
  254. setCursor(Qt::SizeFDiagCursor);
  255. }
  256. // resize bottom left
  257. else if (mousePoint.x() <= (bottomLeft.x() + mouseHandler.x()) &&
  258. mousePoint.x() >= (bottomLeft.x() - mouseHandler.x()) &&
  259. mousePoint.y() >= (bottomLeft.y() - mouseHandler.y()) &&
  260. mousePoint.y() <= (bottomLeft.y() + mouseHandler.y())) {
  261. setCursor(Qt::SizeBDiagCursor);
  262. }
  263. // resize top right
  264. else if (mousePoint.x() <= (topRight.x() + mouseHandler.x()) &&
  265. mousePoint.x() >= (topRight.x() - mouseHandler.x()) &&
  266. mousePoint.y() >= (topRight.y() - mouseHandler.y()) &&
  267. mousePoint.y() <= (topRight.y() + mouseHandler.y())) {
  268. setCursor(Qt::SizeBDiagCursor);
  269. }
  270. else {
  271. setCursor(Qt::ArrowCursor);
  272. }
  273. }
  274. QGraphicsObject::hoverMoveEvent(event);
  275. }
  276. void WindowAppBlockComment::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
  277. {
  278. //if (!isSelected())
  279. //{
  280. // return;
  281. //}
  282. QPointF mousePoint = event->pos();
  283. if (resizing)
  284. {
  285. QTextDocument* doc = this->document();
  286. QAbstractTextDocumentLayout* layout = doc->documentLayout();
  287. //int pixelsWidth = layout->documentSize().width();
  288. //int pixelsHeight = layout->documentSize().height();
  289. //qDebug() << "layout: " << pixelsWidth << "," << pixelsHeight;
  290. if (reDirection & ResizeLeft)
  291. {
  292. blockRect.setLeft(mousePoint.x());
  293. //setElementXPos(static_cast<int>(mapToScene(blockRect.topLeft()).x()));
  294. //setElementWidth(static_cast<int>(qAbs(mapToScene(blockRect.topLeft()).x() - mapToScene(blockRect.topRight()).x())));
  295. // document->setDocumentLayout()
  296. //QSizeF size(200, 200);
  297. //doc->setPageSize(size);
  298. }
  299. if (reDirection & ResizeRight)
  300. {
  301. blockRect.setRight(mousePoint.x());
  302. //setElementWidth(static_cast<int>(qAbs(mapToScene(blockRect.topLeft()).x() - mapToScene(blockRect.topRight()).x())));
  303. }
  304. if (reDirection & ResizeTop)
  305. {
  306. blockRect.setTop(mousePoint.y());
  307. //setElementYPos(static_cast<int>(mapToScene(blockRect.topLeft()).y()));
  308. //setElementHeight(static_cast<int>(qAbs(mapToScene(blockRect.topLeft()).y() - mapToScene(blockRect.bottomLeft()).y())));
  309. }
  310. if (reDirection & ResizeBottom)
  311. {
  312. blockRect.setBottom(mousePoint.y());
  313. // setElementHeight(static_cast<int>(qAbs(blockRect.topLeft().y() - blockRect.bottomLeft().y())));
  314. }
  315. scene()->update();
  316. return;
  317. }
  318. QGraphicsItem::mouseMoveEvent(event);
  319. }
  320. void WindowAppBlockComment::mousePressEvent(QGraphicsSceneMouseEvent* event)
  321. {
  322. QPointF mousePoint = event->pos();
  323. QPointF mouseHandler = QPointF(5, 5);
  324. QPointF topLeft = blockRect.topLeft();
  325. QPointF topRight = blockRect.topRight();
  326. QPointF bottomLeft = blockRect.bottomLeft();
  327. QPointF bottomRight = blockRect.bottomRight();
  328. reDirection = ResizeNone;
  329. resizing = false;
  330. // resize top
  331. if (mousePoint.x() >= (topLeft.x() + 0) &&
  332. mousePoint.x() <= (topRight.x() - 0) &&
  333. mousePoint.y() >= (topLeft.y() - mouseHandler.y()) &&
  334. mousePoint.y() <= (topLeft.y() + mouseHandler.y())) {
  335. reDirection |= ResizeTop;
  336. resizing = true;
  337. }
  338. // resize bottom
  339. if (mousePoint.x() >= (bottomLeft.x() + 0) &&
  340. mousePoint.x() <= (bottomRight.x() - 0) &&
  341. mousePoint.y() >= (bottomLeft.y() - mouseHandler.y()) &&
  342. mousePoint.y() <= (bottomLeft.y() + mouseHandler.y())) {
  343. reDirection |= ResizeBottom;
  344. resizing = true;
  345. }
  346. // resize left
  347. if (mousePoint.x() >= (topLeft.x() - mouseHandler.x()) &&
  348. mousePoint.x() <= (topLeft.x() + mouseHandler.x()) &&
  349. mousePoint.y() >= (topLeft.y() + 0) &&
  350. mousePoint.y() <= (bottomLeft.y() - 0)) {
  351. reDirection |= ResizeLeft;
  352. resizing = true;
  353. }
  354. // resize right
  355. if (mousePoint.x() >= (topRight.x() - mouseHandler.x()) &&
  356. mousePoint.x() <= (topRight.x() + mouseHandler.x()) &&
  357. mousePoint.y() >= (topRight.y() + 0) &&
  358. mousePoint.y() <= (bottomRight.y() - 0)) {
  359. reDirection |= ResizeRight;
  360. resizing = true;
  361. }
  362. switch (reDirection)
  363. {
  364. case ResizeRight:
  365. case ResizeLeft:
  366. setCursor(Qt::SizeHorCursor);
  367. break;
  368. case ResizeBottom:
  369. case ResizeTop:
  370. setCursor(Qt::SizeVerCursor);
  371. break;
  372. case ResizeRight | ResizeBottom:
  373. case ResizeLeft | ResizeTop:
  374. setCursor(Qt::SizeFDiagCursor);
  375. break;
  376. case ResizeLeft | ResizeBottom:
  377. case ResizeRight | ResizeTop:
  378. setCursor(Qt::SizeBDiagCursor);
  379. break;
  380. default:
  381. setCursor(Qt::ArrowCursor);
  382. break;
  383. }
  384. oldPos = pos();
  385. oldWidth = blockRect.width();
  386. oldHeight = blockRect.height();
  387. QGraphicsObject::mousePressEvent(event);
  388. }
  389. void WindowAppBlockComment::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
  390. {
  391. setCursor(Qt::ArrowCursor);
  392. //elementXPos = static_cast<int>(pos().x());
  393. //elementYPos = static_cast<int>(pos().y());
  394. //updatePropertyModel();
  395. //if (oldPos != pos())
  396. //{
  397. // emit elementMoved(oldPos);
  398. //}
  399. //if (resizing)
  400. //{
  401. // emit elementResized(oldWidth, oldHeight, oldPos);
  402. //}
  403. resizing = false;
  404. reDirection = ResizeNone;
  405. QGraphicsObject::mouseReleaseEvent(event);
  406. }
  407. /**
  408. * @brief Element::paintSelected
  409. * @details 绘制选中状态
  410. * @param painter
  411. * @param iLineWidth 线宽
  412. */
  413. void WindowAppBlockComment::paintSelected(QPainter* painter, int iLineWidth)
  414. {
  415. if (isSelected())
  416. {
  417. painter->save();
  418. painter->setBrush(Qt::NoBrush);
  419. //QPen pen(Qt::green, iLineWidth, Qt::DashLine);
  420. //painter->setPen(pen);
  421. QRectF rect = blockRect.adjusted(-1, -1, 1, 1);
  422. // painter->drawRect(rect);
  423. QPen pen2(Qt::green, iLineWidth, Qt::SolidLine);
  424. painter->setPen(pen2);
  425. QPointF pt = QPointF(3, 3);
  426. painter->drawRect(QRectF(rect.topLeft() - pt, rect.topLeft() + pt));
  427. QPointF ptMid = QPointF(rect.left() + rect.width() / 2, rect.top());
  428. painter->drawRect(QRectF(ptMid - pt, ptMid + pt));
  429. painter->drawRect(QRectF(rect.topRight() - pt, rect.topRight() + pt));
  430. ptMid = QPointF(rect.left(), rect.top() + rect.height() / 2);
  431. painter->drawRect(QRectF(ptMid - pt, ptMid + pt));
  432. ptMid = QPointF(rect.right(), rect.top() + rect.height() / 2);
  433. painter->drawRect(QRectF(ptMid - pt, ptMid + pt));
  434. painter->drawRect(QRectF(rect.bottomLeft() - pt, rect.bottomLeft() + pt));
  435. ptMid = QPointF(rect.left() + rect.width() / 2, rect.bottom());
  436. painter->drawRect(QRectF(ptMid - pt, ptMid + pt));
  437. painter->drawRect(QRectF(rect.bottomRight() - pt, rect.bottomRight() + pt));
  438. painter->restore();
  439. }
  440. }
  441. /// <summary>
  442. /// 计算区域边界
  443. /// </summary>
  444. /// <returns></returns>
  445. QRectF WindowAppBlockComment::boundingRect() const
  446. {
  447. return blockRect;
  448. }
  449. /// <summary>
  450. /// 重写Shape函数,使其没有文字的空白部分也可以响应消息
  451. /// </summary>
  452. /// <returns></returns>
  453. QPainterPath WindowAppBlockComment::shape() const
  454. {
  455. QPainterPath path;
  456. path.addRect(blockRect);
  457. return path;
  458. }
  459. //
  460. //
  461. ///// <summary>
  462. ///// 刷新全部(包括文字和尺寸)
  463. ///// </summary>
  464. //void WindowAppBlockComment::updateAll()
  465. //{
  466. //
  467. //}
  468. //====================================================
  469. //
  470. // Del
  471. //
  472. //====================================================
  473. ///// <summary>
  474. ///// 键盘按下时(回车键结束编辑)
  475. ///// </summary>
  476. ///// <param name="event"></param>
  477. //void WindowAppBlockComment::keyPressEvent(QKeyEvent* event)
  478. //{
  479. // // 点击回车失去焦点,编辑完成,后续给FocusOutEvent处理
  480. // if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
  481. // {
  482. // clearFocus();
  483. //
  484. // return;
  485. // }
  486. //
  487. // QGraphicsTextItem::keyPressEvent(event);
  488. //}
  489. ///// <summary>
  490. ///// 返回边界矩形区域
  491. ///// </summary>
  492. ///// <returns></returns>
  493. //QRectF WindowAppBlockComment::boundingRect() const
  494. //{
  495. // return blockBoundingRect;
  496. //}
  497. ///// <summary>
  498. ///// 响应双击事件,弹出编辑注释文字对话框
  499. ///// </summary>
  500. ///// <param name="event"></param>
  501. //void WindowAppBlockComment::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
  502. //{
  503. // // 只有鼠标左键才响应
  504. // if (event->button() == Qt::LeftButton)
  505. // {
  506. // DialogEditComment dialogComm(m_strComment);
  507. //
  508. // if (dialogComm.exec() == QDialog::Accepted)
  509. // {
  510. // this->m_strComment = dialogComm.m_strComment;
  511. //
  512. // // 刷新整个界面
  513. // this->updateAll();
  514. // }
  515. // }
  516. //}
  517. ///// <summary>
  518. ///// 绘制文字(文字左上角对齐)
  519. ///// </summary>
  520. ///// <param name="painter"></param>
  521. //void WindowAppBlockComment::drawContent(QPainter* painter)
  522. //{
  523. // // 设置画笔
  524. // painter->setPen(QPen(COLOR_COMM_FRAME, PEN_WIDTH_FRAME));
  525. //
  526. // // 绘制文字
  527. // painter->setFont(FONT_COMM);
  528. // QRectF textRect = QFontMetrics(FONT_COMM).boundingRect(m_strComment);
  529. // int textX = blockRect.left() + COMM_SIDE_SPACING;
  530. // int textY = blockRect.top() + COMM_SIDE_SPACING + textRect.height() / 2;
  531. // painter->drawText(textX, textY, m_strComment);
  532. //}
  533. //void WindowAppBlockComment::keyReleaseEvent(QKeyEvent* event)
  534. //{
  535. // // 编译完毕后,更新一下外边界
  536. // this->updateRect();
  537. // this->update();
  538. //
  539. // QGraphicsTextItem::keyReleaseEvent(event);
  540. //}