• 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
  • kasten
  • gui
  • io
  • streamencoder
  • viewtext
charbytearraycolumntextrenderer.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta Kasten module, made within the KDE community.
3 
4  Copyright 2003,2008 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 #include "charbytearraycolumntextrenderer.h"
24 
25 // Okteta core
26 #include <abstractbytearraymodel.h>
27 #include <charcodec.h>
28 #include <character.h>
29 // Qt
30 #include <QtCore/QTextStream>
31 
32 
33 namespace Kasten2
34 {
35 
36 CharByteArrayColumnTextRenderer::CharByteArrayColumnTextRenderer(
37  const Okteta::AbstractByteArrayModel* byteArrayModel, Okteta::Address offset,
38  const Okteta::CoordRange& coordRange,
39  int noOfBytesPerLine, int byteSpacingWidth, int noOfGroupedBytes,
40  const QString& charCodecName, QChar substituteChar, QChar undefinedChar )
41  : AbstractByteArrayColumnTextRenderer( byteArrayModel, offset, coordRange,
42  noOfBytesPerLine ),
43  mCharCodec( Okteta::CharCodec::createCodec(charCodecName) ),
44  mSubstituteChar( substituteChar ),
45  mUndefinedChar( undefinedChar )
46 {
47  setWidths( 1, byteSpacingWidth, noOfGroupedBytes );
48 }
49 
50 
51 void CharByteArrayColumnTextRenderer::renderLine( QTextStream* stream, bool isSubline ) const
52 {
53 Q_UNUSED( isSubline )
54 
55  int p = 0;
56  int pEnd = mNoOfBytesPerLine;
57  // correct boundaries
58  if( mRenderLine == mCoordRange.start().line() )
59  p = mCoordRange.start().pos();
60  if( mRenderLine == mCoordRange.end().line() )
61  pEnd = mCoordRange.end().pos()+1;
62 
63  const QChar tabChar = QLatin1Char( '\t' );
64  const QChar returnChar = QLatin1Char( '\n' );
65 
66  // draw individual chars
67  uint e = 0;
68  for( ; p<pEnd; ++p, ++mOffset )
69  {
70  // get next position
71  const uint t = mLinePositions[p];
72  // clear spacing
73  *stream << whiteSpace( t-e );
74 
75  // print char
76  const Okteta::Character byteChar = mCharCodec->decode( mByteArrayModel->byte(mOffset) );
77 
78  const QChar streamChar = byteChar.isUndefined() ? Okteta::Character(mUndefinedChar) :
79  (!byteChar.isPrint()
80  || byteChar == tabChar
81  || byteChar == returnChar) ? Okteta::Character(mSubstituteChar) :
82  byteChar;
83  *stream << streamChar;
84 
85  e = t + 1;
86  }
87 
88  *stream << whiteSpace( mNoOfCharsPerLine-e );
89 
90  ++mRenderLine;
91 }
92 
93 
94 CharByteArrayColumnTextRenderer::~CharByteArrayColumnTextRenderer()
95 {
96  delete mCharCodec;
97 }
98 
99 }
Okteta::CoordRange
describes a range in the buffercoord
Definition: coordrange.h:51
character.h
Okteta::Address
qint32 Address
Definition: address.h:34
Okteta::AbstractByteArrayModel
could it be useful to hide the data access behind an iterator? * class KDataBufferIterator { public: ...
Definition: abstractbytearraymodel.h:79
abstractbytearraymodel.h
Kasten2::AbstractColumnTextRenderer::whiteSpace
static QString whiteSpace(unsigned int length)
Definition: abstractcolumntextrenderer.cpp:35
KDE::Range::start
T start() const
Definition: range.h:86
Okteta::Character::isUndefined
bool isUndefined() const
Definition: character.h:52
Kasten2::AbstractByteArrayColumnTextRenderer::mNoOfBytesPerLine
const int mNoOfBytesPerLine
Definition: abstractbytearraycolumntextrenderer.h:69
Okteta::CharCodec::decode
virtual Character decode(Byte byte) const =0
Kasten2::AbstractByteArrayColumnTextRenderer::setWidths
void setWidths(int byteWidth, int byteSpacingWidth, int noOfGroupedBytes)
Definition: abstractbytearraycolumntextrenderer.cpp:43
Kasten2::CharByteArrayColumnTextRenderer::mCharCodec
const Okteta::CharCodec * mCharCodec
Definition: charbytearraycolumntextrenderer.h:53
Kasten2::AbstractByteArrayColumnTextRenderer::mCoordRange
const Okteta::CoordRange mCoordRange
Definition: abstractbytearraycolumntextrenderer.h:67
Kasten2::CharByteArrayColumnTextRenderer::mSubstituteChar
const QChar mSubstituteChar
Definition: charbytearraycolumntextrenderer.h:54
KDE::Range::end
T end() const
Definition: range.h:88
Kasten2::AbstractByteArrayColumnTextRenderer::mLinePositions
int *const mLinePositions
Definition: abstractbytearraycolumntextrenderer.h:79
Kasten2::CharByteArrayColumnTextRenderer::renderLine
virtual void renderLine(QTextStream *stream, bool isSubline) const
Definition: charbytearraycolumntextrenderer.cpp:51
Kasten2::AbstractByteArrayColumnTextRenderer
Definition: abstractbytearraycolumntextrenderer.h:42
Kasten2::CharByteArrayColumnTextRenderer::mUndefinedChar
const QChar mUndefinedChar
Definition: charbytearraycolumntextrenderer.h:55
Okteta::AbstractByteArrayModel::byte
virtual Byte byte(Address offset) const =0
locates working range The idea behind is to tell buffer which range will be requested in the followin...
Kasten2::AbstractByteArrayColumnTextRenderer::mByteArrayModel
const Okteta::AbstractByteArrayModel * mByteArrayModel
Definition: abstractbytearraycolumntextrenderer.h:65
charcodec.h
Kasten2::AbstractByteArrayColumnTextRenderer::mNoOfCharsPerLine
int mNoOfCharsPerLine
buffered value of how many chars a line needs
Definition: abstractbytearraycolumntextrenderer.h:77
Kasten2::AbstractByteArrayColumnTextRenderer::mOffset
Okteta::Address mOffset
Data to print.
Definition: abstractbytearraycolumntextrenderer.h:74
Kasten2::AbstractByteArrayColumnTextRenderer::mRenderLine
int mRenderLine
Line to print.
Definition: abstractbytearraycolumntextrenderer.h:72
Kasten2::CharByteArrayColumnTextRenderer::CharByteArrayColumnTextRenderer
CharByteArrayColumnTextRenderer(const Okteta::AbstractByteArrayModel *byteArrayModel, Okteta::Address offset, const Okteta::CoordRange &coordRange, int noOfBytesPerLine, int byteSpacingWidth, int noOfGroupedBytes, const QString &charCodecName, QChar substituteChar, QChar undefinedChar)
Definition: charbytearraycolumntextrenderer.cpp:36
charbytearraycolumntextrenderer.h
Kasten2::CharByteArrayColumnTextRenderer::~CharByteArrayColumnTextRenderer
virtual ~CharByteArrayColumnTextRenderer()
Definition: charbytearraycolumntextrenderer.cpp:94
Okteta::Character
Definition: character.h:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:07 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