PulseView  0.3.0
A Qt-based sigrok GUI
viewport.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the PulseView project.
3  *
4  * Copyright (C) 2012 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_VIEW_VIEWPORT_HPP
22 #define PULSEVIEW_PV_VIEW_VIEWPORT_HPP
23 
24 #include <boost/optional.hpp>
25 
26 #include <QTimer>
27 #include <QTouchEvent>
28 
29 #include "pv/util.hpp"
30 #include "viewwidget.hpp"
31 
32 class QPainter;
33 class QPaintEvent;
34 class Session;
35 
36 namespace pv {
37 namespace view {
38 
39 class View;
40 
41 class Viewport : public ViewWidget
42 {
43  Q_OBJECT
44 
45 public:
46  explicit Viewport(View &parent);
47 
48 private:
54  void item_hover(const std::shared_ptr<pv::view::ViewItem> &item);
55 
62  std::shared_ptr<pv::view::ViewItem> get_mouse_over_item(
63  const QPoint &pt);
64 
68  void drag();
69 
74  void drag_by(const QPoint &delta);
75 
79  void drag_release();
80 
84  std::vector< std::shared_ptr<pv::view::ViewItem> > items();
85 
90  bool touch_event(QTouchEvent *e);
91 
92 private:
93  void paintEvent(QPaintEvent *event);
94 
95  void mouseDoubleClickEvent(QMouseEvent * event);
96  void wheelEvent(QWheelEvent *event);
97 
98 private:
99  boost::optional<pv::util::Timestamp> drag_offset_;
101 
105 };
106 
107 } // namespace view
108 } // namespace pv
109 
110 #endif // PULSEVIEW_PV_VIEW_VIEWPORT_HPP
void item_hover(const std::shared_ptr< pv::view::ViewItem > &item)
Definition: viewport.cpp:69
std::shared_ptr< pv::view::ViewItem > get_mouse_over_item(const QPoint &pt)
Definition: viewport.cpp:58
bool event(QEvent *event)
Definition: viewwidget.cpp:232
void paintEvent(QPaintEvent *event)
Definition: viewport.cpp:156
void wheelEvent(QWheelEvent *event)
Definition: viewport.cpp:205
std::vector< std::shared_ptr< pv::view::ViewItem > > items()
Definition: viewport.cpp:100
boost::optional< pv::util::Timestamp > drag_offset_
Definition: viewport.hpp:99
Viewport(View &parent)
Definition: viewport.cpp:50
void drag_by(const QPoint &delta)
Definition: viewport.cpp:84
void mouseDoubleClickEvent(QMouseEvent *event)
Definition: viewport.cpp:195
bool touch_event(QTouchEvent *e)
Definition: viewport.cpp:111