Trace: Removed coloured_bg state
authorJoel Holdsworth <joel@airwebreathe.org.uk>
Wed, 26 Apr 2017 16:12:23 +0000 (10:12 -0600)
committerUwe Hermann <uwe@hermann-uwe.de>
Wed, 3 May 2017 17:08:10 +0000 (19:08 +0200)
The state should be taken from the View

pv/view/trace.cpp
pv/view/trace.hpp
pv/view/view.cpp
pv/view/view.hpp

index 985c295059a5da42c1390323de9396296712bfea..2a1eb959634fb23289cc1b12fa8c5613ef795e81 100644 (file)
@@ -53,20 +53,12 @@ Trace::Trace(shared_ptr<data::SignalBase> channel) :
        popup_(nullptr),
        popup_form_(nullptr)
 {
-       GlobalSettings settings;
-       coloured_bg_ = settings.value(GlobalSettings::Key_View_ColouredBG).toBool();
-
        connect(channel.get(), SIGNAL(name_changed(const QString&)),
                this, SLOT(on_name_changed(const QString&)));
        connect(channel.get(), SIGNAL(colour_changed(const QColor&)),
                this, SLOT(on_colour_changed(const QColor&)));
 }
 
-void Trace::set_coloured_bg(bool state)
-{
-       coloured_bg_ = state;
-}
-
 void Trace::paint_label(QPainter &p, const QRect &rect, bool hover)
 {
        const int y = get_visual_y();
@@ -161,7 +153,10 @@ QRectF Trace::label_rect(const QRectF &rect) const
 
 void Trace::paint_back(QPainter &p, const ViewItemPaintParams &pp)
 {
-       if (coloured_bg_)
+       const View *view = owner_->view();
+       assert(view);
+
+       if (view->coloured_bg())
                p.setBrush(base_->bgcolour());
        else
                p.setBrush(bgcolour_state_ ? BrightGrayBGColour : DarkGrayBGColour);
index 62588a16ce07577aa873b9d48ff477e2aa73c9bf..882c2d7089d7ea90f59c752a24e8b75a7d919705 100644 (file)
@@ -70,11 +70,6 @@ public:
         */
        virtual void set_colour(QColor colour);
 
-       /**
-        * Enables or disables the coloured background for this trace.
-        */
-       void set_coloured_bg(bool state);
-
        /**
         * Paints the signal label.
         * @param p the QPainter to paint into.
@@ -130,7 +125,7 @@ private Q_SLOTS:
 
 protected:
        shared_ptr<data::SignalBase> base_;
-       bool coloured_bg_, coloured_bg_state_;
+       bool coloured_bg_state_;
 
 private:
        pv::widgets::Popup *popup_;
index 8f5494acea39b4e0c449c9e2976e3ac589b0aaf1..ab458f26bf36e981d49a1992826dbddb41e3d6e1 100644 (file)
@@ -570,31 +570,15 @@ void View::enable_show_analog_minor_grid(bool state)
 
 void View::enable_coloured_bg(bool state)
 {
-       const vector<shared_ptr<TraceTreeItem>> items(
-               list_by_type<TraceTreeItem>());
-
-       for (shared_ptr<TraceTreeItem> i : items) {
-               // Can't cast to Trace because it's abstract, so we need to
-               // check for any derived classes individually
-
-               shared_ptr<AnalogSignal> a = dynamic_pointer_cast<AnalogSignal>(i);
-               if (a)
-                       a->set_coloured_bg(state);
-
-               shared_ptr<LogicSignal> l = dynamic_pointer_cast<LogicSignal>(i);
-               if (l)
-                       l->set_coloured_bg(state);
-
-#ifdef ENABLE_DECODE
-               shared_ptr<DecodeTrace> d = dynamic_pointer_cast<DecodeTrace>(i);
-               if (d)
-                       d->set_coloured_bg(state);
-#endif
-       }
-
+       coloured_bg_ = state;
        viewport_->update();
 }
 
+bool View::coloured_bg() const
+{
+       return coloured_bg_;
+}
+
 bool View::cursors_shown() const
 {
        return show_cursors_;
index 08b8a37e51498db342eb82d5ce1ab4b67e4b884e..9fac1a67f8d400933d4a95b2c2b12eca29c483d0 100644 (file)
@@ -212,6 +212,11 @@ public:
         */
        void enable_coloured_bg(bool state);
 
+       /**
+        * Returns true if the trace background should be drawn with a coloured background.
+        */
+       bool coloured_bg() const;
+
        /**
         * Enable or disable showing sampling points.
         */