File indexing completed on 2025-01-05 05:23:52

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2023 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #include "abstractcolumnhtmlrenderer.hpp"
0010 
0011 // Qt
0012 #include <QString>
0013 
0014 namespace Kasten {
0015 
0016 AbstractColumnHtmlRenderer::~AbstractColumnHtmlRenderer() = default;
0017 
0018 QString AbstractColumnHtmlRenderer::whiteSpace(unsigned int length)
0019 {
0020     return QStringLiteral("&nbsp;").repeated(length);
0021 }
0022 
0023 QString AbstractColumnHtmlRenderer::emptyCells(unsigned int length, unsigned int codingWidth)
0024 {
0025     if (length == 0) {
0026         return QString();
0027     }
0028     if (codingWidth == 0) {
0029         return QStringLiteral("<td colspan=%1></td>").arg(length);
0030     }
0031     return QString(QLatin1String("<td><tt>") + whiteSpace(codingWidth) + QLatin1String("</tt></td>")).repeated(length);
0032     // TODO: use colspan where possible and spaces only for empty columns
0033 }
0034 
0035 QString AbstractColumnHtmlRenderer::htmlEscaped(QChar c)
0036 {
0037     if (c.isSpace()) {
0038         return QStringLiteral("&nbsp;");
0039     }
0040     return QString(c).toHtmlEscaped();
0041 }
0042 
0043 int AbstractColumnHtmlRenderer::noOfSublinesNeeded() const { return DefaultNoOfSublines; }
0044 
0045 }