]> sigrok.org Git - pulseview.git/commitdiff
SelectableItem: Renamed to ViewItem
authorJoel Holdsworth <redacted>
Sat, 13 Dec 2014 11:02:01 +0000 (11:02 +0000)
committerJoel Holdsworth <redacted>
Sun, 28 Dec 2014 15:35:43 +0000 (15:35 +0000)
CMakeLists.txt
pv/mainwindow.cpp
pv/view/cursorpair.cpp
pv/view/rowitem.hpp
pv/view/selectableitem.cpp [deleted file]
pv/view/selectableitem.hpp [deleted file]
pv/view/timeitem.hpp
pv/view/trace.cpp
pv/view/viewitem.cpp [new file with mode: 0644]
pv/view/viewitem.hpp [new file with mode: 0644]
test/CMakeLists.txt

index 036946c360984204b0dc7b8ec59abe9ed495831c..9635bfce4d25d66ae70f77c5c0cfa7c86f6a4311 100644 (file)
@@ -177,7 +177,6 @@ set(pulseview_SOURCES
        pv/view/rowitemowner.cpp
        pv/view/rowitempaintparams.cpp
        pv/view/ruler.cpp
-       pv/view/selectableitem.cpp
        pv/view/signal.cpp
        pv/view/timeitem.cpp
        pv/view/timemarker.cpp
@@ -185,6 +184,7 @@ set(pulseview_SOURCES
        pv/view/tracegroup.cpp
        pv/view/tracepalette.cpp
        pv/view/view.cpp
+       pv/view/viewitem.cpp
        pv/view/viewport.cpp
        pv/widgets/colourbutton.cpp
        pv/widgets/colourpopup.cpp
@@ -219,13 +219,13 @@ set(pulseview_HEADERS
        pv/view/marginwidget.hpp
        pv/view/rowitem.hpp
        pv/view/ruler.hpp
-       pv/view/selectableitem.hpp
        pv/view/signal.hpp
        pv/view/timeitem.hpp
        pv/view/timemarker.hpp
        pv/view/trace.hpp
        pv/view/tracegroup.hpp
        pv/view/view.hpp
+       pv/view/viewitem.hpp
        pv/view/viewport.hpp
        pv/widgets/colourbutton.hpp
        pv/widgets/colourpopup.hpp
index b7f360ff7f71f809c6ae714bf7a35acabbd1b60d..9fa4eee6baa2735281a4c3e4dbfda21cc7a3bb62 100644 (file)
@@ -71,7 +71,7 @@ using sigrok::HardwareDevice;
 namespace pv {
 
 namespace view {
-class SelectableItem;
+class ViewItem;
 }
 
 const char *MainWindow::SettingOpenDirectory = "MainWindow/OpenDirectory";
index ecce13893def06fb3e4c3f8559d412ef8d2fa5cc..8432a24b47cfba4fb8ce692ff075925161d7912f 100644 (file)
@@ -135,7 +135,7 @@ void CursorPair::paint_label(QPainter &p, const QRect &rect)
                p.setPen(Cursor::FillColour.lighter());
                p.drawRoundedRect(delta_rect, highlight_radius, highlight_radius);
 
-               p.setPen(SelectableItem::select_text_colour(
+               p.setPen(ViewItem::select_text_colour(
                        Cursor::FillColour));
                p.drawText(text_rect, Qt::AlignCenter | Qt::AlignVCenter,
                        pv::util::format_time(second_->time() - first_->time(), prefix, 2));
index 91c84d352a1dd094a411dc6b44681d020d185e13..e7f55c6268e290e6d102c0baaa2b2e09f87a22c1 100644 (file)
 #include <QPropertyAnimation>
 
 #include "rowitempaintparams.hpp"
-#include "selectableitem.hpp"
+#include "viewitem.hpp"
 
 namespace pv {
 namespace view {
 
 class RowItemOwner;
 
-class RowItem : public SelectableItem,
+class RowItem : public ViewItem,
        public std::enable_shared_from_this<pv::view::RowItem>
 {
        Q_OBJECT
diff --git a/pv/view/selectableitem.cpp b/pv/view/selectableitem.cpp
deleted file mode 100644 (file)
index 6921f19..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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
- */
-
-#include "selectableitem.hpp"
-
-#include <climits>
-
-#include <QApplication>
-#include <QMenu>
-#include <QPalette>
-
-namespace pv {
-namespace view {
-
-const int SelectableItem::HighlightRadius = 6;
-
-SelectableItem::SelectableItem() :
-       context_parent_(NULL),
-       selected_(false),
-       drag_point_(INT_MIN, INT_MIN)
-{
-}
-
-bool SelectableItem::selected() const
-{
-       return selected_;
-}
-
-void SelectableItem::select(bool select)
-{
-       selected_ = select;
-}
-
-bool SelectableItem::dragging() const
-{
-       return drag_point_.x() != INT_MIN && drag_point_.y() != INT_MIN;
-}
-
-QPoint SelectableItem::drag_point() const
-{
-       return drag_point_;
-}
-
-void SelectableItem::drag()
-{
-       drag_point_ = point();
-}
-
-void SelectableItem::drag_release()
-{
-       drag_point_ = QPoint(INT_MIN, INT_MIN);
-}
-
-QMenu* SelectableItem::create_context_menu(QWidget *parent)
-{
-       context_parent_ = parent;
-       return new QMenu(parent);
-}
-
-void SelectableItem::delete_pressed()
-{
-}
-
-QPen SelectableItem::highlight_pen()
-{
-       return QPen(QApplication::palette().brush(
-               QPalette::Highlight), HighlightRadius,
-               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
-}
-
-QColor SelectableItem::select_text_colour(QColor background)
-{
-       return (background.lightness() > 64) ? Qt::black : Qt::white;
-}
-
-} // namespace view
-} // namespace pv
diff --git a/pv/view/selectableitem.hpp b/pv/view/selectableitem.hpp
deleted file mode 100644 (file)
index b61c54d..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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_SELECTABLEITEM_H
-#define PULSEVIEW_PV_SELECTABLEITEM_H
-
-#include <list>
-
-#include <QPen>
-
-class QAction;
-class QMenu;
-class QWidget;
-
-namespace pv {
-
-namespace widgets {
-class Popup;
-}
-
-namespace view {
-
-class SelectableItem : public QObject
-{
-       Q_OBJECT
-
-private:
-       static const int HighlightRadius;
-
-public:
-       SelectableItem();
-
-public:
-       /**
-        * Returns true if the item is visible and enabled.
-        */
-       virtual bool enabled() const = 0;
-
-       /**
-        * Returns true if the item has been selected by the user.
-        */
-       bool selected() const;
-
-       /**
-        * Selects or deselects the signal.
-        */
-       void select(bool select = true);
-
-       /**
-        * Returns true if the item is being dragged.
-        */
-       bool dragging() const;
-
-       /**
-        * Retunrns the current drag point.
-        */
-       QPoint drag_point() const;
-
-       /**
-        * Sets this item into the dragged state.
-        */
-       void drag();
-
-       /**
-        * Sets this item into the un-dragged state.
-        */
-       void drag_release();
-
-       /**
-        * Get the drag point.
-        */
-       virtual QPoint point() const = 0;
-
-       /**
-        * Computes the outline rectangle of a label.
-        * @param rect the rectangle of the header area.
-        * @return Returns the rectangle of the signal label.
-        */
-       virtual QRectF label_rect(const QRectF &rect) const = 0;
-
-public:
-       /**
-        * Gets the text colour.
-        * @remarks This colour is computed by comparing the lightness
-        * of the trace colour against a threshold to determine whether
-        * white or black would be more visible.
-        */
-       static QColor select_text_colour(QColor background);
-
-public:
-       virtual QMenu* create_context_menu(QWidget *parent);
-
-       virtual pv::widgets::Popup* create_popup(QWidget *parent) = 0;
-
-       virtual void delete_pressed();
-
-protected:
-       static QPen highlight_pen();
-
-protected:
-       QWidget *context_parent_;
-
-private:
-       bool selected_;
-       QPoint drag_point_;
-};
-
-} // namespace view
-} // namespace pv
-
-#endif // PULSEVIEW_PV_SELECTABLEITEM_H
index 02d22d218c29b6e7dd953f764e3560afc623bdfc..80fecb5dda316caa587f6616d6af814b5187d041 100644 (file)
 #ifndef PULSEVIEW_PV_VIEW_TIMEITEM_H
 #define PULSEVIEW_PV_VIEW_TIMEITEM_H
 
-#include "selectableitem.hpp"
+#include "viewitem.hpp"
 
 namespace pv {
 namespace view {
 
 class View;
 
-class TimeItem : public SelectableItem
+class TimeItem : public ViewItem
 {
        Q_OBJECT
 
index df6bd63d041ec74a4228919ea4383afb2c982ae4..b24afac24ac303d99275749342a7485f2633841f 100644 (file)
@@ -124,7 +124,7 @@ void Trace::paint_label(QPainter &p, const QRect &rect, bool hover)
 
 QMenu* Trace::create_context_menu(QWidget *parent)
 {
-       QMenu *const menu = SelectableItem::create_context_menu(parent);
+       QMenu *const menu = ViewItem::create_context_menu(parent);
 
        return menu;
 }
diff --git a/pv/view/viewitem.cpp b/pv/view/viewitem.cpp
new file mode 100644 (file)
index 0000000..0d83ee8
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * 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
+ */
+
+#include "viewitem.hpp"
+
+#include <climits>
+
+#include <QApplication>
+#include <QMenu>
+#include <QPalette>
+
+namespace pv {
+namespace view {
+
+const int ViewItem::HighlightRadius = 6;
+
+ViewItem::ViewItem() :
+       context_parent_(NULL),
+       selected_(false),
+       drag_point_(INT_MIN, INT_MIN)
+{
+}
+
+bool ViewItem::selected() const
+{
+       return selected_;
+}
+
+void ViewItem::select(bool select)
+{
+       selected_ = select;
+}
+
+bool ViewItem::dragging() const
+{
+       return drag_point_.x() != INT_MIN && drag_point_.y() != INT_MIN;
+}
+
+QPoint ViewItem::drag_point() const
+{
+       return drag_point_;
+}
+
+void ViewItem::drag()
+{
+       drag_point_ = point();
+}
+
+void ViewItem::drag_release()
+{
+       drag_point_ = QPoint(INT_MIN, INT_MIN);
+}
+
+QMenu* ViewItem::create_context_menu(QWidget *parent)
+{
+       context_parent_ = parent;
+       return new QMenu(parent);
+}
+
+void ViewItem::delete_pressed()
+{
+}
+
+QPen ViewItem::highlight_pen()
+{
+       return QPen(QApplication::palette().brush(
+               QPalette::Highlight), HighlightRadius,
+               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
+}
+
+QColor ViewItem::select_text_colour(QColor background)
+{
+       return (background.lightness() > 64) ? Qt::black : Qt::white;
+}
+
+} // namespace view
+} // namespace pv
diff --git a/pv/view/viewitem.hpp b/pv/view/viewitem.hpp
new file mode 100644 (file)
index 0000000..6a78b1a
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * 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_VIEWITEM_H
+#define PULSEVIEW_PV_VIEWITEM_H
+
+#include <list>
+
+#include <QPen>
+
+class QAction;
+class QMenu;
+class QWidget;
+
+namespace pv {
+
+namespace widgets {
+class Popup;
+}
+
+namespace view {
+
+class ViewItem : public QObject
+{
+       Q_OBJECT
+
+private:
+       static const int HighlightRadius;
+
+public:
+       ViewItem();
+
+public:
+       /**
+        * Returns true if the item is visible and enabled.
+        */
+       virtual bool enabled() const = 0;
+
+       /**
+        * Returns true if the item has been selected by the user.
+        */
+       bool selected() const;
+
+       /**
+        * Selects or deselects the signal.
+        */
+       void select(bool select = true);
+
+       /**
+        * Returns true if the item is being dragged.
+        */
+       bool dragging() const;
+
+       /**
+        * Retunrns the current drag point.
+        */
+       QPoint drag_point() const;
+
+       /**
+        * Sets this item into the dragged state.
+        */
+       void drag();
+
+       /**
+        * Sets this item into the un-dragged state.
+        */
+       void drag_release();
+
+       /**
+        * Get the drag point.
+        */
+       virtual QPoint point() const = 0;
+
+       /**
+        * Computes the outline rectangle of a label.
+        * @param rect the rectangle of the header area.
+        * @return Returns the rectangle of the signal label.
+        */
+       virtual QRectF label_rect(const QRectF &rect) const = 0;
+
+public:
+       /**
+        * Gets the text colour.
+        * @remarks This colour is computed by comparing the lightness
+        * of the trace colour against a threshold to determine whether
+        * white or black would be more visible.
+        */
+       static QColor select_text_colour(QColor background);
+
+public:
+       virtual QMenu* create_context_menu(QWidget *parent);
+
+       virtual pv::widgets::Popup* create_popup(QWidget *parent) = 0;
+
+       virtual void delete_pressed();
+
+protected:
+       static QPen highlight_pen();
+
+protected:
+       QWidget *context_parent_;
+
+private:
+       bool selected_;
+       QPoint drag_point_;
+};
+
+} // namespace view
+} // namespace pv
+
+#endif // PULSEVIEW_PV_VIEWITEM_H
index 3526af69d24b60e7745f33adc21459cc3360e111..064b4e593a3dc29542cf587051710461f5c9e668 100644 (file)
@@ -49,7 +49,6 @@ set(pulseview_TEST_SOURCES
        ${PROJECT_SOURCE_DIR}/pv/view/rowitemowner.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/rowitempaintparams.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/ruler.cpp
-       ${PROJECT_SOURCE_DIR}/pv/view/selectableitem.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/signal.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/timeitem.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/timemarker.cpp
@@ -57,6 +56,7 @@ set(pulseview_TEST_SOURCES
        ${PROJECT_SOURCE_DIR}/pv/view/tracegroup.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/tracepalette.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/view.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/viewitem.cpp
        ${PROJECT_SOURCE_DIR}/pv/view/viewport.cpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.cpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.cpp
@@ -89,13 +89,13 @@ set(pulseview_TEST_HEADERS
        ${PROJECT_SOURCE_DIR}/pv/view/marginwidget.hpp
        ${PROJECT_SOURCE_DIR}/pv/view/rowitem.hpp
        ${PROJECT_SOURCE_DIR}/pv/view/ruler.hpp
-       ${PROJECT_SOURCE_DIR}/pv/view/selectableitem.hpp
        ${PROJECT_SOURCE_DIR}/pv/view/signal.hpp
        ${PROJECT_SOURCE_DIR}/pv/view/timeitem.hpp
        ${PROJECT_SOURCE_DIR}/pv/view/timemarker.hpp
        ${PROJECT_SOURCE_DIR}/pv/view/trace.hpp
        ${PROJECT_SOURCE_DIR}/pv/view/tracegroup.hpp
        ${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/widgets/colourbutton.hpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.hpp