/**
* @file PaiHtmlProperties.cpp
*/
#include
#include "PaiHtmlProperties.h"
#include "PAIConst.h"
#include "Utils.h"
using namespace pai::ios::property;
using namespace pai::objectmodel;
PaiHtmlProperties::PaiHtmlProperties(const QString & icon,
const QString & mainTitle,
const QString & subTitle,
const int tableWithPercent)
{
Init();
m_TableWidth = tableWithPercent;
m_html = QString("\
\
\
\
 | \
%2 | \
\
\
| %3 | \
\
\
\
")
.arg(icon)
.arg(ReplaceToNBSP(mainTitle))
.arg(ReplaceToNBSP(subTitle))
.arg(m_TableWidth);
m_PropertyUnitMap.insert(NOUNIT, "");
m_PropertyUnitMap.insert(Byte, " Byte");
m_PropertyUnitMap.insert(KB, " KB");
m_PropertyUnitMap.insert(MB, " MB");
m_PropertyUnitMap.insert(GB, " GB");
m_PropertyUnitMap.insert(TB, " TB");
m_PropertyUnitMap.insert(PB, " PB");
m_PropertyUnitMap.insert(g, " g");
m_PropertyUnitMap.insert(kg, " kg");
m_PropertyUnitMap.insert(MM, " mm");
m_PropertyUnitMap.insert(CM, " cm");
m_PropertyUnitMap.insert(M, " m");
m_PropertyUnitMap.insert(KM, " km");
m_PropertyUnitMap.insert(SQUAREMETER, " m2");
m_PropertyUnitMap.insert(CUBICMETER, " m3");
m_PropertyUnitMap.insert(SQUAREKILOMETERS, " km2");
}
PaiHtmlProperties::PaiHtmlProperties(const int tableWithPercent)
{
Init();
m_TableWidth = tableWithPercent;
m_html = QString("\
\
\
")
.arg(m_TableWidth);
}
PaiHtmlProperties::PaiHtmlProperties(const QString & html)
{
m_html = html;
}
PaiHtmlProperties::~PaiHtmlProperties()
{
}
void PaiHtmlProperties::AddItem(const QString & name, const QString & content, bool isHtml)
{
QString iName = isHtml ? name : ReplaceToNBSP(name);
QString iContent = isHtml ? content : ReplaceToNBSP(content);
QString contentColor = "#333333";
if((iContent == "Failed") || (iContent == ("Terminated")))
{
contentColor = "#FF0000";
}
QStringList typeContenList = iContent.split("\n");
if(typeContenList.empty())
{
typeContenList.append("");
}
for(int i = 0; i < typeContenList.size(); ++i)
{
QString typeName = "";
if(i == 0)
{
typeName = iName;
}
InsertItem(QString("\
\
| %6 | \
%11 | \
")
.arg(m_NameWidth)
.arg(m_FontSize)
.arg(m_NameColor.name())
.arg(m_NameBackgroundColor.name())
.arg(m_LineHeight)
.arg(typeName)
.arg(m_FontSize)
.arg(m_FontWeight)
.arg(contentColor)
.arg(m_LineHeight)
.arg(typeContenList.at(i)));
}
}
void PaiHtmlProperties::AddItem(const QString & content, bool isHtml)
{
QString iContent = isHtml ? content : ReplaceToNBSP(content);
InsertItem(QString("\
\
| %1 | \
")
.arg(iContent));
}
void PaiHtmlProperties::AddSeparator(bool dashed, bool newTable)
{
if(dashed)
{
InsertItem(QString("\
\
| \
"));
}
else
{
InsertItem(QString("\
\
| \
"));
}
if(newTable)
{
m_html.insert(m_html.lastIndexOf("