• 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
  • parts
  • kpart
browserextension.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta KPart module, made within the KDE community.
3 
4  Copyright 2004,2009 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 "browserextension.h"
24 
25 // part
26 #include "part.h"
27 // Okteta Kasten
28 #include <print/printcontroller.h>
29 #include <bytearrayview.h>
30 #include <bytearraydocument.h>
31 // Qt
32 #include <QtGui/QClipboard>
33 #include <QtGui/QApplication>
34 
35 
36 OktetaBrowserExtension::OktetaBrowserExtension( OktetaPart* part )
37  : KParts::BrowserExtension( part ),
38  mPart( part )
39 {
40  setObjectName( QLatin1String( "oktetapartbrowserextension" ) );
41 
42  connect( mPart, SIGNAL(hasSelectedDataChanged(bool)),
43  SLOT(onSelectionChanged(bool)) );
44 
45  emit enableAction( "copy", false );
46  emit enableAction( "print", true);
47 }
48 
49 void OktetaBrowserExtension::copy()
50 {
51  QMimeData* data = mPart->byteArrayView()->copySelectedData();
52  if( !data )
53  return;
54 
55  QApplication::clipboard()->setMimeData( data, QClipboard::Clipboard );
56 }
57 
58 void OktetaBrowserExtension::print()
59 {
60  mPart->printController()->print();
61 }
62 
63 
64 void OktetaBrowserExtension::onSelectionChanged( bool hasSelection )
65 {
66  emit enableAction( "copy", hasSelection );
67 }
68 
69 
70 void OktetaBrowserExtension::saveState( QDataStream& stream )
71 {
72  KParts::BrowserExtension::saveState( stream );
73 
74  Kasten2::ByteArrayView* view = mPart->byteArrayView();
75 
76  stream << (int)view->offsetColumnVisible() << view->visibleByteArrayCodings()
77  << (int)view->layoutStyle() << (int)view->valueCoding()
78  << view->charCodingName() << (int)view->showsNonprinting()
79 // << view->xOffset() << view->yOffset()
80  << view->cursorPosition()
81 // << (int)view->isCursorBehind()
82 // << view->activeCoding()
83  ;
84 }
85 
86 
87 void OktetaBrowserExtension::restoreState( QDataStream& stream )
88 {
89  KParts::BrowserExtension::restoreState( stream );
90 
91  int offsetColumnVisible;
92  int visibleCodings;
93  int layoutStyle;
94  int valueCoding;
95  QString charCodingName;
96  int showsNonprinting;
97 // int x, y;
98  int position;
99 // int cursorBehind;
100 // int activeCoding;
101 
102  stream >> offsetColumnVisible >> visibleCodings >> layoutStyle >> valueCoding >> charCodingName >> showsNonprinting
103 // >> x >> y
104  >> position
105 // >> cursorBehind
106 // >> activeCoding
107  ;
108 
109  Kasten2::ByteArrayView* view = mPart->byteArrayView();
110 
111  view->toggleOffsetColumn( offsetColumnVisible );
112  view->setVisibleByteArrayCodings( visibleCodings );
113  view->setLayoutStyle( layoutStyle );
114  view->setValueCoding( valueCoding );
115  view->setCharCoding( charCodingName );
116  view->setShowsNonprinting( showsNonprinting );
117 // view->setColumnsPos( x, y );
118  view->setCursorPosition( position );//, cursorBehind );
119 // view->setActiveCoding( (Okteta::ByteArrayColumnView::CodingTypeId)activeCoding );
120 }
Kasten2::ByteArrayView::showsNonprinting
bool showsNonprinting() const
Definition: bytearrayview.cpp:286
Kasten2::ByteArrayView::valueCoding
int valueCoding() const
Definition: bytearrayview.cpp:250
Kasten2::ByteArrayView::charCodingName
QString charCodingName() const
Definition: bytearrayview.cpp:255
Kasten2::ByteArrayView::setValueCoding
void setValueCoding(int valueCoding)
Definition: bytearrayview.cpp:260
Kasten2::ByteArrayView::setCharCoding
void setCharCoding(const QString &charCodingName)
Definition: bytearrayview.cpp:265
OktetaBrowserExtension::copy
void copy()
copy text to clipboard
Definition: browserextension.cpp:49
Kasten2::ByteArrayView::visibleByteArrayCodings
int visibleByteArrayCodings() const
Definition: bytearrayview.cpp:306
Kasten2::ByteArrayView::setLayoutStyle
void setLayoutStyle(int layoutStyle)
Definition: bytearrayview.cpp:336
printcontroller.h
Kasten2::ByteArrayView::copySelectedData
virtual QMimeData * copySelectedData() const
Definition: bytearrayview.cpp:183
Kasten2::ByteArrayView::cursorPosition
Okteta::Address cursorPosition() const
Definition: bytearrayview.cpp:227
Kasten2::ByteArrayView::setShowsNonprinting
void setShowsNonprinting(bool showsNonprinting=true)
Definition: bytearrayview.cpp:316
OktetaPart::printController
Kasten2::PrintController * printController() const
Definition: part.cpp:147
Kasten2::ByteArrayView::setVisibleByteArrayCodings
void setVisibleByteArrayCodings(int columns)
Definition: bytearrayview.cpp:346
Kasten2::ByteArrayView::setCursorPosition
void setCursorPosition(Okteta::Address cursorPosition)
Definition: bytearrayview.cpp:217
OktetaBrowserExtension::saveState
virtual void saveState(QDataStream &stream)
Definition: browserextension.cpp:70
OktetaPart::byteArrayView
Kasten2::ByteArrayView * byteArrayView() const
Definition: part.h:99
Kasten2::ByteArrayView::offsetColumnVisible
bool offsetColumnVisible() const
Definition: bytearrayview.cpp:291
Kasten2::PrintController::print
void print()
Definition: printcontroller.cpp:54
browserextension.h
OktetaBrowserExtension::restoreState
virtual void restoreState(QDataStream &stream)
Definition: browserextension.cpp:87
OktetaBrowserExtension::mPart
OktetaPart * mPart
Definition: browserextension.h:58
bytearraydocument.h
Kasten2::ByteArrayView::layoutStyle
int layoutStyle() const
Definition: bytearrayview.cpp:301
OktetaBrowserExtension::print
void print()
Definition: browserextension.cpp:58
Kasten2::ByteArrayView::toggleOffsetColumn
void toggleOffsetColumn(bool visible)
Definition: bytearrayview.cpp:326
OktetaPart
Definition: part.h:43
Kasten2::ByteArrayView
Definition: bytearrayview.h:51
part.h
OktetaBrowserExtension::OktetaBrowserExtension
OktetaBrowserExtension(OktetaPart *part)
Definition: browserextension.cpp:36
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