#ifndef WAFFLEGRAPHICSVIEW_H #define WAFFLEGRAPHICSVIEW_H #include #include #include #include #include "DieItem.h" #include #include class WaffleGraphicsView : public QGraphicsView { Q_OBJECT public: WaffleGraphicsView(QGraphicsScene* scene, QWidget* parent = nullptr); protected: void mousePressEvent(QMouseEvent* event) override; void mouseMoveEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override; void wheelEvent(QWheelEvent* event) override; bool eventFilter(QObject *obj, QEvent *event) override; private: bool selecting; // 是否正在框选 QPoint lastPos; QPointF selectionStart; // 框选起点 QGraphicsRectItem* selectionRect; // 框选矩形 double scaleFactor; // 当前缩放比例 bool isDragging = false; QMap, QGraphicsItem*> selectedItemsMap; QLabel *thumbnailLabel; // 缩略图标签 bool thumbnailVisible; // 缩略图可见状态 QPair topLeftIndex; QPair bottomRightIndex; QPointer selectedItem; QPointer topLeftItem; QPointer bottomRightItem; void showThumbnail(); void hideThumbnail(); void checkAndCreateRegion(); void clearRegion(); void setRegion(); }; #endif // WAFFLEGRAPHICSVIEW_H