]> sigrok.org Git - pulseview.git/blob - pv/view/tracegroup.hpp
MainWindow, View::View: Fix two memory errors reported by valgrind
[pulseview.git] / pv / view / tracegroup.hpp
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 #ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACEGROUP_HPP
22 #define PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACEGROUP_HPP
23
24 #include "tracetreeitem.hpp"
25 #include "tracetreeitemowner.hpp"
26
27 namespace pv {
28 namespace views {
29 namespace TraceView {
30
31 class TraceGroup : public TraceTreeItem, public TraceTreeItemOwner
32 {
33         Q_OBJECT
34
35 private:
36         static const int Padding;
37         static const int Width;
38         static const int LineThickness;
39         static const QColor LineColour;
40
41 public:
42         /**
43          * Virtual destructor
44          */
45         virtual ~TraceGroup();
46
47         /**
48          * Returns true if the item is visible and enabled.
49          */
50         bool enabled() const;
51
52         /**
53          * Returns the session of the onwer.
54          */
55         pv::Session& session();
56
57         /**
58          * Returns the session of the onwer.
59          */
60         const pv::Session& session() const;
61
62         /**
63          * Returns the view of the owner.
64          */
65         virtual View* view();
66
67         /**
68          * Returns the view of the owner.
69          */
70         virtual const View* view() const;
71
72         /**
73          * Computes the vertical extents of the contents of this row item.
74          * @return A pair containing the minimum and maximum y-values.
75          */
76         std::pair<int, int> v_extents() const;
77
78         /**
79          * Paints the signal label.
80          * @param p the QPainter to paint into.
81          * @param right the x-coordinate of the right edge of the header
82          *      area.
83          * @param hover true if the label is being hovered over by the mouse.
84          */
85         void paint_label(QPainter &p, const QRect &rect, bool hover);
86
87         /**
88          * Computes the outline rectangle of a label.
89          * @param rect the rectangle of the header area.
90          * @return Returns the rectangle of the signal label.
91          */
92         QRectF label_rect(const QRectF &rect) const;
93
94         /**
95          * Determines if a point is in the header label rect.
96          * @param left the x-coordinate of the left edge of the header
97          *      area.
98          * @param right the x-coordinate of the right edge of the header
99          *      area.
100          * @param point the point to test.
101          */
102         bool pt_in_label_rect(int left, int right, const QPoint &point);
103
104         QMenu* create_context_menu(QWidget *parent);
105
106         pv::widgets::Popup* create_popup(QWidget *parent);
107
108         /**
109          * Returns the total vertical offset of this trace and all it's owners
110          */
111         int owner_visual_v_offset() const;
112
113         void restack_items();
114
115         /**
116          * Returns the number of nested parents that this row item owner has.
117          */
118         unsigned int depth() const;
119
120         void ungroup();
121
122 public:
123         void row_item_appearance_changed(bool label, bool content);
124
125         void extents_changed(bool horz, bool vert);
126
127 private Q_SLOTS:
128         void on_ungroup();
129 };
130
131 } // namespace TraceView
132 } // namespace views
133 } // namespace pv
134
135 #endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACEGROUP_HPP