Skip to content

Commit

Permalink
Merge pull request #90 from dragotin/item_linebreak
Browse files Browse the repository at this point in the history
Convert newlines in item text to <p></p>
  • Loading branch information
dragotin authored Dec 5, 2020
2 parents 25cc47f + 1dbc771 commit df00daa
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions reports/invoice.gtmpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<link href="kraft.css" media="print" rel="stylesheet"/>
<title>Kraft Document</title>
</head>
{% autoescape on %}
{% autoescape off %}
<body>
<p id="letterheader">
{{ me.ORGANISATION }} - {{ me.STREET }} - {{ me.POSTCODE }} {{ me.LOCALITY }}
Expand Down Expand Up @@ -86,7 +86,7 @@
{% if item.kind == 'Alternative' or item.kind == 'Demand' %}
<i>
{% endif %}
{{ item.text }}
{{ item.htmlText }}
{% if item.kind == 'Alternative' or item.kind == 'Demand' %}
</i>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions reports/invoice_kfg.gtmpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<title>Kraft Document</title>
</head>

{% autoescape on %}
{% autoescape off %}
<body>

<!-- id vs class of html elements:
Expand Down Expand Up @@ -106,7 +106,7 @@
{% if item.kind == 'Alternative' or item.kind == 'Demand' %}
<i>
{% endif %}
{{ item.text }}
{{ item.htmlText }}
{% if item.kind == 'Alternative' or item.kind == 'Demand' %}
</i>
{% endif %}
Expand Down
15 changes: 15 additions & 0 deletions src/archdocposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ QString ArchDocPosition::taxMarkerHelper() const
return re;
}

QString ArchDocPosition::htmlText(const QString& paraStyle) const
{
QString re;

QString style( paraStyle );
if ( style.isEmpty() ) style = QStringLiteral("text");

// QStringList li = QStringList::split( "\n", escapeTrml2pdfXML( str ) );
QStringList li = mText.toHtmlEscaped().split( "\n" );
re = QString( "<p style=\"%1\">" ).arg( style );
re += li.join( QString( "</p><p style=\"%1\">" ).arg( style ) ) + QStringLiteral("</p>");
// qDebug () << "Returning " << rml;
return re;
}

// ==================================================================

ArchDocPositionList::ArchDocPositionList()
Expand Down
3 changes: 3 additions & 0 deletions src/archdocposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ArchDocPosition
QString posNumber() const { return mPosNo; }

QString text() const { return mText; }
QString htmlText(const QString &paraStyle = QString()) const;

QString unit() const { return mUnit; }

Expand Down Expand Up @@ -106,6 +107,8 @@ if ( property == "itemNumber" )
return object.posNumber();
else if ( property == "text" )
return object.text();
else if ( property == "htmlText" )
return object.htmlText();
else if ( property == "kind" )
return object.kind();
else if ( property == "unit" )
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define KRAFT_VERSION "0.95"
#define KRAFT_VERSION "0.96"

#define KRAFT_CODENAME "Gunny"

Expand Down

0 comments on commit df00daa

Please sign in to comment.