]>
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 | |
efdec55a | 17 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
f1283456 JH |
18 | */ |
19 | ||
26e3af6b | 20 | #include "viewitem.hpp" |
f1283456 | 21 | |
0dda6fe5 JH |
22 | #include <climits> |
23 | ||
d09674d4 | 24 | #include <QApplication> |
9b6378f1 | 25 | #include <QMenu> |
d09674d4 JH |
26 | #include <QPalette> |
27 | ||
f1283456 | 28 | namespace pv { |
f4e57597 | 29 | namespace views { |
1573bf16 | 30 | namespace trace { |
f1283456 | 31 | |
ec39632d | 32 | const QSizeF ViewItem::LabelPadding(4, 0); |
aef68e5e | 33 | const int ViewItem::HighlightRadius = 3; |
d09674d4 | 34 | |
26e3af6b | 35 | ViewItem::ViewItem() : |
4c60462b | 36 | context_parent_(nullptr), |
23e75650 JH |
37 | drag_point_(INT_MIN, INT_MIN), |
38 | selected_(false) | |
f1283456 JH |
39 | { |
40 | } | |
41 | ||
26e3af6b | 42 | bool ViewItem::selected() const |
f1283456 | 43 | { |
8dbbc7f0 | 44 | return selected_; |
f1283456 JH |
45 | } |
46 | ||
26e3af6b | 47 | void ViewItem::select(bool select) |
f1283456 | 48 | { |
8dbbc7f0 | 49 | selected_ = select; |
f1283456 JH |
50 | } |
51 | ||
a009d219 TS |
52 | bool ViewItem::is_draggable() const |
53 | { | |
54 | return true; | |
55 | } | |
56 | ||
26e3af6b | 57 | bool ViewItem::dragging() const |
0dda6fe5 | 58 | { |
8dbbc7f0 | 59 | return drag_point_.x() != INT_MIN && drag_point_.y() != INT_MIN; |
0dda6fe5 JH |
60 | } |
61 | ||
26e3af6b | 62 | void ViewItem::drag() |
0dda6fe5 | 63 | { |
a009d219 | 64 | if (is_draggable()) |
a3d5a7c7 | 65 | drag_point_ = drag_point(QRect()); |
0dda6fe5 JH |
66 | } |
67 | ||
26e3af6b | 68 | void ViewItem::drag_release() |
0dda6fe5 | 69 | { |
8dbbc7f0 | 70 | drag_point_ = QPoint(INT_MIN, INT_MIN); |
0dda6fe5 JH |
71 | } |
72 | ||
3cd51b50 JH |
73 | QRectF ViewItem::label_rect(const QRectF &rect) const |
74 | { | |
75 | (void)rect; | |
76 | return QRectF(); | |
77 | } | |
78 | ||
cbf0f87e | 79 | QRectF ViewItem::hit_box_rect(const ViewItemPaintParams &pp) const |
7708eb92 | 80 | { |
cbf0f87e | 81 | (void)pp; |
7708eb92 JH |
82 | return QRectF(); |
83 | } | |
84 | ||
26e3af6b | 85 | QMenu* ViewItem::create_context_menu(QWidget *parent) |
9b6378f1 | 86 | { |
8dbbc7f0 | 87 | context_parent_ = parent; |
9b6378f1 JH |
88 | return new QMenu(parent); |
89 | } | |
90 | ||
0f2f14a4 JH |
91 | widgets::Popup* ViewItem::create_popup(QWidget *parent) |
92 | { | |
93 | (void)parent; | |
94 | return nullptr; | |
95 | } | |
96 | ||
26e3af6b | 97 | void ViewItem::delete_pressed() |
5ed1adf5 JH |
98 | { |
99 | } | |
100 | ||
26e3af6b | 101 | QPen ViewItem::highlight_pen() |
d09674d4 JH |
102 | { |
103 | return QPen(QApplication::palette().brush( | |
aef68e5e | 104 | QPalette::Highlight), HighlightRadius * 2, |
d09674d4 JH |
105 | Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); |
106 | } | |
107 | ||
fa792224 JH |
108 | void ViewItem::paint_label(QPainter &p, const QRect &rect, bool hover) |
109 | { | |
110 | (void)p; | |
111 | (void)rect; | |
112 | (void)hover; | |
113 | } | |
114 | ||
60938e04 | 115 | void ViewItem::paint_back(QPainter &p, ViewItemPaintParams &pp) |
d4e39570 JH |
116 | { |
117 | (void)p; | |
118 | (void)pp; | |
119 | } | |
120 | ||
60938e04 | 121 | void ViewItem::paint_mid(QPainter &p, ViewItemPaintParams &pp) |
d4e39570 JH |
122 | { |
123 | (void)p; | |
124 | (void)pp; | |
125 | } | |
126 | ||
60938e04 | 127 | void ViewItem::paint_fore(QPainter &p, ViewItemPaintParams &pp) |
d4e39570 JH |
128 | { |
129 | (void)p; | |
130 | (void)pp; | |
131 | } | |
132 | ||
26e3af6b | 133 | QColor ViewItem::select_text_colour(QColor background) |
d8d724cc | 134 | { |
20dd116e | 135 | return (background.lightness() > 110) ? Qt::black : Qt::white; |
d8d724cc JH |
136 | } |
137 | ||
1573bf16 | 138 | } // namespace trace |
f4e57597 | 139 | } // namespace views |
f1283456 | 140 | } // namespace pv |