PulseView  unreleased development snapshot
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, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef PULSEVIEW_PV_VIEWS_TRACE_VIEWWIDGET_HPP
21 #define PULSEVIEW_PV_VIEWS_TRACE_VIEWWIDGET_HPP
22 
23 #include <memory>
24 
25 #include <QPoint>
26 #include <QWidget>
27 
28 #include <pv/util.hpp>
29 
30 using std::shared_ptr;
31 using std::vector;
32 
33 class QTouchEvent;
34 
35 namespace pv {
36 namespace views {
37 namespace trace {
38 
39 class View;
40 class ViewItem;
41 
42 class ViewWidget : public QWidget
43 {
44  Q_OBJECT
45 
46 protected:
47  ViewWidget(View &parent);
48 
55  virtual void item_hover(const shared_ptr<ViewItem> &item, QPoint pos);
56 
62  virtual void item_clicked(const shared_ptr<ViewItem> &item);
63 
68  bool accept_drag() const;
69 
73  bool mouse_down() const;
74 
79  void drag_items(const QPoint &delta);
80 
84  virtual void drag();
85 
91  virtual void drag_by(const QPoint &delta);
92 
96  virtual void drag_release();
97 
101  virtual vector< shared_ptr<ViewItem> > items() = 0;
102 
109  virtual shared_ptr<ViewItem> get_mouse_over_item(const QPoint &pt) = 0;
110 
115  void mouse_left_press_event(QMouseEvent *event);
116 
121  void mouse_left_release_event(QMouseEvent *event);
122 
127  virtual bool touch_event(QTouchEvent *event);
128 
129 protected:
130  bool event(QEvent *event);
131 
132  void mousePressEvent(QMouseEvent *event);
133  void mouseReleaseEvent(QMouseEvent *event);
134  void mouseMoveEvent(QMouseEvent *event);
135 
136  void keyPressEvent(QKeyEvent *event);
137  void keyReleaseEvent(QKeyEvent *event);
138 
139  void leaveEvent(QEvent *event);
140 
141 public Q_SLOTS:
142  void clear_selection();
143 
144 Q_SIGNALS:
145  void selection_changed();
146 
147 protected:
149  QPoint mouse_point_;
152  shared_ptr<ViewItem> mouse_down_item_;
153 
155  Qt::KeyboardModifiers mouse_modifiers_;
156 
158 };
159 
160 } // namespace trace
161 } // namespace views
162 } // namespace pv
163 
164 #endif // PULSEVIEW_PV_VIEWS_TRACE_VIEWWIDGET_HPP
void mouse_left_release_event(QMouseEvent *event)
Definition: viewwidget.cpp:196
pv::util::Timestamp mouse_down_offset_
Definition: viewwidget.hpp:151
virtual shared_ptr< ViewItem > get_mouse_over_item(const QPoint &pt)=0
void mouse_left_press_event(QMouseEvent *event)
Definition: viewwidget.cpp:160
void keyPressEvent(QKeyEvent *event)
Definition: viewwidget.cpp:295
void mouseMoveEvent(QMouseEvent *event)
Definition: viewwidget.cpp:303
virtual bool touch_event(QTouchEvent *event)
Definition: viewwidget.cpp:227
virtual void item_clicked(const shared_ptr< ViewItem > &item)
Definition: viewwidget.cpp:59
Qt::KeyboardModifiers mouse_modifiers_
Keyboard modifiers that were active when mouse was last moved or clicked.
Definition: viewwidget.hpp:155
void mousePressEvent(QMouseEvent *event)
Definition: viewwidget.cpp:251
void leaveEvent(QEvent *event)
Definition: viewwidget.cpp:347
void mouseReleaseEvent(QMouseEvent *event)
Definition: viewwidget.cpp:276
pv::views::trace::View & view_
Definition: viewwidget.hpp:148
virtual void item_hover(const shared_ptr< ViewItem > &item, QPoint pos)
Definition: viewwidget.cpp:53
void drag_items(const QPoint &delta)
Definition: viewwidget.cpp:103
shared_ptr< ViewItem > mouse_down_item_
Definition: viewwidget.hpp:152
boost::multiprecision::number< boost::multiprecision::cpp_dec_float< 24 >, boost::multiprecision::et_off > Timestamp
Timestamp type providing yoctosecond resolution.
Definition: util.hpp:67
virtual vector< shared_ptr< ViewItem > > items()=0
virtual void drag_by(const QPoint &delta)
Definition: viewwidget.cpp:151
bool event(QEvent *event)
Definition: viewwidget.cpp:234
void keyReleaseEvent(QKeyEvent *event)
Definition: viewwidget.cpp:287