]> sigrok.org Git - pulseview.git/commitdiff
Moved Signal selection behaviour into SelectableItem
authorJoel Holdsworth <redacted>
Sun, 12 May 2013 17:56:13 +0000 (18:56 +0100)
committerJoel Holdsworth <redacted>
Sun, 19 May 2013 08:46:00 +0000 (09:46 +0100)
CMakeLists.txt
pv/view/selectableitem.cpp [new file with mode: 0644]
pv/view/selectableitem.h
pv/view/signal.cpp
pv/view/signal.h

index 6552df173e9b5481f0cafc3b6e9d7a10642543fd..60644e16bbc2a9b4aa7fff8b83c6cc7e1f0b5727 100644 (file)
@@ -128,6 +128,7 @@ set(pulseview_SOURCES
        pv/view/header.cpp
        pv/view/logicsignal.cpp
        pv/view/ruler.cpp
+       pv/view/selectableitem.cpp
        pv/view/signal.cpp
        pv/view/timemarker.cpp
        pv/view/view.cpp
diff --git a/pv/view/selectableitem.cpp b/pv/view/selectableitem.cpp
new file mode 100644 (file)
index 0000000..517b687
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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.h"
+
+namespace pv {
+namespace view {
+
+SelectableItem::SelectableItem() :
+       _selected(false)
+{
+}
+
+bool SelectableItem::selected() const
+{
+       return _selected;
+}
+
+void SelectableItem::select(bool select)
+{
+       _selected = select;
+}
+
+} // namespace view
+} // namespace pv
index d54491370bd769a588c82ff544f58d13fb1112cd..69204b29478b901ec703ee858ab3ba457ad318ec 100644 (file)
@@ -34,6 +34,22 @@ class SelectableItem : public QObject
 {
        Q_OBJECT
 
+public:
+       SelectableItem();
+
+public:
+       /**
+        * Returns true if the signal has been selected by the user.
+        */
+       bool selected() const;
+
+       /**
+        * Selects or deselects the signal.
+        */
+       void select(bool select = true);
+
+private:
+       bool _selected;
 };
 
 } // namespace view
index cdbb65b1638e5ac145c1aaa66cf6c3d99bf12971..dd50243a7095c468f4a424ca0e46f9251919c1dc 100644 (file)
@@ -39,8 +39,7 @@ const QPen Signal::SignalAxisPen(QColor(128, 128, 128, 64));
 Signal::Signal(const sr_probe *const probe) :
        _probe(probe),
        _name(probe->name),
-       _v_offset(0),
-       _selected(false)
+       _v_offset(0)
 {
        assert(_probe);
 }
@@ -75,16 +74,6 @@ void Signal::set_v_offset(int v_offset)
        _v_offset = v_offset;
 }
 
-bool Signal::selected() const
-{
-       return _selected;
-}
-
-void Signal::select(bool select)
-{
-       _selected = select;
-}
-
 void Signal::paint_label(QPainter &p, int y, int right, bool hover)
 {
        p.setBrush(_colour);
@@ -114,7 +103,7 @@ void Signal::paint_label(QPainter &p, int y, int right, bool hover)
                QPointF(label_rect.left() + 1, label_rect.bottom() - 1)
        };
 
-       if (_selected) {
+       if (selected()) {
                p.setPen(QPen(QApplication::palette().brush(
                        QPalette::Highlight), LabelHighlightRadius,
                        Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
index 69c1f09cfd225ba67bb9fcc60ea1d95e3681cfbd..4f16e3a72b8bbb4f15cfdebd257b6ab0c6e3dd1d 100644 (file)
@@ -87,16 +87,6 @@ public:
         */
        void set_v_offset(int v_offset);
 
-       /**
-        * Returns true if the signal has been selected by the user.
-        */
-       bool selected() const;
-
-       /**
-        * Selects or deselects the signal.
-        */
-       void select(bool select = true);
-
        /**
         * Paints the signal with a QPainter
         * @param p the QPainter to paint into.
@@ -168,8 +158,6 @@ protected:
        QColor _colour;
        int _v_offset;
 
-       bool _selected;
-
        QSizeF _text_size;
 };