]>
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 | ||
26e3af6b | 21 | #include "viewitem.hpp" |
f1283456 | 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 | ||
ec39632d | 32 | const QSizeF ViewItem::LabelPadding(4, 0); |
aef68e5e | 33 | const int ViewItem::HighlightRadius = 3; |
d09674d4 | 34 | |
26e3af6b | 35 | ViewItem::ViewItem() : |
8dbbc7f0 JH |
36 | context_parent_(NULL), |
37 | selected_(false), | |
38 | drag_point_(INT_MIN, INT_MIN) | |
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 | ||
26e3af6b | 52 | bool ViewItem::dragging() const |
0dda6fe5 | 53 | { |
8dbbc7f0 | 54 | return drag_point_.x() != INT_MIN && drag_point_.y() != INT_MIN; |
0dda6fe5 JH |
55 | } |
56 | ||
26e3af6b | 57 | QPoint ViewItem::drag_point() const |
0dda6fe5 | 58 | { |
8dbbc7f0 | 59 | return drag_point_; |
0dda6fe5 JH |
60 | } |
61 | ||
26e3af6b | 62 | void ViewItem::drag() |
0dda6fe5 | 63 | { |
be717066 | 64 | drag_point_ = point(QRect()); |
0dda6fe5 JH |
65 | } |
66 | ||
26e3af6b | 67 | void ViewItem::drag_release() |
0dda6fe5 | 68 | { |
8dbbc7f0 | 69 | drag_point_ = QPoint(INT_MIN, INT_MIN); |
0dda6fe5 JH |
70 | } |
71 | ||
26e3af6b | 72 | QMenu* ViewItem::create_context_menu(QWidget *parent) |
9b6378f1 | 73 | { |
8dbbc7f0 | 74 | context_parent_ = parent; |
9b6378f1 JH |
75 | return new QMenu(parent); |
76 | } | |
77 | ||
26e3af6b | 78 | void ViewItem::delete_pressed() |
5ed1adf5 JH |
79 | { |
80 | } | |
81 | ||
26e3af6b | 82 | QPen ViewItem::highlight_pen() |
d09674d4 JH |
83 | { |
84 | return QPen(QApplication::palette().brush( | |
aef68e5e | 85 | QPalette::Highlight), HighlightRadius * 2, |
d09674d4 JH |
86 | Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); |
87 | } | |
88 | ||
d4e39570 JH |
89 | void ViewItem::paint_back(QPainter &p, const ViewItemPaintParams &pp) |
90 | { | |
91 | (void)p; | |
92 | (void)pp; | |
93 | } | |
94 | ||
95 | void ViewItem::paint_mid(QPainter &p, const ViewItemPaintParams &pp) | |
96 | { | |
97 | (void)p; | |
98 | (void)pp; | |
99 | } | |
100 | ||
101 | void ViewItem::paint_fore(QPainter &p, const ViewItemPaintParams &pp) | |
102 | { | |
103 | (void)p; | |
104 | (void)pp; | |
105 | } | |
106 | ||
26e3af6b | 107 | QColor ViewItem::select_text_colour(QColor background) |
d8d724cc JH |
108 | { |
109 | return (background.lightness() > 64) ? Qt::black : Qt::white; | |
110 | } | |
111 | ||
f1283456 JH |
112 | } // namespace view |
113 | } // namespace pv |