summaryrefslogtreecommitdiffstats
path: root/khexedit/parts/kpart/khebrowserextension.cpp
blob: 6adebaa68b9084f39d2d58f84f12e53e8d4c6d4b (plain)
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
/***************************************************************************
                          khebrowserextension.cpp  -  description
                             -------------------
    begin                : Di Nov 16 2004
    copyright            : (C) 2004 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.       *
 *                                                                         *
 ***************************************************************************/


// qt specific
#include <tdeaction.h>
// app specific
#include "khexedit.h"
#include "khepart.h"
#include "khebrowserextension.h"

using namespace KHE;


KHexEditBrowserExtension::KHexEditBrowserExtension( KHexEditPart *P )
  : KParts::BrowserExtension( P, "khexeditpartbrowserextension" ),
  HexEditPart( P )
{
  connect( HexEditPart->HexEdit, TQT_SIGNAL( selectionChanged() ), this, TQT_SLOT( slotSelectionChanged() ) );
}

void KHexEditBrowserExtension::copy()
{
  HexEditPart->HexEdit->copy();
}


void KHexEditBrowserExtension::slotSelectionChanged()
{
  emit enableAction( "copy", HexEditPart->HexEdit->hasSelectedData() );
}


void KHexEditBrowserExtension::saveState( TQDataStream &stream )
{
  KParts::BrowserExtension::saveState( stream );

  KHexEdit *HexEdit = HexEditPart->HexEdit;

  stream << (int)HexEdit->offsetColumnVisible() << HexEdit->visibleBufferColumns()
      << (int)HexEdit->resizeStyle() << (int)HexEdit->coding() 
      << HexEdit->encodingName() << (int)HexEdit->showUnprintable()
      << HexEdit->contentsX() << HexEdit->contentsY()
      << HexEdit->cursorPosition() << (int)HexEdit->isCursorBehind()
      << HexEdit->cursorColumn();
}


void KHexEditBrowserExtension::restoreState( TQDataStream &stream )
{
  KParts::BrowserExtension::restoreState( stream );

  int OffsetColumnVisible;
  int VisibleBufferColumns;
  int ResizeStyle;
  int Coding;
  TQString EncodingName;
  int ShowUnprintable;
  int x, y;
  int Position;
  int CursorBehind;
  int CursorColumn;

  stream >> OffsetColumnVisible >> VisibleBufferColumns >> ResizeStyle >> Coding >> EncodingName >> ShowUnprintable 
         >> x >> y >> Position >> CursorBehind >> CursorColumn;

  KHexEdit *HexEdit = HexEditPart->HexEdit;

  HexEdit->toggleOffsetColumn( OffsetColumnVisible );
  HexEdit->showBufferColumns( VisibleBufferColumns );
  HexEdit->setResizeStyle( (KHexEdit::KResizeStyle)ResizeStyle );
  HexEdit->setCoding( (KHexEdit::KCoding)Coding );
  HexEdit->setEncoding( EncodingName );
  HexEdit->setShowUnprintable( ShowUnprintable );
  HexEdit->setContentsPos( x, y );
  HexEdit->setCursorPosition( Position, CursorBehind );
  HexEdit->setCursorColumn( (KHexEdit::TDEBufferColumnId)CursorColumn );

  HexEditPart->fitActionSettings();
}

#include "khebrowserextension.moc"