/usr/include/okteta1/abstractbytearrayview.h is in okteta-dev 4:4.8.4+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | /*
This file is part of the Okteta Gui library, made within the KDE community.
Copyright 2008-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OKTETA_ABSTRACTBYTEARRAYVIEW_H
#define OKTETA_ABSTRACTBYTEARRAYVIEW_H
// lib
#include "columnsview.h"
// Okteta core
#include "addressrange.h"
// Qt
#include <QtGui/QClipboard>
class QMimeData;
class QByteArray;
namespace Okteta
{
class Bookmark;
class ValueCodec;
class CharCodec;
class AbstractByteArrayModel;
class ArrayChangeMetricsList;
class KController;
class AbstractWheelController;
class ByteArrayTableLayout;
class ByteArrayTableCursor;
class ByteArrayTableRanges;
class AbstractByteArrayViewPrivate;
// TODO: for now inherit from ColumnsView, but later on invert this,
// so it's AbstractByteArrayView < ColumnsView < {ByteArrayRowView,ByteArrayColumnView}
class OKTETAGUI_EXPORT AbstractByteArrayView : public ColumnsView
{
friend class KTabController;
friend class KNavigator;
friend class KEditor;
friend class KValueEditor;
friend class KCharEditor;
friend class Dropper;
friend class MouseNavigator;
friend class MousePaster;
friend class Dragger;
Q_OBJECT
Q_PROPERTY( bool OverwriteMode READ isOverwriteMode WRITE setOverwriteMode )
Q_PROPERTY( bool OverwriteOnly READ isOverwriteOnly WRITE setOverwriteOnly )
Q_PROPERTY( bool Modified READ isModified WRITE setModified DESIGNABLE false )
Q_PROPERTY( bool ReadOnly READ isReadOnly WRITE setReadOnly )
//Q_PROPERTY( bool hasSelectedData READ hasSelectedData )
//Q_PROPERTY( QByteArray SelectedData READ selectedData )
Q_PROPERTY( bool TabChangesFocus READ tabChangesFocus WRITE setTabChangesFocus )
Q_PROPERTY( LayoutStyle LayoutStyle READ layoutStyle WRITE setLayoutStyle )
Q_PROPERTY( int NoOfBytesPerLine READ noOfBytesPerLine WRITE setNoOfBytesPerLine )
Q_PROPERTY( int StartOffset READ startOffset WRITE setStartOffset )
Q_PROPERTY( int FirstLineOffset READ firstLineOffset WRITE setFirstLineOffset )
Q_PROPERTY( bool OffsetColumnVisible READ offsetColumnVisible WRITE toggleOffsetColumn )
Q_PROPERTY( CodingTypes VisibleCodings READ visibleCodings WRITE setVisibleCodings )
Q_ENUMS( ValueCoding CharCoding LayoutStyle CodingTypes )
Q_PROPERTY( bool ByteTypeColored READ isByteTypeColored WRITE setByteTypeColored )
// value column
Q_PROPERTY( ValueCoding Coding READ valueCoding WRITE setValueCoding )
Q_PROPERTY( int ByteSpacingWidth READ byteSpacingWidth WRITE setByteSpacingWidth )
Q_PROPERTY( int NoOfGroupedBytes READ noOfGroupedBytes WRITE setNoOfGroupedBytes )
Q_PROPERTY( int GroupSpacingWidth READ groupSpacingWidth WRITE setGroupSpacingWidth )
Q_PROPERTY( int BinaryGapWidth READ binaryGapWidth WRITE setBinaryGapWidth )
// char column
Q_PROPERTY( bool ShowNonprinting READ showsNonprinting WRITE setShowsNonprinting )
Q_PROPERTY( QChar SubstituteChar READ substituteChar WRITE setSubstituteChar )
public:
enum ValueCoding { HexadecimalCoding=0, DecimalCoding=1, OctalCoding=2, BinaryCoding=3, MaxCodingId=0xFFFF };
enum CharCoding { LocalEncoding=0, ISO8859_1Encoding=1, EBCDIC1047Encoding=2,
StartOfOwnEncoding=0x8000, MaxEncodingId=0xFFFF };
enum LayoutStyle { FixedLayoutStyle=0, WrapOnlyByteGroupsLayoutStyle=1, FullSizeLayoutStyle=2, LastUserLayout=0xFF };
enum CodingTypeId { NoCodingId=0, ValueCodingId=1, CharCodingId=2 };
enum CodingTypes { OnlyValueCoding = ValueCodingId, OnlyCharCoding = CharCodingId, ValueAndCharCodings=ValueCodingId|CharCodingId };
public:
virtual ~AbstractByteArrayView();
public: // value access
Okteta::AbstractByteArrayModel* byteArrayModel() const;
bool isModified() const;
bool isOverwriteMode() const;
bool isOverwriteOnly() const;
bool isReadOnly() const;
/** returns the index of the cursor position */
Address cursorPosition() const;
/***/
bool isCursorBehind() const;
Address startOffset() const;
Address firstLineOffset() const;
int noOfBytesPerLine() const;
LayoutStyle layoutStyle() const;
bool tabChangesFocus() const;
CodingTypes visibleCodings() const;
CodingTypeId activeCoding() const;
bool offsetColumnVisible() const;
/** returns true if there is a selected range in the array */
bool hasSelectedData() const;
AddressRange selection() const;
AddressRange marking() const;
ValueCoding valueCoding() const;
/**
* @return encoding used for the chars
*/
CharCoding charCoding() const;
/**
* @return name of the encoding used for the chars
*/
const QString& charCodingName() const;
double zoomLevel() const;
public: // value access API
// value column
virtual int/*PixelX*/ byteSpacingWidth() const = 0;
virtual int noOfGroupedBytes() const = 0;
virtual int/*PixelX*/ groupSpacingWidth() const = 0;
virtual int/*PixelX*/ binaryGapWidth() const = 0;
// char column
/** reports if "non-printing" chars are displayed in the char column
* with their original character. Default is false
* @return @c true if original chars are displayed, otherwise @c false
*/
virtual bool showsNonprinting() const = 0;
/** gives the used substitute character for "unprintable" chars, default is '.'
* @return substitute character
*/
virtual QChar substituteChar() const = 0;
/** returns the actually used undefined character for "undefined" chars, default is '?' */
virtual QChar undefinedChar() const = 0;
virtual bool isByteTypeColored() const = 0;
public:
virtual void setByteArrayModel( Okteta::AbstractByteArrayModel* byteArrayModel );
// setting parameters
// value column parameters
/** sets the spacing between the bytes in the value column
* @param byteSpacingWidth spacing between the bytes in pixels
* default is 3
*/
virtual void setByteSpacingWidth( int/*PixelX*/ byteSpacingWidth ) = 0;
/** sets the number of grouped bytes in the value column
* @param noOfGroupedBytes numbers of grouped bytes, 0 means no grouping
* default is 4
*/
virtual void setNoOfGroupedBytes( int noOfGroupedBytes ) = 0;
/** sets the spacing between the groups of bytes in the value column
* @param groupSpacingWidth spacing between the groups in pixels
* default is 9
*/
virtual void setGroupSpacingWidth( int/*PixelX*/ groupSpacingWidth ) = 0;
/** sets the spacing in the middle of a binary byte in the value column
* @param binaryGapWidth spacing in the middle of a binary in pixels
* returns true if there was a change
*/
virtual void setBinaryGapWidth( int binaryGapWidth ) = 0;
/** sets the spacing in the value column
* @param byteSpacingWidth spacing between the bytes in pixels
* @param noOfGroupedBytes numbers of grouped bytes, 0 means no grouping
* @param groupSpacingWidth spacing between the groups in pixels
* Default is 4 for NoOfGroupedBytes
*/
virtual void setBufferSpacing( int/*PixelX*/ byteSpacingWidth, int noOfGroupedBytes = 0, int/*PixelX*/ groupSpacingWidth = 0 ) = 0;
/** sets the format of the value column. Default is Okteta::HexadecimalCoding */
virtual void setValueCoding( ValueCoding valueCoding ) = 0;
// char column parameters
/** sets whether control chars or "non-printing" chars should be displayed in the char column
* with their corresponding character. Currently this simply means all chars with value <32,
* as known from the ASCII.
* @param showsNonprinting
* returns true if there was a change
*/
virtual void setShowsNonprinting( bool showsNonprinting = true ) = 0;
/** sets the substitute character for "non-printing" chars
* returns true if there was a change
*/
virtual void setSubstituteChar( QChar substituteChar ) = 0;
/** sets the undefined character for "undefined" chars
* returns true if there was a change
*/
virtual void setUndefinedChar( QChar undefinedChar ) = 0;
/** sets the encoding of the char column. Default is Okteta::LocalEncoding.
* If the encoding is not available the format will not be changed. */
virtual void setCharCoding( CharCoding charCoding ) = 0;
/** sets the encoding of the char column. Default is Okteta::LocalEncoding.
* If the encoding is not available the format will not be changed.
* @param charCodingName name of the encoding
*/
virtual void setCharCoding( const QString& charCodingName ) = 0;
virtual void setByteTypeColored( bool isColored ) = 0;
public:
/** sets whether the data should be treated modified or not */
void setModified( bool modified );
/** sets the resizestyle for the value column. Default is Okteta::FullSizeLayoutStyle */
void setLayoutStyle( LayoutStyle layoutStyle );
/** sets whether the widget is readonly or not, Default is true.
* If the databuffer which is worked on can't be written the widget stays readonly
*/
void setReadOnly( bool readOnly );
/** sets whether the widget is overwriteonly or not. Default is false. */
void setOverwriteOnly( bool overwriteOnly );
/** sets whether the widget is in overwrite mode or not. Default is true. */
void setOverwriteMode( bool overwriteMode );
/** sets the number of bytes per line, switching the resize style to Okteta::FixedLayoutStyle */
void setNoOfBytesPerLine( int noOfBytesPerLine );
/** sets absolut offset of the data */
void setStartOffset( Address startOffset );
/** sets offset of the char in the upper left corner */
void setFirstLineOffset( Address firstLineOffset );
/** sets whether on a tab key there should be switched from the char column back to the value column
* or be switched to the next focusable widget. Default is false
*/
void setTabChangesFocus( bool tabChangesFocus = true );
/***/
void setActiveCoding( CodingTypeId codingId );
/** */
void setVisibleCodings( int visibleCodings );
/** switches the Offset column on/off */
void toggleOffsetColumn( bool offsetColumnVisible );
public:
/**
* @return deep copy of the selected data
*/
QByteArray selectedData() const;
QMimeData* selectionAsMimeData() const;
public: // modification access
void pasteData( const QMimeData* data );
/** removes the selected data, takes care of the cursor */
void removeSelectedData();
/** inserts */
void insert( const QByteArray& data );
/** puts the cursor to the position of index, handles all drawing
* @param index
* @param isBehind
*/
void setCursorPosition( Address index, bool isBehind = false );
void setSelectionCursorPosition( Address index );
/** de-/selects all data */
void selectAll( bool select );
void setSelection( Address start, Address end );
void setSelection( const AddressRange& selection );
/** selects word at index, returns true if there is one */
bool selectWord( /*unsigned*/ Address index /*, Chartype*/ );
void setMarking( Address start, Address end );
void setMarking( const AddressRange& marking );
/**
* @param ensureStartVisible if true , otherwise the end
*/
void ensureVisible( const AddressRange& range, bool ensureStartVisible = false );
/** scrolls the view as much as needed to have the cursor fully visible */
void ensureCursorVisible();
/** puts the cursor in the column at the pos of Point (in absolute coord), does not handle the drawing */
void placeCursor( const QPoint& point );
public:
bool canReadData( const QMimeData* data ) const;
public: // zooming
void zoomIn( int pointInc );
void zoomIn();
void zoomOut( int pointDec );
void zoomOut();
void zoomTo( int pointSize );
void unZoom();
void setZoomLevel( double level );
public: // cursor control
/** we have focus again, start the timer */
void startCursor();
/** we lost focus, stop the timer */
void stopCursor();
/** simply pauses any blinking, i.e. ignores any calls to blinkCursor */
void pauseCursor();
/** undoes pauseCursor */
void unpauseCursor();
public:
// clipboard interaction
virtual void copy();
virtual void cut();
virtual void paste();
public:
QRect cursorRect() const;
public: // QWidget API
virtual QSize sizeHint() const;
public: // logic value service
/** detects the index of the byte at the given point
* @param point in viewport coordinate system
* @return index of the byte that covers the point
*/
Address indexByPoint( const QPoint& point ) const;
Q_SIGNALS:
/** Index of the byte that was clicked */
void clicked( Okteta::Address index );
/** Index of the byte that was double clicked */
void doubleClicked( Okteta::Address index );
void cursorPositionChanged( Okteta::Address index );
/** */
void overwriteModeChanged( bool newOverwriteMode );
/** */
void readOnlyChanged( bool isReadOnly );
/** selection has changed */
void hasSelectedDataChanged( bool hasSelectedData );
void selectionChanged( const Okteta::AddressRange& selection );
/** there is a cut available or not */
void cutAvailable( bool Really );
/** there is a copy available or not */
void copyAvailable( bool Really );
/** */
void charCodecChanged( const QString& codecName );
/** */
void valueCodingChanged( int valueCoding );
void focusChanged( bool hasFocus );
protected:
void finishByteEdit();
void emitSelectionSignals();
void updateChanged();
void copyToClipboard( QClipboard::Mode mode ) const;
void pasteFromClipboard( QClipboard::Mode mode );
protected:
const Okteta::ValueCodec* valueCodec() const;
const Okteta::CharCodec* charCodec() const;
ByteArrayTableCursor* tableCursor() const;
ByteArrayTableRanges* tableRanges() const;
ByteArrayTableLayout* layout() const;
protected: // QWidget API
virtual void keyPressEvent( QKeyEvent* keyEvent );
virtual void mousePressEvent( QMouseEvent* mousePressEvent );
virtual void mouseReleaseEvent( QMouseEvent* mouseReleaseEvent );
virtual void mouseMoveEvent( QMouseEvent* mouseMoveEvent );
virtual void mouseDoubleClickEvent( QMouseEvent* mouseDoubleClickEvent );
/// reimplemented to catch Tab and BackTab keys, which otherwise gets stolen
virtual bool event( QEvent* event );
virtual void showEvent( QShowEvent* showEvent );
virtual void focusInEvent( QFocusEvent* focusEvent );
virtual void focusOutEvent( QFocusEvent* focusEvent );
virtual void resizeEvent( QResizeEvent* resizeEvent );
virtual void dragEnterEvent( QDragEnterEvent* dragEnterEvent );
virtual void dragMoveEvent( QDragMoveEvent* dragMoveEvent) ;
virtual void dragLeaveEvent( QDragLeaveEvent* dragLeaveEvent );
virtual void dropEvent( QDropEvent* dropEvent );
// virtual void contextMenuEvent( QContextMenuEvent* contextMenuEvent );
protected: // QAbstractScrollArea API
virtual void wheelEvent( QWheelEvent *e );
virtual bool viewportEvent( QEvent* event );
protected: // ColumnsView API
virtual void setNoOfLines( int newNoOfLines );
protected: // Q_SLOTS QWidget API
virtual void changeEvent( QEvent* event );
protected:
AbstractByteArrayViewPrivate* const d_ptr;
AbstractByteArrayView( AbstractByteArrayViewPrivate* d, QWidget* parent );
private:
Q_DECLARE_PRIVATE( AbstractByteArrayView )
Q_PRIVATE_SLOT( d_func(), void adaptController() )
Q_PRIVATE_SLOT( d_func(), void blinkCursor() )
Q_PRIVATE_SLOT( d_func(), void onByteArrayReadOnlyChange(bool isByteArrayReadOnly) )
Q_PRIVATE_SLOT( d_func(), void onContentsChanged( const Okteta::ArrayChangeMetricsList& changeList ) )
Q_PRIVATE_SLOT( d_func(), void onBookmarksChange( const QList<Okteta::Bookmark>& bookmarks ) )
Q_PRIVATE_SLOT( d_func(), void onRevertedToVersionIndex( int versionIndex ) )
// Q_PRIVATE_SLOT( d_func(), void onClipboardChanged() )
};
}
#endif
|