2 * This file is part of the PulseView project.
4 * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef PULSEVIEW_PV_VIEWWIDGET_H
22 #define PULSEVIEW_PV_VIEWWIDGET_H
36 class ViewWidget : public QWidget
41 ViewWidget(View &parent);
44 * Indicates the event an a view item has been clicked.
45 * @param item the view item that has been clicked.
46 * @remarks the default implementation does nothing.
48 virtual void item_clicked(
49 const std::shared_ptr<pv::view::ViewItem> &item);
52 * Returns true if the selection of row items allows dragging.
53 * @return Returns true if the drag is acceptable.
55 bool accept_drag() const;
58 * Returns true if the mouse button is down.
60 bool mouse_down() const;
63 * Drag the dragging items by the delta offset.
64 * @param delta the drag offset in pixels.
66 void drag_items(const QPoint &delta);
69 * Sets this item into the dragged state.
74 * Drag the background by the delta offset.
75 * @param delta the drag offset in pixels.
76 * @remarks The default implementation does nothing.
78 virtual void drag_by(const QPoint &delta);
81 * Sets this item into the un-dragged state.
83 virtual void drag_release();
86 * Gets the items in the view widget.
88 virtual std::vector< std::shared_ptr<pv::view::ViewItem> > items() = 0;
91 * Gets the first view item which has a hit-box that contains @c pt .
92 * @param pt the point to search with.
93 * @return the view item that has been found, or and empty
94 * @c shared_ptr if no item was found.
96 virtual std::shared_ptr<pv::view::ViewItem> get_mouse_over_item(
97 const QPoint &pt) = 0;
100 * Handles left mouse button press events.
101 * @param event the mouse event that triggered this handler.
103 void mouse_left_press_event(QMouseEvent *event);
106 * Handles left mouse button release events.
107 * @param event the mouse event that triggered this handler.
109 void mouse_left_release_event(QMouseEvent *event);
112 * Handles touch begin update and end events.
113 * @param e the event that triggered this handler.
115 virtual bool touch_event(QTouchEvent *e);
118 bool event(QEvent *event);
120 void mousePressEvent(QMouseEvent * event);
121 void mouseReleaseEvent(QMouseEvent *event);
122 void mouseMoveEvent(QMouseEvent *event);
124 void leaveEvent(QEvent *event);
127 void clear_selection();
130 void selection_changed();
133 pv::view::View &view_;
135 QPoint mouse_down_point_;
136 std::shared_ptr<ViewItem> mouse_down_item_;
143 #endif // PULSEVIEW_PV_VIEWWIDGET_H