From: Joel Holdsworth Date: Sun, 12 May 2013 20:35:37 +0000 (+0100) Subject: Added pv::view::MarginWidget as a common base class of Header and Ruler X-Git-Tag: pulseview-0.2.0~353 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=c23b29d67ed68c1a899000bf0049056fe9f51a62 Added pv::view::MarginWidget as a common base class of Header and Ruler --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 60644e16..d835927e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,7 @@ set(pulseview_SOURCES pv/view/cursor.cpp pv/view/cursorpair.cpp pv/view/header.cpp + pv/view/marginwidget.cpp pv/view/logicsignal.cpp pv/view/ruler.cpp pv/view/selectableitem.cpp @@ -145,6 +146,7 @@ set(pulseview_HEADERS pv/toolbars/samplingbar.h pv/view/cursor.h pv/view/header.h + pv/view/marginwidget.h pv/view/ruler.h pv/view/selectableitem.h pv/view/signal.h diff --git a/pv/view/header.cpp b/pv/view/header.cpp index 6d016fe0..8fb5b4bd 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -43,8 +43,7 @@ namespace pv { namespace view { Header::Header(View &parent) : - QWidget(&parent), - _view(parent), + MarginWidget(parent), _action_set_name(new QAction(tr("Set &Name..."), this)), _action_set_colour(new QAction(tr("Set &Colour..."), this)) { diff --git a/pv/view/header.h b/pv/view/header.h index 8e180b8a..504011b6 100644 --- a/pv/view/header.h +++ b/pv/view/header.h @@ -27,7 +27,7 @@ #include #include -#include +#include "marginwidget.h" namespace pv { namespace view { @@ -35,7 +35,7 @@ namespace view { class Signal; class View; -class Header : public QWidget +class Header : public MarginWidget { Q_OBJECT @@ -71,8 +71,6 @@ signals: void signals_moved(); private: - View &_view; - QPoint _mouse_point; QPoint _mouse_down_point; diff --git a/pv/view/marginwidget.cpp b/pv/view/marginwidget.cpp new file mode 100644 index 00000000..539551dd --- /dev/null +++ b/pv/view/marginwidget.cpp @@ -0,0 +1,35 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2013 Joel Holdsworth + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "view.h" + +#include "marginwidget.h" + +namespace pv { +namespace view { + +MarginWidget::MarginWidget(View &parent) : + QWidget(&parent), + _view(parent) +{ +} + +} // namespace view +} // namespace pv diff --git a/pv/view/marginwidget.h b/pv/view/marginwidget.h new file mode 100644 index 00000000..239692ca --- /dev/null +++ b/pv/view/marginwidget.h @@ -0,0 +1,45 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2013 Joel Holdsworth + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef PULSEVIEW_PV_MARGINWIDGET_H +#define PULSEVIEW_PV_MARGINWIDGET_H + +#include + +namespace pv { +namespace view { + +class View; + +class MarginWidget : public QWidget +{ + Q_OBJECT + +public: + MarginWidget(pv::view::View &parent); + +protected: + pv::view::View &_view; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_MARGINWIDGET_H diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index d323f9be..654e6f45 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -49,8 +49,7 @@ const int Ruler::FirstSIPrefixPower = -15; const int Ruler::HoverArrowSize = 5; Ruler::Ruler(View &parent) : - QWidget(&parent), - _view(parent), + MarginWidget(parent), _grabbed_marker(NULL) { setMouseTracking(true); diff --git a/pv/view/ruler.h b/pv/view/ruler.h index 689b073c..461ec05c 100644 --- a/pv/view/ruler.h +++ b/pv/view/ruler.h @@ -21,7 +21,7 @@ #ifndef PULSEVIEW_PV_VIEW_RULER_H #define PULSEVIEW_PV_VIEW_RULER_H -#include +#include "marginwidget.h" namespace pv { namespace view { @@ -29,7 +29,7 @@ namespace view { class TimeMarker; class View; -class Ruler : public QWidget +class Ruler : public MarginWidget { Q_OBJECT @@ -65,8 +65,6 @@ private slots: void hover_point_changed(); private: - View &_view; - TimeMarker *_grabbed_marker; };