123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- #ifndef QPAPEREDITHANDLER_H
- #define QPAPEREDITHANDLER_H
- #include <QWidget>
- #include "ui_qpaperedithandler.h"
- #include<QPalette>
- #include <QPainter>
- #include <QMouseEvent>
- #include <QStyledItemDelegate>
- #include <vector>
- using namespace std;
- struct ItemInfo
- {
- int id;
- QString origion_imgpath;
- string img_oldpath;
- QImage* pPreviewImg;
- QListWidgetItem* pItem;
- };
- Q_DECLARE_METATYPE(ItemInfo)
- class MyItemPainter : public QStyledItemDelegate
- {
- Q_OBJECT
- public:
- MyItemPainter(QWidget *parent);
- ~MyItemPainter();
- private:
- QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
- void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
- };
- class QPaperEditHandler : public QWidget
- {
- Q_OBJECT
- enum MouseStatus
- {
- Mouse_Normal,
- Mouse_Drag,
- Mouse_Pen,
- Mouse_Line,
- Mouse_Eraser,
- Mouse_Cut,
- Mouse_Cuting,
- Mouse_Locate,
- };
- public:
- QPaperEditHandler(QWidget *parent = 0);
- ~QPaperEditHandler();
- void SetOrigionImg(QString path, string oldpath);
- void SetImgList(vector<QString> imglist,vector<string> oldpathlist);
- void SetShowSchema(bool bshow);//是否显示模板按钮
- vector<string> GetEditedImgs();
- void ShowMovie(bool bshow=true);
- void SetViewMode(bool view = true);//查看模式,不处理异常
- bool m_bIsEdited;//图片是否修改过
- void SetPaper(int paper_id);
- void SetTitleInfo(string info);
- void SetHandlerKaohaoyichang(bool bViewMode = true);
- int paper_id;
- Q_SIGNALS:
- void switchToShibieYichang();
- void PaperChange(QString);
- void sig_SetViewMode(bool);
- private:
- void ClickDrag();
- void ClickRoomin();
- void ClickRoomout();
- void ClickRotate90();
- void ClickRotateN90();
- void ClickUndo();
- void ClickRedo();
- void ClickPen(QObject* sender);
- void ClickEraser(QObject* sender);
- void ClickLine(QObject* sender);
- void ClickCut();
- void ClickLocate(QObject* sender);
- void ClickMore();
- void ClickPre();
- void ClickPreView();
- void ClickNext();
- void ClickRestore();
- void ClickSwitchDrag();//切换到拖移模式
- void ClickCur();//考号冲突 点击当前页
- void ClickConflict(int index);//考号冲突 点击重复1 2 3 4 5
- void ClickSwitchPage();
- void paintEvent(QPaintEvent *);
- void mouseMoveEvent(QMouseEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void wheelEvent(QWheelEvent *event);
- virtual void resizeEvent(QResizeEvent *event);
- bool eventFilter(QObject *watched, QEvent *event);
- QPoint PointSwitchToImg(QPoint sPoint);
- QRect RectSwitchImg(QRect sRect);
- QPoint PointSwitchToClient(QPoint sPoint);
- QRect RectSwitchToClient(QRect sRect);
- void Reset();
- void LoadPreview();
- private slots:
- void ClickButton();
-
- public slots :
- void ClickPreViewLable(int id);
- void ListItemChange(QListWidgetItem*);
- void mergeImg();
- void ClickCutOK();
- void ClickCutDel();
- void ClickCutSave();
- void ClickCutCopy();
- private:
- Ui::QPaperEditHandler ui;
- QPoint startPoint;
- QPoint endPoint;
- bool ispressed;
- MouseStatus mousestatus;
- QPixmap bgmap;
- QImage bgimage;
- float room;
- QString origionImgpath;
- string oldimgpath;
- QPoint offset;
-
- int eraserW;
- int eraserH;
- int locateW;
- int locateH;
- QPen pen;
- int penW;
- QColor penColor;
- int lineW;
- QColor lineColor;
-
- vector<ItemInfo> iteminfos;
- vector<QString> origionImglist;
- vector<string> oldImgpathlist;
- MyItemPainter itemPainter;
- bool bLoadedPreview;//延迟加载预览图
- bool m_bShowMovie;
- int NextItem();
- int preItem();
- void HideButtons();
- bool bFirstResize;//第一次显示图片时完整显示,作个标记
- vector<int> m_conflict_paper;
- int m_curpage;//当前操作的是哪一页 对于考号冲突的情况 当切换到其它试卷时,保存当前页号
- string m_titleInfo;
- };
- #endif // QPAPEREDITHANDLER_H
|