123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758 |
- #include "WindowAppBlockComment.h"
- #include "DialogEditComment.h"
- #include "Pou.h"
- #include "WindowAppPouScene.h"
- #include "VPCommand.h"
- WindowAppBlockComment::WindowAppBlockComment(
- TOOL* pNewTool,
- POU* Pou,
- bool bShowOnly,
- QGraphicsObject* parent
- )
- : WindowAppBlockBase(pNewTool, Pou, bShowOnly, parent)
- , isResizing(false)
- {
- // 设置默认的注释文字
- if (this->m_toolInfo->strComment.isEmpty())
- {
- this->m_toolInfo->strComment = COMM_DEFAULT_TEXT;
- }
-
- // 初始化UI风格
- this->initStyle();
- // 设置注释控件的默认宽度
- blockRect.setRect(
- 0,
- 0,
- COMM_BASIC_WIDTH,
- COMM_BASIC_HEIGHT
- );
- // 更新矩形区域的尺寸
- this->updateRect();
- reDirection = ResizeNone;
- // 2022-10-3,初始化右键菜单
- createContextMenu();
- }
- WindowAppBlockComment::~WindowAppBlockComment()
- {
- }
- /// <summary>
- /// 初始化UI风格
- /// </summary>
- void WindowAppBlockComment::initStyle()
- {
- // 允许移动
- setFlag(QGraphicsItem::ItemIsMovable);
- // 允许选中
- setFlag(QGraphicsItem::ItemIsSelectable);
- // 允许获得焦点
- setFlag(QGraphicsItem::ItemIsFocusable);
- // 允许发送尺寸变更通知
- setFlag(QGraphicsItem::ItemSendsGeometryChanges);
- // 响应鼠标悬停事件(重要,否则QGraphicsItem默认是不响应鼠标悬停事件的)
- this->setAcceptHoverEvents(true);
- }
- /// <summary>
- /// 绘制注释功能块
- /// </summary>
- /// <param name="painter"></param>
- /// <param name="option"></param>
- /// <param name="widget"></param>
- void WindowAppBlockComment::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
- {
- Q_UNUSED(option);
- Q_UNUSED(widget);
- painter->setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing);
- painter->save();
- // 绘制边框
- this->drawFrame(painter);
- // 绘制文字
- this->drawContent(painter);
- painter->restore();
- }
- ////////////////////////////////////////////////////////////////
- // 初始化功能块的右键菜单
- void WindowAppBlockComment::createContextMenu()
- {
- WindowAppBlockBase::createContextMenu();
- connect(deleteAction, &QAction::triggered, this, &WindowAppBlockComment::onMenuDelete);
- contextMenu = new QMenu();
- contextMenu->addAction(deleteAction);
- }
- /// <summary>
- /// 绘制边框
- /// </summary>
- /// <param name="painter"></param>
- void WindowAppBlockComment::drawFrame(QPainter* painter)
- {
- // 设置画笔
- if (!this->isSelected())
- {
- painter->setPen(QPen(COLOR_FRAME_COMM, PEN_WIDTH_FRAME));
- }
- else
- {
- painter->setPen(QPen(COLOR_FRAME_COMM, PEN_WIDTH_FRAME_BOLD));
- }
- // 绘制边框
- painter->drawRoundedRect(blockRect, 0, 0);
- //// 设置画笔
- //painter->setPen(QPen(COLOR_COMM_FRAME, PEN_WIDTH_FRAME));
- // 设置透明
- //painter->setBrush(Qt::transparent);
- }
- /// <summary>
- /// 刷新全部(包括文字和尺寸)
- /// </summary>
- void WindowAppBlockComment::updateAll()
- {
- // 更新矩形区域的尺寸
- this->updateRect();
- // 刷新界面
- this->update();
- }
- /// <summary>
- /// 更新矩形区域的尺寸
- /// </summary>
- void WindowAppBlockComment::updateRect()
- {
- // 根据文字内容计算实际的文字矩形区域(包括换行)
- QRectF textRect = QFontMetrics(FONT_COMM).boundingRect(QRect(), Qt::TextWordWrap, m_toolInfo->strComment);
- // 根据文字矩形区域调整外边框
- double xFix = textRect.width() - blockRect.width();
- double yFix = textRect.height() - blockRect.height();
- blockRect.setRight(blockRect.right() + xFix + COMM_SIDE_X_SPACING * 2.0);
- blockRect.setBottom(blockRect.bottom() + yFix - COMM_SIDE_Y_SPACING * 2.0);
- // 如果调整完后的区域小于最小区域,则调成到最小区域
- if (blockRect.width() < COMM_BASIC_WIDTH)
- {
- blockRect.setRight(blockRect.left() + COMM_BASIC_WIDTH);
- }
- if (blockRect.height() < COMM_BASIC_HEIGHT)
- {
- blockRect.setBottom(blockRect.top() + COMM_BASIC_HEIGHT);
- }
- }
- /// <summary>
- /// 响应双击事件,弹出编辑内容对话框
- /// </summary>
- /// <param name="event"></param>
- void WindowAppBlockComment::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
- {
- // 只有鼠标左键才响应
- if (event->button() == Qt::LeftButton)
- {
- DialogEditComment dialogComm(m_toolInfo->strComment);
- // 接收用户输入的注释内容
- if (dialogComm.exec() == QDialog::Accepted)
- {
- this->m_toolInfo->strComment = dialogComm.m_strComment;
- // 如果用户输入了空的注释内容,直接删除本注释控件
- if (this->m_toolInfo->strComment.isEmpty())
- {
- qDebug() << "WindowAppBlockComment::mouseDoubleClickEvent - m_strComment is empty, delete myslef.";
- // 向scene发送通知
- emit this->emptyContent(this);
- }
- // 刷新整个界面
- this->updateAll();
- }
- }
- }
- /// <summary>
- /// 绘制文字(文字左上角对齐)
- /// </summary>
- /// <param name="painter"></param>
- void WindowAppBlockComment::drawContent(QPainter* painter)
- {
- // 设置画笔
- painter->setPen(QPen(COLOR_FRAME_COMM, PEN_WIDTH_FRAME));
- // 绘制文字
- painter->setFont(FONT_COMM);
- // 文字区域比当前四边略微缩小一点
- QRectF textRect = blockRect.adjusted(
- COMM_SIDE_X_SPACING,
- COMM_SIDE_Y_SPACING,
- - COMM_SIDE_Y_SPACING,
- - COMM_SIDE_Y_SPACING
- );
- //QTextOption toption(Qt::AlignLeft | Qt::AlignTop);
- //toption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
- painter->drawText(textRect, Qt::TextWordWrap, m_toolInfo->strComment);
- }
- /// <summary>
- /// 计算区域边界
- /// </summary>
- /// <returns></returns>
- QRectF WindowAppBlockComment::boundingRect() const
- {
- return blockRect;
- }
- /// <summary>
- /// 菜单 - Delete
- /// </summary>
- void WindowAppBlockComment::onMenuDelete()
- {
- //// 由Scene统一删除
- //m_pPou->parentScene()->delToolItem(this);
- // 生成删除指令,调用Undo体系进行删除
- PouToolDelCommand* toolDelCommand = new PouToolDelCommand(
- (WindowAppPouScene*)this->scene(),
- this->m_toolInfo,
- this->scenePos()
- );
- ((WindowAppPouScene*)scene())->m_CommandManager.executeCommand(toolDelCommand);
- }
- //======================================================================
- //
- // 注释控件缩放相关代码
- //
- //======================================================================
- /// <summary>
- /// 鼠标悬浮事件(用于显示拉伸用的鼠标)
- /// </summary>
- /// <param name="event"></param>
- void WindowAppBlockComment::hoverMoveEvent(QGraphicsSceneHoverEvent* event)
- {
- // qDebug() << "WindowAppBlockComment::hoverMoveEvent";
- // 如果控件处于选中状态,则根据鼠标位置显示拉伸鼠标
- if (this->isSelected())
- {
- QPointF mousePoint = event->pos();
- QPointF mouseHandler = QPointF(10, 10);
- QPointF topLeft = blockRect.topLeft();
- QPointF topRight = blockRect.topRight();
- QPointF bottomLeft = blockRect.bottomLeft();
- QPointF bottomRight = blockRect.bottomRight();
- // resize top
- if (mousePoint.x() >= (topLeft.x() + mouseHandler.x()) &&
- mousePoint.x() <= (topRight.x() - mouseHandler.x()) &&
- mousePoint.y() >= (topLeft.y() - mouseHandler.y()) &&
- mousePoint.y() <= (topLeft.y() + mouseHandler.y()))
- {
- setCursor(Qt::SizeVerCursor);
- }
- // resize bottom
- else if (mousePoint.x() >= (bottomLeft.x() + mouseHandler.x()) &&
- mousePoint.x() <= (bottomRight.x() - mouseHandler.x()) &&
- mousePoint.y() >= (bottomLeft.y() - mouseHandler.y()) &&
- mousePoint.y() <= (bottomLeft.y() + mouseHandler.y()))
- {
- setCursor(Qt::SizeVerCursor);
- }
- // resize left
- else if (mousePoint.x() >= (topLeft.x() - mouseHandler.x()) &&
- mousePoint.x() <= (topLeft.x() + mouseHandler.x()) &&
- mousePoint.y() >= (topLeft.y() + mouseHandler.y()) &&
- mousePoint.y() <= (bottomLeft.y() - mouseHandler.y()))
- {
- setCursor(Qt::SizeHorCursor);
- }
- // resize right
- else if (mousePoint.x() >= (topRight.x() - mouseHandler.x()) &&
- mousePoint.x() <= (topRight.x() + mouseHandler.x()) &&
- mousePoint.y() >= (topRight.y() + mouseHandler.y()) &&
- mousePoint.y() <= (bottomRight.y() - mouseHandler.y()))
- {
- setCursor(Qt::SizeHorCursor);
- }
- // resize top left
- else if (mousePoint.x() <= (topLeft.x() + mouseHandler.x()) &&
- mousePoint.x() >= (topLeft.x() - mouseHandler.x()) &&
- mousePoint.y() <= (topLeft.y() + mouseHandler.y()) &&
- mousePoint.y() >= (topLeft.y() - mouseHandler.y()))
- {
- setCursor(Qt::SizeFDiagCursor);
- }
- // resize bottom right
- else if (mousePoint.x() <= (bottomRight.x() + mouseHandler.x()) &&
- mousePoint.x() >= (bottomRight.x() - mouseHandler.x()) &&
- mousePoint.y() <= (bottomRight.y() + mouseHandler.y()) &&
- mousePoint.y() >= (bottomRight.y() - mouseHandler.y()))
- {
- setCursor(Qt::SizeFDiagCursor);
- }
- // resize bottom left
- else if (mousePoint.x() <= (bottomLeft.x() + mouseHandler.x()) &&
- mousePoint.x() >= (bottomLeft.x() - mouseHandler.x()) &&
- mousePoint.y() >= (bottomLeft.y() - mouseHandler.y()) &&
- mousePoint.y() <= (bottomLeft.y() + mouseHandler.y()))
- {
- setCursor(Qt::SizeBDiagCursor);
- }
- // resize top right
- else if (mousePoint.x() <= (topRight.x() + mouseHandler.x()) &&
- mousePoint.x() >= (topRight.x() - mouseHandler.x()) &&
- mousePoint.y() >= (topRight.y() - mouseHandler.y()) &&
- mousePoint.y() <= (topRight.y() + mouseHandler.y()))
- {
- setCursor(Qt::SizeBDiagCursor);
- }
- else
- {
- setCursor(Qt::ArrowCursor);
- }
- }
- QGraphicsObject::hoverMoveEvent(event);
- }
- /// <summary>
- /// 鼠标移动事件(用于拉伸控件)
- /// </summary>
- /// <param name="event"></param>
- void WindowAppBlockComment::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
- {
- if (!isSelected())
- {
- return;
- }
- QPointF mousePoint = event->pos();
- // 如果处于拉伸状态,则调整控件的矩形区域
- if (this->isResizing)
- {
- if (reDirection & ResizeLeft)
- {
- blockRect.setLeft(mousePoint.x());
- }
- if (reDirection & ResizeRight)
- {
- blockRect.setRight(mousePoint.x());
- }
- if (reDirection & ResizeTop)
- {
- blockRect.setTop(mousePoint.y());
- }
- if (reDirection & ResizeBottom)
- {
- blockRect.setBottom(mousePoint.y());
- }
- scene()->update();
- return;
- }
- QGraphicsItem::mouseMoveEvent(event);
- }
- /// <summary>
- /// 鼠标按下事件(用于触发控件拉伸)
- /// </summary>
- /// <param name="event"></param>
- void WindowAppBlockComment::mousePressEvent(QGraphicsSceneMouseEvent* event)
- {
- QPointF mousePoint = event->pos();
- QPointF mouseHandler = QPointF(5, 5);
- QPointF topLeft = blockRect.topLeft();
- QPointF topRight = blockRect.topRight();
- QPointF bottomLeft = blockRect.bottomLeft();
- QPointF bottomRight = blockRect.bottomRight();
- reDirection = ResizeNone;
- this->isResizing = false;
- // resize top
- if (mousePoint.x() >= (topLeft.x() + 0) &&
- mousePoint.x() <= (topRight.x() - 0) &&
- mousePoint.y() >= (topLeft.y() - mouseHandler.y()) &&
- mousePoint.y() <= (topLeft.y() + mouseHandler.y()))
- {
- reDirection |= ResizeTop;
- this->isResizing = true;
- }
- // resize bottom
- if (mousePoint.x() >= (bottomLeft.x() + 0) &&
- mousePoint.x() <= (bottomRight.x() - 0) &&
- mousePoint.y() >= (bottomLeft.y() - mouseHandler.y()) &&
- mousePoint.y() <= (bottomLeft.y() + mouseHandler.y()))
- {
- reDirection |= ResizeBottom;
- this->isResizing = true;
- }
- // resize left
- if (mousePoint.x() >= (topLeft.x() - mouseHandler.x()) &&
- mousePoint.x() <= (topLeft.x() + mouseHandler.x()) &&
- mousePoint.y() >= (topLeft.y() + 0) &&
- mousePoint.y() <= (bottomLeft.y() - 0))
- {
- reDirection |= ResizeLeft;
- this->isResizing = true;
- }
- // resize right
- if (mousePoint.x() >= (topRight.x() - mouseHandler.x()) &&
- mousePoint.x() <= (topRight.x() + mouseHandler.x()) &&
- mousePoint.y() >= (topRight.y() + 0) &&
- mousePoint.y() <= (bottomRight.y() - 0))
- {
- reDirection |= ResizeRight;
- this->isResizing = true;
- }
- // 根据移动方向设置不同的鼠标指针
- switch (reDirection)
- {
- case ResizeRight:
- case ResizeLeft:
- setCursor(Qt::SizeHorCursor);
- break;
- case ResizeBottom:
- case ResizeTop:
- setCursor(Qt::SizeVerCursor);
- break;
- case ResizeRight | ResizeBottom:
- case ResizeLeft | ResizeTop:
- setCursor(Qt::SizeFDiagCursor);
- break;
- case ResizeLeft | ResizeBottom:
- case ResizeRight | ResizeTop:
- setCursor(Qt::SizeBDiagCursor);
- break;
- default:
- setCursor(Qt::ArrowCursor);
- break;
- }
- // 2022-10-4,调用一下基类的mousePressEvent,执行对应的功能(多选,位置保存等等)
- WindowAppBlockBase::mousePressEvent(event);
- QGraphicsObject::mousePressEvent(event);
- }
- /// <summary>
- /// 鼠标释放事件(用于鼠标还原以及接收拉伸状态)
- /// </summary>
- /// <param name="event"></param>
- void WindowAppBlockComment::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
- {
- // 还原鼠标
- setCursor(Qt::ArrowCursor);
- // 结束拉伸状态
- this->isResizing = false;
- reDirection = ResizeNone;
- // 2022-10-4,调用一下基类的mouseReleaseEvent,执行对应的功能
- WindowAppBlockBase::mouseReleaseEvent(event);
- QGraphicsObject::mouseReleaseEvent(event);
- }
- //======================================================================
- //
- // 注释控件缩放相关代码 - 结束
- //
- //======================================================================
- //====================================================
- //
- // Del
- //
- //====================================================
- ///// <summary>
- ///// 键盘按下时(回车键结束编辑)
- ///// </summary>
- ///// <param name="event"></param>
- //void WindowAppBlockComment::keyPressEvent(QKeyEvent* event)
- //{
- // // 点击回车失去焦点,编辑完成,后续给FocusOutEvent处理
- // if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
- // {
- // clearFocus();
- //
- // return;
- // }
- //
- // QGraphicsTextItem::keyPressEvent(event);
- //}
- //void WindowAppBlockComment::keyReleaseEvent(QKeyEvent* event)
- //{
- // // 编译完毕后,更新一下外边界
- // this->updateRect();
- // this->update();
- //
- // QGraphicsTextItem::keyReleaseEvent(event);
- //}
- //QVariant WindowAppBlockComment::itemChange(GraphicsItemChange change,
- // const QVariant& value)
- //{
- // if (change == QGraphicsItem::ItemSelectedHasChanged)
- // {
- // emit selectedChange(this);
- // }
- //
- // return value;
- //}
- ///// <summary>
- ///// 在文本内容变更时触发,自动更新边距
- ///// </summary>
- //void WindowAppBlockComment::onContentsChanged()
- //{
- // // 有内容变更时,更新一下外边界
- // this->updateRect();
- // this->update();
- //}
- //
- //
- ///// <summary>
- ///// 响应双击事件,激活文本编辑模式
- ///// </summary>
- ///// <param name="event"></param>
- //void WindowAppBlockComment::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
- //{
- // if (event->button() == Qt::LeftButton && textInteractionFlags() == Qt::NoTextInteraction)
- // {
- // setTextInteractionFlags(Qt::TextEditorInteraction);
- // }
- //
- // QGraphicsTextItem::mouseDoubleClickEvent(event);
- //}
- //
- //
- ///// <summary>
- ///// 重写Shape函数,使其没有文字的空白部分也可以响应消息
- ///// </summary>
- ///// <returns></returns>
- //QPainterPath WindowAppBlockComment::shape() const
- //{
- // QPainterPath path;
- // path.addRect(blockRect);
- // return path;
- //}
- //void WindowAppBlockComment::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
- //{
- // qDebug() << "WindowAppBlockComment::hoverEnterEvent";
- //
- // update();
- // QGraphicsObject::hoverEnterEvent(event);
- //}
- //
- //
- //void WindowAppBlockComment::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
- //{
- // qDebug() << "WindowAppBlockComment::hoverLeaveEvent";
- //
- // setCursor(QCursor(Qt::ArrowCursor));
- // scene()->update(sceneBoundingRect());
- // update();
- // QGraphicsObject::hoverLeaveEvent(event);
- //}
- //void WindowAppBlockComment::hoverMoveEvent(QGraphicsSceneHoverEvent* event)
- //{
- // if (this->isSelected())
- // {
- // QPointF mousePoint = event->pos();
- // QPointF mouseHandler = QPointF(5, 5);
- // QPointF topLeft = blockRect.topLeft();
- // QPointF topRight = blockRect.topRight();
- // QPointF bottomLeft = blockRect.bottomLeft();
- // QPointF bottomRight = blockRect.bottomRight();
- //
- // // resize top
- // if (mousePoint.x() >= (topLeft.x() + mouseHandler.x()) &&
- // mousePoint.x() <= (topRight.x() - mouseHandler.x()) &&
- // mousePoint.y() >= (topLeft.y() - mouseHandler.y()) &&
- // mousePoint.y() <= (topLeft.y() + mouseHandler.y())) {
- // setCursor(Qt::SizeVerCursor);
- // }
- // // resize bottom
- // else if (mousePoint.x() >= (bottomLeft.x() + mouseHandler.x()) &&
- // mousePoint.x() <= (bottomRight.x() - mouseHandler.x()) &&
- // mousePoint.y() >= (bottomLeft.y() - mouseHandler.y()) &&
- // mousePoint.y() <= (bottomLeft.y() + mouseHandler.y())) {
- // setCursor(Qt::SizeVerCursor);
- // }
- // // resize left
- // else if (mousePoint.x() >= (topLeft.x() - mouseHandler.x()) &&
- // mousePoint.x() <= (topLeft.x() + mouseHandler.x()) &&
- // mousePoint.y() >= (topLeft.y() + mouseHandler.y()) &&
- // mousePoint.y() <= (bottomLeft.y() - mouseHandler.y())) {
- // setCursor(Qt::SizeHorCursor);
- // }
- // // resize right
- // else if (mousePoint.x() >= (topRight.x() - mouseHandler.x()) &&
- // mousePoint.x() <= (topRight.x() + mouseHandler.x()) &&
- // mousePoint.y() >= (topRight.y() + mouseHandler.y()) &&
- // mousePoint.y() <= (bottomRight.y() - mouseHandler.y())) {
- // setCursor(Qt::SizeHorCursor);
- // }
- // // resize top left
- // else if (mousePoint.x() <= (topLeft.x() + mouseHandler.x()) &&
- // mousePoint.x() >= (topLeft.x() - mouseHandler.x()) &&
- // mousePoint.y() <= (topLeft.y() + mouseHandler.y()) &&
- // mousePoint.y() >= (topLeft.y() - mouseHandler.y())) {
- // setCursor(Qt::SizeFDiagCursor);
- // }
- // // resize bottom right
- // else if (mousePoint.x() <= (bottomRight.x() + mouseHandler.x()) &&
- // mousePoint.x() >= (bottomRight.x() - mouseHandler.x()) &&
- // mousePoint.y() <= (bottomRight.y() + mouseHandler.y()) &&
- // mousePoint.y() >= (bottomRight.y() - mouseHandler.y())) {
- // setCursor(Qt::SizeFDiagCursor);
- // }
- // // resize bottom left
- // else if (mousePoint.x() <= (bottomLeft.x() + mouseHandler.x()) &&
- // mousePoint.x() >= (bottomLeft.x() - mouseHandler.x()) &&
- // mousePoint.y() >= (bottomLeft.y() - mouseHandler.y()) &&
- // mousePoint.y() <= (bottomLeft.y() + mouseHandler.y())) {
- // setCursor(Qt::SizeBDiagCursor);
- // }
- // // resize top right
- // else if (mousePoint.x() <= (topRight.x() + mouseHandler.x()) &&
- // mousePoint.x() >= (topRight.x() - mouseHandler.x()) &&
- // mousePoint.y() >= (topRight.y() - mouseHandler.y()) &&
- // mousePoint.y() <= (topRight.y() + mouseHandler.y())) {
- // setCursor(Qt::SizeBDiagCursor);
- // }
- // else {
- // setCursor(Qt::ArrowCursor);
- // }
- // }
- // QGraphicsObject::hoverMoveEvent(event);
- //}
- ///**
- // * @brief Element::paintSelected
- // * @details 绘制选中状态
- // * @param painter
- // * @param iLineWidth 线宽
- // */
- //void WindowAppBlockComment::paintSelected(QPainter* painter, int iLineWidth)
- //{
- // if (isSelected())
- // {
- // painter->save();
- //
- // painter->setBrush(Qt::NoBrush);
- //
- // //QPen pen(Qt::green, iLineWidth, Qt::DashLine);
- // //painter->setPen(pen);
- // QRectF rect = blockRect.adjusted(-1, -1, 1, 1);
- // // painter->drawRect(rect);
- //
- // QPen pen2(Qt::green, iLineWidth, Qt::SolidLine);
- // painter->setPen(pen2);
- // QPointF pt = QPointF(3, 3);
- //
- // painter->drawRect(QRectF(rect.topLeft() - pt, rect.topLeft() + pt));
- // QPointF ptMid = QPointF(rect.left() + rect.width() / 2, rect.top());
- // painter->drawRect(QRectF(ptMid - pt, ptMid + pt));
- // painter->drawRect(QRectF(rect.topRight() - pt, rect.topRight() + pt));
- //
- // ptMid = QPointF(rect.left(), rect.top() + rect.height() / 2);
- // painter->drawRect(QRectF(ptMid - pt, ptMid + pt));
- // ptMid = QPointF(rect.right(), rect.top() + rect.height() / 2);
- // painter->drawRect(QRectF(ptMid - pt, ptMid + pt));
- //
- // painter->drawRect(QRectF(rect.bottomLeft() - pt, rect.bottomLeft() + pt));
- // ptMid = QPointF(rect.left() + rect.width() / 2, rect.bottom());
- // painter->drawRect(QRectF(ptMid - pt, ptMid + pt));
- // painter->drawRect(QRectF(rect.bottomRight() - pt, rect.bottomRight() + pt));
- //
- // painter->restore();
- // }
- //}
|