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