mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Issue #77 Break dependency of htmlutils on propertyindexlist
This commit is contained in:
@@ -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() ?
|
||||
|
||||
@@ -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 = "");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user