diff --git a/README.md b/README.md index d9c1bae0e77254b44fe162d2b321e5bf0adeb83e..e66fcd89a1b4a3945870c25aa0f296ab87316542 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ 子工程主要分为两个类型`app`和`lib`,`app`类型为可执行文件,`lib`类型为库文件。 ``` -|-model -> 模型,主要用于存放核心的数据结构模型 +|-model -> 系统工作时的数据模型及显示渲染 |-ofd -> ofd,主要用与ofd文件读取导出,以及ofd读取初期所使用的数据结构 |-start -> start,主要存放启动程序已经程序的一些基本的界面文件。 @@ -31,3 +31,24 @@ |-test_pan -> 潘言星的测试工程 |-test_yang -> 杨语晨的测试工程 ``` + +## Qt 帮助文档 +Qt的帮助文档极为丰富,看完之后能够对Qt的功能产生系统性的了解,这样设计软件时,思路就会更加的清晰。 + +| 文件名 | 作用 | +| --- | --- | +| Qt Data Types.pdf | Qt的一些基础数据类型 | +| Creating Custom Qt Types.pdf | 创建自定义的Qt 类 | +| MainWindow.pdf | 主窗口相关的 | +| Widget Tutorial.pdf | Widget 的简要教程 | +| Layout.pdf | 布局 | +| State Machine.pdf | 状态机 | +| Sighals and Slots.pdf | 信号槽 | +| Event System.pdf | 事件系统 | +| Drag and Drop.pdf | 拖拽操作处理 | +| Painting System.pdf | 绘画系统 | +| Qgraphics view framework.pdf | Qt的快速响应的图形渲染方式 | +| Qt 富文本框架.pdf | Qt富文本系统 | +| Creating Qt Plugins.pdf | 制作Qt插件 | +| Model View Programming.pdf | 模型视图结构编程 | +| Model View Tutorial.pdf | 模型视图结构教学 | diff --git a/ofdEditor/model/Doc/DocBasicTypes.h b/ofdEditor/model/Doc/DocBasicTypes.h new file mode 100644 index 0000000000000000000000000000000000000000..8d8fe820b767667f311cc970e27ea63367a9a52f --- /dev/null +++ b/ofdEditor/model/Doc/DocBasicTypes.h @@ -0,0 +1,31 @@ +#ifndef DOCBASICTYPES_H +#define DOCBASICTYPES_H + +#include "model_global.h" + +/** + * @Author Chaoqun + * @brief 功能同 ST_Box + * @date 2017/04/30 + */ +class MODELSHARED_EXPORT DocBox +{ +public: + double x; + double y; + double width; + double height; + + void set(double x, double y,double width, double height) + { + this->x = x; + this->y = y; + this->width = width; + this->height = height; + } + +}; + + + +#endif // DOCBASICTYPES_H diff --git a/ofdEditor/model/Doc/DocBlock.cpp b/ofdEditor/model/Doc/DocBlock.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c46a4fb2a9a761d0e9d7a3623756acd4c761afaa --- /dev/null +++ b/ofdEditor/model/Doc/DocBlock.cpp @@ -0,0 +1,25 @@ +#include "DocBlock.h" + +#include +#include +#include + +DocBlock::DocBlock(QGraphicsItem *parent , Qt::WindowFlags wFlags) + :QGraphicsProxyWidget(parent,wFlags) +{ + this->boundary.set(0,0,0,0); // 默认是一个空的包围矩形 + this->setVisible(true); + this->setZValue(200); + +} + +void DocBlock::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + qDebug() << "被鼠标点了一下 "<<(event->pos()).x() + << "," << event->pos().y(); + + QGraphicsScene * scene = this->scene(); + qDebug() << scene->width() << ", " + << scene->height() ; +} + diff --git a/ofdEditor/model/Doc/DocBlock.h b/ofdEditor/model/Doc/DocBlock.h new file mode 100644 index 0000000000000000000000000000000000000000..801a2a93980a2b9b0fbea6df18b6f38a1f357588 --- /dev/null +++ b/ofdEditor/model/Doc/DocBlock.h @@ -0,0 +1,39 @@ +#ifndef DOCBLOCK_H +#define DOCBLOCK_H + +#include "model_global.h" // 导出lib使用 +#include "Doc/DocBasicTypes.h" +#include +#include + +class DocLayer; + + +/** + * @Author Chaoqun + * @brief 一个块 + * @param 参数 + * @return 返回值 + * @date 2017/05/03 + */ +class MODELSHARED_EXPORT DocBlock + :public QGraphicsProxyWidget +{ + Q_OBJECT +public: + DocBlock(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); + + void setLayer(DocLayer * layer){this->layer = layer;} + DocLayer * getLayer(){return this->layer;} + + +protected: + void mousePressEvent(QGraphicsSceneMouseEvent *event); +private: + DocBox boundary; // 该块的外包矩形 + DocLayer * layer; // 该块在哪一个层之中 + + +}; + +#endif // DOCBLOCK_H diff --git a/ofdEditor/model/Doc/DocDrawParam.cpp b/ofdEditor/model/Doc/DocDrawParam.cpp new file mode 100644 index 0000000000000000000000000000000000000000..374e0cc3e878044f10a0df480ea6d4f348d1ca1d --- /dev/null +++ b/ofdEditor/model/Doc/DocDrawParam.cpp @@ -0,0 +1,6 @@ +#include "DocDrawParam.h" + +DocDrawParam::DocDrawParam() +{ + +} diff --git a/ofdEditor/model/Doc/DocDrawParam.h b/ofdEditor/model/Doc/DocDrawParam.h new file mode 100644 index 0000000000000000000000000000000000000000..5f715d1de03163813738c208fa9737e527d6734c --- /dev/null +++ b/ofdEditor/model/Doc/DocDrawParam.h @@ -0,0 +1,17 @@ +#ifndef DOCDRAWPARAN_H +#define DOCDRAWPARAN_H + +#include "model_global.h" + +/** + * @Author Chaoqun + * @brief 结合渲染,因此这里的绘画模式要更接近于Qt的 + * @date 2017/04/30 + */ +class MODELSHARED_EXPORT DocDrawParam +{ +public: + DocDrawParam(); +}; + +#endif // DOCDRAWPARAN_H diff --git a/ofdEditor/model/Doc/DocGraph.cpp b/ofdEditor/model/Doc/DocGraph.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c554b77011da31b52317065b97de4a44def8b35e --- /dev/null +++ b/ofdEditor/model/Doc/DocGraph.cpp @@ -0,0 +1,13 @@ +#include "DocGraph.h" + + +DocGraph::DocGraph(QObject *parent) + :DocImage(parent) +{ + +} + +DocGraph::~DocGraph() +{ + +} diff --git a/ofdEditor/model/Doc/DocGraph.h b/ofdEditor/model/Doc/DocGraph.h new file mode 100644 index 0000000000000000000000000000000000000000..97abef0bb0fe782b1b87dc2f23d103c57731b1ab --- /dev/null +++ b/ofdEditor/model/Doc/DocGraph.h @@ -0,0 +1,17 @@ +#ifndef DOCGRAPH_H +#define DOCGRAPH_H + +#include "model_global.h" // 导出lib使用 +#include "Doc/DocBasicTypes.h" +#include "Doc/DocImage.h" + +class MODELSHARED_EXPORT DocGraph + :public DocImage +{ + Q_OBJECT +public: + DocGraph(QObject *parent = Q_NULLPTR); + ~DocGraph(); +}; + +#endif // DOCGRAPH_H diff --git a/ofdEditor/model/DocImage.cpp b/ofdEditor/model/Doc/DocImage.cpp similarity index 51% rename from ofdEditor/model/DocImage.cpp rename to ofdEditor/model/Doc/DocImage.cpp index 1c5d849f8976a95ab2c6122ea57be04708e97318..ba350ba428362d031593e0eef7373d40e1d0d866 100644 --- a/ofdEditor/model/DocImage.cpp +++ b/ofdEditor/model/Doc/DocImage.cpp @@ -1,7 +1,7 @@ #include "DocImage.h" // 测试 -DocImage::DocImage() +DocImage::DocImage(QObject *parent) { } diff --git a/ofdEditor/model/Doc/DocImage.h b/ofdEditor/model/Doc/DocImage.h new file mode 100644 index 0000000000000000000000000000000000000000..052e06309729b37792402fa7825e806c51f0c1e1 --- /dev/null +++ b/ofdEditor/model/Doc/DocImage.h @@ -0,0 +1,22 @@ +#ifndef DOCIMAGE_H +#define DOCIMAGE_H + +#include "model_global.h" +#include "Doc/DocBlock.h" + +#include // 文档 + +// 本类型用来表述文章中的图形、图片之类的 + +class MODELSHARED_EXPORT DocImage + :public QTextDocument +{ + Q_OBJECT +public: + DocImage(QObject *parent = Q_NULLPTR); +private: + +}; + +#endif // DOCIMAGE_H + diff --git a/ofdEditor/model/Doc/DocLayer.cpp b/ofdEditor/model/Doc/DocLayer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c92f879295210d233d77263cf2ff13992e7602c5 --- /dev/null +++ b/ofdEditor/model/Doc/DocLayer.cpp @@ -0,0 +1,121 @@ +#include "DocLayer.h" +#include "Doc/DocBlock.h" // 块 +#include "Doc/DocTable.h" // 表格 +#include "Doc/DocDrawParam.h" + + +DocLayer::DocLayer() +{ + +} + +DocLayer::DocLayer(DocPage::Layer layer) +{ + this->type = layer; +} + +DocLayer::~DocLayer() +{ + + // 释放块 + int blocks_length = this->blocks.size(); + for(int i = 0; i < blocks_length; i++) + { + //挨个释放内存空间 + DocBlock* temp = this->blocks.at(i); + if(temp != NULL) + { + delete temp; + (this->blocks)[i] = NULL; + } + } + this->blocks.clear(); + + // 释放表格 + int tables_length = this->tables.size(); + for(int i = 0; i < tables_length; i++) + { + // 挨个释放表格的空间 + DocTable* temp = this->tables.at(i); + if(temp != NULL) + { + delete temp; + (this->tables)[i]=NULL; + } + } + this->tables.clear(); + + // 释放绘制模式 + if(this->drawParam != NULL) + { + delete this->drawParam; + this->drawParam = NULL; + } + +} + +/** + * @Author Chaoqun + * @brief 修改本层的 zValue的值 + * @param qreal z + * @return void + * @date 2017/05/03 + */ +void DocLayer::setZValue(qreal z) +{ + this->zValue = z; + + // 遍历所有块,将他们的值全部修改为 z + +} + +/** + * @Author Chaoqun + * @brief 向该层添加一个block + * @param DocBlock * block + * @return void + * @date 2017/05/06 + */ +void DocLayer::addBlock(DocBlock *block) +{ + this->blocks.append(block); // 追加到队尾 +} + +/** + * @Author Chaoqun + * @brief 移除块 + * @param DocBlock * block + * @return void + * @date 2017/05/06 + */ +void DocLayer::removeBlock(DocBlock *block) +{ + // 判断参数是否正确 + if(block == NULL) + return; + // 判断是否包含本块 + if(this->blocks.contains(block)) + { + int index = this->blocks.indexOf(block); + this->blocks.remove(index); + } +} + +/** + * @Author Chaoqun + * @brief 获得本层的所有blocks + * @return QVector + * @date 2017/05/06 + */ +QVector* DocLayer::getBlocks() +{ + QVector *vector = new QVector(); + int length = this->blocks.length(); + + for(int i = 0; ipush_back((this->blocks)[i]); + } + + return vector; +} diff --git a/ofdEditor/model/Doc/DocLayer.h b/ofdEditor/model/Doc/DocLayer.h new file mode 100644 index 0000000000000000000000000000000000000000..5319f70344c89441d9dd7834007a14cd318ea517 --- /dev/null +++ b/ofdEditor/model/Doc/DocLayer.h @@ -0,0 +1,51 @@ +#ifndef DOCLAYER_H +#define DOCLAYER_H + +#include "model_global.h" // 导出lib使用 +#include "Doc/DocPage.h" + +#include + +class DocBlock; // 块 +class DocTable; // 表格 +class DocDrawParam; // 默认绘画模式 + +/** + * @Author Chaoqun + * @brief 层概念,只负责作为一个管理集合,并无实际用途 + * @date 2017/04/30 + */ +class MODELSHARED_EXPORT DocLayer +{ +public: + DocLayer(); + DocLayer(DocPage::Layer layer); + ~DocLayer(); + + void setZValue(qreal z); // 设置本层的 ZValue的值 + qreal getZValue(){return this->zValue;} // 获取本层的 ZValue的值 + + void addBlock(DocBlock *block); // 添加Block + void removeBlock(DocBlock* block); // 移除Block + QVector *getBlocks(); // 获得所有Block + + DocPage::Layer getLayer(){return type;} + void setLayer(DocPage::Layer layer){this->type = layer;} + + + + +private: + QVector blocks; // 块 -文字块图形块的父类 + QVector tables; // 表格 + + DocDrawParam* drawParam; // 该层的默认绘画模式 + + DocPage::Layer type; // 共三层 + DocPage* parent; // 表明此层是哪一个页面的 + + qreal zValue; // 该层 QGraphicsItem默认的zValue; + +}; + +#endif // DOCLAYER_H diff --git a/ofdEditor/model/Doc/DocPage.cpp b/ofdEditor/model/Doc/DocPage.cpp new file mode 100644 index 0000000000000000000000000000000000000000..493787262db8131e192aeb8e0fc81d31ca1ed1fb --- /dev/null +++ b/ofdEditor/model/Doc/DocPage.cpp @@ -0,0 +1,164 @@ +#include "DocPage.h" +#include "DocLayer.h" +#include "Tool/UnitTool.h" +#include "Doc/DocBlock.h" + +#include +#include +#include + +// #include "DataTypes/page/CT_PageArea.h" // 页面大小 + +DocPage::DocPage(QWidget *parent) + :QGraphicsView(parent) +{ + this->setSize(210,297); + this->scaleFactor = 1.0; + this->init(); + +} + +DocPage::DocPage(double width, + double height, double scaleFactor, QWidget *parent) + :QGraphicsView(parent) +{ + this->setSize(width,height); // 设置widget大小 + this->scaleFactor = scaleFactor; + this->setVisible(true); + this->init(); +} + +DocPage::~DocPage() +{ + // area空间释放 + +} + + +/** + * @Author Chaoqun + * @brief 调整页面的大小 + * @param double width, double height + * @return 返回值 + * @date 2017/05/01 + */ +void DocPage::setSize(double width, double height) +{ + // 保存mm单位大小 + this->width_mm = width; + this->height_mm = height; + + this->setFixedSize(UnitTool::mmToPixel(width), + UnitTool::mmToPixel(height)); // 设置页面大小 + this->setSceneRect(0,0, + UnitTool::mmToPixel(width), + UnitTool::mmToPixel(height) ); + this->setBackgroundRole(QPalette::BrightText); // 背景颜色 + this->setAutoFillBackground(true); +} + +/** + * @Author Chaoqun + * @brief 获得页面的大小-像素大小 + * @return QSize + * @date 2017/05/01 + */ +QSize DocPage::getSize() +{ + return QSize(UnitTool::mmToPixel(width_mm), + UnitTool::mmToPixel(height_mm)); +} + +/** + * @Author Chaoqun + * @brief 添加一个新的块到页面之中 + * @param DocBlock* block 具体的块 + * @param Layer layer 在哪层 + * @return 返回值 + * @date 2017/05/06 + */ +void DocPage::addBlock(DocBlock *block, DocPage::Layer layer) +{ + + qDebug() << "DocPage::addBlock excuted"; + this->docScene->addItem(block); // 添加元素 + qDebug() << "DocPage::addBlock excuted this->docScene->addItem(block);"; + + switch (layer) { + case Body: + this->bodyLayer->addBlock(block); + break; + case Foreground: + this->foregroundLayer->addBlock(block); + break; + case Background: + this->backgroundLayer->addBlock(block); + break; + default: + break; + } + + +} + +/** + * @Author Chaoqun + * @brief 将item添加到scene中 + * @param QGraphicsItem *item + * @return void + * @date 2017/05/13 + */ +void DocPage::addItem(QGraphicsItem *item) +{ + this->docScene->addItem(item); +} + +/** + * @Author Chaoqun + * @brief 传递接口 + * @param 参数 + * @return 返回值 + * @date 2017/05/03 + */ +QGraphicsProxyWidget *DocPage::addWidget(QWidget *widget, + Qt::WindowFlags wFlags) +{ + return this->docScene->addWidget(widget,wFlags); +} + + +/** + * @Author Chaoqun + * @brief 摘要 + * @param 参数 + * @return 返回值 + * @date 2017/05/02 + */ +void DocPage::paintEvent(QPaintEvent *event) +{ + QGraphicsView::paintEvent(event); +} + + +/** + * @Author Chaoqun + * @brief 初始化DocPage + * @date 2017/05/06 + */ +void DocPage::init() +{ + this->docScene = new QGraphicsScene(); // 新建 + this->setScene(this->docScene); // 设置场景 + + this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + + + // 新建三个层 + this->foregroundLayer = new DocLayer(Foreground); + this->bodyLayer = new DocLayer(DocPage::Body); + this->backgroundLayer = new DocLayer(Background); + + +} diff --git a/ofdEditor/model/Doc/DocPage.h b/ofdEditor/model/Doc/DocPage.h new file mode 100644 index 0000000000000000000000000000000000000000..dc8d1284d41694a8fd865b7a6976f9278a7c2898 --- /dev/null +++ b/ofdEditor/model/Doc/DocPage.h @@ -0,0 +1,71 @@ +#ifndef DOCPAGE_H +#define DOCPAGE_H + +#include "model_global.h" // 导出lib使用 + +#include +#include +#include +#include +#include + +// 类声明 +class DocLayer; +//class CT_PageArea; +class DocBlock; +class DocTextBlock; + + +/** + * @Author Chaoqun + * @brief 用来表示文章中的某一页 + * @date 2017/04/30 + */ +class MODELSHARED_EXPORT DocPage + :public QGraphicsView +{ + Q_OBJECT +public: + enum Layer{Body,Foreground,Background}; // 分为三层 + + explicit DocPage(QWidget * parent = 0); + DocPage(double width, + double height, double scaleFactor,QWidget * parent = 0); + ~DocPage(); + + void setSize(double width, double height); // 设置页面大小 + QSize getSize(); // 获得页面像素大小 + double getWidth(){return width_mm;} // 返回毫米单位宽度 + double getHeight(){return height_mm;} // 返回毫米单位高度 + + void addBlock(DocBlock* block, DocPage::Layer layer); // 为页面添加一个新元素 +// void addBlock(DocTextBlock* textBlock, DocPage::Layer layer); // 为页面添加一个新元素 + void addItem(QGraphicsItem *item); // 拓展接口 + QGraphicsProxyWidget *addWidget(QWidget *widget, + Qt::WindowFlags wFlags = Qt::WindowFlags()); + +protected: + void paintEvent(QPaintEvent *event); + +private: + QGraphicsScene* docScene; // 场景数据 + //QVector layers; // 一个文档具有很多层 + + DocLayer* foregroundLayer; // 前景层 + DocLayer* bodyLayer; // 正文层 + DocLayer* backgroundLayer; // 背景层 + + // 还应该有模板页 + //CT_PageArea* area; // 页面大小描述 + + double width_mm; // 页面的宽 --单位 mm + double height_mm; // 页面的高 + + double scaleFactor; // 表示缩放倍数 + + void init(); // 初始化UI + + +}; + +#endif // DOCPAGE_H diff --git a/ofdEditor/model/Doc/DocParaStyle.cpp b/ofdEditor/model/Doc/DocParaStyle.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f96a407ab3dd9374eab3fcc3f6b627e8a7c2e9a2 --- /dev/null +++ b/ofdEditor/model/Doc/DocParaStyle.cpp @@ -0,0 +1,13 @@ +#include "DocParaStyle.h" +#include "Doc/DocImage.h" + + +DocParaStyle::DocParaStyle() +{ + +} + +DocParaStyle::~DocParaStyle() +{ + +} diff --git a/ofdEditor/model/Doc/DocParaStyle.h b/ofdEditor/model/Doc/DocParaStyle.h new file mode 100644 index 0000000000000000000000000000000000000000..8b63fa94c10ece7629fc01678ec6e7d9508d7822 --- /dev/null +++ b/ofdEditor/model/Doc/DocParaStyle.h @@ -0,0 +1,33 @@ +#ifndef DOCPARASTYLE_H +#define DOCPARASTYLE_H + +class DocImage; + + +class DocParaStyle +{ +public: + DocParaStyle(); + ~DocParaStyle(); +private: + double spaceAbove; // 段前间距 + double spaceBelow; // 段后间距 + + double indentFirstLine; // 首行缩进多少字符 + + double deltaLineSpace; // 行距 -- 和字体有关是一行高度的比例 + double fixedLineSpace; // 固定行距 -- 和字体无关,用毫米表示 + int LineSpaceType; // 0-deltaLineSpace + // 1-fixedlineSpace + + DocImage *background; // 段落可能需要背景颜色花纹等 + + // 大纲级别 -- 用来做大纲 + + enum ParaAlign{Left,Centered,Right,Fullness}; + // 段落缩进,居左,居中,居右,撑满 + ParaAlign alignment; + +}; + +#endif // DOCPARASTYLE_H diff --git a/ofdEditor/model/DocParagraph.cpp b/ofdEditor/model/Doc/DocParagraph.cpp similarity index 100% rename from ofdEditor/model/DocParagraph.cpp rename to ofdEditor/model/Doc/DocParagraph.cpp diff --git a/ofdEditor/model/Doc/DocParagraph.h b/ofdEditor/model/Doc/DocParagraph.h new file mode 100644 index 0000000000000000000000000000000000000000..4dd38fcd2d46dd6905ceb8f4387790df1a54b731 --- /dev/null +++ b/ofdEditor/model/Doc/DocParagraph.h @@ -0,0 +1,21 @@ +#ifndef PARAGRAPH_H +#define PARAGRAPH_H + +#include "model_global.h" +#include + +class DocText; // 文字小段 + +class DocParaStyle; // 段落的样式 + +class MODELSHARED_EXPORT DocParagraph +{ +public: + DocParagraph(); +private: + DocParaStyle* paraStyle; // 段落的样式 + QVector texts; // 段落中的字体一致的几个文字 + +}; + +#endif // PARAGRAPH_H diff --git a/ofdEditor/model/Doc/DocPassage.cpp b/ofdEditor/model/Doc/DocPassage.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8dd04ba33d08ae122d063f8e74f3c2b362c4d536 --- /dev/null +++ b/ofdEditor/model/Doc/DocPassage.cpp @@ -0,0 +1,247 @@ +#include "DocPassage.h" + +#include "DocPage.h" +#include "DataTypes/document/CT_DocInfo.h" + +#include +#include +#include +#include +#include +#include + +//#include "DataTypes/document/CT_CommonData.h" + +/** + * @Author Chaoqun + * @brief 默认构造函数 + * @date 2017/04/30 + */ +DocPassage::DocPassage(QWidget *parent) + :docType("OFD"),version("1.0"),QScrollArea(parent) +{ + this->scaleFactor = 1.0; // 缩放100% + this->docInfo = new CT_DocInfo(); +// this->commonData = new CT_CommonData(); + this->init(); // 初始化界面 + + this->addPage(new DocPage()); // 添加一个空白页面 + + setAttribute(Qt::WA_DeleteOnClose); + +} + +/** + * @Author Chaoqun + * @brief 含参构造函数 + * @date 2017/05/01 + */ +DocPassage::DocPassage(QWidget *parent, + QString version, QString docType, double scaleFactor) + :QScrollArea(parent) +{ + this->version = version; + this->docType = docType; + this->scaleFactor = scaleFactor; +} + +DocPassage::~DocPassage() +{ + // 释放根节点内容 + if(this->docInfo != NULL) + { + delete this->docInfo; + this->docInfo = NULL; + } + + // 释放公共数据 +// if(this->commonData != NULL) +// { +// delete this->commonData; +// this->commonData = NULL; +// } + + // 释放this->pages + int pages_length = this->pages.size(); + for(int i = 0; i < pages_length; i++) + { + // 需要挨个释放内存空间 + DocPage* temp = this->pages.at(i); + if(temp != NULL) + { + delete temp; + (this->pages)[i] = NULL; + } + } + this->pages.clear(); + +} + +/** + * @Author Chaoqun + * @brief 向该面板中,增加很多区域 + * @param 参数 + * @return 返回值 + * @date 2017/05/01 + */ +void DocPassage::addPage(DocPage *page) +{ + if(page == NULL) + { + qDebug() << "DocPassage::addPage(DocPage* page) " + << "You have add a NULL pointer"; + return; + } + + // 先添加到 vector + this->pages.append(page); + + // 再添加到ScrollArea + + this->adjustWidgetSize(); // 调整大小 + + this->layout->addWidget(page,0,Qt::AlignCenter); + // 向layout中增加一页,并居中显示 + this->layout->update(); // 更新 + + qDebug() << "You have added an new page"; + +} + +/** + * @Author Chaoqun + * @brief 向场景中增加很多页面 + * @param QVector& passage + * @return void + * @date 2017/05/01 + */ +void DocPassage::addPassage(QVector& passage) +{ + int passage_length = passage.size(); + for(int i = 0; i < passage_length; i++) + { + this->addPage(passage[i]); + } +} + +/** + * @Author Chaoqun + * @brief 设置重置响应事件,窗口大小发生调整,将会调用这个函数u + * @param QResizeEvent *event + * @return void + * @date 2017/05/02 + */ +void DocPassage::resizeEvent(QResizeEvent *event) +{ + this->adjustWidgetSize(); // 调整整体大小 + qDebug() << "DocPassage::resizeEvent Runs"; +} + +void DocPassage::init() +{ + this->layout = new QVBoxLayout; // 新建布局 + + // 新增widget + this->widget = new QWidget(this); + this->widget->setLayout(this->layout); + this->widget->setVisible(true); + this->widget->setBackgroundRole(QPalette::Dark); // 背景 + this->widget->setAutoFillBackground(true); + + this->setWidget(this->widget); // 设置内置widget + this->setBackgroundRole(QPalette::Dark); // 背景 + + this->horizontalWhite = 100; // 文章两侧黑边 + this->verticalWhite = 50; // 文章之间黑边 + this->setAlignment(Qt::AlignHCenter); // 设置位置水平居中 + + // 设置滚动条策略 + this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + this->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + + adjustScrollBarRange(); // 调整进度条长度 + + // 设置滚动条位置 + adjustScrollBar(this->horizontalScrollBar(), 1); + adjustScrollBar(this->verticalScrollBar(),1); + +} + +/** + * @Author Chaoqun + * @brief 调整滑动条 + * @param QScrollBar *scrollBar + * @param Double factor + * @return 返回值 + * @date 2017/05/01 + */ +void DocPassage::adjustScrollBar(QScrollBar *scrollBar, double factor) +{ + // 设置滚动条位置 + scrollBar->setValue(int(factor * scrollBar->value() + + ((factor -1) * scrollBar->pageStep()/2)) + 1); +} + +void DocPassage::adjustScrollBarRange() +{ + QSize areaSize = this->viewport()->size(); // 视窗大小 + QSize widgetSize = this->widget->size(); // 面板大小 + + + this->horizontalScrollBar()->setPageStep(areaSize.width()); + this->horizontalScrollBar()->setRange(0,widgetSize.width() + - areaSize.width()); + + this->verticalScrollBar()->setPageStep(areaSize.height()); + this->verticalScrollBar()->setRange(0,widgetSize.height() + - areaSize.height()); + + +} + +/** + * @Author Chaoqun + * @brief 根据每一页的大小,调整显示区域面积 + * @return void + * @date 2017/05/01 + */ +void DocPassage::adjustWidgetSize() +{ + // 计算页面大小 + int width = 0; + int height = 0; + + int length = this->pages.size(); + for(int i = 0; i pages[i]->getSize().width()) + { + width = this->pages[i]->getSize().width(); + } + + height += verticalWhite + this->pages[i]->getSize().height(); + } + + height += verticalWhite; + width += 2*horizontalWhite; + + this->widget->setMinimumSize(width, height); // 设置内容大小 + + // 保存计算结果 + this->widgetWidth = width; + this->widgetHeight = height; + this->QScrollArea::update(); + + adjustScrollBarRange(); // 调整进度条长度 + + // 调整滚动条位置 + adjustScrollBar(this->horizontalScrollBar(), this->scaleFactor); + adjustScrollBar(this->verticalScrollBar(), this->scaleFactor); + + + + + qDebug() <<"widget's Size"<widget->size(); + qDebug() << "ScrollArea's Size" << this->size(); + +} diff --git a/ofdEditor/model/Doc/DocPassage.h b/ofdEditor/model/Doc/DocPassage.h new file mode 100644 index 0000000000000000000000000000000000000000..729981df9445e3253becb8b0339d062ebeab8168 --- /dev/null +++ b/ofdEditor/model/Doc/DocPassage.h @@ -0,0 +1,73 @@ +#ifndef DOCPASSAGE_H +#define DOCPASSAGE_H + +#include "model_global.h" // 导出lib使用 + +#include +#include +#include +#include +#include // 树状排布 +#include + +// 类声明 +class DocPage; +class CT_DocInfo; +class CT_CommonData; + +/** + * @Author Chaoqun + * @brief 表述一篇文章 + * @date 2017/04/30 + */ +class MODELSHARED_EXPORT DocPassage + :public QScrollArea +{ + Q_OBJECT +public: + explicit DocPassage(QWidget* parent = 0); + DocPassage(QWidget *parent, QString version, + QString docType,double scaleFactor); + ~DocPassage(); + + void addPage(DocPage *page); // 添加一个新页面 + void addPassage(QVector& passage); // 添加很多界面 + +protected: + void resizeEvent(QResizeEvent* event); + + +private: + // 数据区 + QString version; // OFD 版本默认 1.0 + QString docType; // 类型默认是 OFD + CT_DocInfo* docInfo; // 文档元数据结构 ofd/CT_DocInfo + //CT_CommonData* commonData; // 文档公用文档数据 + + QVector pages; // 既作为数据,也作为渲染 + + // 渲染区 + QVBoxLayout * layout; // 纵向排列 + QWidget * widget; // 用widget做缓冲 + + double scaleFactor; // 表示缩放倍数 + double widgetWidth; // 内容的宽度 + double widgetHeight; // 内容的高度 + + int horizontalWhite; // 白色页面左右两边的灰色区域 + int verticalWhite; // 白色页面上下的灰色区域 + + +private: + void init(); // 初始化 + void adjustScrollBar(QScrollBar *scrollBar, + double factor); // 调整滑动条 + void adjustScrollBarRange(); //调整滑动条范围 + void adjustWidgetSize(); // 根据页数来自动调整widget大小 + + + + +}; + +#endif // DOCPASSAGE_H diff --git a/ofdEditor/model/Doc/DocPicture.cpp b/ofdEditor/model/Doc/DocPicture.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b851a29a1de25ec253d9a07e60aa87ca11b7c404 --- /dev/null +++ b/ofdEditor/model/Doc/DocPicture.cpp @@ -0,0 +1,13 @@ +#include "DocPicture.h" + + +DocPicture::DocPicture(QObject *parent) + :DocImage(parent) +{ + +} + +DocPicture::~DocPicture() +{ + +} diff --git a/ofdEditor/model/Doc/DocPicture.h b/ofdEditor/model/Doc/DocPicture.h new file mode 100644 index 0000000000000000000000000000000000000000..dd2fa73a43202d135bebc1ebe940d0dfcd7c709a --- /dev/null +++ b/ofdEditor/model/Doc/DocPicture.h @@ -0,0 +1,19 @@ +#ifndef DOCPICTURE_H +#define DOCPICTURE_H + +#include "model_global.h" // 导出lib使用 +#include "Doc/DocBasicTypes.h" +#include "Doc/DocImage.h" + + +// 这个类应该只用来放图片,所以不需要鼠标光标编辑,直接通过菜单进行编辑 +class MODELSHARED_EXPORT DocPicture + :public DocImage +{ + Q_OBJECT +public: + DocPicture(QObject *parent = Q_NULLPTR); + ~DocPicture(); +}; + +#endif // DOCPICTURE_H diff --git a/ofdEditor/model/Doc/DocTable.cpp b/ofdEditor/model/Doc/DocTable.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cbf53d540c51dca4d6411a39ec0a59325c920835 --- /dev/null +++ b/ofdEditor/model/Doc/DocTable.cpp @@ -0,0 +1,14 @@ +#include "DocTable.h" + + + +DocTable::DocTable(QWidget *parent) + :QTextEdit(parent) +{ + +} + +DocTable::~DocTable() +{ + +} diff --git a/ofdEditor/model/Doc/DocTable.h b/ofdEditor/model/Doc/DocTable.h new file mode 100644 index 0000000000000000000000000000000000000000..9b7e8caed0a3a1b5568eb7c178b199e0646a3b27 --- /dev/null +++ b/ofdEditor/model/Doc/DocTable.h @@ -0,0 +1,24 @@ +#ifndef TABLE_H +#define TABLE_H + +#include "model_global.h" +#include "Doc/DocBasicTypes.h" +#include +#include +#include + + +// 这个类专门用来表示表格 +class MODELSHARED_EXPORT DocTable + :public QTextEdit +{ + Q_OBJECT +public: + DocTable(QWidget *parent = Q_NULLPTR); + ~DocTable(); + +private: + // tableCell的内容估计使用QTextBlock +}; + +#endif // TABLE_H diff --git a/ofdEditor/model/Doc/DocTableCell.cpp b/ofdEditor/model/Doc/DocTableCell.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6d0316e739de53bfb8b9b9c6aa8388cb667237b8 --- /dev/null +++ b/ofdEditor/model/Doc/DocTableCell.cpp @@ -0,0 +1,6 @@ +#include "DocTableCell.h" + +DocTableCell::DocTableCell() +{ + +} diff --git a/ofdEditor/model/Doc/DocTableCell.h b/ofdEditor/model/Doc/DocTableCell.h new file mode 100644 index 0000000000000000000000000000000000000000..dcc4cbbec5ecfd797bdda5af98f42e3bef81f66a --- /dev/null +++ b/ofdEditor/model/Doc/DocTableCell.h @@ -0,0 +1,13 @@ +#ifndef DOCTABLECELL_H +#define DOCTABLECELL_H + +#include "model_global.h" // 导出lib使用 + + +class MODELSHARED_EXPORT DocTableCell +{ +public: + DocTableCell(); +}; + +#endif // DOCTABLECELL_H diff --git a/ofdEditor/model/Doc/DocTableRow.cpp b/ofdEditor/model/Doc/DocTableRow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..80b83549b0b490e8bcb2b2ad488ac854b7d738cc --- /dev/null +++ b/ofdEditor/model/Doc/DocTableRow.cpp @@ -0,0 +1,6 @@ +#include "DocTableRow.h" + +DocTableRow::DocTableRow() +{ + +} diff --git a/ofdEditor/model/Doc/DocTableRow.h b/ofdEditor/model/Doc/DocTableRow.h new file mode 100644 index 0000000000000000000000000000000000000000..90fe403d9f964f3a5d3481365ba04052ea215ebc --- /dev/null +++ b/ofdEditor/model/Doc/DocTableRow.h @@ -0,0 +1,13 @@ +#ifndef DOCTABLEROW_H +#define DOCTABLEROW_H + +#include "model_global.h" // 导出lib使用 + + +class MODELSHARED_EXPORT DocTableRow +{ +public: + DocTableRow(); +}; + +#endif // DOCTABLEROW_H diff --git a/ofdEditor/model/Doc/DocTemplate.cpp b/ofdEditor/model/Doc/DocTemplate.cpp new file mode 100644 index 0000000000000000000000000000000000000000..98ce4e9d255f1a23c1a29101fc9062251e85ab0a --- /dev/null +++ b/ofdEditor/model/Doc/DocTemplate.cpp @@ -0,0 +1,26 @@ +#include "DocTemplate.h" +// #include "DataTypes/page/CT_PageArea.h" // 页面大小 + +DocTemplate::DocTemplate() +{ + +} + +DocTemplate::~DocTemplate() +{ + // area空间释放 + + // 层空间释放 + int layers_length = layers.size(); + for(int i = 0; i < layers_length; i++) + // 挨个释放空间 + { + DocLayer* temp = this->layers.at(i); + if(temp != NULL) + { + delete temp; + (this->layers)[i] = NULL; + } + } + this->layers.clear(); // 清空层 +} diff --git a/ofdEditor/model/Doc/DocTemplate.h b/ofdEditor/model/Doc/DocTemplate.h new file mode 100644 index 0000000000000000000000000000000000000000..feecb497eaa1377fc451d054dc6172c2b980b25a --- /dev/null +++ b/ofdEditor/model/Doc/DocTemplate.h @@ -0,0 +1,24 @@ +#ifndef DOCTEMPLATE_H +#define DOCTEMPLATE_H + +#include "model_global.h" // 导出lib使用 +#include + +// 类声明 +class DocLayer; +class CT_PageArea; + +class MODELSHARED_EXPORT DocTemplate +{ +public: + DocTemplate(); + ~DocTemplate(); +private: + QVector layers; // 模板的层 + + CT_PageArea* area; // 模板的页面大小 + + +}; + +#endif // DOCTEMPLATE_H diff --git a/ofdEditor/model/Doc/DocText.cpp b/ofdEditor/model/Doc/DocText.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2c20643ce594dde491ef43eb509cb5fdd8ae3d96 --- /dev/null +++ b/ofdEditor/model/Doc/DocText.cpp @@ -0,0 +1,6 @@ +#include "DocText.h" + +DocText::DocText() +{ + +} diff --git a/ofdEditor/model/Doc/DocText.h b/ofdEditor/model/Doc/DocText.h new file mode 100644 index 0000000000000000000000000000000000000000..34c6349c85f5aca86ed292c2696ec606f9063f95 --- /dev/null +++ b/ofdEditor/model/Doc/DocText.h @@ -0,0 +1,17 @@ +#ifndef DOCTEXT_H +#define DOCTEXT_H + +#include "model_global.h" // 导出lib使用 +#include + +class DocTextStyle; + +class MODELSHARED_EXPORT DocText +{ +public: + DocText(); + DocTextStyle* style; // 字体样式 + QString content; // 内容 +}; + +#endif // DOCTEXT_H diff --git a/ofdEditor/model/Doc/DocTextBlock.cpp b/ofdEditor/model/Doc/DocTextBlock.cpp new file mode 100644 index 0000000000000000000000000000000000000000..10776ed75138ad50ba4941f7904e394bb5519d4f --- /dev/null +++ b/ofdEditor/model/Doc/DocTextBlock.cpp @@ -0,0 +1,19 @@ +#include "DocTextBlock.h" +#include "Doc/DocParagraph.h" + +#include +#include + +DocTextBlock::DocTextBlock(QWidget *parent) + :QTextEdit(parent) +{ +// QTextCursor cursor(this->textCursor()); +// cursor.insertText(tr("testsesetstsetestes")); + +// this->setBackgroundRole(QPalette::Dark); +} + +DocTextBlock::~DocTextBlock() +{ + +} diff --git a/ofdEditor/model/Doc/DocTextBlock.h b/ofdEditor/model/Doc/DocTextBlock.h new file mode 100644 index 0000000000000000000000000000000000000000..9507dbe949b9f6344e6edc9e9ebce868ef36bec4 --- /dev/null +++ b/ofdEditor/model/Doc/DocTextBlock.h @@ -0,0 +1,25 @@ +#ifndef DOCTEXTBLOCK_H +#define DOCTEXTBLOCK_H + +#include "model_global.h" // 导出lib使用 +#include "Doc/DocBlock.h" +#include +#include +#include + +class DocParagraph; + +class MODELSHARED_EXPORT DocTextBlock + :public QTextEdit +{ + Q_OBJECT +public: + DocTextBlock(QWidget *parent = Q_NULLPTR); + ~DocTextBlock(); + + +private: + +}; + +#endif // DOCTEXTBLOCK_H diff --git a/ofdEditor/model/Doc/DocTextStyle.cpp b/ofdEditor/model/Doc/DocTextStyle.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d18e29b24979a98d0729164e2b329f00355c890a --- /dev/null +++ b/ofdEditor/model/Doc/DocTextStyle.cpp @@ -0,0 +1,6 @@ +#include "DocTextStyle.h" + +DocTextStyle::DocTextStyle() +{ + +} diff --git a/ofdEditor/model/Doc/DocTextStyle.h b/ofdEditor/model/Doc/DocTextStyle.h new file mode 100644 index 0000000000000000000000000000000000000000..7a0886573c4616121c4a68ba2da4d8a3cbaa97a4 --- /dev/null +++ b/ofdEditor/model/Doc/DocTextStyle.h @@ -0,0 +1,13 @@ +#ifndef DOCTEXTSTYLE_H +#define DOCTEXTSTYLE_H + +class DocTextStyle +{ +public: + DocTextStyle(); + +private: + +}; + +#endif // DOCTEXTSTYLE_H diff --git a/ofdEditor/model/DocImage.h b/ofdEditor/model/DocImage.h deleted file mode 100644 index dca8d8703f8e1452157638efa61c1a73886e5568..0000000000000000000000000000000000000000 --- a/ofdEditor/model/DocImage.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef DOCIMAGE_H -#define DOCIMAGE_H - -#include "model_global.h" - -// 本类型用来表述文章中的图片 - -class DocImage -{ -public: - DocImage(); -}; - -#endif // DOCIMAGE_H - diff --git a/ofdEditor/model/DocMainBody.cpp b/ofdEditor/model/DocMainBody.cpp deleted file mode 100644 index 3fd4b8b506e19031b39c7ee11236e7d2b908598c..0000000000000000000000000000000000000000 --- a/ofdEditor/model/DocMainBody.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "DocMainBody.h" - -DocMainBody::DocMainBody() -{ - -} diff --git a/ofdEditor/model/DocMainBody.h b/ofdEditor/model/DocMainBody.h deleted file mode 100644 index 89005fbbf3f2466afd8eace01cc69e52fddc821b..0000000000000000000000000000000000000000 --- a/ofdEditor/model/DocMainBody.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef MAINBODY_H -#define MAINBODY_H - -#include "model_global.h" - -// 本类型用来表述文章的正文部分 - -class MODELSHARED_EXPORT DocMainBody -{ -public: - DocMainBody(); -}; - -#endif // MAINBODY_H diff --git a/ofdEditor/model/DocParagraph.h b/ofdEditor/model/DocParagraph.h deleted file mode 100644 index f6de7e9a9d8bd1a68562eaf4beccdc9bedc2ee72..0000000000000000000000000000000000000000 --- a/ofdEditor/model/DocParagraph.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef PARAGRAPH_H -#define PARAGRAPH_H - -#include "model_global.h" - -class MODELSHARED_EXPORT DocParagraph -{ -public: - DocParagraph(); -}; - -#endif // PARAGRAPH_H diff --git a/ofdEditor/model/DocTable.cpp b/ofdEditor/model/DocTable.cpp deleted file mode 100644 index 92624b8129afdecbb9a213adeac874dc3af89301..0000000000000000000000000000000000000000 --- a/ofdEditor/model/DocTable.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "DocTable.h" - -DocTable::DocTable() -{ - -} diff --git a/ofdEditor/model/DocTable.h b/ofdEditor/model/DocTable.h deleted file mode 100644 index 3c7b3c3851373fd5086ec914c3c6a4d5d58a2752..0000000000000000000000000000000000000000 --- a/ofdEditor/model/DocTable.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef TABLE_H -#define TABLE_H - -#include "model_global.h" - -class MODELSHARED_EXPORT DocTable -{ -public: - DocTable(); -}; - -#endif // TABLE_H diff --git a/ofdEditor/model/Tool/UnitTool.cpp b/ofdEditor/model/Tool/UnitTool.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c6ff99531a4b42dbdff1ffbbfdf270680bc76c3b --- /dev/null +++ b/ofdEditor/model/Tool/UnitTool.cpp @@ -0,0 +1,25 @@ +#include "UnitTool.h" +#include +#include + +UnitTool::UnitTool() +{ + +} + + +/** + * @Author Chaoqun + * @brief 将文件格式中的毫米单位转换为电脑上的像素单位 + * @param double mm + * @return int + * @date 2017/05/01 + */ +int UnitTool::mmToPixel(double mm) +{ + double inch = mm * 0.0393700787; // 转换成英寸 + QScreen* screen = QApplication::primaryScreen(); + double dotsPerInch = screen->physicalDotsPerInch(); // 每英寸多少像素 + + return (int)(inch * dotsPerInch); // 返回像素大小 +} diff --git a/ofdEditor/model/Tool/UnitTool.h b/ofdEditor/model/Tool/UnitTool.h new file mode 100644 index 0000000000000000000000000000000000000000..18cd395186c5cb1bfdc8528e6418e490a07ffe27 --- /dev/null +++ b/ofdEditor/model/Tool/UnitTool.h @@ -0,0 +1,16 @@ +#ifndef UNITTOOL_H +#define UNITTOOL_H + +/** + * @Author Chaoqun + * @brief 预计用来进行单位换算的工具,如毫米和像素之间的转换 + * @date 2017/05/01 + */ +class UnitTool +{ +public: + UnitTool(); + static int mmToPixel(double mm); // 将毫米单位和像素单位进行换算 +}; + +#endif // UNITTOOL_H diff --git a/ofdEditor/model/Widget/PassageWidget.cpp b/ofdEditor/model/Widget/PassageWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..07659a16db374abadd0159288bf1622d3140ad32 --- /dev/null +++ b/ofdEditor/model/Widget/PassageWidget.cpp @@ -0,0 +1,6 @@ +#include "PassageWidget.h" + +PassageWidget::PassageWidget(QWidget *parent) : QWidget(parent) +{ + +} diff --git a/ofdEditor/model/Widget/PassageWidget.h b/ofdEditor/model/Widget/PassageWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..3a93dfca6dc3187bc8b4cae752153c669f853487 --- /dev/null +++ b/ofdEditor/model/Widget/PassageWidget.h @@ -0,0 +1,36 @@ +#ifndef PASSAGEWIDGET_H +#define PASSAGEWIDGET_H + +#include +#include + +class DocPassage; // 文章 + + +/** + * @Author Chaoqun + * @brief 显示文章的widget + * @param 参数 + * @return 返回值 + * @date 2017/05/01 + */ +class PassageWidget + : public QWidget +{ + Q_OBJECT +public: + explicit PassageWidget(QWidget *parent = 0); +private: + DocPassage * passage; // 一篇文章 + QScrollArea * scrollArea; // 滚动条区 + + + + +signals: + +public slots: + +}; + +#endif // PASSAGEWIDGET_H diff --git a/ofdEditor/model/model.pro b/ofdEditor/model/model.pro index 1032e5ed52c8d5362f41a8d551c4a4738978cc85..a9b35e665200b50ae7811a2d2755512e7542e45a 100644 --- a/ofdEditor/model/model.pro +++ b/ofdEditor/model/model.pro @@ -25,25 +25,68 @@ DEFINES += QT_DEPRECATED_WARNINGS #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += model.cpp \ - DocImage.cpp \ - DocMainBody.cpp \ - DocParagraph.cpp \ - DocTable.cpp + Doc/DocBlock.cpp \ + Doc/DocGraph.cpp \ + Doc/DocImage.cpp \ + Doc/DocLayer.cpp \ + Doc/DocPage.cpp \ + Doc/DocParagraph.cpp \ + Doc/DocPassage.cpp \ + Doc/DocPicture.cpp \ + Doc/DocTable.cpp \ + Doc/DocTableCell.cpp \ + Doc/DocTableRow.cpp \ + Doc/DocTemplate.cpp \ + Doc/DocText.cpp \ + Doc/DocTextBlock.cpp \ + Doc/DocDrawParam.cpp \ + Doc/DocParaStyle.cpp \ + Doc/DocTextStyle.cpp \ + Widget/PassageWidget.cpp \ + Tool/UnitTool.cpp HEADERS += model.h\ model_global.h \ - DocImage.h \ - DocMainBody.h \ - DocParagraph.h \ - DocTable.h + Doc/DocBlock.h \ + Doc/DocGraph.h \ + Doc/DocImage.h \ + Doc/DocLayer.h \ + Doc/DocPage.h \ + Doc/DocParagraph.h \ + Doc/DocPassage.h \ + Doc/DocPicture.h \ + Doc/DocTable.h \ + Doc/DocTableCell.h \ + Doc/DocTableRow.h \ + Doc/DocTemplate.h \ + Doc/DocText.h \ + Doc/DocTextBlock.h \ + Doc/DocDrawParam.h \ + Doc/DocBasicTypes.h \ + Doc/DocParaStyle.h \ + Doc/DocTextStyle.h \ + Widget/PassageWidget.h \ + Tool/UnitTool.h DESTDIR = ../bin # 生成文件在这 MOC_DIR = ./moc # Q_OBJECT 类转换后的文件 RCC_DIR = ./rcc # .qrc 文件转换后存放路径 OBJECTS_DIR += ./tmp # .obj 文件存放路径 +INCLUDEPATH += $$PWD/../ofd \ + $$PWD/../model + unix { target.path = /usr/lib INSTALLS += target } + +unix{ + LIBS += ../bin/libofd.so + +} + +win32{ + LIBS += ../bin/ofd.lib +} diff --git a/ofdEditor/ofd/DataTypes/document/CT_DocInfo.cpp b/ofdEditor/ofd/DataTypes/document/CT_DocInfo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..efe24b1524b9caf670647a61318fadf8c8fb5ef8 --- /dev/null +++ b/ofdEditor/ofd/DataTypes/document/CT_DocInfo.cpp @@ -0,0 +1,11 @@ +#include "CT_DocInfo.h" + +CT_DocInfo::CT_DocInfo() +{ + +} + +CT_DocInfo::~CT_DocInfo() +{ + +} diff --git a/ofdEditor/ofd/DataTypes/document/CT_DocInfo.h b/ofdEditor/ofd/DataTypes/document/CT_DocInfo.h index dc3a35922b8059d43a947a6000263500efcef878..4d46b26210aadd3d0725b4ab2218ab959fb57f86 100644 --- a/ofdEditor/ofd/DataTypes/document/CT_DocInfo.h +++ b/ofdEditor/ofd/DataTypes/document/CT_DocInfo.h @@ -5,6 +5,8 @@ #include "../../ofd_global.h" // 生成库文件需要 class OFDSHARED_EXPORT CT_DocInfo { //文档员数据信息 + +public: string doc_id; string title; string author; @@ -18,6 +20,9 @@ class OFDSHARED_EXPORT CT_DocInfo { //文档员数据信息 string creator; //创建文档的应用程序 string creator_version; //创建文档的应用程序的版本信息 //++用户自定义信息 + + CT_DocInfo(); + ~CT_DocInfo(); }; #endif // CT_DOCINFO_H diff --git a/ofdEditor/ofd/Loaders/ZipTool.cpp b/ofdEditor/ofd/Loaders/ZipTool.cpp index e0df798d5cfedac083bd06f4d20c2403f13498f6..a27f1621f715754da5a59b45112c1fa5346ca9b8 100644 --- a/ofdEditor/ofd/Loaders/ZipTool.cpp +++ b/ofdEditor/ofd/Loaders/ZipTool.cpp @@ -1,5 +1,6 @@ #include "ZipTool.h" #include +#include #include "JlCompress.h" // 压缩文件库 @@ -51,7 +52,9 @@ bool ZipTool::compressDir(QString fileCompressed, if(deleteDir == true) { // 如果需要删除源文件夹,比如保存并关闭文件 - QFile* files = new QFile(dir); + //QFile* files = new QFile(dir); + QDir * files = new QDir(dir); + if(!files->exists()) { qDebug("Files don't exist! ", @@ -61,9 +64,79 @@ bool ZipTool::compressDir(QString fileCompressed, } else { - return files->remove(); + //return files->remove(); + ZipTool::deleteFolder(dir); + } + return true; + } +} + +/** + * @Author Chaoqun + * @brief 彻底删除某个文件夹 + * @param const QString &folderFullPath + * @return void + * @date 2017/04/29 + */ +void ZipTool::deleteFolder(const QString &folderFullPath) +{ + QDir dir(folderFullPath); + QFileInfoList fileList; + QFileInfo curFile; + QFileInfoList fileListTemp; + int infoNum; + int i; + int j; + /* 首先获取目标文件夹内所有文件及文件夹信息 */ + fileList=dir.entryInfoList(QDir::Dirs|QDir::Files + |QDir::Readable|QDir::Writable + |QDir::Hidden|QDir::NoDotAndDotDot + ,QDir::Name); + + while(fileList.size() > 0) + { + infoNum = fileList.size(); + + for(i = infoNum - 1; i >= 0; i--) + { + curFile = fileList[i]; + if(curFile.isFile()) /* 如果是文件,删除文件 */ + { + QFile fileTemp(curFile.filePath()); + fileTemp.remove(); + fileList.removeAt(i); + } + + if(curFile.isDir()) /* 如果是文件夹 */ + { + QDir dirTemp(curFile.filePath()); + fileListTemp = dirTemp.entryInfoList(QDir::Dirs | QDir::Files + | QDir::Readable | QDir::Writable + | QDir::Hidden | QDir::NoDotAndDotDot + , QDir::Name); + if(fileListTemp.size() == 0) + /* 下层没有文件或文件夹 则直接删除 */ + { + dirTemp.rmdir("."); + fileList.removeAt(i); + } + else /* 下层有文件夹或文件 则将信息添加到列表 */ + { + for(j = 0; j < fileListTemp.size(); j++) + { + if(!(fileList.contains(fileListTemp[j]))) + { + fileList.append(fileListTemp[j]); + } + } + } + } } } + dir.rmdir("."); + /*删除目标文件夹, + * 如果只是清空文件夹folderFullPath的内容 + * 而不删除folderFullPath本身,则删掉本行即可 */ } diff --git a/ofdEditor/ofd/Loaders/ZipTool.h b/ofdEditor/ofd/Loaders/ZipTool.h index 4651a5af8b5f37e7c649bf2901c9c3961daad445..6b578c0d7c9ca667dd172dec250f114d39526dd6 100644 --- a/ofdEditor/ofd/Loaders/ZipTool.h +++ b/ofdEditor/ofd/Loaders/ZipTool.h @@ -24,6 +24,7 @@ public: static bool compressDir(QString fileCompressed, QString dir,bool deleteDir = false); // 压缩目录 + static void deleteFolder(const QString& folderFullPath); private: ZipTool(); // 不允许实例化 diff --git a/ofdEditor/ofd/ofd.pro b/ofdEditor/ofd/ofd.pro index 00c853fa2eb8793872dbc696c69f36149f654db1..5b32b3abb4d2e9ceec4d7a13df7c8e5cd2e3c21d 100644 --- a/ofdEditor/ofd/ofd.pro +++ b/ofdEditor/ofd/ofd.pro @@ -32,7 +32,8 @@ SOURCES += \ DataTypes/image/CT_Image.cpp \ DataTypes/image/CT_Path.cpp \ DataTypes/page/CT_PageArea.cpp \ - Loaders/ZipTool.cpp + Loaders/ZipTool.cpp \ + DataTypes/document/CT_DocInfo.cpp HEADERS +=\ diff --git a/ofdEditor/ofdEditor.pro b/ofdEditor/ofdEditor.pro index 67a5a6810daefe7613271610d6efc58c2e729d6a..8282a60c167d808156ff48329d695bdd1a937750 100644 --- a/ofdEditor/ofdEditor.pro +++ b/ofdEditor/ofdEditor.pro @@ -9,9 +9,9 @@ TEMPLATE = subdirs # 工程类型,多工程 # 子工程 -SUBDIRS += \ - model \ +SUBDIRS += \ ofd \ + model \ start \ test_chaoqun\ test_pan \ diff --git a/ofdEditor/start/icons.qrc b/ofdEditor/start/icons.qrc new file mode 100644 index 0000000000000000000000000000000000000000..07194af9d25a68899a5e09ccebf3be25256eebf1 --- /dev/null +++ b/ofdEditor/start/icons.qrc @@ -0,0 +1,3 @@ + + + diff --git a/ofdEditor/start/main.cpp b/ofdEditor/start/main.cpp index b48f94ec827033ef073fb3c7f060837e90b935ec..7b735802b1e081c8fc0335c5c6f9de0eac83f1d8 100644 --- a/ofdEditor/start/main.cpp +++ b/ofdEditor/start/main.cpp @@ -1,10 +1,11 @@ #include "mainwindow.h" #include +#include "ui/PassageMainWindow.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); - MainWindow w; + PassageMainWindow w; w.show(); return a.exec(); diff --git a/ofdEditor/start/start.pro b/ofdEditor/start/start.pro index 84365b0d2d064e0a84c0d5a560bfbd483a2d918e..df63f7546d8582dc8337c733f0cce5b374859f7d 100644 --- a/ofdEditor/start/start.pro +++ b/ofdEditor/start/start.pro @@ -26,9 +26,11 @@ DEFINES += QT_DEPRECATED_WARNINGS SOURCES += main.cpp\ - mainwindow.cpp + mainwindow.cpp \ + ui/PassageMainWindow.cpp -HEADERS += mainwindow.h +HEADERS += mainwindow.h \ + ui/PassageMainWindow.h DESTDIR = ../bin # 生成文件在这 MOC_DIR = ./moc # Q_OBJECT 类转换后的文件 @@ -50,3 +52,6 @@ win32{ LIBS += ../bin/model.lib \ ../bin/ofd.lib } + +RESOURCES += \ + icons.qrc diff --git a/ofdEditor/start/ui/PassageMainWindow.cpp b/ofdEditor/start/ui/PassageMainWindow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b02b4f34a235708a97794b25ed21465a15071189 --- /dev/null +++ b/ofdEditor/start/ui/PassageMainWindow.cpp @@ -0,0 +1,240 @@ +#include "PassageMainWindow.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "Doc/DocPassage.h" + +PassageMainWindow::PassageMainWindow(QWidget *parent) + :QMainWindow(parent) +{ + init(); +} + +PassageMainWindow::~PassageMainWindow() +{ + +} + +/** + * @Author Chaoqun + * @brief 摘要 + * @param 参数 + * @return 返回值 + * @date 2017/05/13 + */ +DocPassage *PassageMainWindow::createMdiChild() +{ + DocPassage * child = new DocPassage; + this->area->addSubWindow(child); + child->setVisible(true); // 设置可见 + return NULL; +} + +/** + * @Author Chaoqun + * @brief 初始化窗口 + * @param void + * @return void + * @date 2017/05/13 + */ +void PassageMainWindow::init() +{ + this->area = new QMdiArea(); + this->setCentralWidget(this->area); + + initAction(); + connectAction(); + + QLabel * status = new QLabel(); + this->statusBar()->addWidget(status); + + this->setMinimumSize(960,720); + this->setBackgroundRole(QPalette::Text); + +} + +/** + * @Author Chaoqun + * @brief 初始化动作 + * @param 参数 + * @return 返回值 + * @date 2017/05/13 + */ +void PassageMainWindow::initAction() +{ + this->newFileAction = new QAction(tr("New File")); // 新建文件 + this->newFileAction->setStatusTip(tr("Create a new ofd file")); + this->newFileAction->setShortcut(QKeySequence::New); + + this->openFileAtcion = new QAction(tr("Open File")); // 打开文件 + this->openFileAtcion->setStatusTip(tr("Open an existing ofd file")); + this->openFileAtcion->setShortcut(QKeySequence::Open); + + this->saveAction = new QAction(tr("Save")); // 保存 + this->saveAction->setStatusTip(tr("Save file")); + this->saveAction->setShortcut(QKeySequence::Save); + + this->saveAsAction = new QAction(tr("Save as")); // 另存为 + this->saveAsAction->setStatusTip(tr("Save as")); + this->saveAsAction->setShortcut(QKeySequence::SaveAs); + + this->printAction = new QAction(tr("Print")); // 打印 + this->printAction->setStatusTip(tr("Print your document")); + + this->undoAction = new QAction(tr("Undo")); // 撤销操作 + this->undoAction->setStatusTip(tr("Undo your last action")); + this->undoAction->setShortcut(QKeySequence::Undo); + + this->redoAction = new QAction(tr("Redo")); // 重新操作 + this->redoAction->setStatusTip(tr("Redo the action you undo")); + this->redoAction->setShortcut(QKeySequence::Redo); + + this->copyAction = new QAction(tr("Copy")); // 复制文本 + this->copyAction->setStatusTip(tr("Copy the content you selected")); + this->copyAction->setShortcut(QKeySequence::Copy); + + this->cutAction = new QAction(tr("Cut")); // 剪切 + this->cutAction->setStatusTip(tr("Cut the content you selected")); + this->cutAction->setShortcut(QKeySequence::Cut); + + this->pasteAction = new QAction(tr("Paste")); // 粘贴 + this->pasteAction->setStatusTip(tr("Paste your pasteboard content")); + this->pasteAction->setShortcut(QKeySequence::Paste); + + this->insertTextBlockAction = new QAction("Insert TextBlock"); // 插入文本框 + this->insertTextBlockAction->setStatusTip(tr("Insert a new TextBlock")); + + this->insertImageAction = new QAction("Insert Image"); // 插入图片 + this->insertImageAction->setStatusTip(tr("Insert a image")); + + this->insertTableAction = new QAction("Insert Table"); // 插入一个表格 + this->insertTableAction->setStatusTip(tr("Insert a table")); + + this->textFormat = new QAction(tr("Text Format")); // 文字格式 + this->textFormat->setStatusTip(tr("Set the selected texts' Format")); + + this->paragraphFormat = new QAction(tr("Paragraph Format")); // 段落格式 + this->paragraphFormat->setStatusTip(tr("Set this paragarph format")); + + this->imageFormat = new QAction(tr("Image Format")); // 图片格式 + this->imageFormat->setStatusTip(tr("Set the Selected image's format")); + + this->tableFormat = new QAction(tr("Table Format")); // 表格格式 + this->tableFormat->setStatusTip(tr("Set the selected table's format")); + + this->aboutQtAction = new QAction(tr("about Qt")); // 关于QT + + this->aboutAppAction = new QAction(tr("About App")); // 关于本应用 + this->aboutAppAction->setStatusTip(tr("About this Application")); + + this->helpAciton = new QAction(tr("Help")); + this->helpAciton->setStatusTip(tr("Show the help Window")); + + this->filesMenu = this->menuBar()->addMenu(tr("Files")); + this->editMenu = this->menuBar()->addMenu(tr("Edit")); + this->formatMenu = this->menuBar()->addMenu(tr("Format")); + this->insertMenu = this->menuBar()->addMenu(tr("Insert")); + this->aboutMenu = this->menuBar()->addMenu(tr("About")); + + this->filesMenu->addAction(this->newFileAction); + this->filesMenu->addAction(this->openFileAtcion); + this->filesMenu->addAction(this->saveAction); + this->filesMenu->addAction(this->saveAsAction); + this->filesMenu->addAction(this->printAction); + + this->editMenu->addAction(this->undoAction); + this->editMenu->addAction(this->redoAction); + this->editMenu->addSeparator(); // 分割线 + this->editMenu->addAction(this->copyAction); + this->editMenu->addAction(this->cutAction); + this->editMenu->addAction(this->pasteAction); + + this->formatMenu->addAction(this->textFormat); + this->formatMenu->addAction(this->paragraphFormat); + this->formatMenu->addAction(this->imageFormat); + this->formatMenu->addAction(this->tableFormat); + + this->insertMenu->addAction(this->insertTextBlockAction); + this->insertMenu->addAction(this->insertImageAction); + this->insertMenu->addAction(this->insertTableAction); + + this->aboutMenu->addAction(this->aboutQtAction); + this->aboutMenu->addAction(this->aboutAppAction); + this->aboutMenu->addAction(this->helpAciton); +/*---------------------------------------------------------------------*/ + this->file_toolBar = this->addToolBar(tr("File")); + this->edit_toolBar = this->addToolBar(tr("Edit")); + this->format_toolBar = this->addToolBar(tr("Format")); + this->insert_toolBar = this->addToolBar(tr("Insert")); + + this->file_toolBar->addAction(this->newFileAction); + this->file_toolBar->addAction(this->openFileAtcion); + this->file_toolBar->addAction(this->saveAction); + + this->edit_toolBar->addAction(this->undoAction); + this->edit_toolBar->addAction(this->redoAction); + + this->format_toolBar->addAction(this->textFormat); + this->format_toolBar->addAction(this->paragraphFormat); + this->format_toolBar->addAction(this->imageFormat); + this->format_toolBar->addAction(this->tableFormat); + + this->insert_toolBar->addAction(this->insertTextBlockAction); + this->insert_toolBar->addAction(this->insertImageAction); + this->insert_toolBar->addAction(this->insertTableAction); + +} + +/** + * @Author Chaoqun + * @brief 为QActions链接响应事件 + * @param 参数 + * @return 返回值 + * @date 2017/05/13 + */ +void PassageMainWindow::connectAction() +{ + connect(this->newFileAction, &QAction::triggered, + this,&PassageMainWindow::createMdiChild); // 新建窗口 +} + +/** + * @Author Chaoqun + * @brief 解除QAction的所有事件响应 + * @param void + * @return 返回值 + * @date 2017/05/13 + */ +void PassageMainWindow::disconnectAction() +{ + +} + +/** + * @Author Chaoqun + * @brief 获取激活的窗口 + * @param void + * @return DocPassage * + * @date 2017/05/13 + */ +DocPassage *PassageMainWindow::activeMdiChild() +{ + if (QMdiSubWindow *activeSubWindow = this->area->activeSubWindow()) + return qobject_cast(activeSubWindow->widget()); + return 0; +} diff --git a/ofdEditor/start/ui/PassageMainWindow.h b/ofdEditor/start/ui/PassageMainWindow.h new file mode 100644 index 0000000000000000000000000000000000000000..1babeee33820f52f90b2617b64ce5fc4e0c4ac6c --- /dev/null +++ b/ofdEditor/start/ui/PassageMainWindow.h @@ -0,0 +1,84 @@ +#ifndef PASSAGEMAINWINDOW_H +#define PASSAGEMAINWINDOW_H + +#include +#include +#include + +class QAction; +class QMenu; +class QMdiArea; +class DocPassage; + +// 编辑窗口的主界面 +class PassageMainWindow + :public QMainWindow +{ + Q_OBJECT +public: + explicit PassageMainWindow(QWidget *parent = 0); + ~PassageMainWindow(); + + DocPassage *createMdiChild(); + +private: + + // 菜单栏 + QMenu * filesMenu; // 文件 + QMenu * editMenu; // 编辑 + QMenu * formatMenu; // 格式 + QMenu * insertMenu; // 插入 + QMenu * aboutMenu; // 关于 + + QToolBar* file_toolBar; // 文件 + QToolBar* edit_toolBar; // 编辑 + QToolBar* format_toolBar; // 格式 + QToolBar* insert_toolBar; // 插入 + + + // QAction + // 文件 + QAction * newFileAction; // 新建文件 + QAction * openFileAtcion; // 打开文件 + QAction * saveAction; // 保存 + QAction * saveAsAction; // 另存为 + QAction * printAction; // 打印 + + // 编辑 + QAction * undoAction; // 撤销 + QAction * redoAction; // 恢复操作 + QAction * copyAction; // 复制 + QAction * cutAction; // 剪切 + QAction * pasteAction; // 粘贴 + + // 插入 + QAction * insertTextBlockAction; // 插入文本框 + QAction * insertImageAction; // 插入图片 + QAction * insertTableAction; // 插入表格 + + // 格式 + QAction * textFormat; // 文字格式调整 + QAction * paragraphFormat; // 段落格式调整 + QAction * imageFormat; // 图形格式调整 + QAction * tableFormat; // 表格格式调整 + + // 关于 + QAction * aboutQtAction; // 关于Qt + QAction * aboutAppAction; // 关于本工程的介绍 + QAction * helpAciton; // 帮助文档,如何使用本软件 + + QMdiArea * area; // 多窗口区域 + + + void init(); // 初始化 + void initAction(); // 初始化QAction + void connectAction(); // 链接QAction的相应事件 + void disconnectAction(); // 断开事件响应 + + DocPassage *activeMdiChild(); + + + +}; + +#endif // PASSAGEMAINWINDOW_H diff --git a/ofdEditor/test_chaoqun/PassageMainWindow.cpp b/ofdEditor/test_chaoqun/PassageMainWindow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4db97a93176e18fdbdbe6f9a4455b8857eec0bfc --- /dev/null +++ b/ofdEditor/test_chaoqun/PassageMainWindow.cpp @@ -0,0 +1,55 @@ +#include "PassageMainWindow.h" +#include "Doc/DocPassage.h" +#include "Doc/DocPage.h" + +#include + +#include + +PassageMainWindow::PassageMainWindow(QWidget *parent) : QMainWindow(parent) +{ + + this->setBackgroundRole(QPalette::Button); + +} + +PassageMainWindow::~PassageMainWindow() +{ + +} + +/** + * @Author Chaoqun + * @brief 设置页面中的文章 + * @date 2017/05/01 + */ +void PassageMainWindow::setPassage(DocPassage *passage) +{ + this->passage = passage; + this->setCentralWidget(this->passage); + +} + +/** + * @Author Chaoqun + * @brief 摘要 + * @param DocPage + * @return void + * @date 2017/05/01 + */ +void PassageMainWindow::addPage(DocPage *page) +{ + this->passage->addPage(page); +} + +void PassageMainWindow::resizeEvent(QResizeEvent *event) +{ + if(this->passage != NULL) + { + this->passage->resize(event->size().width(), + event->size().height()); + qDebug() << "MainWindow:resize"; + } + + +} diff --git a/ofdEditor/test_chaoqun/PassageMainWindow.h b/ofdEditor/test_chaoqun/PassageMainWindow.h new file mode 100644 index 0000000000000000000000000000000000000000..82b8a10e096649af19f10cc71fc04da3947ea739 --- /dev/null +++ b/ofdEditor/test_chaoqun/PassageMainWindow.h @@ -0,0 +1,30 @@ +#ifndef PASSAGEMAINWINDOW_H +#define PASSAGEMAINWINDOW_H + +#include +#include + +class DocPassage; // 文档类型 +class DocPage; // 文档中的某一页 + +class PassageMainWindow : public QMainWindow +{ + Q_OBJECT +public: + explicit PassageMainWindow(QWidget *parent = 0); + ~PassageMainWindow(); + void setPassage(DocPassage *passage); + void addPage(DocPage* page); +signals: + +public slots: + +private: + DocPassage* passage; // 文章 + +protected: + void resizeEvent(QResizeEvent *event); + +}; + +#endif // PASSAGEMAINWINDOW_H diff --git a/ofdEditor/test_chaoqun/main.cpp b/ofdEditor/test_chaoqun/main.cpp index dac3ecc706303c9eb2090a95f58dcfc4977e4631..716adadda6bc7a5351e1b6daaa0cca43ea421c36 100644 --- a/ofdEditor/test_chaoqun/main.cpp +++ b/ofdEditor/test_chaoqun/main.cpp @@ -1,11 +1,54 @@ #include "mainwindow.h" +#include "PassageMainWindow.h" #include +#include "Doc/DocPassage.h" +#include "Doc/DocPage.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Doc/DocTextBlock.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); - MainWindow w; +// MainWindow w; +// w.show(); + PassageMainWindow w; + w.setMinimumSize(1000,800); +// w.setMinimumSize(QApplication::primaryScreen()->size().width(), +// QApplication::primaryScreen()->size().height()); +// w.showMaximized(); + + + DocPage* page1 = new DocPage(210,297,1,&w); + DocPage* page2 = new DocPage(210,297,1,&w); + + DocPassage * pas = new DocPassage(); + pas->addPage(page1); + pas->addPage(page2); + + w.setPassage(pas); + + DocTextBlock * textBlock = new DocTextBlock(); + + DocBlock * block = new DocBlock(); + + block->setWidget(textBlock); + block->setPos(0,0); + block->resize(400,300); + block->setVisible(true); + block->setZValue(100); + + page1->addBlock(block, DocPage::Foreground); + //page1->addBlock(new DocTextBlock(page1),DocPage::Body); + w.show(); return a.exec(); diff --git a/ofdEditor/test_chaoqun/mainwindow.cpp b/ofdEditor/test_chaoqun/mainwindow.cpp index a7c1fca181757646b5fb81957bc030c0cdcf2f03..4df4c8807de2175a6dc7fbe8af0957ded8e49bc9 100644 --- a/ofdEditor/test_chaoqun/mainwindow.cpp +++ b/ofdEditor/test_chaoqun/mainwindow.cpp @@ -108,7 +108,7 @@ void MainWindow::compressDir() ZipTool::compressDir( QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/test.ofd", - this->file); + this->file, true); } void MainWindow::extractDir() diff --git a/ofdEditor/test_chaoqun/test_chaoqun.pro b/ofdEditor/test_chaoqun/test_chaoqun.pro index 7c4690440dd773eac043be8ea8182478f583a684..f1fa458460972ec240b36fcb233bee610a22f225 100644 --- a/ofdEditor/test_chaoqun/test_chaoqun.pro +++ b/ofdEditor/test_chaoqun/test_chaoqun.pro @@ -24,9 +24,11 @@ DEFINES += QT_DEPRECATED_WARNINGS SOURCES += main.cpp\ - mainwindow.cpp + mainwindow.cpp \ + PassageMainWindow.cpp -HEADERS += mainwindow.h +HEADERS += mainwindow.h \ + PassageMainWindow.h DESTDIR = ../bin # 生成文件在这 MOC_DIR = ./moc # Q_OBJECT 类转换后的文件