From b848cf6e2313be519b921ff92d3ed78b16f73cff Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 5 Jul 2016 12:40:23 +0200 Subject: [PATCH] refs #702, HTML utility --- src/blackmisc/htmlutils.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/blackmisc/htmlutils.h diff --git a/src/blackmisc/htmlutils.h b/src/blackmisc/htmlutils.h new file mode 100644 index 000000000..9b05808b8 --- /dev/null +++ b/src/blackmisc/htmlutils.h @@ -0,0 +1,39 @@ +/* Copyright (C) 2016 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKMISC_HTMLUTILS_H +#define BLACKMISC_HTMLUTILS_H + +#include "blackmisc/blackmiscexport.h" + + +//! Free functions in BlackMisc +namespace BlackMisc +{ + //! Container to standard HTML table + template 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 += "" + obj.propertyByIndex(index).toQString(true) + ""; + } + html += "" + rowHtml + ""; + } + return "" + html + "
"; + } +} // ns + +#endif // guard