0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-01-11 17:18:10 +03:00

fontLetterSpacing property has been added to TextItem

This commit is contained in:
Arin Alex 2019-05-04 11:54:52 +03:00
parent 5e7ee21463
commit 356e48bee3
2 changed files with 27 additions and 5 deletions

View File

@ -59,7 +59,7 @@ namespace LimeReport{
TextItem::TextItem(QObject *owner, QGraphicsItem *parent)
: ContentItemDesignIntf(xmlTag,owner,parent), m_angle(Angle0), m_trimValue(true), m_allowHTML(false),
m_allowHTMLInFields(false), m_replaceCarriageReturns(false), m_followTo(""), m_follower(0), m_textIndent(0),
m_textLayoutDirection(Qt::LayoutDirectionAuto), m_hideIfEmpty(false)
m_textLayoutDirection(Qt::LayoutDirectionAuto), m_hideIfEmpty(false), m_fontLetterSpacing(0)
{
PageItemDesignIntf* pageItem = dynamic_cast<PageItemDesignIntf*>(parent);
BaseDesignIntf* parentItem = dynamic_cast<BaseDesignIntf*>(parent);
@ -547,6 +547,23 @@ TextItem::TextPtr TextItem::textDocument() const
}
int TextItem::fontLetterSpacing() const
{
return m_fontLetterSpacing;
}
void TextItem::setFontLetterSpacing(int value)
{
if (m_fontLetterSpacing != value){
int oldValue = m_fontLetterSpacing;
m_fontLetterSpacing = value;
QFont curFont = font();
curFont.setLetterSpacing(QFont::AbsoluteSpacing, m_fontLetterSpacing);
setFont(curFont);
notify("fontLetterSpacing", oldValue, value);
}
}
bool TextItem::hideIfEmpty() const
{
return m_hideIfEmpty;
@ -969,6 +986,7 @@ void TextItem::setTextItemFont(QFont value)
{
if (font()!=value){
QFont oldValue = font();
value.setLetterSpacing(QFont::AbsoluteSpacing, m_fontLetterSpacing);
setFont(value);
if (!isLoading()) update();
notify("font",oldValue,value);

View File

@ -75,11 +75,12 @@ class TextItem : public LimeReport::ContentItemDesignIntf, IPageInit {
Q_PROPERTY(bool watermark READ isWatermark WRITE setWatermark)
Q_PROPERTY(bool replaceCRwithBR READ isReplaceCarriageReturns WRITE setReplaceCarriageReturns)
Q_PROPERTY(bool hideIfEmpty READ hideIfEmpty WRITE setHideIfEmpty)
Q_PROPERTY(int fontLetterSpacing READ fontLetterSpacing WRITE setFontLetterSpacing)
public:
enum AutoWidth{NoneAutoWidth,MaxWordLength,MaxStringLength};
enum AngleType{Angle0,Angle90,Angle180,Angle270,Angle45,Angle315};
enum ValueType{Default,DateTime,Double};
enum AutoWidth{NoneAutoWidth, MaxWordLength, MaxStringLength};
enum AngleType{Angle0, Angle90, Angle180, Angle270, Angle45, Angle315};
enum ValueType{Default, DateTime, Double};
void Init();
TextItem(QObject* owner=0, QGraphicsItem* parent=0);
@ -176,6 +177,9 @@ public:
bool hideIfEmpty() const;
void setHideIfEmpty(bool hideIfEmpty);
int fontLetterSpacing() const;
void setFontLetterSpacing(int fontLetterSpacing);
protected:
void updateLayout();
bool isNeedExpandContent() const;
@ -220,7 +224,7 @@ private:
qreal m_textIndent;
Qt::LayoutDirection m_textLayoutDirection;
bool m_hideIfEmpty;
int m_fontLetterSpacing;
};
}