]> sigrok.org Git - pulseview.git/blame - pv/view/viewitem.cpp
SamplingBar: Handle a failure to list the LIMIT_SAMPLES key
[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
JH
29namespace pv {
30namespace view {
31
ec39632d 32const QSizeF ViewItem::LabelPadding(4, 0);
aef68e5e 33const int ViewItem::HighlightRadius = 3;
d09674d4 34
26e3af6b 35ViewItem::ViewItem() :
8dbbc7f0 36 context_parent_(NULL),
23e75650
JH
37 drag_point_(INT_MIN, INT_MIN),
38 selected_(false)
f1283456
JH
39{
40}
41
26e3af6b 42bool ViewItem::selected() const
f1283456 43{
8dbbc7f0 44 return selected_;
f1283456
JH
45}
46
26e3af6b 47void ViewItem::select(bool select)
f1283456 48{
8dbbc7f0 49 selected_ = select;
f1283456
JH
50}
51
26e3af6b 52bool ViewItem::dragging() const
0dda6fe5 53{
8dbbc7f0 54 return drag_point_.x() != INT_MIN && drag_point_.y() != INT_MIN;
0dda6fe5
JH
55}
56
26e3af6b 57void ViewItem::drag()
0dda6fe5 58{
be717066 59 drag_point_ = point(QRect());
0dda6fe5
JH
60}
61
26e3af6b 62void ViewItem::drag_release()
0dda6fe5 63{
8dbbc7f0 64 drag_point_ = QPoint(INT_MIN, INT_MIN);
0dda6fe5
JH
65}
66
7708eb92
JH
67QRectF ViewItem::hit_box_rect(const QRectF &rect) const
68{
69 (void)rect;
70 return QRectF();
71}
72
26e3af6b 73QMenu* ViewItem::create_context_menu(QWidget *parent)
9b6378f1 74{
8dbbc7f0 75 context_parent_ = parent;
9b6378f1
JH
76 return new QMenu(parent);
77}
78
26e3af6b 79void ViewItem::delete_pressed()
5ed1adf5
JH
80{
81}
82
26e3af6b 83QPen ViewItem::highlight_pen()
d09674d4
JH
84{
85 return QPen(QApplication::palette().brush(
aef68e5e 86 QPalette::Highlight), HighlightRadius * 2,
d09674d4
JH
87 Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
88}
89
d4e39570
JH
90void ViewItem::paint_back(QPainter &p, const ViewItemPaintParams &pp)
91{
92 (void)p;
93 (void)pp;
94}
95
96void ViewItem::paint_mid(QPainter &p, const ViewItemPaintParams &pp)
97{
98 (void)p;
99 (void)pp;
100}
101
102void ViewItem::paint_fore(QPainter &p, const ViewItemPaintParams &pp)
103{
104 (void)p;
105 (void)pp;
106}
107
26e3af6b 108QColor ViewItem::select_text_colour(QColor background)
d8d724cc
JH
109{
110 return (background.lightness() > 64) ? Qt::black : Qt::white;
111}
112
f1283456
JH
113} // namespace view
114} // namespace pv