forked from KDE/okteta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpiecetablebytearraymodel.cpp
262 lines (188 loc) · 6.19 KB
/
piecetablebytearraymodel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/*
This file is part of the Okteta Core library, made within the KDE community.
SPDX-FileCopyrightText: 2008-2009 Friedrich W. H. Kossebau <[email protected]>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "piecetablebytearraymodel.hpp"
#include "piecetablebytearraymodel_p.hpp"
namespace Okteta {
// TODO: a wrapper to a raw data, plus a function to dump the current version to the original data
PieceTableByteArrayModel::PieceTableByteArrayModel(const QByteArray& data, QObject* parent)
: AbstractByteArrayModel(std::make_unique<PieceTableByteArrayModelPrivate>(this, data), parent)
{}
PieceTableByteArrayModel::PieceTableByteArrayModel(int size, Byte fillByte, QObject* parent)
: AbstractByteArrayModel(std::make_unique<PieceTableByteArrayModelPrivate>(this, size, fillByte), parent)
{}
PieceTableByteArrayModel::~PieceTableByteArrayModel() = default;
Byte PieceTableByteArrayModel::byte(Address offset) const
{
Q_D(const PieceTableByteArrayModel);
return d->byte(offset);
}
Size PieceTableByteArrayModel::size() const
{
Q_D(const PieceTableByteArrayModel);
return d->size();
}
bool PieceTableByteArrayModel::isReadOnly() const
{
Q_D(const PieceTableByteArrayModel);
return d->isReadOnly();
}
bool PieceTableByteArrayModel::isModified() const
{
Q_D(const PieceTableByteArrayModel);
return d->isModified();
}
void PieceTableByteArrayModel::setReadOnly(bool readOnly)
{
Q_D(PieceTableByteArrayModel);
d->setReadOnly(readOnly);
}
void PieceTableByteArrayModel::setModified(bool modified)
{
Q_D(PieceTableByteArrayModel);
d->setModified(modified);
}
void PieceTableByteArrayModel::setData(const QByteArray& data)
{
Q_D(PieceTableByteArrayModel);
d->setData(data);
}
void PieceTableByteArrayModel::setByte(Address offset, Byte byte)
{
Q_D(PieceTableByteArrayModel);
d->setByte(offset, byte);
}
Size PieceTableByteArrayModel::insert(Address offset, const Byte* insertData, int insertLength)
{
Q_D(PieceTableByteArrayModel);
return d->insert(offset, insertData, insertLength);
}
Size PieceTableByteArrayModel::remove(const AddressRange& removeRange)
{
Q_D(PieceTableByteArrayModel);
return d->remove(removeRange);
}
Size PieceTableByteArrayModel::replace(const AddressRange& removeRange, const Byte* insertData, int insertLength)
{
Q_D(PieceTableByteArrayModel);
return d->replace(removeRange, insertData, insertLength);
}
bool PieceTableByteArrayModel::swap(Address firstStart, const AddressRange& secondRange)
{
Q_D(PieceTableByteArrayModel);
return d->swap(firstStart, secondRange);
}
Size PieceTableByteArrayModel::fill(Byte fillByte, Address offset, Size fillLength)
{
Q_D(PieceTableByteArrayModel);
return d->fill(fillByte, offset, fillLength);
}
// int PieceTableByteArrayModel::indexOf( const char *searchString, int length, int from ) const
// {
// return d->indexOf( searchString, length, from );
// }
//
// int PieceTableByteArrayModel::lastIndexOf( const char *searchString, int length, int from ) const
// {
// return d->lastIndexOf( searchString, length, from );
// }
int PieceTableByteArrayModel::versionIndex() const
{
Q_D(const PieceTableByteArrayModel);
return d->versionIndex();
}
int PieceTableByteArrayModel::versionCount() const
{
Q_D(const PieceTableByteArrayModel);
return d->versionCount();
}
QString PieceTableByteArrayModel::versionDescription(int versionIndex) const
{
Q_D(const PieceTableByteArrayModel);
return d->versionDescription(versionIndex);
}
void PieceTableByteArrayModel::revertToVersionByIndex(int versionIndex)
{
Q_D(PieceTableByteArrayModel);
d->revertToVersionByIndex(versionIndex);
}
void PieceTableByteArrayModel::addBookmarks(const QVector<Okteta::Bookmark>& bookmarks)
{
Q_D(PieceTableByteArrayModel);
d->addBookmarks(bookmarks);
}
void PieceTableByteArrayModel::removeBookmarks(const QVector<Okteta::Bookmark>& bookmarks)
{
Q_D(PieceTableByteArrayModel);
d->removeBookmarks(bookmarks);
}
void PieceTableByteArrayModel::removeAllBookmarks()
{
Q_D(PieceTableByteArrayModel);
d->removeAllBookmarks();
}
void PieceTableByteArrayModel::setBookmark(unsigned int index, const Okteta::Bookmark& bookmark)
{
Q_D(PieceTableByteArrayModel);
d->setBookmark(index, bookmark);
}
Okteta::BookmarksConstIterator PieceTableByteArrayModel::createBookmarksConstIterator() const
{
Q_D(const PieceTableByteArrayModel);
return d->createBookmarksConstIterator();
}
const Okteta::Bookmark& PieceTableByteArrayModel::bookmarkAt(unsigned int index) const
{
Q_D(const PieceTableByteArrayModel);
return d->bookmarkAt(index);
}
const Okteta::Bookmark& PieceTableByteArrayModel::bookmarkFor(int offset) const
{
Q_D(const PieceTableByteArrayModel);
return d->bookmarkFor(offset);
}
bool PieceTableByteArrayModel::containsBookmarkFor(int offset) const
{
Q_D(const PieceTableByteArrayModel);
return d->containsBookmarkFor(offset);
}
unsigned int PieceTableByteArrayModel::bookmarksCount() const
{
Q_D(const PieceTableByteArrayModel);
return d->bookmarksCount();
}
void PieceTableByteArrayModel::openGroupedChange(const QString& description)
{
Q_D(PieceTableByteArrayModel);
d->openGroupedChange(description);
}
void PieceTableByteArrayModel::cancelGroupedChange()
{
Q_D(PieceTableByteArrayModel);
d->cancelGroupedChange();
}
void PieceTableByteArrayModel::closeGroupedChange(const QString& description)
{
Q_D(PieceTableByteArrayModel);
d->closeGroupedChange(description);
}
QVector<ByteArrayChange> PieceTableByteArrayModel::changes(int firstVersionIndex, int lastVersionIndex) const
{
Q_D(const PieceTableByteArrayModel);
return d->changes(firstVersionIndex, lastVersionIndex);
}
QByteArray PieceTableByteArrayModel::initialData() const
{
Q_D(const PieceTableByteArrayModel);
return d->initialData();
}
void PieceTableByteArrayModel::doChanges(const QVector<Okteta::ByteArrayChange>& changes,
int oldVersionIndex, int newVersionIndex)
{
Q_D(PieceTableByteArrayModel);
d->doChanges(changes, oldVersionIndex, newVersionIndex);
}
}
#include "moc_piecetablebytearraymodel.cpp"