]> sigrok.org Git - pulseview.git/blame_incremental - pv/view/viewitem.cpp
MainWindow: Use regular pointer for QDockWidgets
[pulseview.git] / pv / view / viewitem.cpp
... / ...
CommitLineData
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
21#include "viewitem.hpp"
22
23#include <climits>
24
25#include <QApplication>
26#include <QMenu>
27#include <QPalette>
28
29namespace pv {
30namespace views {
31namespace TraceView {
32
33const QSizeF ViewItem::LabelPadding(4, 0);
34const int ViewItem::HighlightRadius = 3;
35
36ViewItem::ViewItem() :
37 context_parent_(nullptr),
38 drag_point_(INT_MIN, INT_MIN),
39 selected_(false)
40{
41}
42
43bool ViewItem::selected() const
44{
45 return selected_;
46}
47
48void ViewItem::select(bool select)
49{
50 selected_ = select;
51}
52
53bool ViewItem::is_draggable() const
54{
55 return true;
56}
57
58bool ViewItem::dragging() const
59{
60 return drag_point_.x() != INT_MIN && drag_point_.y() != INT_MIN;
61}
62
63void ViewItem::drag()
64{
65 if (is_draggable())
66 drag_point_ = point(QRect());
67}
68
69void ViewItem::drag_release()
70{
71 drag_point_ = QPoint(INT_MIN, INT_MIN);
72}
73
74QRectF ViewItem::label_rect(const QRectF &rect) const
75{
76 (void)rect;
77 return QRectF();
78}
79
80QRectF ViewItem::hit_box_rect(const ViewItemPaintParams &pp) const
81{
82 (void)pp;
83 return QRectF();
84}
85
86QMenu* ViewItem::create_context_menu(QWidget *parent)
87{
88 context_parent_ = parent;
89 return new QMenu(parent);
90}
91
92widgets::Popup* ViewItem::create_popup(QWidget *parent)
93{
94 (void)parent;
95 return nullptr;
96}
97
98void ViewItem::delete_pressed()
99{
100}
101
102QPen ViewItem::highlight_pen()
103{
104 return QPen(QApplication::palette().brush(
105 QPalette::Highlight), HighlightRadius * 2,
106 Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
107}
108
109void ViewItem::paint_label(QPainter &p, const QRect &rect, bool hover)
110{
111 (void)p;
112 (void)rect;
113 (void)hover;
114}
115
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
134QColor ViewItem::select_text_colour(QColor background)
135{
136 return (background.lightness() > 110) ? Qt::black : Qt::white;
137}
138
139} // namespace TraceView
140} // namespace views
141} // namespace pv