File indexing completed on 2024-04-21 16:33:52
0001 /* 0002 This file is part of the Okteta Core library, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2008-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 "piecetablebytearraymodel.hpp" 0010 #include "piecetablebytearraymodel_p.hpp" 0011 0012 namespace Okteta { 0013 // TODO: a wrapper to a raw data, plus a function to dump the current version to the original data 0014 0015 PieceTableByteArrayModel::PieceTableByteArrayModel(const QByteArray& data, QObject* parent) 0016 : AbstractByteArrayModel(new PieceTableByteArrayModelPrivate(this, data), parent) 0017 {} 0018 0019 PieceTableByteArrayModel::PieceTableByteArrayModel(int size, Byte fillByte, QObject* parent) 0020 : AbstractByteArrayModel(new PieceTableByteArrayModelPrivate(this, size, fillByte), parent) 0021 {} 0022 0023 PieceTableByteArrayModel::~PieceTableByteArrayModel() = default; 0024 0025 Byte PieceTableByteArrayModel::byte(Address offset) const 0026 { 0027 Q_D(const PieceTableByteArrayModel); 0028 0029 return d->byte(offset); 0030 } 0031 0032 Size PieceTableByteArrayModel::size() const 0033 { 0034 Q_D(const PieceTableByteArrayModel); 0035 0036 return d->size(); 0037 } 0038 0039 bool PieceTableByteArrayModel::isReadOnly() const 0040 { 0041 Q_D(const PieceTableByteArrayModel); 0042 0043 return d->isReadOnly(); 0044 } 0045 0046 bool PieceTableByteArrayModel::isModified() const 0047 { 0048 Q_D(const PieceTableByteArrayModel); 0049 0050 return d->isModified(); 0051 } 0052 0053 void PieceTableByteArrayModel::setReadOnly(bool readOnly) 0054 { 0055 Q_D(PieceTableByteArrayModel); 0056 0057 d->setReadOnly(readOnly); 0058 } 0059 0060 void PieceTableByteArrayModel::setModified(bool modified) 0061 { 0062 Q_D(PieceTableByteArrayModel); 0063 0064 d->setModified(modified); 0065 } 0066 0067 void PieceTableByteArrayModel::setData(const QByteArray& data) 0068 { 0069 Q_D(PieceTableByteArrayModel); 0070 0071 d->setData(data); 0072 } 0073 0074 void PieceTableByteArrayModel::setByte(Address offset, Byte byte) 0075 { 0076 Q_D(PieceTableByteArrayModel); 0077 0078 d->setByte(offset, byte); 0079 } 0080 0081 Size PieceTableByteArrayModel::insert(Address offset, const Byte* insertData, int insertLength) 0082 { 0083 Q_D(PieceTableByteArrayModel); 0084 0085 return d->insert(offset, insertData, insertLength); 0086 } 0087 0088 Size PieceTableByteArrayModel::remove(const AddressRange& removeRange) 0089 { 0090 Q_D(PieceTableByteArrayModel); 0091 0092 return d->remove(removeRange); 0093 } 0094 0095 Size PieceTableByteArrayModel::replace(const AddressRange& removeRange, const Byte* insertData, int insertLength) 0096 { 0097 Q_D(PieceTableByteArrayModel); 0098 0099 return d->replace(removeRange, insertData, insertLength); 0100 } 0101 0102 bool PieceTableByteArrayModel::swap(Address firstStart, const AddressRange& secondRange) 0103 { 0104 Q_D(PieceTableByteArrayModel); 0105 0106 return d->swap(firstStart, secondRange); 0107 } 0108 0109 Size PieceTableByteArrayModel::fill(Byte fillByte, Address offset, Size fillLength) 0110 { 0111 Q_D(PieceTableByteArrayModel); 0112 0113 return d->fill(fillByte, offset, fillLength); 0114 } 0115 0116 // int PieceTableByteArrayModel::indexOf( const char *searchString, int length, int from ) const 0117 // { 0118 // return d->indexOf( searchString, length, from ); 0119 // } 0120 // 0121 // int PieceTableByteArrayModel::lastIndexOf( const char *searchString, int length, int from ) const 0122 // { 0123 // return d->lastIndexOf( searchString, length, from ); 0124 // } 0125 0126 int PieceTableByteArrayModel::versionIndex() const 0127 { 0128 Q_D(const PieceTableByteArrayModel); 0129 0130 return d->versionIndex(); 0131 } 0132 0133 int PieceTableByteArrayModel::versionCount() const 0134 { 0135 Q_D(const PieceTableByteArrayModel); 0136 0137 return d->versionCount(); 0138 } 0139 0140 QString PieceTableByteArrayModel::versionDescription(int versionIndex) const 0141 { 0142 Q_D(const PieceTableByteArrayModel); 0143 0144 return d->versionDescription(versionIndex); 0145 } 0146 0147 void PieceTableByteArrayModel::revertToVersionByIndex(int versionIndex) 0148 { 0149 Q_D(PieceTableByteArrayModel); 0150 0151 d->revertToVersionByIndex(versionIndex); 0152 } 0153 0154 void PieceTableByteArrayModel::addBookmarks(const QVector<Okteta::Bookmark>& bookmarks) 0155 { 0156 Q_D(PieceTableByteArrayModel); 0157 0158 d->addBookmarks(bookmarks); 0159 } 0160 0161 void PieceTableByteArrayModel::removeBookmarks(const QVector<Okteta::Bookmark>& bookmarks) 0162 { 0163 Q_D(PieceTableByteArrayModel); 0164 0165 d->removeBookmarks(bookmarks); 0166 } 0167 0168 void PieceTableByteArrayModel::removeAllBookmarks() 0169 { 0170 Q_D(PieceTableByteArrayModel); 0171 0172 d->removeAllBookmarks(); 0173 } 0174 0175 void PieceTableByteArrayModel::setBookmark(unsigned int index, const Okteta::Bookmark& bookmark) 0176 { 0177 Q_D(PieceTableByteArrayModel); 0178 0179 d->setBookmark(index, bookmark); 0180 } 0181 0182 Okteta::BookmarksConstIterator PieceTableByteArrayModel::createBookmarksConstIterator() const 0183 { 0184 Q_D(const PieceTableByteArrayModel); 0185 0186 return d->createBookmarksConstIterator(); 0187 } 0188 0189 const Okteta::Bookmark& PieceTableByteArrayModel::bookmarkAt(unsigned int index) const 0190 { 0191 Q_D(const PieceTableByteArrayModel); 0192 0193 return d->bookmarkAt(index); 0194 } 0195 0196 const Okteta::Bookmark& PieceTableByteArrayModel::bookmarkFor(int offset) const 0197 { 0198 Q_D(const PieceTableByteArrayModel); 0199 0200 return d->bookmarkFor(offset); 0201 } 0202 0203 bool PieceTableByteArrayModel::containsBookmarkFor(int offset) const 0204 { 0205 Q_D(const PieceTableByteArrayModel); 0206 0207 return d->containsBookmarkFor(offset); 0208 } 0209 0210 unsigned int PieceTableByteArrayModel::bookmarksCount() const 0211 { 0212 Q_D(const PieceTableByteArrayModel); 0213 0214 return d->bookmarksCount(); 0215 } 0216 0217 void PieceTableByteArrayModel::openGroupedChange(const QString& description) 0218 { 0219 Q_D(PieceTableByteArrayModel); 0220 0221 d->openGroupedChange(description); 0222 } 0223 0224 void PieceTableByteArrayModel::cancelGroupedChange() 0225 { 0226 Q_D(PieceTableByteArrayModel); 0227 0228 d->cancelGroupedChange(); 0229 } 0230 0231 void PieceTableByteArrayModel::closeGroupedChange(const QString& description) 0232 { 0233 Q_D(PieceTableByteArrayModel); 0234 0235 d->closeGroupedChange(description); 0236 } 0237 0238 QVector<ByteArrayChange> PieceTableByteArrayModel::changes(int firstVersionIndex, int lastVersionIndex) const 0239 { 0240 Q_D(const PieceTableByteArrayModel); 0241 0242 return d->changes(firstVersionIndex, lastVersionIndex); 0243 } 0244 0245 QByteArray PieceTableByteArrayModel::initialData() const 0246 { 0247 Q_D(const PieceTableByteArrayModel); 0248 0249 return d->initialData(); 0250 } 0251 0252 void PieceTableByteArrayModel::doChanges(const QVector<Okteta::ByteArrayChange>& changes, 0253 int oldVersionIndex, int newVersionIndex) 0254 { 0255 Q_D(PieceTableByteArrayModel); 0256 0257 d->doChanges(changes, oldVersionIndex, newVersionIndex); 0258 } 0259 0260 } 0261 0262 #include "moc_piecetablebytearraymodel.cpp"