File indexing completed on 2025-01-19 05:20:18
0001 /* 0002 This file is part of the Okteta Kasten module, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2009 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_BYTEARRAYPATTERNGENERATOR_HPP 0010 #define KASTEN_BYTEARRAYPATTERNGENERATOR_HPP 0011 0012 // Kasten core 0013 #include <Kasten/AbstractModelDataGenerator> 0014 // Qt 0015 #include <QObject> 0016 #include <QString> 0017 0018 class KConfigGroup; 0019 0020 namespace Kasten { 0021 0022 class ByteArrayPatternGeneratorSettings 0023 { 0024 public: 0025 // matching Okteta::ByteArrayComboBox 0026 enum Coding 0027 { 0028 InvalidCoding = -1, 0029 HexadecimalCoding = 0, 0030 DecimalCoding = 1, 0031 OctalCoding = 2, 0032 BinaryCoding = 3, 0033 CharCoding = 4, 0034 Utf8Coding = 5, 0035 _CodingCount 0036 }; 0037 0038 private: 0039 static const QByteArray DefaultPattern; 0040 0041 static inline constexpr Coding DefaultPatternCoding = HexadecimalCoding; 0042 static inline constexpr int DefaultCount = 1; 0043 0044 static inline constexpr char PatternConfigKey[] = "Pattern"; 0045 static inline constexpr char PatternCodingConfigKey[] = "PatternCoding"; 0046 static inline constexpr char CountConfigKey[] = "Count"; 0047 0048 public: 0049 ByteArrayPatternGeneratorSettings(); 0050 ByteArrayPatternGeneratorSettings(const ByteArrayPatternGeneratorSettings&) = default; 0051 0052 ~ByteArrayPatternGeneratorSettings() = default; 0053 0054 ByteArrayPatternGeneratorSettings& operator=(const ByteArrayPatternGeneratorSettings&) = default; 0055 0056 bool operator==(const ByteArrayPatternGeneratorSettings& other) const; 0057 0058 public: 0059 void loadConfig(const KConfigGroup& configGroup); 0060 void saveConfig(KConfigGroup& configGroup) const; 0061 0062 public: 0063 QByteArray pattern = QByteArray(1, 0); 0064 Coding patternCoding = HexadecimalCoding; 0065 int count = 1; 0066 }; 0067 0068 class ByteArrayPatternGenerator : public AbstractModelDataGenerator 0069 { 0070 Q_OBJECT 0071 0072 private: 0073 static inline constexpr char ConfigGroupId[] = "ByteArrayPatternGenerator"; 0074 0075 public: 0076 ByteArrayPatternGenerator(); 0077 0078 ~ByteArrayPatternGenerator() override; 0079 0080 public: // AbstractModelDataGenerator API 0081 QMimeData* generateData() override; 0082 0083 public: 0084 ByteArrayPatternGeneratorSettings settings() const; 0085 void setSettings(const ByteArrayPatternGeneratorSettings& settings); 0086 0087 private: 0088 ByteArrayPatternGeneratorSettings mSettings; 0089 }; 0090 0091 inline ByteArrayPatternGeneratorSettings ByteArrayPatternGenerator::settings() const { return mSettings; } 0092 0093 } 0094 0095 #endif