]> sigrok.org Git - pulseview.git/blame - pv/view/viewitem.cpp
ViewWidget: Moved in drag_items
[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
26e3af6b 67QMenu* ViewItem::create_context_menu(QWidget *parent)
9b6378f1 68{
8dbbc7f0 69 context_parent_ = parent;
9b6378f1
JH
70 return new QMenu(parent);
71}
72
26e3af6b 73void ViewItem::delete_pressed()
5ed1adf5
JH
74{
75}
76
26e3af6b 77QPen ViewItem::highlight_pen()
d09674d4
JH
78{
79 return QPen(QApplication::palette().brush(
aef68e5e 80 QPalette::Highlight), HighlightRadius * 2,
d09674d4
JH
81 Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
82}
83
d4e39570
JH
84void ViewItem::paint_back(QPainter &p, const ViewItemPaintParams &pp)
85{
86 (void)p;
87 (void)pp;
88}
89
90void ViewItem::paint_mid(QPainter &p, const ViewItemPaintParams &pp)
91{
92 (void)p;
93 (void)pp;
94}
95
96void ViewItem::paint_fore(QPainter &p, const ViewItemPaintParams &pp)
97{
98 (void)p;
99 (void)pp;
100}
101
26e3af6b 102QColor ViewItem::select_text_colour(QColor background)
d8d724cc
JH
103{
104 return (background.lightness() > 64) ? Qt::black : Qt::white;
105}
106
f1283456
JH
107} // namespace view
108} // namespace pv