File indexing completed on 2024-04-14 05:45:45
0001 /* 0002 This file is part of the Okteta Core library, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2003, 2007-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 #include "bytearraymodel.hpp" 0010 0011 // lib 0012 #include "bytearraymodel_p.hpp" 0013 #include "arraychangemetricslist.hpp" 0014 0015 namespace Okteta { 0016 0017 ByteArrayModel::ByteArrayModel(Byte* data, int size, int rawSize, bool keepMemory, QObject* parent) 0018 : AbstractByteArrayModel(new ByteArrayModelPrivate(this, data, size, rawSize, keepMemory), parent) 0019 {} 0020 0021 ByteArrayModel::ByteArrayModel(const Byte* data, int size, QObject* parent) 0022 : AbstractByteArrayModel(new ByteArrayModelPrivate(this, data, size), parent) 0023 {} 0024 0025 ByteArrayModel::ByteArrayModel(int size, int maxSize, QObject* parent) 0026 : AbstractByteArrayModel(new ByteArrayModelPrivate(this, size, maxSize), parent) 0027 {} 0028 0029 ByteArrayModel::~ByteArrayModel() = default; 0030 0031 Byte ByteArrayModel::byte(Address offset) const 0032 { 0033 Q_D(const ByteArrayModel); 0034 0035 return d->byte(offset); 0036 } 0037 0038 Size ByteArrayModel::size() const 0039 { 0040 Q_D(const ByteArrayModel); 0041 0042 return d->size(); 0043 } 0044 0045 bool ByteArrayModel::isReadOnly() const 0046 { 0047 Q_D(const ByteArrayModel); 0048 0049 return d->isReadOnly(); 0050 } 0051 0052 bool ByteArrayModel::isModified() const 0053 { 0054 Q_D(const ByteArrayModel); 0055 0056 return d->isModified(); 0057 } 0058 0059 void ByteArrayModel::setReadOnly(bool readOnly) 0060 { 0061 Q_D(ByteArrayModel); 0062 0063 d->setReadOnly(readOnly); 0064 } 0065 0066 void ByteArrayModel::setModified(bool modified) 0067 { 0068 Q_D(ByteArrayModel); 0069 0070 d->setModified(modified); 0071 } 0072 0073 void ByteArrayModel::setMaxSize(int maxSize) 0074 { 0075 Q_D(ByteArrayModel); 0076 0077 d->setMaxSize(maxSize); 0078 } 0079 0080 void ByteArrayModel::setKeepsMemory(bool keepsMemory) 0081 { 0082 Q_D(ByteArrayModel); 0083 0084 d->setKeepsMemory(keepsMemory); 0085 } 0086 0087 void ByteArrayModel::setAutoDelete(bool autoDelete) 0088 { 0089 Q_D(ByteArrayModel); 0090 0091 d->setAutoDelete(autoDelete); 0092 } 0093 0094 void ByteArrayModel::setData(Byte* data, int size, int rawSize, bool keepMemory) 0095 { 0096 Q_D(ByteArrayModel); 0097 0098 d->setData(data, size, rawSize, keepMemory); 0099 } 0100 0101 Byte* ByteArrayModel::data() const 0102 { 0103 Q_D(const ByteArrayModel); 0104 0105 return d->data(); 0106 } 0107 0108 int ByteArrayModel::maxSize() const 0109 { 0110 Q_D(const ByteArrayModel); 0111 0112 return d->maxSize(); 0113 } 0114 0115 bool ByteArrayModel::keepsMemory() const 0116 { 0117 Q_D(const ByteArrayModel); 0118 0119 return d->keepsMemory(); 0120 } 0121 0122 bool ByteArrayModel::autoDelete() const 0123 { 0124 Q_D(const ByteArrayModel); 0125 0126 return d->autoDelete(); 0127 } 0128 0129 void ByteArrayModel::signalContentsChanged(int start, int end) 0130 { 0131 const int length = end - start + 1; 0132 Q_EMIT contentsChanged(ArrayChangeMetricsList::oneReplacement(start, length, length)); 0133 } 0134 0135 void ByteArrayModel::setByte(Address offset, Byte byte) 0136 { 0137 Q_D(ByteArrayModel); 0138 0139 d->setByte(offset, byte); 0140 } 0141 0142 Size ByteArrayModel::insert(Address offset, const Byte* insertData, int insertLength) 0143 { 0144 Q_D(ByteArrayModel); 0145 0146 return d->insert(offset, insertData, insertLength); 0147 } 0148 0149 Size ByteArrayModel::remove(const AddressRange& removeRange) 0150 { 0151 Q_D(ByteArrayModel); 0152 0153 return d->remove(removeRange); 0154 } 0155 0156 Size ByteArrayModel::replace(const AddressRange& removeRange, const Byte* insertData, int insertLength) 0157 { 0158 Q_D(ByteArrayModel); 0159 0160 return d->replace(removeRange, insertData, insertLength); 0161 } 0162 0163 bool ByteArrayModel::swap(Address firstStart, const AddressRange& secondRange) 0164 { 0165 Q_D(ByteArrayModel); 0166 0167 return d->swap(firstStart, secondRange); 0168 } 0169 0170 Size ByteArrayModel::fill(Byte fillByte, Address offset, Size fillLength) 0171 { 0172 Q_D(ByteArrayModel); 0173 0174 return d->fill(fillByte, offset, fillLength); 0175 } 0176 0177 void ByteArrayModel::addBookmarks(const QVector<Okteta::Bookmark>& bookmarks) 0178 { 0179 Q_D(ByteArrayModel); 0180 0181 d->addBookmarks(bookmarks); 0182 } 0183 0184 void ByteArrayModel::removeBookmarks(const QVector<Okteta::Bookmark>& bookmarks) 0185 { 0186 Q_D(ByteArrayModel); 0187 0188 d->removeBookmarks(bookmarks); 0189 } 0190 0191 void ByteArrayModel::removeAllBookmarks() 0192 { 0193 Q_D(ByteArrayModel); 0194 0195 d->removeAllBookmarks(); 0196 } 0197 0198 void ByteArrayModel::setBookmark(unsigned int index, const Okteta::Bookmark& bookmark) 0199 { 0200 Q_D(ByteArrayModel); 0201 0202 d->setBookmark(index, bookmark); 0203 } 0204 0205 Okteta::BookmarksConstIterator ByteArrayModel::createBookmarksConstIterator() const 0206 { 0207 Q_D(const ByteArrayModel); 0208 0209 return d->createBookmarksConstIterator(); 0210 } 0211 0212 const Okteta::Bookmark& ByteArrayModel::bookmarkFor(int offset) const 0213 { 0214 Q_D(const ByteArrayModel); 0215 0216 return d->bookmarkFor(offset); 0217 } 0218 0219 const Okteta::Bookmark& ByteArrayModel::bookmarkAt(unsigned int index) const 0220 { 0221 Q_D(const ByteArrayModel); 0222 0223 return d->bookmarkAt(index); 0224 } 0225 0226 bool ByteArrayModel::containsBookmarkFor(int offset) const 0227 { 0228 Q_D(const ByteArrayModel); 0229 0230 return d->containsBookmarkFor(offset); 0231 } 0232 0233 unsigned int ByteArrayModel::bookmarksCount() const 0234 { 0235 Q_D(const ByteArrayModel); 0236 0237 return d->bookmarksCount(); 0238 } 0239 0240 } 0241 0242 #include "moc_bytearraymodel.cpp"