Issue #77 Break dependency of htmlutils on propertyindexlist

This commit is contained in:
Mat Sutcliffe
2020-08-28 18:05:34 +01:00
parent 515dc7fef1
commit 2391d242ed
2 changed files with 1 additions and 26 deletions

View File

@@ -8,6 +8,7 @@
#include "blackmisc/htmlutils.h"
#include <QStringBuilder>
#include <QStringList>
namespace BlackMisc
{
@@ -33,11 +34,6 @@ namespace BlackMisc
return u"<table>" % html % u"</table>";
}
QString unwrappedTooltip(const QString &text)
{
return u"<p style='white-space:pre'>" % text % u"</p>";
}
QString asHyperlink(const QString &url, const QString &text)
{
return text.isEmpty() ?

View File

@@ -11,36 +11,15 @@
#ifndef BLACKMISC_HTMLUTILS_H
#define BLACKMISC_HTMLUTILS_H
#include "blackmisc/propertyindexlist.h"
#include "blackmisc/blackmiscexport.h"
#include <QStringBuilder>
//! Free functions in BlackMisc
namespace BlackMisc
{
//! Container to standard HTML table
template <class Obj, class Container> QString toHtmlTable(const CPropertyIndexList &indexes, const Container &container)
{
if (indexes.isEmpty() || container.isEmpty()) { return {}; }
QString html;
for (const Obj &obj : container)
{
QString rowHtml;
for (const CPropertyIndex &index : indexes)
{
rowHtml += u"<td>" % obj.propertyByIndex(index).toQString(true) % u"</td>";
}
html += u"<tr>" % rowHtml % u"</tr>";
}
return u"<table>" % html % u"</table>";
}
//! Values as HTML table
BLACKMISC_EXPORT QString toHtmTable(const QStringList &values, int columns);
//! As white space preformatted
BLACKMISC_EXPORT QString unwrappedTooltip(const QString &text);
//! As hyperlink
BLACKMISC_EXPORT QString asHyperlink(const QString &url, const QString &text = "");