]>
Commit | Line | Data |
---|---|---|
722930c1 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 | ||
21 | #include <assert.h> | |
22 | ||
23 | #include <algorithm> | |
24 | ||
25 | #include "tracegroup.h" | |
26 | ||
a5d93c27 | 27 | using std::pair; |
722930c1 JH |
28 | using std::shared_ptr; |
29 | ||
30 | namespace pv { | |
31 | namespace view { | |
32 | ||
b781f806 JH |
33 | const int TraceGroup::Padding = 8; |
34 | const int TraceGroup::Width = 12; | |
35 | ||
722930c1 JH |
36 | TraceGroup::~TraceGroup() |
37 | { | |
38 | _owner = nullptr; | |
39 | clear_child_items(); | |
40 | } | |
41 | ||
42 | bool TraceGroup::enabled() const | |
43 | { | |
44 | return std::any_of(child_items().begin(), child_items().end(), | |
45 | [](const shared_ptr<RowItem> &r) { return r->enabled(); }); | |
46 | } | |
47 | ||
48 | pv::SigSession& TraceGroup::session() | |
49 | { | |
50 | assert(_owner); | |
51 | return _owner->session(); | |
52 | } | |
53 | ||
54 | const pv::SigSession& TraceGroup::session() const | |
55 | { | |
56 | assert(_owner); | |
57 | return _owner->session(); | |
58 | } | |
59 | ||
60 | pv::view::View* TraceGroup::view() | |
61 | { | |
62 | assert(_owner); | |
63 | return _owner->view(); | |
64 | } | |
65 | ||
66 | const pv::view::View* TraceGroup::view() const | |
67 | { | |
68 | assert(_owner); | |
69 | return _owner->view(); | |
70 | } | |
71 | ||
a5d93c27 JH |
72 | pair<int, int> TraceGroup::v_extents() const |
73 | { | |
74 | return RowItemOwner::v_extents(); | |
75 | } | |
76 | ||
722930c1 JH |
77 | void TraceGroup::paint_label(QPainter &p, int right, bool hover) |
78 | { | |
79 | (void)p; | |
80 | (void)right; | |
81 | (void)hover; | |
82 | } | |
83 | ||
0067d804 | 84 | QRectF TraceGroup::label_rect(int right) const |
722930c1 | 85 | { |
b781f806 JH |
86 | QRectF rect; |
87 | for (const shared_ptr<RowItem> r : child_items()) | |
88 | if (r) | |
89 | rect = rect.united(r->label_rect(right)); | |
90 | ||
91 | return QRectF(rect.x() - Width - Padding, rect.y(), | |
92 | Width, rect.height()); | |
722930c1 JH |
93 | } |
94 | ||
95 | bool TraceGroup::pt_in_label_rect(int left, int right, const QPoint &point) | |
96 | { | |
97 | (void)left; | |
98 | (void)right; | |
99 | (void)point; | |
100 | ||
101 | return false; | |
102 | } | |
103 | ||
104 | QMenu* TraceGroup::create_context_menu(QWidget *parent) | |
105 | { | |
106 | (void)parent; | |
107 | ||
108 | return NULL; | |
109 | } | |
110 | ||
111 | pv::widgets::Popup* TraceGroup::create_popup(QWidget *parent) | |
112 | { | |
113 | (void)parent; | |
114 | return NULL; | |
115 | } | |
116 | ||
117 | int TraceGroup::owner_v_offset() const | |
118 | { | |
119 | return v_offset() + _owner->owner_v_offset(); | |
120 | } | |
121 | ||
122 | void TraceGroup::update_viewport() | |
123 | { | |
124 | if (_owner) | |
125 | _owner->update_viewport(); | |
126 | } | |
127 | ||
128 | } // namespace view | |
129 | } // namespace pv |