diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 2bda8f7717adf28da4af0d34fb82f63d2868c31d (patch) | |
tree | 8d927b7b47a90c4adb646482a52613f58acd6f8c /khexedit/parts/kbytesedit | |
download | tdeutils-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/parts/kbytesedit')
-rw-r--r-- | khexedit/parts/kbytesedit/Makefile.am | 15 | ||||
-rw-r--r-- | khexedit/parts/kbytesedit/README | 23 | ||||
-rw-r--r-- | khexedit/parts/kbytesedit/kbyteseditwidget.cpp | 319 | ||||
-rw-r--r-- | khexedit/parts/kbytesedit/kbyteseditwidget.desktop | 52 | ||||
-rw-r--r-- | khexedit/parts/kbytesedit/kbyteseditwidget.h | 185 |
5 files changed, 594 insertions, 0 deletions
diff --git a/khexedit/parts/kbytesedit/Makefile.am b/khexedit/parts/kbytesedit/Makefile.am new file mode 100644 index 0000000..b8be127 --- /dev/null +++ b/khexedit/parts/kbytesedit/Makefile.am @@ -0,0 +1,15 @@ +kde_module_LTLIBRARIES = libkbyteseditwidget.la + +INCLUDES = -I$(srcdir)/../../lib $(all_includes) + +noinst_HEADERS = kbyteseditwidget.h + +METASOURCES = AUTO + +libkbyteseditwidget_la_SOURCES = kbyteseditwidget.cpp + +libkbyteseditwidget_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module -avoid-version -no-undefined +libkbyteseditwidget_la_LIBADD = ../../lib/libkhexeditcommon.la $(LIB_KPARTS) + +service_DATA = kbyteseditwidget.desktop +servicedir = $(kde_servicesdir) diff --git a/khexedit/parts/kbytesedit/README b/khexedit/parts/kbytesedit/README new file mode 100644 index 0000000..e3aa164 --- /dev/null +++ b/khexedit/parts/kbytesedit/README @@ -0,0 +1,23 @@ +KBytesEdit widget modul +======================= +part of the KHexEdit 2 project (kdenonbeta/khexedit2) +Author/Maintainer: Friedrich W. H. Kossebau <[email protected]> + + +description: +------------ +This module delivers a service for the service type "KHexEdit/KBytesEdit". +It is a hex edit widget that operates on an array of chars given by +the programmer. +It serves right now the interfaces +HexColumnInterface, TextColumnInterface, ZoomInterface, ClipBoardInterface. + + +installing: +----------- +Installs the .desktop file describing the service and the module library. + + +usage: +------ +Only official known usage is by KPilot (kdepim/kpilot) for now.
\ No newline at end of file diff --git a/khexedit/parts/kbytesedit/kbyteseditwidget.cpp b/khexedit/parts/kbytesedit/kbyteseditwidget.cpp new file mode 100644 index 0000000..4cc91ab --- /dev/null +++ b/khexedit/parts/kbytesedit/kbyteseditwidget.cpp @@ -0,0 +1,319 @@ +/*************************************************************************** + kbyteseditwidget.cpp - description + ------------------- + begin : Fri Aug 29 2003 + copyright : (C) 2003 by Friedrich W. H. Kossebau + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +// qt specific +#include <qlayout.h> +// kde specific +#include <klocale.h> +#include <kgenericfactory.h> +#include <kapplication.h> +// lib specific +#include "kbytesedit.h" +#include "kbyteseditwidget.h" + + +KBytesEditWidget::KBytesEditWidget( QWidget *parent, const char *name, const QStringList & ) + : QWidget( parent, name) +{ + QHBoxLayout* Layout = new QHBoxLayout( this ); + BytesEdit = new KHE::KBytesEdit( this, "BytesEdit" ); + Layout->addWidget( BytesEdit ); +// connect( _editor, SIGNAL( canUndo(bool) ), this, SIGNAL( canUndo(bool) ) ); + connect( BytesEdit, SIGNAL(copyAvailable( bool )), this, SIGNAL(copyAvailable( bool )) ); +} + + + +void KBytesEditWidget::setData( char *D, int S, int RS, bool KM ) +{ + BytesEdit->setData( D, S, RS, KM ); +} + + +void KBytesEditWidget::setReadOnly( bool RO ) +{ + BytesEdit->setReadOnly( RO ); +} + +void KBytesEditWidget::setMaxDataSize( int MS ) +{ + BytesEdit->setMaxDataSize( MS ); +} + +void KBytesEditWidget::setAutoDelete( bool AD ) +{ + BytesEdit->setAutoDelete( AD ); +} + + +void KBytesEditWidget::setKeepsMemory( bool KM ) +{ + BytesEdit->setKeepsMemory( KM ); +} + + +void KBytesEditWidget::setCursorPosition( int Index ) +{ + BytesEdit->setCursorPosition( Index ); +} + +void KBytesEditWidget::setCoding( KCoding C ) +{ + BytesEdit->setCoding( (KHE::KHexEdit::KCoding) C ); +} + +void KBytesEditWidget::setResizeStyle( KResizeStyle Style ) +{ + BytesEdit->setResizeStyle( (KHE::KHexEdit::KResizeStyle) Style ); +} +int KBytesEditWidget::noOfBytesPerLine() const +{ + return BytesEdit->noOfBytesPerLine(); +} + +KBytesEditWidget::KResizeStyle KBytesEditWidget::resizeStyle() const +{ + return (KResizeStyle)BytesEdit->resizeStyle(); +} +void KBytesEditWidget::setNoOfBytesPerLine( int NoCpL ) +{ + BytesEdit->setNoOfBytesPerLine( NoCpL ); +} + + + +void KBytesEditWidget::setOverwriteOnly( bool b ) +{ + BytesEdit->setOverwriteOnly( b ); +} + + +void KBytesEditWidget::setOverwriteMode( bool b ) +{ + BytesEdit->setOverwriteMode( b ); +} + + +void KBytesEditWidget::setModified( bool b ) +{ + BytesEdit->setModified( b ); +} + + +void KBytesEditWidget::setByteSpacingWidth( int BSW ) +{ + BytesEdit->setByteSpacingWidth( BSW ); +} + +void KBytesEditWidget::setNoOfGroupedBytes( int NoGB ) +{ + BytesEdit->setNoOfGroupedBytes( NoGB ); +} + +void KBytesEditWidget::setGroupSpacingWidth( int GSW ) +{ + BytesEdit->setGroupSpacingWidth( GSW ); +} + +void KBytesEditWidget::setBinaryGapWidth( int BGW ) +{ + BytesEdit->setBinaryGapWidth( BGW ); +} + +void KBytesEditWidget::setEncoding( KEncoding C ) +{ + BytesEdit->setEncoding( (KHE::KHexEdit::KEncoding)C ); +} + +void KBytesEditWidget::setShowUnprintable( bool SU ) +{ + BytesEdit->setShowUnprintable( SU ); +} + +void KBytesEditWidget::setSubstituteChar( QChar SC ) +{ + BytesEdit->setSubstituteChar( SC ); +} + + +char *KBytesEditWidget::data() const +{ + return BytesEdit->data(); +} + +int KBytesEditWidget::dataSize() const +{ + return BytesEdit->dataSize(); +} +int KBytesEditWidget::maxDataSize () const +{ + return BytesEdit->maxDataSize(); +} +bool KBytesEditWidget::isAutoDelete() const +{ + return BytesEdit->isAutoDelete(); +} + +bool KBytesEditWidget::keepsMemory() const +{ + return BytesEdit->keepsMemory(); +} + +bool KBytesEditWidget::isOverwriteMode() const +{ + return BytesEdit->isOverwriteMode(); +} + +bool KBytesEditWidget::isOverwriteOnly() const +{ + return BytesEdit->isOverwriteOnly(); +} + +bool KBytesEditWidget::isModified() const +{ + return BytesEdit->isModified(); +} + +bool KBytesEditWidget::isReadOnly() const +{ + return BytesEdit->isReadOnly(); +} + + +// bool KBytesEditWidget::tabChangesFocus() const +// { +// } + + + +KBytesEditWidget::KCoding KBytesEditWidget::coding() const +{ + return (KCoding)BytesEdit->coding(); +} + +int KBytesEditWidget::byteSpacingWidth() const +{ + return BytesEdit->byteSpacingWidth(); +} + +int KBytesEditWidget::noOfGroupedBytes() const +{ + return BytesEdit->noOfGroupedBytes(); +} + +int KBytesEditWidget::groupSpacingWidth() const +{ + return BytesEdit->groupSpacingWidth(); +} + +int KBytesEditWidget::binaryGapWidth() const +{ + return BytesEdit->binaryGapWidth(); +} + +bool KBytesEditWidget::showUnprintable() const +{ + return BytesEdit->showUnprintable(); +} + +QChar KBytesEditWidget::substituteChar() const +{ + return BytesEdit->substituteChar(); +} + +KBytesEditWidget::KEncoding KBytesEditWidget::encoding() const +{ + return (KEncoding)BytesEdit->encoding(); +} + + +bool KBytesEditWidget::hasSelectedData() const +{ + return BytesEdit->hasSelectedData(); +} + + +void KBytesEditWidget::repaintRange( int i1, int i2 ) +{ + BytesEdit->repaintRange( i1, i2 ); +} + + +void KBytesEditWidget::insert( const QByteArray &D ) +{ + BytesEdit->insert( D ); +} + + +void KBytesEditWidget::selectAll( bool Select ) +{ + BytesEdit->selectAll( Select ); +} + + // clipboard interface +void KBytesEditWidget::copy() +{ + BytesEdit->copy(); +} + +void KBytesEditWidget::cut() +{ + BytesEdit->cut(); +} + +void KBytesEditWidget::paste() +{ + BytesEdit->paste(); +} + +// zooming interface +void KBytesEditWidget::zoomIn( int PointInc ) +{ + BytesEdit->zoomIn( PointInc ); +} + +void KBytesEditWidget::zoomIn() +{ + BytesEdit->zoomIn(); +} + +void KBytesEditWidget::zoomOut( int PointDec ) +{ + BytesEdit->zoomOut( PointDec ); +} + +void KBytesEditWidget::zoomOut() +{ + BytesEdit->zoomOut(); +} + +void KBytesEditWidget::zoomTo( int PointSize ) +{ + BytesEdit->zoomTo( PointSize ); +} + +void KBytesEditWidget::unZoom() +{ + BytesEdit->unZoom(); +} + + +typedef K_TYPELIST_1( KBytesEditWidget ) Product; +K_EXPORT_COMPONENT_FACTORY( libkbyteseditwidget, KGenericFactory<Product>( "kbytesedit" ) ) +//K_EXPORT_COMPONENT_FACTORY( libkbyteseditwidget, KGenericFactory<MyPlugin> ) + +#include "kbyteseditwidget.moc" diff --git a/khexedit/parts/kbytesedit/kbyteseditwidget.desktop b/khexedit/parts/kbytesedit/kbyteseditwidget.desktop new file mode 100644 index 0000000..4a050a6 --- /dev/null +++ b/khexedit/parts/kbytesedit/kbyteseditwidget.desktop @@ -0,0 +1,52 @@ +[Desktop Entry] +Type=Service +Name=BytesEdit Widget +Name[ar]=كائن BytesEdit +Name[bg]=Модул за двоично редактиране на файлове +Name[bs]=BytesEdit grafički element +Name[ca]=Estri BytesEdit +Name[cy]=Celfigyn GolyguBeit +Name[de]=BytesEdit-Bedienelement +Name[el]=Γραφικό συστατικό BytesEdit +Name[eo]=BytesEdit-fenestraĵo +Name[es]=Ventana de edición de bytes +Name[et]=Baitide redigeerimise komponent +Name[eu]=Byteak Editatzeko Widget-a +Name[fa]=عنصر ویرایش بایت +Name[fi]=BytesEdit käyttöliittymäkomponentti +Name[fr]=Composant éditeur binaire +Name[ga]=Giuirléid BytesEdit +Name[he]=פריט עורך הביטויים הסדירים +Name[hi]=बाइट्स-एडिट विजेट +Name[hu]=BytesEdit grafikus elem +Name[is]=Græja til að sýsla með bætaskrár +Name[it]=Elemento grafico editor di byte +Name[ja]=バイトエディットウィジェット +Name[kk]=Бинарлы деректерді өңдеу бөлшегі +Name[km]=វត្ថុមើលឃើញ BytesEdit +Name[lt]=BytesEdit valdiklis +Name[mk]=BytesEdit - графичка контрола +Name[nb]=BytesEdit skjermelement +Name[nds]=BytesEdit-Bedeenelement +Name[ne]=बाइट सम्पादन विजेट +Name[nn]=BytesEdit-skjermelement +Name[pa]=ਬਾਈਟ ਸੋਧ ਸਹਾਇਕ +Name[pl]=Okienko BytesEdit +Name[pt]=Editor de Bytes +Name[pt_BR]=Widget do Editor de Bytes +Name[ro]=Componentă de editare octeţi +Name[ru]=Виджет редактирования двоичных данных +Name[sk]=Prvok BytesEdit +Name[sl]=Gradnik BytesEdit +Name[sr]=Контрола за бинарно уређивање +Name[sr@Latn]=Kontrola za binarno uređivanje +Name[sv]=Grafisk komponent för att redigera binärdata +Name[ta]= பைட்ஸ்தொகுப்பு சாளரம் +Name[tg]=Элементи Таҳрири Додаҳои Дуӣ +Name[uk]=Віджет побайтового редагування +Name[zh_CN]=字节编辑部件 +Name[zh_TW]=位元編輯器元件 +X-KDE-Library=libkbyteseditwidget +InitialPreference=2 +ServiceTypes=KHexEdit/KBytesEdit + diff --git a/khexedit/parts/kbytesedit/kbyteseditwidget.h b/khexedit/parts/kbytesedit/kbyteseditwidget.h new file mode 100644 index 0000000..78e4dba --- /dev/null +++ b/khexedit/parts/kbytesedit/kbyteseditwidget.h @@ -0,0 +1,185 @@ +/*************************************************************************** + kbyteseditwidget.h - description + ------------------- + begin : Fri Aug 29 2003 + copyright : (C) 2003 by Friedrich W. H. Kossebau + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +#ifndef KBYTESEDITWIDGET_H +#define KBYTESEDITWIDGET_H + +// qt specific +#include <qwidget.h> +// kde specific +#include <khexedit/byteseditinterface.h> +#include <khexedit/valuecolumninterface.h> +#include <khexedit/charcolumninterface.h> +#include <khexedit/zoominterface.h> +#include <khexedit/clipboardinterface.h> + + +namespace KHE { +class KBytesEdit; +} + +/** + hex editor/viewer. + + @author Friedrich W. H. Kossebau <[email protected]> + @version 0.1 + **/ +class KBytesEditWidget : public QWidget, public KHE::BytesEditInterface, + public KHE::ValueColumnInterface, public KHE::CharColumnInterface, + public KHE::ZoomInterface, public KHE::ClipboardInterface +{ + Q_OBJECT + + public: + /** constructor API as demanded by KGenericFactory */ + KBytesEditWidget( QWidget *parent, const char *name, const QStringList & = QStringList() ); + + public: // bytesedit interface + /** hands over to the editor a new byte array. + * If there exists an old one and autodelete is set the old one gets deleted. + * @param D pointer to memory + * @param DS_ size of used memory + * @param RS_ real size of the memory + * @param KM keep the memory on resize (RS_ is the maximum size) + */ + virtual void setData( char *D, int DS_, int RS_ = -1, bool KM = true ); + + /** sets the maximal size of the actual byte array. If the actual array is already larger + * it will not be modified but there can be only done non-inserting actions + * until the array's is below the limit + */ + virtual void setMaxDataSize( int MS ); + /** sets whether the array should be deleted on the widget's end or if a new array is set. + * Default is false + */ + virtual void setAutoDelete( bool AD = true ); + /** sets whether the memory given by setData or in the constructor should be kept on resize + */ + virtual void setKeepsMemory( bool KM = true ); + /** */ + virtual char *data() const; + /** returns the size of the actual byte array */ + virtual int dataSize() const; + /** returns the maximal allowed size for the byte array */ + virtual int maxDataSize () const; + /** returns whether autodelete is set for the byte array */ + virtual bool isAutoDelete() const; + /** returns whether the memory of the byte array is kept */ + virtual bool keepsMemory() const; + /** */ + virtual bool isOverwriteMode() const; + virtual bool isOverwriteOnly() const; + virtual bool isReadOnly() const; + virtual bool isModified() const; + /** repaint the indizes from i1 to i2 */ + virtual void repaintRange( int i1, int i2 ); + + public: // cursor interface + /** */ + virtual void setCursorPosition( int Index ); +// virtual bool tabChangesFocus() const; + + public: // layout interface ?? + /** sets the resizestyle for the value column. Default is KHE::FullSizeUsage */ + virtual void setResizeStyle( KResizeStyle Style ); + /** sets the number of bytes per line, switching the resize style to KHE::NoResize */ + virtual void setNoOfBytesPerLine( int NoCpL ); + + virtual int noOfBytesPerLine() const; + virtual KResizeStyle resizeStyle() const; + + public: // value column + /** sets the format of the value column. Default is KHE::HexadecimalCoding */ + virtual void setCoding( KCoding C ); + /** sets the spacing between the bytes in pixels */ + virtual void setByteSpacingWidth( int BSW ); + /** sets the numbers of grouped bytes, 0 means no grouping, Default is 4 */ + virtual void setNoOfGroupedBytes( int NoGB ); + /** sets the spacing between the groups in pixels */ + virtual void setGroupSpacingWidth( int GSW ); + /** sets the spacing in the middle of a binary byte in the value column + * @param BGW spacing in the middle of a binary in pixels + */ + virtual void setBinaryGapWidth( int BGW ); + + virtual KCoding coding() const; + virtual int byteSpacingWidth() const; + + virtual int noOfGroupedBytes() const; + virtual int groupSpacingWidth() const; + virtual int binaryGapWidth() const; + + public: // char column + /** sets whether "unprintable" chars (>32) should be displayed in the char column + * with their corresponding character. + * @param SU + * returns true if there was a change + */ + virtual void setShowUnprintable( bool SU = true ); + /** sets the substitute character for "unprintable" chars + * returns true if there was a change + */ + virtual void setSubstituteChar( QChar SC ); + /** sets the encoding of the char column. Default is KHE::LocalEncoding. + * If the encoding is not available the format will not be changed. */ + virtual void setEncoding( KEncoding C ); + /** returns true if "unprintable" chars (>32) are displayed in the char column + * with their corresponding character, default is false + */ + virtual bool showUnprintable() const; + /** returns the actually used substitute character for "unprintable" chars, default is '.' */ + virtual QChar substituteChar() const; + /** */ + virtual KEncoding encoding() const; + + public: // edit interface + /** */ + virtual void insert( const QByteArray &D ); + /** de-/selects all data */ + virtual void selectAll( bool select ); + /** returns true if there is a selected range in the array */ + virtual bool hasSelectedData() const; + + public slots: + // bytesedit interface + virtual void setReadOnly( bool RO = true ); + virtual void setOverwriteOnly( bool b ); + virtual void setOverwriteMode( bool b ); + virtual void setModified( bool b ); + + // clipboard interface + virtual void copy(); + virtual void cut(); + virtual void paste(); + + // zooming interface + virtual void zoomIn( int PointInc ); + virtual void zoomIn(); + virtual void zoomOut( int PointDec ); + virtual void zoomOut(); + virtual void zoomTo( int PointSize ); + virtual void unZoom(); + + signals: + // clipboard interface + virtual void copyAvailable( bool Really ); + + protected: + KHE::KBytesEdit* BytesEdit; +}; + +#endif |