MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / formatBlock

Function formatBlock

src/gui/about_dialog.cpp:51–80  ·  view source on GitHub ↗

* Puts the items of a QStringList into an HTML block or a sequence of blocks. */

Source from the content-addressed store, hash-verified

49 * Puts the items of a QStringList into an HTML block or a sequence of blocks.
50 */
51QString formatBlock(const QStringList& items)
52{
53#if defined(Q_OS_ANDROID) // or any other small-screen device
54 QString block = QLatin1String("<p>")
55 + items.join(QString::fromLatin1(", "))
56 + QLatin1String("</p>");
57#else
58 QString block;
59 block.reserve(100 + 30 * items.size());
60 block.append(QLatin1String("<table><tr><td>"));
61 constexpr int columns = 3;
62 const int rows = (int)ceil((double)items.size() / columns);
63 for (int i = 0, row = 1; i < items.size(); ++i)
64 {
65 block.append(items[i]);
66 if (rows != row)
67 {
68 block.append(QString::fromLatin1("<br/>"));
69 ++row;
70 }
71 else if (i < items.size())
72 {
73 block.append(QString::fromLatin1("</td><td>&nbsp;&nbsp;&nbsp;</td><td>"));
74 row = 1;
75 }
76 }
77 block.append(QString::fromLatin1("</td></tr></table>"));
78#endif
79 return block;
80}
81
82
83} // namespace

Callers 1

aboutMethod · 0.85

Calls 2

QLatin1StringClass · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected