PulseView  0.3.0
A Qt-based sigrok GUI
viewwidget.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the PulseView project.
3  *
4  * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 #ifndef PULSEVIEW_PV_VIEWWIDGET_HPP
22 #define PULSEVIEW_PV_VIEWWIDGET_HPP
23 
24 #include <memory>
25 
26 #include <QWidget>
27 
28 class QTouchEvent;
29 
30 namespace pv {
31 namespace view {
32 
33 class View;
34 class ViewItem;
35 
36 class ViewWidget : public QWidget
37 {
38  Q_OBJECT
39 
40 protected:
41  ViewWidget(View &parent);
42 
49  virtual void item_hover(
50  const std::shared_ptr<pv::view::ViewItem> &item);
51 
57  virtual void item_clicked(
58  const std::shared_ptr<pv::view::ViewItem> &item);
59 
64  bool accept_drag() const;
65 
69  bool mouse_down() const;
70 
75  void drag_items(const QPoint &delta);
76 
80  virtual void drag();
81 
87  virtual void drag_by(const QPoint &delta);
88 
92  virtual void drag_release();
93 
97  virtual std::vector< std::shared_ptr<pv::view::ViewItem> > items() = 0;
98 
105  virtual std::shared_ptr<pv::view::ViewItem> get_mouse_over_item(
106  const QPoint &pt) = 0;
107 
112  void mouse_left_press_event(QMouseEvent *event);
113 
118  void mouse_left_release_event(QMouseEvent *event);
119 
124  virtual bool touch_event(QTouchEvent *e);
125 
126 protected:
127  bool event(QEvent *event);
128 
129  void mousePressEvent(QMouseEvent * event);
130  void mouseReleaseEvent(QMouseEvent *event);
131  void mouseMoveEvent(QMouseEvent *event);
132 
133  void leaveEvent(QEvent *event);
134 
135 public Q_SLOTS:
136  void clear_selection();
137 
138 Q_SIGNALS:
139  void selection_changed();
140 
141 protected:
143  QPoint mouse_point_;
145  std::shared_ptr<ViewItem> mouse_down_item_;
147 };
148 
149 } // namespace view
150 } // namespace pv
151 
152 #endif // PULSEVIEW_PV_VIEWWIDGET_HPP
virtual void item_clicked(const std::shared_ptr< pv::view::ViewItem > &item)
Definition: viewwidget.cpp:58
bool accept_drag() const
Definition: viewwidget.cpp:63
void drag_items(const QPoint &delta)
Definition: viewwidget.cpp:102
virtual std::vector< std::shared_ptr< pv::view::ViewItem > > items()=0
pv::view::View & view_
Definition: viewwidget.hpp:142
ViewWidget(View &parent)
Definition: viewwidget.cpp:36
virtual void drag()
Definition: viewwidget.cpp:146
void leaveEvent(QEvent *event)
Definition: viewwidget.cpp:294
virtual std::shared_ptr< pv::view::ViewItem > get_mouse_over_item(const QPoint &pt)=0
bool mouse_down() const
Definition: viewwidget.cpp:96
bool event(QEvent *event)
Definition: viewwidget.cpp:232
virtual void item_hover(const std::shared_ptr< pv::view::ViewItem > &item)
Definition: viewwidget.cpp:53
virtual void drag_release()
Definition: viewwidget.cpp:155
std::shared_ptr< ViewItem > mouse_down_item_
Definition: viewwidget.hpp:145
void mousePressEvent(QMouseEvent *event)
Definition: viewwidget.cpp:249
virtual void drag_by(const QPoint &delta)
Definition: viewwidget.cpp:150
virtual bool touch_event(QTouchEvent *e)
Definition: viewwidget.cpp:226
void mouse_left_press_event(QMouseEvent *event)
Definition: viewwidget.cpp:159
void mouseReleaseEvent(QMouseEvent *event)
Definition: viewwidget.cpp:260
void mouse_left_release_event(QMouseEvent *event)
Definition: viewwidget.cpp:195
void mouseMoveEvent(QMouseEvent *event)
Definition: viewwidget.cpp:270