mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-02 11:36:18 -04:00
HTML Export: Don't waste horizontal space
The previous version left a lot of white space to the right of the table, meaning that more pages needed to be printed for a paper backup. The table has been reorganized. HTML Backup for the demo.kdbx database is now down from 6 to 3 pages.
This commit is contained in:
parent
656e6d289a
commit
6b96806914
1 changed files with 29 additions and 21 deletions
|
@ -80,15 +80,11 @@ bool HtmlExporter::exportDatabase(QIODevice* device, const QSharedPointer<const
|
||||||
"th, td "
|
"th, td "
|
||||||
"{ text-align: left; vertical-align: top; padding: 1px; }"
|
"{ text-align: left; vertical-align: top; padding: 1px; }"
|
||||||
"th "
|
"th "
|
||||||
"{ min-width: 5em; } "
|
"{ min-width: 5em; width: 20%; } "
|
||||||
".username, .password, .url, .attr "
|
".username, .password, .url, .attr "
|
||||||
"{ font-size: larger; font-family: monospace; } "
|
"{ font-size: larger; font-family: monospace; } "
|
||||||
".notes "
|
".notes "
|
||||||
"{ font-size: medium; } "
|
"{ font-size: medium; } "
|
||||||
"@media print {"
|
|
||||||
".entry"
|
|
||||||
"{ page-break-inside: avoid; } "
|
|
||||||
"}"
|
|
||||||
"</style>"
|
"</style>"
|
||||||
"</head>\n"
|
"</head>\n"
|
||||||
"<body>"
|
"<body>"
|
||||||
|
@ -162,16 +158,14 @@ bool HtmlExporter::writeGroup(QIODevice& device, const Group& group, QString pat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Begin the table for the entries in this group
|
||||||
|
auto table = QString("<table width=\"100%\">");
|
||||||
|
|
||||||
// Output the entries in this group
|
// Output the entries in this group
|
||||||
for (const auto entry : entries) {
|
for (const auto entry : entries) {
|
||||||
auto item = QString("<div class=\"entry\"><h3>");
|
|
||||||
|
|
||||||
// Begin formatting this item into HTML
|
// Here we collect the table rows with this entry's data fields
|
||||||
item.append(PixmapToHTML(entry->iconPixmap(IconSize::Medium)));
|
QString item;
|
||||||
item.append(" ");
|
|
||||||
item.append(entry->title().toHtmlEscaped());
|
|
||||||
item.append("</h3>\n"
|
|
||||||
"<table>");
|
|
||||||
|
|
||||||
// Output the fixed fields
|
// Output the fixed fields
|
||||||
const auto& u = entry->username();
|
const auto& u = entry->username();
|
||||||
|
@ -230,18 +224,32 @@ bool HtmlExporter::writeGroup(QIODevice& device, const Group& group, QString pat
|
||||||
item.append("<tr><th>");
|
item.append("<tr><th>");
|
||||||
item.append(key.toHtmlEscaped());
|
item.append(key.toHtmlEscaped());
|
||||||
item.append("</th><td class=\"attr\">");
|
item.append("</th><td class=\"attr\">");
|
||||||
item.append(attr->value(key).toHtmlEscaped().replace("\n", "<br>"));
|
item.append(attr->value(key).toHtmlEscaped().replace(" ", " ").replace("\n", "<br>"));
|
||||||
item.append("</td></tr>");
|
item.append("</td></tr>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done with this entry
|
// Skip if everything is empty
|
||||||
item.append("</table></div>\n");
|
if (item.isEmpty())
|
||||||
if (device.write(item.toUtf8()) == -1) {
|
continue;
|
||||||
|
|
||||||
|
// Output it into our table. First the left side with
|
||||||
|
// icon and entry title ...
|
||||||
|
table += "<tr>";
|
||||||
|
table += "<td width=\"1%\">" + PixmapToHTML(entry->iconPixmap(IconSize::Medium)) + "</td>";
|
||||||
|
table += "<td width=\"19%\" valign=\"top\"><h3>" + entry->title().toHtmlEscaped() + "</h3></td>";
|
||||||
|
|
||||||
|
// ... then the right side with the data fields
|
||||||
|
table += "<td style=\"padding-bottom: 0.5em;\"><table width=\"100%\">" + item + "</table></td>";
|
||||||
|
table += "</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output the complete table of this group
|
||||||
|
table.append("</table>\n");
|
||||||
|
if (device.write(table.toUtf8()) == -1) {
|
||||||
m_error = device.errorString();
|
m_error = device.errorString();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Recursively output the child groups
|
// Recursively output the child groups
|
||||||
const auto& children = group.children();
|
const auto& children = group.children();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue