• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

okteta

  • sources
  • kde-4.12
  • kdesdk
  • okteta
  • core
piecetablebytearraymodel_p.h
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta Core library, made within the KDE community.
3 
4  Copyright 2008-2009 Friedrich W. H. Kossebau <kossebau@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) version 3, or any
10  later version accepted by the membership of KDE e.V. (or its
11  successor approved by the membership of KDE e.V.), which shall
12  act as a proxy defined in Section 6 of version 3 of the license.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #ifndef OKTETA_PIECETABLEBYTEARRAYMODEL_P_H
24 #define OKTETA_PIECETABLEBYTEARRAYMODEL_P_H
25 
26 // lib
27 #include "piecetablebytearraymodel.h"
28 #include "bookmarksconstiterator.h"
29 #include "bookmarklistconstiteratoradapter.h"
30 #include "bookmarklist.h"
31 #include "changesdatastorage.h"
32 #include "arraychangemetricslist.h"
33 // piecetable
34 #include "piecetable/revertablepiecetable.h"
35 
36 
37 namespace Okteta
38 {
39 
40 class PieceTableByteArrayModelPrivate
41 {
42  public:
44  explicit PieceTableByteArrayModelPrivate( PieceTableByteArrayModel* parent, const QByteArray& data );
46  explicit PieceTableByteArrayModelPrivate( PieceTableByteArrayModel* parent, int size, Byte fillByte = '\0' );
47 
48  ~PieceTableByteArrayModelPrivate();
49 
50  public: // AbstractByteArrayModel API
51  Byte byte( Address offset ) const;
52  Size size() const;
53  bool isReadOnly() const;
54  bool isModified() const;
55 
56  Size insert( Address offset, const Byte* insertData, int insertLength );
57  Size remove( const AddressRange& removeRange );
58  Size replace( const AddressRange& removeRange, const Byte* insertData, int insertLength );
59  bool swap( Address firstStart, const AddressRange& secondRange );
60  Size fill( Byte fillByte, Address offset = 0, Size fillLength = -1 );
61  void setByte( Address offset, Byte byte );
62 
63  void setModified( bool modified = true );
64  void setReadOnly( bool isReadOnly = true );
65 
66  public: // Versionable API
67  int versionIndex() const;
68  int versionCount() const;
69  QString versionDescription( int versionIndex ) const;
70 
71  public: // set/action
72  void revertToVersionByIndex( int versionIndex );
73 
74  public:
75  void addBookmarks( const QList<Bookmark>& bookmarks );
76  void removeBookmarks( const QList<Bookmark>& bookmarks );
77  void removeAllBookmarks();
78  void setBookmark( unsigned int index, const Bookmark& bookmark );
79 
80  BookmarksConstIterator createBookmarksConstIterator() const;
81  const Bookmark& bookmarkAt( unsigned int index ) const;
82  const Bookmark& bookmarkFor( int offset ) const;
83  bool containsBookmarkFor( int offset ) const;
84  unsigned int bookmarksCount() const;
85 
86  public: // ChangesDescribable API
87  void openGroupedChange( const QString& description );
88  void cancelGroupedChange();
89  void closeGroupedChange( const QString& description );
90 
91  public: // ChangeHistory API
92  QList<ByteArrayChange> changes( int firstVersionIndex, int lastVersionIndex ) const;
93  const QByteArray& initialData() const;
94  void doChanges( const QList<Okteta::ByteArrayChange>& changes,
95  int oldVersionIndex, int newVersionIndex );
96 
97  public:
98  void setData( const QByteArray& data );
99 
100  protected:
101  void doInsertChange( Address offset, const Byte* insertData, int insertLength );
102  void doRemoveChange( const AddressRange& removeRange );
103  void doReplaceChange( const AddressRange& removeRange, const Byte* insertData, int insertLength );
104  void doSwapChange( Address firstStart, const AddressRange& secondRange );
105  void doFillChange( Address offset, Size filledLength,
106  Byte fillByte, int fillLength );
107 
108  void beginChanges();
109  void endChanges();
110 
111  protected: // data
112  PieceTableByteArrayModel *p;
114  bool mReadOnly :1;
115 
116  QByteArray mInitialData;
117  KPieceTable::RevertablePieceTable mPieceTable;
118  ChangesDataStorage mChangesDataStorage;
120  BookmarkList mBookmarks;
122  int mBeforeGroupedChangeVersionIndex;
123 
124  int mBeforeChangesVersionIndex;
125  ArrayChangeMetricsList mChangeMetrics;
126  QList<ByteArrayChange> mChanges;
127  bool mBeforeChangesModified:1;
128  bool mBookmarksModified:1;
129 };
130 
131 
132 inline const QByteArray& PieceTableByteArrayModelPrivate::initialData() const { return mInitialData; }
133 inline Size PieceTableByteArrayModelPrivate::size() const { return mPieceTable.size(); }
134 
135 inline bool PieceTableByteArrayModelPrivate::isReadOnly() const { return mReadOnly; }
136 inline bool PieceTableByteArrayModelPrivate::isModified() const { return !mPieceTable.isAtBase(); }
137 
138 inline void PieceTableByteArrayModelPrivate::setReadOnly( bool readOnly )
139 {
140  if( mReadOnly != readOnly )
141  {
142  mReadOnly = readOnly;
143  emit p->readOnlyChanged( readOnly );
144  }
145 }
146 inline void PieceTableByteArrayModelPrivate::setModified( bool modified )
147 {
148  if( isModified() != modified )
149  {
150  mPieceTable.setBeforeCurrentChangeAsBase(modified);
151  // TODO: is the call setModified of any use?
152  // shouldn't there be only a setUnmodified(void) or else call?
153  emit p->modifiedChanged( modified );
154  }
155 }
156 
157 inline int PieceTableByteArrayModelPrivate::versionIndex() const { return mPieceTable.appliedChangesCount(); }
158 inline int PieceTableByteArrayModelPrivate::versionCount() const { return mPieceTable.changesCount()+1; }
159 inline QString PieceTableByteArrayModelPrivate::versionDescription( int versionIndex ) const
160 { return mPieceTable.changeDescription( versionIndex-1 ); }
161 
162 inline void PieceTableByteArrayModelPrivate::addBookmarks( const QList<Bookmark> &bookmarks )
163 {
164  mBookmarks.addBookmarks( bookmarks );
165  emit p->bookmarksAdded( bookmarks );
166 }
167 inline void PieceTableByteArrayModelPrivate::removeBookmarks( const QList<Bookmark> &bookmarks )
168 {
169  mBookmarks.removeBookmarks( bookmarks );
170  emit p->bookmarksRemoved( bookmarks );
171 }
172 
173 inline void PieceTableByteArrayModelPrivate::removeAllBookmarks()
174 {
175  const QList<Bookmark> bookmarks = mBookmarks.list();
176  mBookmarks.clear();
177  emit p->bookmarksRemoved( bookmarks );
178 }
179 inline void PieceTableByteArrayModelPrivate::setBookmark( unsigned int index, const Bookmark& bookmark )
180 {
181  mBookmarks.setBookmark( index, bookmark );
182 
183  QList<int> changedBookmarkIndizes;
184  changedBookmarkIndizes.append( index );
185  emit p->bookmarksModified( changedBookmarkIndizes );
186 }
187 
188 inline BookmarksConstIterator PieceTableByteArrayModelPrivate::createBookmarksConstIterator() const
189 {
190  return BookmarksConstIterator( new BookmarkListConstIteratorAdapter(mBookmarks) );
191 }
192 
193 inline const Bookmark& PieceTableByteArrayModelPrivate::bookmarkAt( unsigned int index ) const
194 {
195  return mBookmarks.at( index );
196 }
197 inline const Bookmark& PieceTableByteArrayModelPrivate::bookmarkFor( int offset ) const
198 {
199  return mBookmarks.bookmark( offset );
200 }
201 inline bool PieceTableByteArrayModelPrivate::containsBookmarkFor( int offset ) const { return mBookmarks.contains( offset ); }
202 inline unsigned int PieceTableByteArrayModelPrivate::bookmarksCount() const { return mBookmarks.size(); }
203 
204 }
205 
206 #endif
Okteta::PieceTableByteArrayModelPrivate::removeAllBookmarks
void removeAllBookmarks()
Definition: piecetablebytearraymodel_p.h:173
Okteta::PieceTableByteArrayModelPrivate::doFillChange
void doFillChange(Address offset, Size filledLength, Byte fillByte, int fillLength)
Okteta::Address
qint32 Address
Definition: address.h:34
Okteta::BookmarkListConstIteratorAdapter
Definition: bookmarklistconstiteratoradapter.h:37
Okteta::PieceTableByteArrayModelPrivate::closeGroupedChange
void closeGroupedChange(const QString &description)
Okteta::PieceTableByteArrayModelPrivate::bookmarkAt
const Bookmark & bookmarkAt(unsigned int index) const
Definition: piecetablebytearraymodel_p.h:193
Okteta::BookmarkList
Definition: bookmarklist.h:40
KPieceTable::RevertablePieceTable::changeDescription
QString changeDescription(int change) const
Definition: revertablepiecetable.h:117
Okteta::PieceTableByteArrayModelPrivate::addBookmarks
void addBookmarks(const QList< Bookmark > &bookmarks)
Definition: piecetablebytearraymodel_p.h:162
KPieceTable::RevertablePieceTable::size
Size size() const
Definition: revertablepiecetable.h:113
Okteta::PieceTableByteArrayModelPrivate::mReadOnly
bool mReadOnly
Definition: piecetablebytearraymodel_p.h:114
Okteta::BookmarkList::bookmark
const Bookmark & bookmark(Address offset) const
Definition: bookmarklist.cpp:177
Okteta::BookmarkList::removeBookmarks
void removeBookmarks(const QList< Okteta::Bookmark > &bookmarks)
Definition: bookmarklist.cpp:86
Okteta::Bookmark
Definition: bookmark.h:38
KPieceTable::RevertablePieceTable
Definition: revertablepiecetable.h:34
KDE::NumberRange< Address, Size >
Okteta::PieceTableByteArrayModelPrivate::mPieceTable
KPieceTable::RevertablePieceTable mPieceTable
Definition: piecetablebytearraymodel_p.h:117
Okteta::PieceTableByteArrayModelPrivate::mChanges
QList< ByteArrayChange > mChanges
Definition: piecetablebytearraymodel_p.h:126
Okteta::PieceTableByteArrayModelPrivate::changes
QList< ByteArrayChange > changes(int firstVersionIndex, int lastVersionIndex) const
Okteta::Byte
unsigned char Byte
Definition: byte.h:29
Okteta::AbstractByteArrayModel::readOnlyChanged
void readOnlyChanged(bool isReadOnly)
Okteta::PieceTableByteArrayModelPrivate::openGroupedChange
void openGroupedChange(const QString &description)
Okteta::AbstractByteArrayModel::modifiedChanged
void modifiedChanged(bool isModified)
Okteta::PieceTableByteArrayModelPrivate::mBookmarksModified
bool mBookmarksModified
Definition: piecetablebytearraymodel_p.h:128
Okteta::PieceTableByteArrayModelPrivate::mChangesDataStorage
ChangesDataStorage mChangesDataStorage
Definition: piecetablebytearraymodel_p.h:118
Okteta::PieceTableByteArrayModelPrivate::versionDescription
QString versionDescription(int versionIndex) const
Definition: piecetablebytearraymodel_p.h:159
Okteta::PieceTableByteArrayModelPrivate::revertToVersionByIndex
void revertToVersionByIndex(int versionIndex)
KPieceTable::RevertablePieceTable::appliedChangesCount
int appliedChangesCount() const
Definition: revertablepiecetable.h:115
Okteta::PieceTableByteArrayModelPrivate::mBeforeChangesVersionIndex
int mBeforeChangesVersionIndex
Definition: piecetablebytearraymodel_p.h:124
Okteta::PieceTableByteArrayModelPrivate::byte
Byte byte(Address offset) const
Okteta::PieceTableByteArrayModelPrivate::setData
void setData(const QByteArray &data)
Okteta::PieceTableByteArrayModelPrivate::cancelGroupedChange
void cancelGroupedChange()
Okteta::PieceTableByteArrayModelPrivate::replace
Size replace(const AddressRange &removeRange, const Byte *insertData, int insertLength)
Okteta::PieceTableByteArrayModelPrivate::insert
Size insert(Address offset, const Byte *insertData, int insertLength)
Okteta::PieceTableByteArrayModelPrivate::PieceTableByteArrayModelPrivate
PieceTableByteArrayModelPrivate(PieceTableByteArrayModel *parent, const QByteArray &data)
piecetablebytearraymodel.h
Okteta::BookmarksConstIterator
Definition: bookmarksconstiterator.h:36
Okteta::PieceTableByteArrayModelPrivate::createBookmarksConstIterator
BookmarksConstIterator createBookmarksConstIterator() const
Definition: piecetablebytearraymodel_p.h:188
KPieceTable::RevertablePieceTable::setBeforeCurrentChangeAsBase
void setBeforeCurrentChangeAsBase(bool hide)
Definition: revertablepiecetable.h:108
Okteta::PieceTableByteArrayModelPrivate::endChanges
void endChanges()
Okteta::PieceTableByteArrayModelPrivate::setReadOnly
void setReadOnly(bool isReadOnly=true)
Definition: piecetablebytearraymodel_p.h:138
KPieceTable::RevertablePieceTable::isAtBase
bool isAtBase() const
Definition: revertablepiecetable.h:116
Okteta::PieceTableByteArrayModel::bookmarksModified
void bookmarksModified(bool modified)
Okteta::PieceTableByteArrayModelPrivate::mBeforeChangesModified
bool mBeforeChangesModified
Definition: piecetablebytearraymodel_p.h:127
bookmarksconstiterator.h
Okteta::PieceTableByteArrayModelPrivate::beginChanges
void beginChanges()
Okteta::PieceTableByteArrayModelPrivate::mBookmarks
BookmarkList mBookmarks
Definition: piecetablebytearraymodel_p.h:120
Okteta::PieceTableByteArrayModelPrivate::fill
Size fill(Byte fillByte, Address offset=0, Size fillLength=-1)
Okteta::PieceTableByteArrayModelPrivate::isReadOnly
bool isReadOnly() const
Definition: piecetablebytearraymodel_p.h:135
Okteta::ArrayChangeMetricsList
Definition: arraychangemetricslist.h:36
Okteta::BookmarkList::contains
bool contains(Address offset) const
Definition: bookmarklist.cpp:190
Okteta::PieceTableByteArrayModel::bookmarksRemoved
void bookmarksRemoved(const QList< Okteta::Bookmark > &bookmarks)
Okteta::PieceTableByteArrayModelPrivate::isModified
bool isModified() const
Definition: piecetablebytearraymodel_p.h:136
Okteta::PieceTableByteArrayModelPrivate::bookmarkFor
const Bookmark & bookmarkFor(int offset) const
Definition: piecetablebytearraymodel_p.h:197
Okteta::PieceTableByteArrayModelPrivate::doRemoveChange
void doRemoveChange(const AddressRange &removeRange)
Okteta::PieceTableByteArrayModelPrivate::containsBookmarkFor
bool containsBookmarkFor(int offset) const
Definition: piecetablebytearraymodel_p.h:201
Okteta::PieceTableByteArrayModel::bookmarksAdded
void bookmarksAdded(const QList< Okteta::Bookmark > &bookmarks)
Okteta::PieceTableByteArrayModelPrivate::doChanges
void doChanges(const QList< Okteta::ByteArrayChange > &changes, int oldVersionIndex, int newVersionIndex)
Okteta::PieceTableByteArrayModelPrivate::swap
bool swap(Address firstStart, const AddressRange &secondRange)
Okteta::ChangesDataStorage
Definition: changesdatastorage.h:32
Okteta::PieceTableByteArrayModelPrivate::doReplaceChange
void doReplaceChange(const AddressRange &removeRange, const Byte *insertData, int insertLength)
Okteta::BookmarkList::addBookmarks
void addBookmarks(const QList< Okteta::Bookmark > &bookmarks)
Definition: bookmarklist.cpp:64
revertablepiecetable.h
Okteta::PieceTableByteArrayModelPrivate::p
PieceTableByteArrayModel * p
Definition: piecetablebytearraymodel_p.h:112
Okteta::PieceTableByteArrayModelPrivate
Definition: piecetablebytearraymodel_p.h:40
arraychangemetricslist.h
Okteta::BookmarkList::list
QList< Okteta::Bookmark > list() const
Definition: bookmarklist.cpp:167
Okteta::PieceTableByteArrayModelPrivate::bookmarksCount
unsigned int bookmarksCount() const
Definition: piecetablebytearraymodel_p.h:202
KPieceTable::RevertablePieceTable::changesCount
int changesCount() const
Definition: revertablepiecetable.h:114
bookmarklistconstiteratoradapter.h
bookmarklist.h
Okteta::PieceTableByteArrayModelPrivate::setBookmark
void setBookmark(unsigned int index, const Bookmark &bookmark)
Definition: piecetablebytearraymodel_p.h:179
Okteta::PieceTableByteArrayModelPrivate::mBeforeGroupedChangeVersionIndex
int mBeforeGroupedChangeVersionIndex
temporary workaround for cancelling groups.
Definition: piecetablebytearraymodel_p.h:122
Okteta::PieceTableByteArrayModelPrivate::versionIndex
int versionIndex() const
Definition: piecetablebytearraymodel_p.h:157
Okteta::BookmarkList::setBookmark
void setBookmark(unsigned int index, const Bookmark &bookmark)
Definition: bookmarklist.cpp:92
Okteta::PieceTableByteArrayModelPrivate::versionCount
int versionCount() const
Definition: piecetablebytearraymodel_p.h:158
Okteta::PieceTableByteArrayModelPrivate::mInitialData
QByteArray mInitialData
Definition: piecetablebytearraymodel_p.h:116
Okteta::PieceTableByteArrayModelPrivate::doInsertChange
void doInsertChange(Address offset, const Byte *insertData, int insertLength)
changesdatastorage.h
Okteta::PieceTableByteArrayModelPrivate::doSwapChange
void doSwapChange(Address firstStart, const AddressRange &secondRange)
Okteta::PieceTableByteArrayModelPrivate::size
Size size() const
Definition: piecetablebytearraymodel_p.h:133
Okteta::Size
qint32 Size
Definition: size.h:33
Okteta::PieceTableByteArrayModelPrivate::initialData
const QByteArray & initialData() const
Definition: piecetablebytearraymodel_p.h:132
Okteta::PieceTableByteArrayModelPrivate::setByte
void setByte(Address offset, Byte byte)
Okteta::PieceTableByteArrayModel
Definition: piecetablebytearraymodel.h:44
Okteta::PieceTableByteArrayModelPrivate::mChangeMetrics
ArrayChangeMetricsList mChangeMetrics
Definition: piecetablebytearraymodel_p.h:125
Okteta::PieceTableByteArrayModelPrivate::removeBookmarks
void removeBookmarks(const QList< Bookmark > &bookmarks)
Definition: piecetablebytearraymodel_p.h:167
Okteta::PieceTableByteArrayModelPrivate::~PieceTableByteArrayModelPrivate
~PieceTableByteArrayModelPrivate()
QList
Definition: bookmarkable.h:29
Okteta::PieceTableByteArrayModelPrivate::setModified
void setModified(bool modified=true)
Definition: piecetablebytearraymodel_p.h:146
Okteta::BookmarkList::at
const Bookmark & at(unsigned int index) const
Definition: bookmarklist.cpp:207
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okteta

Skip menu "okteta"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal