]> sigrok.org Git - pulseview.git/commitdiff
Added ViewWidget as a common ancestor of all view widgets
authorJoel Holdsworth <redacted>
Sun, 21 Dec 2014 17:56:31 +0000 (17:56 +0000)
committerJoel Holdsworth <redacted>
Mon, 29 Dec 2014 12:24:04 +0000 (12:24 +0000)
CMakeLists.txt
pv/view/marginwidget.cpp
pv/view/marginwidget.hpp
pv/view/viewport.cpp
pv/view/viewport.hpp
pv/view/viewwidget.cpp [new file with mode: 0644]
pv/view/viewwidget.hpp [new file with mode: 0644]
test/CMakeLists.txt

index 546b99dcfe98b615a44594ebcf351de396effe46..edb8a82c9e16fe7338cd9bcbbc123886f91efb0c 100644 (file)
@@ -186,6 +186,7 @@ set(pulseview_SOURCES
        pv/view/viewitem.cpp
        pv/view/viewitempaintparams.cpp
        pv/view/viewport.cpp
+       pv/view/viewwidget.cpp
        pv/widgets/colourbutton.cpp
        pv/widgets/colourpopup.cpp
        pv/widgets/popup.cpp
@@ -227,6 +228,7 @@ set(pulseview_HEADERS
        pv/view/view.hpp
        pv/view/viewitem.hpp
        pv/view/viewport.hpp
+       pv/view/viewwidget.hpp
        pv/widgets/colourbutton.hpp
        pv/widgets/colourpopup.hpp
        pv/widgets/popup.hpp
index 7582f4af187bfbfbc1dc7125c42378d6bd2fd387..fcbb31bf0174bb1944286005b11d0d978d715126 100644 (file)
@@ -34,8 +34,7 @@ namespace pv {
 namespace view {
 
 MarginWidget::MarginWidget(View &parent) :
-       QWidget(&parent),
-       view_(parent),
+       ViewWidget(parent),
        dragging_(false)
 {
        setAttribute(Qt::WA_NoSystemBackground, true);
index 54ace028fcda121bd79588c20a1b32d6af159c67..308d9348d12a0341aa6a203cd1b214a8c74839cf 100644 (file)
 #include <memory>
 
 #include <QPoint>
-#include <QWidget>
+
+#include "viewwidget.hpp"
 
 namespace pv {
 namespace view {
 
-class View;
 class ViewItem;
 
-class MarginWidget : public QWidget
+class MarginWidget : public ViewWidget
 {
        Q_OBJECT
 
@@ -109,7 +109,6 @@ Q_SIGNALS:
        void selection_changed();
 
 protected:
-       pv::view::View &view_;
        QPoint mouse_point_;
        QPoint mouse_down_point_;
        std::shared_ptr<ViewItem> mouse_down_item_;
index feb880e94a0bd0ea477ed225bdae4642c5cef767..0c33fe2c4a00685976320634315c26b8ffd90185 100644 (file)
@@ -43,14 +43,12 @@ namespace pv {
 namespace view {
 
 Viewport::Viewport(View &parent) :
-       QWidget(&parent),
-       view_(parent),
+       ViewWidget(parent),
        mouse_down_valid_(false),
        pinch_zoom_active_(false)
 {
        setAttribute(Qt::WA_AcceptTouchEvents, true);
 
-       setMouseTracking(true);
        setAutoFillBackground(true);
        setBackgroundRole(QPalette::Base);
 
index 07bfcad9c5263a49b2fa5d22e9992dbf0541add5..94ebe8ee4f0a4655ad3af4084bb5b2211854e0e8 100644 (file)
 #define PULSEVIEW_PV_VIEW_VIEWPORT_H
 
 #include <QTimer>
-#include <QWidget>
 #include <QTouchEvent>
 
+#include "viewwidget.hpp"
+
 class QPainter;
 class QPaintEvent;
 class Session;
@@ -34,7 +35,7 @@ namespace view {
 
 class View;
 
-class Viewport : public QWidget
+class Viewport : public ViewWidget
 {
        Q_OBJECT
 
@@ -57,8 +58,6 @@ private Q_SLOTS:
        void on_signals_moved();
 
 private:
-       View &view_;
-
        QPoint mouse_down_point_;
        double mouse_down_offset_;
        bool mouse_down_valid_;
diff --git a/pv/view/viewwidget.cpp b/pv/view/viewwidget.cpp
new file mode 100644 (file)
index 0000000..357b6fe
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * 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.hpp"
+#include "viewwidget.hpp"
+
+namespace pv {
+namespace view {
+
+ViewWidget::ViewWidget(View &parent) :
+       QWidget(&parent),
+       view_(parent)
+{
+}
+
+} // namespace view
+} // namespace pv
diff --git a/pv/view/viewwidget.hpp b/pv/view/viewwidget.hpp
new file mode 100644 (file)
index 0000000..5c8889e
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * 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_VIEWWIDGET_H
+#define PULSEVIEW_PV_VIEWWIDGET_H
+
+#include <QWidget>
+
+namespace pv {
+namespace view {
+
+class View;
+
+class ViewWidget : public QWidget
+{
+       Q_OBJECT
+
+protected:
+       ViewWidget(View &parent);
+
+protected:
+       pv::view::View &view_;
+};
+
+} // namespace view
+} // namespace pv
+
+#endif // PULSEVIEW_PV_VIEWWIDGET_H
index 446c868b253ae8a7b5eb4816fc5fcb54560a2b19..4041d293cdfa3b8ee6637e048076b5c58b24cea0 100644 (file)
@@ -58,6 +58,7 @@ set(pulseview_TEST_SOURCES
        ${PROJECT_SOURCE_DIR}/pv/view/viewitem.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/viewitempaintparams.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/viewport.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/viewwidget.cpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.cpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.cpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/popup.cpp
@@ -97,6 +98,7 @@ set(pulseview_TEST_HEADERS
        ${PROJECT_SOURCE_DIR}/pv/view/view.hpp
        ${PROJECT_SOURCE_DIR}/pv/view/viewitem.hpp
        ${PROJECT_SOURCE_DIR}/pv/view/viewport.hpp
+       ${PROJECT_SOURCE_DIR}/pv/view/viewwidget.hpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.hpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.hpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/popup.hpp