]>
Commit | Line | Data |
---|---|---|
f1283456 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 | ||
21 | #include "selectableitem.h" | |
22 | ||
0dda6fe5 JH |
23 | #include <climits> |
24 | ||
d09674d4 | 25 | #include <QApplication> |
9b6378f1 | 26 | #include <QMenu> |
d09674d4 JH |
27 | #include <QPalette> |
28 | ||
f1283456 JH |
29 | namespace pv { |
30 | namespace view { | |
31 | ||
d09674d4 JH |
32 | const int SelectableItem::HighlightRadius = 6; |
33 | ||
f1283456 | 34 | SelectableItem::SelectableItem() : |
9b6378f1 | 35 | _context_parent(NULL), |
0dda6fe5 JH |
36 | _selected(false), |
37 | _drag_point(INT_MIN, INT_MIN) | |
f1283456 JH |
38 | { |
39 | } | |
40 | ||
41 | bool SelectableItem::selected() const | |
42 | { | |
43 | return _selected; | |
44 | } | |
45 | ||
46 | void SelectableItem::select(bool select) | |
47 | { | |
48 | _selected = select; | |
49 | } | |
50 | ||
0dda6fe5 JH |
51 | bool SelectableItem::dragging() const |
52 | { | |
53 | return _drag_point.x() != INT_MIN && _drag_point.y() != INT_MIN; | |
54 | } | |
55 | ||
56 | QPoint SelectableItem::drag_point() const | |
57 | { | |
58 | return _drag_point; | |
59 | } | |
60 | ||
61 | void SelectableItem::drag() | |
62 | { | |
63 | _drag_point = point(); | |
64 | } | |
65 | ||
66 | void SelectableItem::drag_release() | |
67 | { | |
68 | _drag_point = QPoint(INT_MIN, INT_MIN); | |
69 | } | |
70 | ||
9b6378f1 JH |
71 | QMenu* SelectableItem::create_context_menu(QWidget *parent) |
72 | { | |
73 | _context_parent = parent; | |
74 | return new QMenu(parent); | |
75 | } | |
76 | ||
5ed1adf5 JH |
77 | void SelectableItem::delete_pressed() |
78 | { | |
79 | } | |
80 | ||
d09674d4 JH |
81 | QPen SelectableItem::highlight_pen() |
82 | { | |
83 | return QPen(QApplication::palette().brush( | |
84 | QPalette::Highlight), HighlightRadius, | |
85 | Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); | |
86 | } | |
87 | ||
f1283456 JH |
88 | } // namespace view |
89 | } // namespace pv |