174 lines
6.3 KiB
C++
174 lines
6.3 KiB
C++
#ifndef CCSCALCULATE_H
|
||
#define CCSCALCULATE_H
|
||
#include "ccspageinterface.h"
|
||
#include "ccsrendertablecell.h"
|
||
#include "ccsreport.h"
|
||
#include "QtMath"
|
||
#include "ccsrendertable.h"
|
||
namespace CCS_Report {
|
||
|
||
class CCSRenderTableInfo :public QObject
|
||
{
|
||
Q_OBJECT
|
||
public:
|
||
int m_Row;
|
||
int m_Col;
|
||
QList<qreal> rowheight;//标识每行的最大行高
|
||
CCSRenderTable* m_ptrTable;
|
||
QMap<int,QMap<int,CCSRenderTableCell*>> mapinfos;
|
||
public:
|
||
CCSRenderTableInfo()
|
||
{
|
||
m_Row = 0;
|
||
m_Col = 0;
|
||
m_ptrTable = nullptr;
|
||
mapinfos.clear();
|
||
}
|
||
CCSRenderTableInfo(int row,int col,CCSRenderTable* table)
|
||
{
|
||
m_Row = row;
|
||
m_Col = col;
|
||
m_ptrTable = table;
|
||
|
||
for (int j = 0; j < row; j++){
|
||
QMap<int,CCSRenderTableCell*> mapinfo;
|
||
for (int k = 0; k< col; k++)
|
||
{
|
||
CCSRenderTableCell* info = new CCSRenderTableCell();
|
||
mapinfo.insert(k,info);
|
||
}
|
||
mapinfos.insert(j,mapinfo);
|
||
}
|
||
}
|
||
|
||
CCSRenderTableInfo(CCSRenderTableInfo* info)
|
||
{
|
||
m_Row = info->m_Row;
|
||
m_Col = info->m_Col;
|
||
m_ptrTable = info->m_ptrTable;
|
||
foreach (qreal h, info->rowheight) {
|
||
rowheight.append(h);
|
||
}
|
||
QMap<int,QMap<int,CCSRenderTableCell*>>::iterator iter = info->mapinfos.begin();
|
||
while (iter != info->mapinfos.end())
|
||
{
|
||
QMap<int,CCSRenderTableCell*>::iterator iter1 = iter.value().begin();
|
||
QMap<int,CCSRenderTableCell*> mapTableinfo;
|
||
while (iter1 != iter.value().end()) {
|
||
CCSRenderTableCell* info1 = new CCSRenderTableCell(iter1.value());
|
||
mapTableinfo.insert(iter1.key(),info1);
|
||
iter1++;
|
||
}
|
||
mapinfos.insert(iter.key(),mapTableinfo);
|
||
iter++;
|
||
}
|
||
}
|
||
|
||
~CCSRenderTableInfo()
|
||
{
|
||
for (int i = 0; i < m_Row; i++){
|
||
for (int j = 0; j< m_Col; j++)
|
||
{
|
||
if (mapinfos[i][j] != nullptr)
|
||
{
|
||
//delete mapinfos[i][j];
|
||
//mapinfos[i][j] = nullptr;
|
||
}
|
||
}
|
||
}
|
||
mapinfos.clear();
|
||
}
|
||
/// <summary>
|
||
/// 浅拷贝,共用RenderTableCell
|
||
/// </summary>
|
||
CCSRenderTableInfo* ShallowCopy(CCSRenderTable* pParentTable = nullptr);
|
||
/// <summary>
|
||
/// 深拷贝
|
||
/// </summary>
|
||
/// <param name="pParentTable"></param>
|
||
/// <returns></returns>
|
||
CCSRenderTableInfo* DeepCopy(CCSRenderTable* pParentTable = nullptr);
|
||
CCSRenderTableCell* GetTableInfo(int row, int col);
|
||
|
||
void SetRowCellYPos(int row, qreal currentY);
|
||
|
||
void SetTableInfoCellHeight(int fromRow = 0);
|
||
/*
|
||
*找非跨行的表格,计算高度,根据结果然后调整同一行的高度
|
||
*/
|
||
void SetCellRowHeight(int fromRow = 0);
|
||
/*
|
||
*找跨行的表格,计算高度,根据结果然后调整同一行的高度
|
||
*/
|
||
void SetCellSpanRowHeight(int fromRow = 0);
|
||
//设置每行得高度
|
||
void SetRowHeight(int fromRow = 0);
|
||
/// <summary
|
||
////返回当前的页 和 currentY位置
|
||
///
|
||
/// </summary>
|
||
/// <param name="page">当前页</param>
|
||
/// <param name="currentY">当前页的位置</param>
|
||
/// <param name="bHeader"></param>
|
||
/// <param name="mapelmentinfo"></param>
|
||
/// <param name="iNum"></param>
|
||
/// <param name="pPageTable"></param>
|
||
/// <returns>当前页</returns>
|
||
CCSPageInterface* CalculatePostion(CCSPageInterface* page, qreal& currentY,
|
||
bool bHeader, QMap<int, CCSRenderTableInfo*> mapelmentinfo, int iNum, CCSPageRenderTable*& pPageTable);
|
||
|
||
CCSPageInterface* CalculatePostion(CCSPageInterface* page, qreal& currentY, CCSPageRenderTable*& pPageTable);
|
||
|
||
|
||
|
||
//判断此行是否有图片,如果有返回图片的高度
|
||
int GetPictureRow(int rowcount, qreal startY, qreal endY, qreal& maxHeight);
|
||
|
||
//在index处插入tableinfo,后续的往后移动
|
||
void MoveTableInfo(QMap<int, CCSRenderTableCell*>& listInfo, int index);
|
||
|
||
void HandleFooter(CCS_Report::CCSPageInterface* page, qreal& currentY);
|
||
void HandleHeader(CCS_Report::CCSPageInterface* page, qreal& currentY);
|
||
|
||
void SetHeaderFooterInfo(CCSPageInterface* page, int index, qreal Y);
|
||
/// <summary>
|
||
/// 判断行是否需要拆分,如果拆分,进行拆分处理
|
||
/// </summary>
|
||
/// <param name="first">当前行</param>
|
||
/// <param name="startY">页开始位置</param>
|
||
/// <param name="endY">页结束位置</param>
|
||
/// <param name="currentY">当前位置</param>
|
||
/// <param name="splitheight"></param>
|
||
/// <param name="rtn">=0 无拆分 =1 有拆分 = 2 带图片的强制分页 =3 是表头在跨页处,返回,进行换页后处理</param>
|
||
/// <param name="bHeader"></param>
|
||
/// <param name="qHeightHeader"></param>
|
||
/// <returns></returns>
|
||
QMap<int, CCSRenderTableCell*> SplitTable(int& first, qreal startY, qreal endY, qreal& currentY, qreal& splitheight, int& rtn, bool bHeader, qreal qHeightHeader);
|
||
|
||
|
||
bool FindUpCell(int& rowindex, qreal& height, int colindex);
|
||
|
||
bool JudgeBlandRow(int row);
|
||
|
||
//void InsertNewRow(int& row,qreal& currentY,qreal h,qreal endY,qreal newrowH,QMap<int,CCSRenderTableCell*>& mapInfo,bool bHasValue)
|
||
void InsertNewRow(int& row, qreal endY, qreal newrowH, QMap<int, CCSRenderTableCell*>& mapInfo, bool bHasValue);
|
||
|
||
CCS_Report::CCSPageInterface* AllocCellToPage(QList<int> listPageindex, CCS_Report::CCSPageInterface* page,
|
||
CCS_Report::CCSPageInterface* currentpage,
|
||
qreal& startY, QMap<int, CCSRenderTableInfo*> mapelmentinfo, int iNum, CCSPageRenderTable*& pPageTable);
|
||
//判断动态列的列头是否跨页 true 跨页
|
||
bool IfHeaderCrossPage(int first, qreal currentY, qreal endY);
|
||
//判断是否需要换页
|
||
bool IfNewPage(int first, qreal endY, qreal currentY);
|
||
qreal GetTableInfosHeight(QMap<int, CCSRenderTableInfo*> mapelmentinfo, int iIndex = -1);
|
||
|
||
void UpdateRenderCell(int row, int col, qreal width, qreal left, Qt::Alignment alignflag, int frame, int before, int after, int space,
|
||
QMap<int, QList<SCellText*>> cellContent, QList < int > iLineHeightList);
|
||
|
||
void CopyTableRows(int iBeginRowNumber, int iEndRowNumber, CCSRenderTableInfo* pInfos);
|
||
|
||
void MergeCell(int iJumpRows, int iBreakRows, int repeatcolCount);
|
||
};
|
||
}
|
||
#endif // CCSCALCULATE_H
|