logplus/Workflow/WFEngine/ObjectModel/ObjectModelBase/include/PaiHtmlProperties.h
2026-01-16 17:18:41 +08:00

165 lines
4.7 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.

/**
* @file PaiHtmlProperties.h
* @brief 组装属性信息成Html类的定义
* @date 2012-03-22
*/
#ifndef PAI_FRAME_IOBJECTMODEL_PAIHTMLPROPERTIES_H
#define PAI_FRAME_IOBJECTMODEL_PAIHTMLPROPERTIES_H
#include <QString>
#include <QMap>
#include <QColor>
#include "Property.h"
#include "Turtle.h"
namespace pai
{
namespace objectmodel
{
/**
* @class PaiHtmlProperties
* @brief 组装属性信息成Html
*/
class PAI_OBJECTMODEL_EXPORT PaiHtmlProperties
{
public:
/**
* @brief 构造函数
* @param[in] tableWithPercent 表格宽度百分比
*/
PaiHtmlProperties(const int tableWithPercent = 0);
/**
* @brief 通过html来构造该类
* @param[in] html 必须是从该类GetHtml()函数获得的html
*/
PaiHtmlProperties(const QString & html);
/**
* @brief 构造函数
* @param[in] icon 图标
* @param[in] mainTitle 主标题
* @param[in] subTitle 副标题
* @param[in] tableWithPercent 表格宽度百分比
*/
PaiHtmlProperties(const QString & icon,
const QString & mainTitle,
const QString & subTitle,
const int tableWithPercent = 0);
/**
* @brief 虚析构函数
*/
virtual ~PaiHtmlProperties();
/**
* @brief 添加一条记录,占一行两列
* @param[in] content 内容
* @param[in] isHtml 参数中是否含有Html
*/
void AddItem(const QString & content, bool isHtml = false);
/**
* @brief 添加一条记录
* @param[in] name 记录名
* @param[in] content 内容
* @param[in] isHtml 参数中是否含有Html
* @note content 参数请用QString类型不要用char*以免与其它AddItem函数产生混乱
*/
void AddItem(const QString & name, const QString & content, bool isHtml = false);
/**
* @brief 添加一条横线做分隔符
* @param[in] dashed 是否为虚线风格
* @param[in] newTable 是否为接下来的文本创建新的表格。
* false: 默认,不创建新的表格,接下来的文本会显示在同一个表格,这样可以使得上下文本列对齐
* true: 创建新的表格,接下来的文本会显示在新的表格,这个可以在上下表格列宽度需求不同时使用。
*/
void AddSeparator(bool dashed = false, bool newTable = false);
/**
* @brief 获得组装后的html字符窗
* @return 组装后的html字符窗
*/
QString GetHtml() const;
/**
* @brief 获得组装后的html格式的属性窗
* @param[in] propertyGroup 属性组
* @return 组装后的html字符窗
*/
QString GetHtml(const std::vector< std::vector< pai::ios::property::PropertyItem > > & propertyGroup);
/**
* @brief 设置名字背景颜色
* @param[in] color 背景颜色
*/
void SetNameBackgroundColor(const QColor & color);
/**
* @brief 设置字体大小
* @param[in] fontSize 字体大小
*/
void SetFontSize(const int fontSize);
/**
* @brief 设置名字颜色
* @param[in] nameColor 名字颜色
*/
void SetNameColor(const QColor & nameColor);
/**
* @brief 设置名字列宽度
* @param[in] nameWidth 名字列宽度
*/
void SetNameWidth(int nameWidth);
/**
* @brief 设置字体加粗
* @param[in] fontWeight 加粗系数
*
*/
void SetFontWeight(int fontWeight);
/**
* @brief 设置行高
* @param[in] lineHeight 高度
*/
void SetLineHeight(int lineHeight);
private:
/**
* @brief 用&nbsp替换字符转中的空格因当有空格时有时会出现自动换行的现象
* @param[in] replace 要替换的字符串
* @return 替换后的字符串
*/
QString ReplaceToNBSP(const QString & replace);
/*
* @brief 插入item
* @param[in] item 需要插入item
*/
void InsertItem(const QString & item);
/**
* @brief 保存变量
*/
void Init();
private:
QString m_html; ///< 记录html字符串
QColor m_NameBackgroundColor; ///< 名字列的背景颜色
int m_FontSize; ///< 字体大小
QColor m_NameColor; ///< 名字颜色
int m_NameWidth; ///< 名字列宽度
int m_TableWidth; ///< 分隔线下的表格宽度
int m_FontWeight; ///< 字体加粗
int m_LineHeight; ///< 行高
QMap< pai::ios::property::ItemUnit, QString > m_PropertyUnitMap; ///< 属性单位Map
};
}
}
#endif ///< PAI_FRAME_IOBJECTMODEL_PAIHTMLPROPERTIES_H