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

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 #ifndef KASTEN_BYTEARRAYROWSCOLUMNHTMLRENDERER_HPP
0010 #define KASTEN_BYTEARRAYROWSCOLUMNHTMLRENDERER_HPP
0011 
0012 // lib
0013 #include "abstractcolumnhtmlrenderer.hpp"
0014 // Okteta gui
0015 #include <Okteta/CoordRange>
0016 // Okteta core
0017 #include <Okteta/OktetaCore>
0018 // Qt
0019 #include <QChar>
0020 // Std
0021 #include <memory>
0022 
0023 namespace Okteta {
0024 class ValueCodec;
0025 class CharCodec;
0026 class AbstractByteArrayModel;
0027 }
0028 
0029 namespace Kasten {
0030 
0031 // TODO: offset should be set in renderFirstLine, calculated using coordRange,
0032 // in constructor instead take startOffset
0033 class ByteArrayRowsColumnHtmlRenderer : public AbstractColumnHtmlRenderer
0034 {
0035 public:
0036     ByteArrayRowsColumnHtmlRenderer(const Okteta::AbstractByteArrayModel* byteArrayModel, Okteta::Address offset,
0037                                     const Okteta::CoordRange& coordRange,
0038                                     int noOfBytesPerLine, int noOfGroupedBytes,
0039                                     int visibleCodings,
0040                                     Okteta::ValueCoding valueCoding,
0041                                     const QString& charCodecName, QChar substituteChar, QChar undefinedChar);
0042     ~ByteArrayRowsColumnHtmlRenderer() override;
0043 
0044 public: // AbstractColumnHtmlRenderer API
0045     void renderFirstLine(QTextStream* stream, int lineIndex) const override;
0046     void renderNextLine(QTextStream* stream, bool isSubline) const override;
0047     int noOfSublinesNeeded() const override;
0048 
0049 private:
0050     void renderLine(QTextStream* stream, bool isSubline) const;
0051 
0052 private:
0053     const Okteta::AbstractByteArrayModel* const mByteArrayModel;
0054 
0055     const Okteta::CoordRange mCoordRange;
0056 
0057     const int mNoOfBytesPerLine;
0058 
0059     const int mVisibleCodings;
0060     std::unique_ptr<Okteta::ValueCodec> const mValueCodec;
0061     std::unique_ptr<Okteta::CharCodec> const mCharCodec;
0062     const QChar mSubstituteChar;
0063     const QChar mUndefinedChar;
0064 
0065     /** Line to print */
0066     mutable int mRenderLine;
0067     /** Data to print */
0068     mutable Okteta::Address mOffset;
0069 };
0070 
0071 }
0072 
0073 #endif