File indexing completed on 2024-04-28 05:52:37

0001 /*
0002     This file is part of the Okteta Gui library, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2008-2009 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef OKTETA_MOUSENAVIGATOR_HPP
0010 #define OKTETA_MOUSENAVIGATOR_HPP
0011 
0012 // lib
0013 #include "abstractmousecontroller.hpp"
0014 // Qt
0015 #include <QObject>
0016 #include <QPoint>
0017 
0018 class QMouseEvent;
0019 class QTimer;
0020 
0021 namespace Okteta {
0022 
0023 class MouseNavigator : public QObject
0024                      , public AbstractMouseController
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     MouseNavigator(AbstractByteArrayView* view, AbstractMouseController* parent);
0030 
0031     ~MouseNavigator() override;
0032 
0033 public: // AbstractMouseController API
0034     bool handleMousePressEvent(QMouseEvent* mouseEvent) override;
0035     bool handleMouseMoveEvent(QMouseEvent* mouseEvent) override;
0036     bool handleMouseReleaseEvent(QMouseEvent* mouseEvent) override;
0037     bool handleMouseDoubleClickEvent(QMouseEvent* mouseEvent) override;
0038 
0039 private:
0040     /** handles the move of the mouse with pressed buttons */
0041     void handleMouseMove(QPoint point);
0042 
0043 private Q_SLOTS:
0044     /** gets called by the scroll timer (for mouse selection) */
0045     void autoScrollTimerDone();
0046     /** */
0047     void startDrag();
0048 
0049 private:
0050     /** Timer that triggers ensureCursorVisible function calls */
0051     QTimer* mScrollTimer;
0052 /*     QTimer *ChangeIntervalTimer, */
0053     /** Timer to start a drag */
0054     QTimer* mDragStartTimer;
0055     /** timer to measure whether the time between a double click and the following counts for a tripleclick */
0056     QTimer* mTrippleClickTimer;
0057 
0058 private:
0059     /** point at which the current double click happended (used by TrippleClick) */
0060     QPoint mDoubleClickPoint;
0061     /** line in which the current double click happended (used by TrippleClick) */
0062     int mDoubleClickLine;
0063     /** point at which the current dragging started */
0064     QPoint mDragStartPoint;
0065 
0066 private: // parameters
0067     /** flag if the left mouse button is pressed */
0068     bool mLMBPressed : 1;
0069     /** flag if a double click is happening */
0070     bool mInLMBDoubleClick : 1;
0071     /** flag if a drag might have started */
0072     bool mDragStartPossible : 1;
0073 };
0074 
0075 }
0076 
0077 #endif