diff --git a/src/format/HtmlExporter.cpp b/src/format/HtmlExporter.cpp index 812af7868..e0ce2c800 100644 --- a/src/format/HtmlExporter.cpp +++ b/src/format/HtmlExporter.cpp @@ -80,15 +80,11 @@ bool HtmlExporter::exportDatabase(QIODevice* device, const QSharedPointer" "\n" "" @@ -162,16 +158,14 @@ bool HtmlExporter::writeGroup(QIODevice& device, const Group& group, QString pat } } - // Output the entries in this group - for (const auto entry : entries) { - auto item = QString("

"); + // Begin the table for the entries in this group + auto table = QString(""); - // Begin formatting this item into HTML - item.append(PixmapToHTML(entry->iconPixmap(IconSize::Medium))); - item.append(" "); - item.append(entry->title().toHtmlEscaped()); - item.append("\n" - "
"); + // Output the entries in this group + for (const auto entry : entries) { + + // Here we collect the table rows with this entry's data fields + QString item; // Output the fixed fields const auto& u = entry->username(); @@ -230,17 +224,31 @@ bool HtmlExporter::writeGroup(QIODevice& device, const Group& group, QString pat item.append(""); } } - // Done with this entry - item.append("
"); item.append(key.toHtmlEscaped()); item.append(""); - item.append(attr->value(key).toHtmlEscaped().replace("\n", "
")); + item.append(attr->value(key).toHtmlEscaped().replace(" ", " ").replace("\n", "
")); item.append("

\n"); - if (device.write(item.toUtf8()) == -1) { - m_error = device.errorString(); - return false; - } + // Skip if everything is empty + if (item.isEmpty()) + continue; + + // Output it into our table. First the left side with + // icon and entry title ... + table += ""; + table += "" + PixmapToHTML(entry->iconPixmap(IconSize::Medium)) + ""; + table += "

" + entry->title().toHtmlEscaped() + "

"; + + // ... then the right side with the data fields + table += "" + item + "
"; + table += ""; + } + + // Output the complete table of this group + table.append("\n"); + if (device.write(table.toUtf8()) == -1) { + m_error = device.errorString(); + return false; } // Recursively output the child groups