218 lines
8.5 KiB
C
218 lines
8.5 KiB
C
|
#ifndef CCSDYNAMICTABLE_H
|
|||
|
#define CCSDYNAMICTABLE_H
|
|||
|
#include "ccstable.h"
|
|||
|
#include "QPainter"
|
|||
|
#include "common_types.h"
|
|||
|
#include "ccsreport_global.h"
|
|||
|
|
|||
|
namespace CCS_Report {
|
|||
|
class CCSTable;
|
|||
|
class CCSTablePrivate;
|
|||
|
class CCSTableDynamicPrivate;
|
|||
|
class CCSColumnContent;
|
|||
|
class CCSColumnBottom;
|
|||
|
class CCSSubTable;
|
|||
|
class CCSCell;
|
|||
|
class CCSColumn;
|
|||
|
|
|||
|
class CCS_COMPASSREPORT_EXPORT CCSTableDynamic:public CCSTable
|
|||
|
{
|
|||
|
Q_OBJECT
|
|||
|
Q_PROPERTY(bool titlerepeat READ titlerepeat WRITE SetTitleRepeat)
|
|||
|
Q_PROPERTY(bool colrepeat READ colrepeat WRITE SetColReapeat)
|
|||
|
Q_PROPERTY(bool colshow READ colshow WRITE SetColShow)
|
|||
|
Q_PROPERTY(QStringList tablenames READ tablenames WRITE SetTablenames )
|
|||
|
Q_PROPERTY(QStringList fieldkeys READ fieldkeys WRITE SetFieldKeys )
|
|||
|
Q_PROPERTY(QString dynamickey READ dynamickey WRITE SetDynamicKey )
|
|||
|
Q_PROPERTY(bool dynamic READ dynamic WRITE SetDynamic)
|
|||
|
Q_PROPERTY(bool linewrap READ linewrap WRITE SetLineWrap)
|
|||
|
Q_PROPERTY(bool shownorecord READ shownorecord WRITE SetShowNoRecord)
|
|||
|
Q_PROPERTY(int breaktype READ breaktype WRITE SetBreakType)
|
|||
|
Q_PROPERTY(bool transpose READ transpose WRITE SetTranspose)
|
|||
|
Q_PROPERTY(int tablebordertype READ tablebordertype WRITE SetTableBorderType)
|
|||
|
Q_PROPERTY(int subHeaderPos READ subHeaderPos WRITE SetSubHeaderPos)
|
|||
|
protected:
|
|||
|
friend class CCSReportCore;
|
|||
|
public:
|
|||
|
CCSTableDynamic(QObject * parent = 0);
|
|||
|
~CCSTableDynamic();
|
|||
|
|
|||
|
virtual CCSBaseItemInterface * createInstance(QObject * parent) const;
|
|||
|
virtual CCSBaseItemInterface * clone(bool withChildren = true, bool init = true) const;
|
|||
|
virtual void SetValue(const QString &text,int iPos=0){}
|
|||
|
virtual void exeFunction(ReportFunPara& arg);
|
|||
|
|
|||
|
bool titlerepeat() const;
|
|||
|
void SetTitleRepeat(const bool &bFlag);
|
|||
|
|
|||
|
bool colrepeat () const;
|
|||
|
void SetColReapeat(const bool &bFlag);
|
|||
|
bool colshow () const;
|
|||
|
void SetColShow(const bool &bFlag);
|
|||
|
|
|||
|
QStringList tablenames () const;
|
|||
|
void SetTablenames (const QStringList &names);
|
|||
|
QStringList fieldkeys () const;
|
|||
|
void SetFieldKeys (const QStringList &keys);
|
|||
|
QString dynamickey () const;
|
|||
|
void SetDynamicKey (const QString &dynkey);
|
|||
|
|
|||
|
bool dynamic () const;
|
|||
|
void SetDynamic(const bool &bFlag);
|
|||
|
bool linewrap () const;
|
|||
|
void SetLineWrap(const bool &bFlag);
|
|||
|
bool shownorecord() const;
|
|||
|
void SetShowNoRecord(const bool &bFlag);
|
|||
|
bool transpose() const;
|
|||
|
void SetTranspose(const bool& bFlag);
|
|||
|
|
|||
|
int breaktype() const;
|
|||
|
void SetBreakType(const int &iType);
|
|||
|
|
|||
|
int tablebordertype() const ;
|
|||
|
void SetTableBorderType(int iType);
|
|||
|
|
|||
|
int subHeaderPos() const ;
|
|||
|
void SetSubHeaderPos(int iType);
|
|||
|
|
|||
|
int recordnum() const;
|
|||
|
void SetRecordNum(const int& num);
|
|||
|
// QList<CCS_Report::CCSRenderCell*> calculateCell(QPainter* paint,qreal X,qreal Y,qreal& lastY);
|
|||
|
QList<CCS_Report::CCSColumnContent*> colContents();
|
|||
|
CCS_Report::CCSColumnContent* colContent();
|
|||
|
QList<CCS_Report::CCSColumnBottom*> colBottoms();
|
|||
|
CCS_Report::CCSColumnBottom* colBottom();
|
|||
|
QList<CCS_Report::CCSSubTable*> subtables();
|
|||
|
|
|||
|
int GetBottomRow();
|
|||
|
QPair<QString,int> HasDynamicField();
|
|||
|
void SetRepeatColumn();
|
|||
|
qreal GetRepeatColWidth();
|
|||
|
virtual int Parse(QList<QPair<CCSTableInterface*, int>>& tablesinfo, QList<QPair<QString,QString>>& groupkey);
|
|||
|
|
|||
|
protected:
|
|||
|
Q_DECLARE_PRIVATE(CCSTableDynamic)
|
|||
|
CCSTableDynamic(CCSTableDynamicPrivate *dd, QObject * parent);
|
|||
|
virtual CCSBaseItemInterface * itemClone() const;
|
|||
|
public:
|
|||
|
/// <summary>
|
|||
|
/// 动态表中的动态表头的解析
|
|||
|
/// </summary>
|
|||
|
/// <param name="groupkey"></param>
|
|||
|
/// <returns></returns>
|
|||
|
QPair<QString, int> ParseHeader(QList<QPair<QString, QString>>& groupkey);
|
|||
|
/// <summary>
|
|||
|
/// 表头的动态列的解析
|
|||
|
/// </summary>
|
|||
|
/// <param name="pos"></param>
|
|||
|
/// <param name="dynField"></param>
|
|||
|
/// <param name="groupkey"></param>
|
|||
|
/// <returns></returns>
|
|||
|
QList<QString> ParseDynamicColumn(int pos,QString& dynField,QList<QPair<QString,QString>> groupkey);
|
|||
|
void ParseSubTable(QList<QObject*>& listTableData,QList<QPair<QString, QString>> &groupkey);
|
|||
|
/// <summary>
|
|||
|
/// 动态表中的动态内容的解析
|
|||
|
/// </summary>
|
|||
|
/// <param name="table"></param>
|
|||
|
void ParseContent(QList<QObject*> table);
|
|||
|
/// <summary>
|
|||
|
/// 解析动态表中有动态列的 动态内容的解析
|
|||
|
/// </summary>
|
|||
|
/// <param name="table"></param>
|
|||
|
void ParseDynamicContent(QMap<QString, QMap<QString, QString>> datasetDyn);
|
|||
|
|
|||
|
QList<QString> GetDynamicContentField();
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//void ParseDynamicTableContent(CCS_Report::CCSColumn* column,QMap<QString,QMap<QString,QString>> datasetDyn);
|
|||
|
QPair<QString, int> ParseDynamicHeader(QList<QPair<QString, QString>>& groupkey);
|
|||
|
bool FillData(QPair<QString, int> pairDynmaicCol, QList<QObject*> listData,QList<QPair<QString, QString>>& groupkey);
|
|||
|
/// <summary>
|
|||
|
/// 根据动态列的个数,在动态表内容中新增列
|
|||
|
/// </summary>
|
|||
|
/// <param name="iDynFieldPos"></param>
|
|||
|
/// <param name="listDynamicCol"></param>
|
|||
|
void SetDynamicContent(int iDynFieldPos,QList<QString> listDynamicCol);
|
|||
|
void SetDynamicHeader(int iDynFieldPos,CCS_Report::CCSCell* ItemCell,QList<QString> listDynamicCol);
|
|||
|
//解析转置表
|
|||
|
void ParseTranspose(QList<QPair<QString, QString>> &groupkey);
|
|||
|
|
|||
|
void CalculateContentColumnWidth();
|
|||
|
QList<qreal> GetContentColumnWidthPercent();
|
|||
|
bool IfChangeOrient();
|
|||
|
void SetBreakColumnFlag();
|
|||
|
void HandleHeaderLineBreak();
|
|||
|
void HandleDyanmicSpanColumn();
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 判断在纸张方向是横向时,如果列数超出横向的宽度,是否要变更纸张方向
|
|||
|
/// </summary>
|
|||
|
void HandleOrientChange();
|
|||
|
public:
|
|||
|
int m_iRecordNum; //动态表的记录数
|
|||
|
QList<int> listBreakIndex; //折行标记 //记录折行在第几列的标记
|
|||
|
QList<int> listDynamicNum; //标记动态列在每行的个数,用于同列其他行设置跨列数
|
|||
|
QList<QPair<int,qreal>> listRepeatCols;
|
|||
|
/// <summary>
|
|||
|
/// QMap<key1,QMap<key2,value>> key1 所在列 key2 所在行 value 跨列个数
|
|||
|
/// </summary>
|
|||
|
QMap<int,QMap<int,int>> mapRepeatCell; //标识在折行时需要处理跨列的cell
|
|||
|
};
|
|||
|
class CCSTableDynamicPrivate:public CCSTablePrivate
|
|||
|
{
|
|||
|
public:
|
|||
|
CCSTableDynamicPrivate()
|
|||
|
:CCSTablePrivate(),
|
|||
|
m_bTitleRepeat(false),
|
|||
|
m_bColRepeat(true),
|
|||
|
m_bColVisble(true),
|
|||
|
m_bDynamic(false),
|
|||
|
m_bLineWrap(true),
|
|||
|
m_bShowNoRecord(true),
|
|||
|
m_eBreakType(0),
|
|||
|
m_bTranspose(false),
|
|||
|
m_iTableBorderType(0),
|
|||
|
m_iSubHeaderPos(0)
|
|||
|
{
|
|||
|
m_strTable.clear();
|
|||
|
m_strKeys.clear();
|
|||
|
m_strKeyField="";
|
|||
|
}
|
|||
|
CCSTableDynamicPrivate(const CCSTableDynamicPrivate& p)
|
|||
|
:CCSTablePrivate(p),
|
|||
|
m_bTitleRepeat(p.m_bTitleRepeat),
|
|||
|
m_bColRepeat(p.m_bColRepeat),
|
|||
|
m_bColVisble(p.m_bColVisble),
|
|||
|
m_strTable(p.m_strTable),
|
|||
|
m_strKeys(p.m_strKeys),
|
|||
|
m_strKeyField(p.m_strKeyField),
|
|||
|
m_bDynamic(p.m_bDynamic),
|
|||
|
m_bLineWrap(p.m_bLineWrap),
|
|||
|
m_bShowNoRecord(p.m_bShowNoRecord),
|
|||
|
m_eBreakType(p.m_eBreakType),
|
|||
|
m_bTranspose(p.m_bTranspose),
|
|||
|
m_iTableBorderType(p.m_iTableBorderType),
|
|||
|
m_iSubHeaderPos(p.m_iSubHeaderPos)
|
|||
|
{}
|
|||
|
virtual ~CCSTableDynamicPrivate(){}
|
|||
|
|
|||
|
bool m_bTitleRepeat; //换页时,表标题是否重复
|
|||
|
bool m_bColRepeat;//换页时,表头是否重复
|
|||
|
//TableTitlePostion eTitlePos;
|
|||
|
bool m_bColVisble; //列头是否显示
|
|||
|
QStringList m_strTable; //表名,多个表名时用逗号隔开
|
|||
|
QStringList m_strKeys; //备用,用于多表联合查询时
|
|||
|
QString m_strKeyField; //对于动态列,需要查询的
|
|||
|
bool m_bDynamic; //是否有动态列
|
|||
|
bool m_bLineWrap; //是否折行 当列过多时,
|
|||
|
bool m_bShowNoRecord; //当没有记录时表格是否显示 true显示 false 不显示
|
|||
|
int m_eBreakType; //折行类型,按记录折行还是按表折行或者因为过长,变化纸张的方向 =2 按表折行 =3 按记录折行 = 1 变化纸张的方向不折行
|
|||
|
//int m_eNoRecordShowType; //当表中没有记录时,此表是否显示
|
|||
|
bool m_bTranspose; //是否进行表的转置 缺省false
|
|||
|
int m_iTableBorderType; //表格边框样式 =1 在表头上下有边框 =2 表头上下和记录尾部有 = 3 表头下部和记录下部有边框 =4 表头上下都有边框和记录下部有边框 =5 全边框
|
|||
|
int m_iSubHeaderPos; //子表表头的位置。 = 0 在子表 = 1 在父表的表头
|
|||
|
};
|
|||
|
}
|
|||
|
#endif // CCSDYNAMICTABLE_H
|