163 lines
5.2 KiB
C++
163 lines
5.2 KiB
C++
#ifndef CCSTABLE_H
|
||
#define CCSTABLE_H
|
||
#include "ccstableinterface.h"
|
||
#include "qglobal.h"
|
||
#include <QList>
|
||
#include "ccsreport_global.h"
|
||
|
||
namespace CCS_Report {
|
||
class CCSBaseItemInterface;
|
||
class CCSTableInterface;
|
||
class CCSColumnHeader;
|
||
class CCSTablePrivate;
|
||
class CCSText;
|
||
class CCSColumn;
|
||
class CCSCell;
|
||
class CCSParagraph;
|
||
class SCellText;
|
||
//class CCSPageInterface;
|
||
|
||
class CCS_COMPASSREPORT_EXPORT CCSTable:public CCSTableInterface
|
||
{
|
||
Q_OBJECT
|
||
Q_PROPERTY(int tablewidth READ tablewidth WRITE SetTablewidth)
|
||
Q_PROPERTY(int height READ height WRITE SetHeight)
|
||
Q_PROPERTY(int rownum READ rownum WRITE SetRownum)
|
||
Q_PROPERTY(int colnum READ colnum WRITE SetColnum)
|
||
Q_PROPERTY(int marginleft READ marginleft WRITE SetMarginLeft)
|
||
Q_PROPERTY(int marginright READ marginright WRITE SetMarginRight)
|
||
Q_PROPERTY(bool newpage READ newpage WRITE SetNewPage)
|
||
Q_PROPERTY(int orientation READ orientation WRITE SetOrientation)
|
||
Q_PROPERTY(qreal padding READ padding WRITE SetPadding)
|
||
|
||
public:
|
||
CCSTable(QObject * parent = 0);
|
||
~CCSTable();
|
||
virtual CCSBaseItemInterface * createInstance(QObject * parent) const=0;
|
||
virtual CCSBaseItemInterface * clone(bool withChildren = true, bool init = true) const=0;
|
||
|
||
int tablewidth() const;
|
||
void SetTablewidth(const int &width);
|
||
int height() const;
|
||
void SetHeight(const int &height);
|
||
int rownum() const;
|
||
void SetRownum(const int &rows);
|
||
int colnum() const;
|
||
void SetColnum(const int &cols);
|
||
void SetRowAndColumn(const int &row,const int &col);
|
||
int marginleft() const;
|
||
void SetMarginLeft(const int &left);
|
||
int marginright() const;
|
||
void SetMarginRight(const int &right);
|
||
|
||
bool newpage() const;
|
||
void SetNewPage(const bool & flag);
|
||
int orientation() const;
|
||
void SetOrientation(const int& o);
|
||
qreal pageheight() const;
|
||
void SetPageHeight(const qreal& h);
|
||
qreal realwidthinpage() const;
|
||
void SetWidthInPage(const qreal& w);
|
||
qreal padding() const;
|
||
void SetPadding(const qreal& p);
|
||
|
||
QList<qreal> headerwidths()
|
||
{
|
||
return m_headerwidth;
|
||
}
|
||
qreal headerwidth(int col)
|
||
{
|
||
if (col < m_headerwidth.count())
|
||
{
|
||
return m_headerwidth.at(col);
|
||
}
|
||
else
|
||
return 0;
|
||
}
|
||
CCS_Report::CCSColumnHeader* columnheader();
|
||
QList<CCS_Report::CCSColumnHeader*> columnheaders();
|
||
|
||
|
||
QList<qreal> GetHeaderColumnWidthPercent();
|
||
void SetColumnWidths(QList<qreal> listWPercent);
|
||
QList<CCS_Report::CCSText*> CalculateText(qreal columnwidth,QList<CCSBaseInterface*> baseitems,QMap<int,int> tempheight,qreal &maxHeight);
|
||
qreal GetCellWidth(int ipos,int colspan);
|
||
//qreal GetTableWidth(CCSPageInterface* page);
|
||
virtual int Parse(QList<QPair<CCSTableInterface*, int>>& tablesinfo, CCSGroup& groupkey) = 0;
|
||
|
||
|
||
|
||
void ParseFieldValue(CCSBaseItemInterface* item, CCSGroup& groupkey);
|
||
void SetTableFieldValue(CCSBaseItemInterface* item, CCSGroup& value);
|
||
QString GetTableFieldName(CCSBaseItemInterface* item,QString tablename="");
|
||
void SetTableInfo();
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="sizePage">原始页大小</param>
|
||
/// <param name="marginContent">页边距</param>
|
||
/// <param name="iorient">方向 =-1 用表格自身的方向 != -1 是用户传入的方向</param>
|
||
void SetTableMargin(QSize sizePage, QMarginsF marginContent, int iorient = -1);
|
||
/// <summary>
|
||
/// 设置每列的实际宽度(像素)
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
int CalColumnWidth();
|
||
/// <summary>
|
||
/// 获取此表格的级别
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
int GetParaGrade();
|
||
protected:
|
||
Q_DECLARE_PRIVATE(CCSTable)
|
||
CCSTable(CCSTablePrivate *dd, QObject * parent);
|
||
virtual CCSBaseItemInterface * itemClone() const=0;
|
||
|
||
protected:
|
||
QList<qreal> m_headerwidth;
|
||
};
|
||
|
||
class CCSTablePrivate:public CCSTableInterfacePrivate
|
||
{
|
||
public:
|
||
CCSTablePrivate()
|
||
:CCSTableInterfacePrivate(),
|
||
m_iTableWidth(100),
|
||
m_iRowNum(0),
|
||
m_iColNum(0),
|
||
m_iHeight(0),
|
||
m_iMarginLeft(0),
|
||
m_iMargingRight(0),
|
||
m_bNewPage(false),
|
||
m_iOrientation(0),
|
||
m_qPadding(0)
|
||
{}
|
||
CCSTablePrivate(const CCSTablePrivate& p)
|
||
:CCSTableInterfacePrivate(p),
|
||
m_iTableWidth(p.m_iTableWidth),
|
||
m_iColNum(p.m_iColNum),
|
||
m_iRowNum(p.m_iRowNum),
|
||
m_iHeight(p.m_iHeight),
|
||
m_iMarginLeft(p.m_iMarginLeft),
|
||
m_iMargingRight(p.m_iMargingRight),
|
||
m_bNewPage(p.m_bNewPage),
|
||
m_iOrientation(p.m_iOrientation),
|
||
m_qPadding(p.m_qPadding)
|
||
{}
|
||
virtual ~CCSTablePrivate(){}
|
||
|
||
bool m_bNewPage; //是否起新页
|
||
int m_iHeight; //一般不用,但对于插入图片时可能会用到,表格高度
|
||
int m_iRowNum;
|
||
int m_iColNum;
|
||
int m_iTableWidth; //表格宽度 占左右边距内的百分比
|
||
int m_iMarginLeft; //距页左边距的百分比
|
||
int m_iMargingRight; //距页右边距的百分比
|
||
int m_iOrientation; //新起页的方向 =0 纵向 =1 横向
|
||
qreal m_qWidthInPage; //表格在页中的实际宽度
|
||
qreal m_qPageHeight; //表格所在页的实际高度;主要用于图片的高度的设置
|
||
qreal m_qPadding; //矩边框的距离
|
||
};
|
||
}
|
||
#endif // CCSTABLE_H
|