• 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
  • controllers
  • view
  • bytetable
bytetabletool.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 2007-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 "bytetabletool.h"
24 
25 // controller
26 #include "bytetablemodel.h"
27 // lib
28 #include <bytearrayview.h>
29 #include <bytearraydocument.h>
30 // Okteta core
31 #include <character.h>
32 #include <charcodec.h>
33 #include <abstractbytearraymodel.h>
34 #include <changesdescribable.h>
35 // KDE
36 #include <KLocale>
37 
38 
39 namespace Kasten2
40 {
41 
42 ByteTableTool::ByteTableTool()
43  : mByteTableModel( new ByteTableModel(this) ),
44  mByteArrayView( 0 ), mByteArrayModel( 0 )
45 {
46  setObjectName( QLatin1String( "ByteTable" ) );
47 }
48 
49 QString ByteTableTool::title() const { return i18nc("@title:window", "Value/Char Table"); }
50 ByteTableModel *ByteTableTool::byteTableModel() const { return mByteTableModel; }
51 bool ByteTableTool::hasWriteable() const
52 {
53  return ( mByteArrayView && mByteArrayModel ) ? !mByteArrayView->isReadOnly() : false;
54 }
55 
56 
57 void ByteTableTool::setTargetModel( AbstractModel* model )
58 {
59  if( mByteArrayView )
60  {
61  mByteArrayView->disconnect( mByteTableModel );
62  mByteArrayView->disconnect( this );
63  }
64 
65  mByteArrayView = model ? qobject_cast<ByteArrayView*>( model ) : 0;
66 
67  ByteArrayDocument* document =
68  mByteArrayView ? qobject_cast<ByteArrayDocument*>( mByteArrayView->baseModel() ) : 0;
69  mByteArrayModel = document ? document->content() : 0;
70 
71  const bool hasView = ( mByteArrayView && mByteArrayModel );
72  if( hasView )
73  {
74  mByteTableModel->setCharCodec( mByteArrayView->charCodingName() );
75  mByteTableModel->setUndefinedChar( mByteArrayView->undefinedChar() );
76  connect( mByteArrayView, SIGNAL(charCodecChanged(QString)),
77  mByteTableModel, SLOT(setCharCodec(QString)) );
78  connect( mByteArrayView, SIGNAL(undefinedCharChanged(QChar)),
79  mByteTableModel, SLOT(setUndefinedChar(QChar)) );
80 
81  connect( mByteArrayView, SIGNAL(readOnlyChanged(bool)),
82  SLOT(onReadOnlyChanged(bool)) );
83  }
84 
85  const bool isWriteable = ( hasView && !mByteArrayView->isReadOnly() );
86 
87  emit hasWriteableChanged( isWriteable );
88 }
89 
90 void ByteTableTool::insert( unsigned char byte, int count )
91 {
92  const QByteArray data( count, byte );
93 
94  Okteta::ChangesDescribable *changesDescribable =
95  qobject_cast<Okteta::ChangesDescribable*>( mByteArrayModel );
96 
97  if( changesDescribable )
98  {
99  // TODO: how to note the byte? charcoding might change...
100  const QString changeDescription =
101  i18np( "Inserted 1 Byte","Inserted %1 Bytes", count );
102 
103  changesDescribable->openGroupedChange( changeDescription );
104  }
105 
106  mByteArrayView->insert( data );
107 
108  if( changesDescribable )
109  changesDescribable->closeGroupedChange();
110 // void ByteTableController::fill( const QByteArray &Data )
111 // {
112 // if( HexEdit && ByteArray )
113 // ByteArray->insert( HexEdit->cursorPosition(), Data );
114 // }
115  mByteArrayView->setFocus();
116 }
117 
118 void ByteTableTool::onReadOnlyChanged( bool isReadOnly )
119 {
120  const bool isWriteable = !isReadOnly;
121 
122  emit hasWriteableChanged( isWriteable );
123 }
124 
125 ByteTableTool::~ByteTableTool() {}
126 
127 }
Kasten2::ByteArrayView::setFocus
virtual void setFocus()
Definition: bytearrayview.cpp:155
character.h
Kasten2::ByteTableModel::setCharCodec
void setCharCodec(const QString &codecName)
Definition: bytetablemodel.cpp:63
Kasten2::ByteTableTool::setTargetModel
virtual void setTargetModel(AbstractModel *model)
Definition: bytetabletool.cpp:57
abstractbytearraymodel.h
Kasten2::ByteTableModel::setUndefinedChar
void setUndefinedChar(QChar undefinedChar)
Definition: bytetablemodel.cpp:56
Okteta::ChangesDescribable::closeGroupedChange
virtual void closeGroupedChange(const QString &description=QString())=0
Kasten2::ByteArrayView::charCodingName
QString charCodingName() const
Definition: bytearrayview.cpp:255
bytetabletool.h
Okteta::ChangesDescribable::openGroupedChange
virtual void openGroupedChange(const QString &description=QString())=0
Okteta::ChangesDescribable
Definition: changesdescribable.h:33
Kasten2::ByteTableTool::hasWriteableChanged
void hasWriteableChanged(bool hasWriteable)
Kasten2::ByteTableTool::title
virtual QString title() const
Definition: bytetabletool.cpp:49
Kasten2::AbstractModel::baseModel
AbstractModel * baseModel() const
Definition: abstractmodel.cpp:40
Kasten2::ByteTableTool::~ByteTableTool
virtual ~ByteTableTool()
Definition: bytetabletool.cpp:125
Kasten2::ByteTableModel
Definition: bytetablemodel.h:38
Kasten2::ByteTableTool::insert
void insert(unsigned char byte, int count)
Definition: bytetabletool.cpp:90
bytetablemodel.h
Kasten2::ByteTableTool::byteTableModel
ByteTableModel * byteTableModel() const
Definition: bytetabletool.cpp:50
Kasten2::ByteArrayView::insert
void insert(const QByteArray &byteArray)
Definition: bytearrayview.cpp:281
Kasten2::ByteTableTool::ByteTableTool
ByteTableTool()
Definition: bytetabletool.cpp:42
Kasten2::ByteArrayView::undefinedChar
QChar undefinedChar() const
Definition: bytearrayview.cpp:373
charcodec.h
changesdescribable.h
Kasten2::ByteArrayDocument
Definition: bytearraydocument.h:54
Kasten2::AbstractModel
Definition: abstractmodel.h:40
bytearraydocument.h
Kasten2::ByteTableTool::hasWriteable
bool hasWriteable() const
Definition: bytetabletool.cpp:51
Kasten2::ByteArrayView
Definition: bytearrayview.h:51
Kasten2::ByteArrayView::isReadOnly
virtual bool isReadOnly() const
default returns true
Definition: bytearrayview.cpp:152
bytearrayview.h
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