• 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
  • gui
  • controller
mousepaster.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta Gui library, made within the KDE community.
3 
4  Copyright 2008-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 "mousepaster.h"
24 
25 // lib
26 #include <bytearraycolumnview.h>
27 #include <bytearraytableranges.h>
28 #include <bytearraytablecursor.h>
29 #include <bytearraytablelayout.h>
30 // Qt
31 #include <QtGui/QMouseEvent>
32 
33 
34 namespace Okteta
35 {
36 
37 MousePaster::MousePaster( AbstractByteArrayView* view, AbstractMouseController* parent )
38  : AbstractMouseController( view, parent )
39 {
40 }
41 
42 bool MousePaster::handleMousePressEvent( QMouseEvent* mouseEvent )
43 {
44  bool eventUsed = false;
45 
46  if( mouseEvent->button() == Qt::MidButton && ! mView->isReadOnly() )
47  {
48  mView->pauseCursor();
49  mView->finishByteEdit();
50 
51  ByteArrayTableRanges* tableRanges = mView->tableRanges();
52  tableRanges->removeSelection();
53 
54  if( tableRanges->isModified() )
55  {
56  mView->updateChanged();
57  mView->viewport()->setCursor( mView->isReadOnly() ? Qt::ArrowCursor : Qt::IBeamCursor );
58  }
59  mView->unpauseCursor();
60 
61  eventUsed = true;
62  }
63 
64  return eventUsed ? true : AbstractMouseController::handleMousePressEvent( mouseEvent );
65 }
66 
67 bool MousePaster::handleMouseReleaseEvent( QMouseEvent* mouseEvent )
68 {
69  bool eventUsed = false;
70  // middle mouse button paste?
71  if( mouseEvent->button() == Qt::MidButton && ! mView->isReadOnly() )
72  {
73  const QPoint releasePoint = mView->viewportToColumns( mouseEvent->pos() );
74 
75  mView->pauseCursor();
76  mView->finishByteEdit();
77 
78  mView->placeCursor( releasePoint );
79 
80  ByteArrayTableRanges* tableRanges = mView->tableRanges();
81  ByteArrayTableCursor* tableCursor = mView->tableCursor();
82  // replace no selection?
83  if( tableRanges->hasSelection() && ! tableRanges->selectionIncludes(tableCursor->index()) )
84  tableRanges->removeSelection();
85 
86  mView->pasteFromClipboard( QClipboard::Selection );
87 
88  // ensure selection changes to be drawn TODO: create a insert/pasteAtCursor that leaves out drawing
89  mView->updateChanged();
90 
91  mView->ensureCursorVisible();
92  mView->unpauseCursor();
93 
94  emit mView->cursorPositionChanged( tableCursor->realIndex() );
95 
96  if( tableRanges->selectionJustStarted() )
97  tableRanges->removeSelection();
98 
99  if( ! mView->isOverwriteMode() ) emit mView->cutAvailable( tableRanges->hasSelection() );
100  emit mView->copyAvailable( tableRanges->hasSelection() );
101  emit mView->hasSelectedDataChanged( tableRanges->hasSelection() );
102 
103  eventUsed = true;
104  }
105 
106  return eventUsed ? true : AbstractMouseController::handleMouseReleaseEvent( mouseEvent );
107 }
108 
109 MousePaster::~MousePaster() {}
110 
111 }
Okteta::AbstractByteArrayView::tableCursor
ByteArrayTableCursor * tableCursor() const
Definition: abstractbytearrayview.cpp:106
Okteta::ByteArrayTableCursor::index
Address index() const
the index that is drawn at the actual coord
Definition: bytearraytablecursor.h:170
Okteta::ByteArrayTableRanges
a class to control all the ranges like marking and selections holds also all modified ranges and merg...
Definition: bytearraytableranges.h:45
Okteta::ColumnsView::viewportToColumns
QPoint viewportToColumns(const QPoint &point) const
translates the point to coordinates in the columns
Definition: columnsview.cpp:120
Okteta::AbstractByteArrayView::updateChanged
void updateChanged()
Definition: abstractbytearrayview.cpp:505
Okteta::AbstractMouseController::handleMousePressEvent
virtual bool handleMousePressEvent(QMouseEvent *mouseEvent)
Definition: abstractmousecontroller.cpp:35
Okteta::AbstractByteArrayView::isReadOnly
bool isReadOnly() const
Definition: abstractbytearrayview.cpp:59
Okteta::ByteArrayTableRanges::selectionIncludes
bool selectionIncludes(Address index) const
Definition: bytearraytableranges.h:141
Okteta::AbstractByteArrayView
Definition: abstractbytearrayview.h:55
Okteta::MousePaster::~MousePaster
virtual ~MousePaster()
Definition: mousepaster.cpp:109
Okteta::AbstractByteArrayView::isOverwriteMode
bool isOverwriteMode() const
Definition: abstractbytearrayview.cpp:49
Okteta::AbstractByteArrayView::cutAvailable
void cutAvailable(bool Really)
there is a cut available or not
Okteta::MousePaster::MousePaster
MousePaster(AbstractByteArrayView *view, AbstractMouseController *parent)
Definition: mousepaster.cpp:37
Okteta::AbstractByteArrayView::copyAvailable
void copyAvailable(bool Really)
there is a copy available or not
bytearraytablelayout.h
Okteta::ByteArrayTableRanges::selectionJustStarted
bool selectionJustStarted() const
Definition: bytearraytableranges.h:138
Okteta::MousePaster::handleMousePressEvent
virtual bool handleMousePressEvent(QMouseEvent *mouseEvent)
Definition: mousepaster.cpp:42
Okteta::ByteArrayTableRanges::hasSelection
bool hasSelection() const
Definition: bytearraytableranges.h:136
Okteta::AbstractMouseController::handleMouseReleaseEvent
virtual bool handleMouseReleaseEvent(QMouseEvent *mouseEvent)
Definition: abstractmousecontroller.cpp:43
Okteta::AbstractMouseController::mView
AbstractByteArrayView * mView
Definition: abstractmousecontroller.h:48
Okteta::AbstractByteArrayView::pauseCursor
void pauseCursor()
simply pauses any blinking, i.e.
Definition: abstractbytearrayview.cpp:421
Okteta::AbstractByteArrayView::cursorPositionChanged
void cursorPositionChanged(Okteta::Address index)
Okteta::AbstractMouseController
Definition: abstractmousecontroller.h:33
mousepaster.h
Okteta::AbstractByteArrayView::finishByteEdit
void finishByteEdit()
Definition: abstractbytearrayview.cpp:487
Okteta::ByteArrayTableCursor
navigates through the buffer in an abstract way, based on the layout
Definition: bytearraytablecursor.h:60
Okteta::MousePaster::handleMouseReleaseEvent
virtual bool handleMouseReleaseEvent(QMouseEvent *mouseEvent)
Definition: mousepaster.cpp:67
bytearraycolumnview.h
Okteta::AbstractByteArrayView::unpauseCursor
void unpauseCursor()
undoes pauseCursor
Definition: abstractbytearrayview.cpp:409
Okteta::AbstractByteArrayView::tableRanges
ByteArrayTableRanges * tableRanges() const
Definition: abstractbytearrayview.cpp:111
Okteta::ByteArrayTableCursor::realIndex
Address realIndex() const
returns the real index.
Definition: bytearraytablecursor.h:175
bytearraytableranges.h
Okteta::ByteArrayTableRanges::removeSelection
AddressRange removeSelection(int id=0)
removes selection with id and returns it
Definition: bytearraytableranges.cpp:156
Okteta::AbstractByteArrayView::ensureCursorVisible
void ensureCursorVisible()
scrolls the view as much as needed to have the cursor fully visible
Definition: abstractbytearrayview.cpp:390
Okteta::AbstractByteArrayView::placeCursor
void placeCursor(const QPoint &point)
puts the cursor in the column at the pos of Point (in absolute coord), does not handle the drawing ...
Definition: abstractbytearrayview.cpp:396
bytearraytablecursor.h
Okteta::AbstractByteArrayView::pasteFromClipboard
void pasteFromClipboard(QClipboard::Mode mode)
Definition: abstractbytearrayview.cpp:517
Okteta::ByteArrayTableRanges::isModified
bool isModified() const
Definition: bytearraytableranges.h:133
Okteta::AbstractByteArrayView::hasSelectedDataChanged
void hasSelectedDataChanged(bool hasSelectedData)
selection has changed
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:08 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