File indexing completed on 2024-05-12 17:22:02

0001 /*
0002     SPDX-FileCopyrightText: 2009 Csaba Karai <cskarai@freemail.hu>
0003     SPDX-FileCopyrightText: 2009-2022 Krusader Krew <https://krusader.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef KRMOUSEHANDLER_H
0009 #define KRMOUSEHANDLER_H
0010 
0011 // QtCore
0012 #include <QPoint>
0013 #include <QStringList>
0014 #include <QTime>
0015 #include <QTimer>
0016 
0017 class QMouseEvent;
0018 class QWheelEvent;
0019 class KrView;
0020 class KrViewItem;
0021 class QDragEnterEvent;
0022 class QDragMoveEvent;
0023 class QDragLeaveEvent;
0024 class QDropEvent;
0025 
0026 /**
0027  * @brief Mouse handler for view
0028  */
0029 class KrMouseHandler : public QObject
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     KrMouseHandler(KrView *view, int contextMenuShift);
0035 
0036     bool mousePressEvent(QMouseEvent *e);
0037     bool mouseReleaseEvent(QMouseEvent *e);
0038     bool mouseDoubleClickEvent(QMouseEvent *e);
0039     bool mouseMoveEvent(QMouseEvent *e);
0040     bool wheelEvent(QWheelEvent *);
0041     bool dragEnterEvent(QDragEnterEvent *e);
0042     bool dragMoveEvent(QDragMoveEvent *e);
0043     bool dragLeaveEvent(QDragLeaveEvent *e);
0044     bool dropEvent(QDropEvent *e);
0045     void handleContextMenu(KrViewItem *it, const QPoint &pos);
0046     void otherEvent(QEvent *e);
0047     void cancelTwoClickRename();
0048 
0049 public slots:
0050     void showContextMenu();
0051 
0052 signals:
0053     void renameCurrentItem();
0054 
0055 protected:
0056     KrView *_view;
0057     KrViewItem *_rightClickedItem;
0058     KrViewItem *_clickedItem;
0059     bool _rightClickSelects;
0060     bool _singleClick;
0061     QPoint _contextMenuPoint;
0062     QTimer _contextMenuTimer;
0063     int _contextMenuShift;
0064     bool _singleClicked;
0065     KrViewItem *_singleClickedItem;
0066     QTime _singleClickTime;
0067     QTimer _renameTimer;
0068     QPoint _dragStartPos;
0069     bool _emptyContextMenu;
0070     QStringList _selectedItemNames;
0071 };
0072 
0073 #endif