summaryrefslogtreecommitdiffstats
path: root/khexedit/lib/kbytesedit.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit2bda8f7717adf28da4af0d34fb82f63d2868c31d (patch)
tree8d927b7b47a90c4adb646482a52613f58acd6f8c /khexedit/lib/kbytesedit.cpp
downloadtdeutils-2bda8f7717adf28da4af0d34fb82f63d2868c31d.tar.gz
tdeutils-2bda8f7717adf28da4af0d34fb82f63d2868c31d.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeutils@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'khexedit/lib/kbytesedit.cpp')
-rw-r--r--khexedit/lib/kbytesedit.cpp162
1 files changed, 162 insertions, 0 deletions
diff --git a/khexedit/lib/kbytesedit.cpp b/khexedit/lib/kbytesedit.cpp
new file mode 100644
index 0000000..40b57a1
--- /dev/null
+++ b/khexedit/lib/kbytesedit.cpp
@@ -0,0 +1,162 @@
+/***************************************************************************
+ kbytesedit.cpp - description
+ -------------------
+ begin : Die Jul 9 2003
+ copyright : (C) 2003 by Friedrich W. H. Kossebau
+ email : Friedrich.W.H@Kossebau.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License version 2 as published by the Free Software Foundation. *
+ * *
+ ***************************************************************************/
+
+
+// lib specific
+#include "kplainbuffer.h"
+#include "kbytesedit.h"
+#include "kbufferranges.h"
+#include "kbuffercursor.h"
+
+using namespace KHE;
+
+
+KBytesEdit::KBytesEdit( char *D, int DS_, int RS_, bool KM, QWidget *Parent, const char *Name, WFlags F )
+ : KHexEdit( 0L, Parent, Name, F ),
+ AutoDelete( false )
+{
+ setData( D, DS_, RS_, KM );
+}
+
+KBytesEdit::KBytesEdit( char *D, int DS_, QWidget *Parent, const char *Name, WFlags F )
+ : KHexEdit( 0L, Parent, Name, F ),
+ AutoDelete( false )
+{
+ setData( D, DS_ );
+}
+
+
+KBytesEdit::KBytesEdit( QWidget *Parent, const char *Name, WFlags F )
+ : KHexEdit( 0L, Parent, Name, F ),
+ AutoDelete( false )
+{
+ setDataBuffer( new KPlainBuffer() );
+}
+
+KBytesEdit::~KBytesEdit()
+{
+ clean();
+}
+
+void KBytesEdit::setReadOnly( bool RO )
+{
+ KPlainBuffer *Buffer = dynamic_cast<KPlainBuffer *>(DataBuffer);
+ if( Buffer )
+ Buffer->setReadOnly( RO );
+ KHexEdit::setReadOnly( RO );
+}
+
+
+void KBytesEdit::setAutoDelete( bool AD )
+{
+ AutoDelete = AD;
+}
+
+
+char *KBytesEdit::data() const
+{
+ KPlainBuffer *Buffer = dynamic_cast<KPlainBuffer *>(DataBuffer);
+ return Buffer ? Buffer->data() : 0L;
+}
+
+
+void KBytesEdit::setData( char *D, int S, int RS_, bool KM )
+{
+ KPlainBuffer *NewBuffer = new KPlainBuffer( D, S, RS_, KM );
+ if( DataBuffer )
+ {
+ // take the settings
+ NewBuffer->setReadOnly( DataBuffer->isReadOnly() );
+ clean();
+ }
+ else
+ NewBuffer->setReadOnly( isReadOnly() );
+
+ setDataBuffer( NewBuffer );
+}
+
+
+int KBytesEdit::dataSize() const
+{
+ KPlainBuffer *Buffer = dynamic_cast<KPlainBuffer *>(DataBuffer);
+ return Buffer ? Buffer->size() : -1;
+}
+
+
+int KBytesEdit::maxDataSize() const
+{
+ KPlainBuffer *Buffer = dynamic_cast<KPlainBuffer *>(DataBuffer);
+ return Buffer ? Buffer->maxSize() : -1;
+}
+
+
+void KBytesEdit::setMaxDataSize( int MS )
+{
+ KPlainBuffer *Buffer = dynamic_cast<KPlainBuffer *>(DataBuffer);
+ if( Buffer )
+ Buffer->setMaxSize( MS );
+}
+
+
+bool KBytesEdit::keepsMemory() const
+{
+ KPlainBuffer *Buffer = dynamic_cast<KPlainBuffer *>(DataBuffer);
+ return Buffer ? Buffer->keepsMemory() : false;
+}
+
+
+void KBytesEdit::setKeepsMemory( bool KM )
+{
+ KPlainBuffer *Buffer = dynamic_cast<KPlainBuffer *>(DataBuffer);
+ if( Buffer )
+ Buffer->setKeepsMemory( KM );
+}
+
+
+bool KBytesEdit::isAutoDelete() const { return AutoDelete; }
+
+
+void KBytesEdit::repaintRange( int i1, int i2 )
+{
+ bool ChangeCursor = !(CursorPaused) && KSection(i1,i2).includes( BufferCursor->index() );
+ if( ChangeCursor )
+ pauseCursor();
+
+ BufferRanges->addChangedRange( i1, i2 );
+
+ repaintChanged();
+
+ if( ChangeCursor )
+ unpauseCursor();
+}
+
+
+void KBytesEdit::clean()
+{
+ if( DataBuffer )
+ {
+ if( AutoDelete )
+ {
+ char *D = data();
+ if( D )
+ delete [] D;
+ }
+ delete DataBuffer;
+ }
+}
+
+
+#include "kbytesedit.moc"