summaryrefslogtreecommitdiffstats
path: root/src/eventinfo.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 01:49:02 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 01:49:02 +0000
commit5de3dd4762ca33a0f92e79ffa4fe2ff67069d531 (patch)
treebad482b7afa4cdf47422d60a5dd2c61c7e333b09 /src/eventinfo.cpp
downloadktechlab-5de3dd4762ca33a0f92e79ffa4fe2ff67069d531.tar.gz
ktechlab-5de3dd4762ca33a0f92e79ffa4fe2ff67069d531.zip
Added KDE3 version of ktechlab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ktechlab@1095338 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/eventinfo.cpp')
-rw-r--r--src/eventinfo.cpp132
1 files changed, 132 insertions, 0 deletions
diff --git a/src/eventinfo.cpp b/src/eventinfo.cpp
new file mode 100644
index 0000000..f6c0746
--- /dev/null
+++ b/src/eventinfo.cpp
@@ -0,0 +1,132 @@
+/***************************************************************************
+ * Copyright (C) 2005 by David Saxton *
+ * david@bluehaze.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+
+#include "eventinfo.h"
+#include "itemdocument.h"
+#include "itemview.h"
+
+
+EventInfo::EventInfo()
+{
+ reset();
+}
+
+
+EventInfo::EventInfo( ItemView *itemView, QEvent *e )
+{
+ Q_UNUSED(itemView);
+ Q_UNUSED(e);
+ reset();
+}
+
+EventInfo::EventInfo( ItemView *itemView, QMouseEvent *e )
+{
+ pos = e->pos()/itemView->zoomLevel();
+ globalPos = e->globalPos();
+ isRightClick = e->button() == Qt::RightButton;
+ ctrlPressed = e->state() & QMouseEvent::ControlButton;
+ shiftPressed = e->state() & QMouseEvent::ShiftButton;
+ altPressed = e->state() & QMouseEvent::AltButton;
+ if ( ItemDocument * id = dynamic_cast<ItemDocument*>(itemView->document()) )
+ qcanvasItemClickedOn = id->itemAtTop(pos);
+ itemRtti = qcanvasItemClickedOn ? qcanvasItemClickedOn->rtti() : ItemDocument::RTTI::None;
+ scrollDelta = 0;
+ scrollOrientation = Qt::Vertical;
+}
+
+
+EventInfo::EventInfo( ItemView *itemView, QWheelEvent *e )
+{
+ pos = e->pos()/itemView->zoomLevel();
+ globalPos = e->globalPos();
+ isRightClick = false;
+ ctrlPressed = e->state() & QMouseEvent::ControlButton;
+ shiftPressed = e->state() & QMouseEvent::ShiftButton;
+ altPressed = e->state() & QMouseEvent::AltButton;
+ if ( ItemDocument * id = dynamic_cast<ItemDocument*>(itemView->document()) )
+ qcanvasItemClickedOn = id->itemAtTop(pos);
+ itemRtti = qcanvasItemClickedOn ? qcanvasItemClickedOn->rtti() : ItemDocument::RTTI::None;
+ scrollDelta = e->delta();
+ scrollOrientation = e->orientation();
+
+// kdDebug() << "scrollOrientation="<<scrollOrientation<<endl;
+}
+
+
+void EventInfo::reset()
+{
+ isRightClick = false;
+ ctrlPressed = false;
+ shiftPressed = false;
+ altPressed = false;
+ qcanvasItemClickedOn = 0l;
+ itemRtti = ItemDocument::RTTI::None;
+ scrollDelta = 0;
+ scrollOrientation = Qt::Vertical;
+}
+
+
+QMouseEvent *EventInfo::mousePressEvent( int dx, int dy ) const
+{
+ return new QMouseEvent( QEvent::MouseButtonPress,
+ pos + QPoint( dx, dy ),
+ (isRightClick ? Qt::RightButton : Qt::LeftButton),
+ (isRightClick ? Qt::RightButton : Qt::LeftButton) |
+ (ctrlPressed ? Qt::ControlButton : 0 ) |
+ (shiftPressed ? Qt::ShiftButton : 0 ) |
+ (altPressed ? Qt::AltButton : 0 ) );
+}
+
+
+QMouseEvent *EventInfo::mouseReleaseEvent( int dx, int dy ) const
+{
+ return new QMouseEvent( QEvent::MouseButtonRelease,
+ pos + QPoint( dx, dy ),
+ (isRightClick ? Qt::RightButton : Qt::LeftButton),
+ (isRightClick ? Qt::RightButton : Qt::LeftButton) |
+ (ctrlPressed ? Qt::ControlButton : 0 ) |
+ (shiftPressed ? Qt::ShiftButton : 0 ) |
+ (altPressed ? Qt::AltButton : 0 ) );
+}
+
+
+QMouseEvent *EventInfo::mouseDoubleClickEvent( int dx, int dy ) const
+{
+ return new QMouseEvent( QEvent::MouseButtonDblClick,
+ pos + QPoint( dx, dy ),
+ (isRightClick ? Qt::RightButton : Qt::LeftButton),
+ (isRightClick ? Qt::RightButton : Qt::LeftButton) |
+ (ctrlPressed ? Qt::ControlButton : 0 ) |
+ (shiftPressed ? Qt::ShiftButton : 0 ) |
+ (altPressed ? Qt::AltButton : 0 ) );
+}
+
+
+QMouseEvent *EventInfo::mouseMoveEvent( int dx, int dy ) const
+{
+ return new QMouseEvent( QEvent::MouseMove,
+ pos + QPoint( dx, dy ),
+ Qt::NoButton,
+ (ctrlPressed ? Qt::ControlButton : 0 ) |
+ (shiftPressed ? Qt::ShiftButton : 0 ) |
+ (altPressed ? Qt::AltButton : 0 ) );
+}
+
+
+QWheelEvent *EventInfo::wheelEvent( int dx, int dy ) const
+{
+ return new QWheelEvent( pos + QPoint( dx, dy ),
+ scrollDelta,
+ (ctrlPressed ? Qt::ControlButton : 0 ) |
+ (shiftPressed ? Qt::ShiftButton : 0 ) |
+ (altPressed ? Qt::AltButton : 0 ),
+ scrollOrientation );
+}
+