COMPASSi/trunk/code/3rd/CCSReport_2/include/translation/ccsrendertablecell.h

210 lines
7.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef CCSRENDERTABLECELL_H
#define CCSRENDERTABLECELL_H
#include "QColor"
#include "QFont"
#include "qglobal.h"
#include "QObject"
#include "baseGraphicDefinition.h"
#include "common_types.h"
namespace CCS_Report {
class CCSRenderTableCell:public QObject
{
Q_OBJECT
public:
int m_iRowIndex =0;
int m_iColIndex =0;
int m_iRowspan =1;
int m_iColspan =1;
qreal m_x = 0; //以像素为单位\在报告中的起始X位置. 坐标原点在左上角X'轴往右正向Y轴向下为正
qreal m_y = 0; //以像素为单位,在报告中的起始Y位置 坐标原点在左上角X'轴往右正向Y轴向下为正
qreal m_width = 0; //以像素为单位
qreal m_height = 0;//以像素为单位
bool m_bBreak = false; //是否折行
int m_iFrame = 0; //是否有边框 =0 无 =1 有
int m_paddingtop = 0; //单元格边距
int m_paddingbottom = 0;
int m_distancebefore=0;
int m_distanceafter=0;
int m_linespace=0;
qreal m_angle = 0;
QString m_strIdentify = ""; //段落标识,用于查找段落所在的页
QColor m_background = QColor(255,255,255); //单元格背景色
CCSCellFlag::CellFlag m_eCellFlag= CCSCellFlag::Nothing; //标识属于跨行跨列的空Cell =0 标识是个具体内容的单元格 =-1 是空的单元格
CCSCellFlag::CellContentFlag m_iCellType = CCSCellFlag::Text; // =0 文本 =1 图片 = 2 SVG格式图片
Qt::Alignment m_Align = Qt::AlignCenter; //
QList<int> m_lineheight; //单元格内容的每行高度,用于后续的分页和输出高度的计算
QMap<int,QList<SCellText*>> m_mapTextInfo;
public:
CCSRenderTableCell();
CCSRenderTableCell(CCSRenderTableCell* info);
~CCSRenderTableCell();
// int distancebefore() const {return m_distancebefore;}
// void SetDistanceBefore(const int& before){m_distancebefore = before;}
// int distanceafter() const {return m_distanceafter;}
// void SetDistanceAfter(const int& after){m_distanceafter = after;}
// int linespace() const {return m_linespace;}
// void SetLineSpace(const int& space){m_linespace = space;}
qreal x() const{return m_x;}
qreal y() const {return m_y;}
qreal width() const{return m_width;}
qreal height() const{return m_height;}
QColor background() const{return m_background;}
int align() const{return m_Align;}
qreal angle() const { return m_angle; }
void SetAngle(const qreal& value) { m_angle = value; }
void SetX(const qreal &x){m_x=x;}
void SetY(const qreal &y){m_y=y;}
void SetWidth(const qreal &w){m_width=w;}
void SetHeight(const qreal &h){m_height=h;}
void SetAddHeight(const qreal &addH){m_height +=addH;}
void SetBackground(const QColor &color){m_background=color;}
void SetCellType(const CCSCellFlag::CellContentFlag&flag){m_iCellType = flag;}
void SetFrame(const int &frame){m_iFrame = frame;}
void SetAlign(const Qt::Alignment algin){m_Align = algin;}
inline bool breakflag()
{
return m_bBreak;
}
inline void SetBreakFlag(bool bFlag)
{
m_bBreak = bFlag;
}
inline void SetRowSpan(int span) {m_iRowspan = span;}
inline int rowspan(){return m_iRowspan;}
inline void SetColSpan(int span) {m_iColspan = span;}
inline int colspan(){return m_iColspan;}
// int rowindex() const {return m_RowIndex;}
// int colindex() const {return m_ColIndex;}
// void SetRowIndex(const int & index){m_RowIndex = index;}
// void SetColIndex(const int & index){m_ColIndex = index;}
CCSCellFlag::CellContentFlag celltype() const {return m_iCellType;}
void SetIdentify(const QString& identify){m_strIdentify = identify;}
QString identify() const {return m_strIdentify;}
void SetConstName(QString strName="CONST");
void SetFrame(CCSFrame::FrameFlags frame);
void SetName(QString& name) {this->setObjectName(name);}
void setCellFlag(CCSCellFlag::CellFlag flag)
{
m_eCellFlag = flag;
}
QMap<int,QList<SCellText*>> mapTextInfo() {return m_mapTextInfo;}
inline qreal totaltextheight()
{
qreal totalH = 0;
foreach (qreal h, m_lineheight) {
totalH += h;
}
return totalH;
}
QList<int> lineheight(){ return m_lineheight;}
void SetLineHeight(QList<int> heights)
{
foreach (int height, heights) {
m_lineheight.append(height);
}
}
void SetLineHeight(int heights)
{
m_lineheight.append(heights);
}
void AddText(SCellText* text)
{
QList<int> keys = m_mapTextInfo.keys();
if (keys.count()> 0)
{
m_mapTextInfo[keys[0]].append(text);
}else
{
QList<SCellText*> listtext;
listtext.append(text);
m_mapTextInfo.insert(0,listtext);
}
}
void AddText(int row,QList<SCellText*> texts)
{
QList<int> keys = m_mapTextInfo.keys();
if (keys.contains(row))
{
m_mapTextInfo[row].append(texts);
}else{
m_mapTextInfo.insert(row,texts);
}
}
void AddText(QMap<int,QList<SCellText*>> texts)
{
m_mapTextInfo = texts;
}
void AddNewText(QMap<int, QList<SCellText*>> texts)
{
for (int i = 0; i < texts.count(); i++)
{
QList<SCellText*> newText;
QList<SCellText*> text = texts[i];
for (int j = 0; j < text.count(); j++)
{
SCellText* newCellText = new SCellText();
newCellText->CopyBy(text.at(j));
newText.append(newCellText);
}
m_mapTextInfo.insert(i, newText);
}
}
void DeleteText(int row);
void DeleteAllText();
void GetMaxHeight(qreal& max)
{
; if ((m_eCellFlag == CCSCellFlag::Normal) && ((m_iRowspan == 1)))
{
qreal tempHeight = GetCalculateFormateHeight();
max = (max<tempHeight)?tempHeight:max;
}
}
inline qreal GetCalculateFormateHeight()
{
int count = m_lineheight.count();
qreal qHeight = totaltextheight();
qreal calheight = qHeight+m_paddingbottom+m_paddingtop+count*m_linespace+m_distanceafter+m_distancebefore;
return calheight;
}
// 返回:=0 无分割 >0 在第几行进行分割 pageHeight 页剩余高度
int GetSplitRowIndex(qreal pageHeight);
CCSRenderTableCell* SplitCell(int realrow, int row, qreal h);
//图片高度小于跨行高度拆分上下两个单元格图片在原来的tableinfo中新的没有
CCSRenderTableCell* SplitImageCell(int realrow, int row, qreal h);
CCSRenderTableCell* SplitTextCell(int realrow, int row, qreal remainHeight);
CCSRenderTableCell* SplitTextCellInfo(int index, qreal splitY);
void SetCellInfo(int rowspan, int colspan, qreal colwidth,
qreal xPos, QColor backColor, Qt::Alignment align, int frame, int before = 0, int after = 0, int space = 0);
CCSRenderTableCell* Copy(bool bTextCopyFlag = false);
bool JudgeFrame(int frame,int iPos);
CCSRenderTableCell * clone(bool bTextFlag=true);
void CellClear();
void UpdateText(QList<QPair<QString,QString>> content);
void Draw(QPainter* paint,int iType=0);
void UpdateCell(CCSRenderTableCell* info);
protected:
};
}
#endif // CCSDATACELL_H