0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 16:44:39 +03:00

TextItem: Value trimming behavior has been fixed

This commit is contained in:
Arin Alex 2022-07-18 18:45:09 +03:00
parent aeafc9e3b3
commit 1b1c0d52bc

View File

@ -276,10 +276,6 @@ void TextItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* style, Q
BaseDesignIntf::paint(painter, style, widget); BaseDesignIntf::paint(painter, style, widget);
} }
QString TextItem::content() const{
return m_strText;
}
void TextItem::Init() void TextItem::Init()
{ {
m_autoWidth = NoneAutoWidth; m_autoWidth = NoneAutoWidth;
@ -299,14 +295,8 @@ void TextItem::setContent(const QString &value)
{ {
if (m_strText.compare(value)!=0){ if (m_strText.compare(value)!=0){
QString oldValue = m_strText; QString oldValue = m_strText;
if (m_trimValue)
m_strText=value.trimmed();
else
m_strText=value;
// if (itemMode() == DesignMode && (autoHeight())){ m_strText = value;
// initTextSizes();
// }
if (!isLoading()){ if (!isLoading()){
if (autoHeight() || autoWidth() || hasFollower()) if (autoHeight() || autoWidth() || hasFollower())
@ -317,6 +307,10 @@ void TextItem::setContent(const QString &value)
} }
} }
QString TextItem::content() const{
return m_strText;
}
void TextItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight) void TextItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
{ {
@ -502,20 +496,22 @@ QString TextItem::formatFieldValue()
default: default:
return value.toString(); return value.toString();
} }
} }
TextItem::TextPtr TextItem::textDocument() const TextItem::TextPtr TextItem::textDocument() const
{ {
TextPtr text(new QTextDocument); TextPtr text(new QTextDocument);
QString content = m_trimValue ? m_strText.trimmed() : m_strText;
if (allowHTML()) if (allowHTML())
if (isReplaceCarriageReturns()){ if (isReplaceCarriageReturns()){
text->setHtml(replaceReturns(m_strText)); text->setHtml(replaceReturns(content));
} else { } else {
text->setHtml(m_strText); text->setHtml(content);
} }
else else
text->setPlainText(m_strText); text->setPlainText(content);
QTextOption to; QTextOption to;
to.setAlignment(m_alignment); to.setAlignment(m_alignment);
@ -785,6 +781,7 @@ void TextItem::setTrimValue(bool value)
{ {
bool oldValue = m_trimValue; bool oldValue = m_trimValue;
m_trimValue = value; m_trimValue = value;
update();
notify("trimValue",oldValue,value); notify("trimValue",oldValue,value);
} }