mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
qthelper.cpp: support line breaks for notes when printing
The Dive::put_notes() does not handle HTML formatting or line breaks properly. Apparently Grantlee supports HTML variables, but the planned notes (which are HTML) look very bad when inserted in the Grantlee template - e.g. the text is huge and the table box is cut for some odd reason. I don't have a good solution for these issues ATM; especially for the "table cell being cut part". An important feature in the dive notes is to support line breaks. This patch adds support for line breaks both in planned dive notes and non-planned dive notes via the <br> tag. This makes the planned dive notes look tolerable. The next step would be to support the <br> tag, which has to happen in the bundled templates them self. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6cb30ba1b6
commit
00a085f858
1 changed files with 17 additions and 7 deletions
|
@ -214,15 +214,25 @@ void Dive::put_temp()
|
|||
|
||||
void Dive::put_notes()
|
||||
{
|
||||
if (same_string(dive->dc.model, "planned dive")) {
|
||||
QTextDocument notes;
|
||||
notes.setHtml(QString::fromUtf8(dive->notes));
|
||||
m_notes = notes.toPlainText();
|
||||
} else {
|
||||
m_notes = QString::fromUtf8(dive->notes);
|
||||
}
|
||||
m_notes = QString::fromUtf8(dive->notes);
|
||||
if (m_notes.isEmpty()) {
|
||||
m_notes = "--";
|
||||
return;
|
||||
}
|
||||
if (same_string(dive->dc.model, "planned dive")) {
|
||||
QTextDocument notes;
|
||||
QString notesFormatted = m_notes;
|
||||
#define _NOTES_BR "\n"
|
||||
notesFormatted = notesFormatted.replace("<thead>", "<thead>"_NOTES_BR);
|
||||
notesFormatted = notesFormatted.replace("<br>", "<br>"_NOTES_BR);
|
||||
notesFormatted = notesFormatted.replace("<tr>", "<tr>"_NOTES_BR);
|
||||
notesFormatted = notesFormatted.replace("</tr>", "</tr>"_NOTES_BR);
|
||||
notes.setHtml(notesFormatted);
|
||||
m_notes = notes.toPlainText();
|
||||
m_notes.replace(_NOTES_BR, "<br>");
|
||||
#undef _NOTES_BR
|
||||
} else {
|
||||
m_notes.replace("\n", "<br>");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue