]> sigrok.org Git - pulseview.git/blame - pv/view/marginwidget.cpp
MarginWidget: Moved in contextMenuEvent
[pulseview.git] / pv / view / marginwidget.cpp
CommitLineData
c23b29d6
JH
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
2155b66b
JH
21#include <QMenu>
22#include <QMouseEvent>
23
2acdb232 24#include "view.hpp"
c23b29d6 25
2acdb232 26#include "marginwidget.hpp"
c23b29d6 27
786b7678
JH
28#include <pv/widgets/popup.hpp>
29
30using std::shared_ptr;
31
c23b29d6
JH
32namespace pv {
33namespace view {
34
35MarginWidget::MarginWidget(View &parent) :
36 QWidget(&parent),
f4433aa9
JH
37 view_(parent),
38 dragging_(false)
c23b29d6 39{
e02e05c6 40 setAttribute(Qt::WA_NoSystemBackground, true);
dbfae3f1
JH
41 setFocusPolicy(Qt::ClickFocus);
42 setMouseTracking(true);
c23b29d6
JH
43}
44
786b7678
JH
45void MarginWidget::show_popup(const shared_ptr<ViewItem> &item)
46{
47 pv::widgets::Popup *const p = item->create_popup(this);
48 if (p)
49 p->show();
50}
51
19552bb8
JH
52void MarginWidget::leaveEvent(QEvent*)
53{
54 mouse_point_ = QPoint(-1, -1);
55 update();
56}
57
2155b66b
JH
58void MarginWidget::contextMenuEvent(QContextMenuEvent *event)
59{
60 const shared_ptr<ViewItem> r = get_mouse_over_item(mouse_point_);
61 if (!r)
62 return;
63
64 QMenu *menu = r->create_context_menu(this);
65 if (menu)
66 menu->exec(event->globalPos());
67}
68
84a0d458
JS
69void MarginWidget::clear_selection()
70{
71}
72
c23b29d6
JH
73} // namespace view
74} // namespace pv