]> sigrok.org Git - pulseview.git/commitdiff
Update the popup when a decoder is stacked
authorJoel Holdsworth <redacted>
Sun, 24 Nov 2013 16:16:38 +0000 (16:16 +0000)
committerJoel Holdsworth <redacted>
Sat, 30 Nov 2013 18:14:05 +0000 (18:14 +0000)
pv/view/decodetrace.cpp
pv/view/trace.cpp
pv/view/trace.h

index 7e2051a4022202ff77ea496e5259c147f07475e9..d3d10b6981953eaf02651a572c30d4f53e89cec9 100644 (file)
@@ -346,6 +346,8 @@ void DecodeTrace::on_stack_decoder(srd_decoder *decoder)
        _decoder_stack->push(shared_ptr<data::decode::Decoder>(
                new data::decode::Decoder(decoder)));
        _decoder_stack->begin_decode();
+
+       create_popup_form();
 }
 
 } // namespace view
index 79255bec3f98fa4491a4e81c6cb4529c12b176f0..464cadcde2ede54aaa6b4c8e0f3fcae9a1308e9f 100644 (file)
@@ -183,10 +183,8 @@ pv::widgets::Popup* Trace::create_popup(QWidget *parent)
        using pv::widgets::Popup;
 
        _popup = new Popup(parent);
-       _popup_form = new QFormLayout(_popup);
-       _popup->setLayout(_popup_form);
 
-       populate_popup_form(_popup, _popup_form);
+       create_popup_form();
 
        connect(_popup, SIGNAL(closed()),
                this, SLOT(on_popup_closed()));
@@ -224,6 +222,22 @@ void Trace::add_colour_option(QWidget *parent, QFormLayout *form)
        form->addRow(tr("Colour"), colour_button);
 }
 
+void Trace::create_popup_form()
+{
+       // Clear the layout
+
+       // Transfer the layout and the child widgets to a temporary widget
+       // which then goes out of scope destroying the layout and all the child
+       // widgets.
+       if (_popup_form)
+               QWidget().setLayout(_popup_form);
+
+       // Repopulate the popup
+       _popup_form = new QFormLayout(_popup);
+       _popup->setLayout(_popup_form);
+       populate_popup_form(_popup, _popup_form);
+}
+
 void Trace::populate_popup_form(QWidget *parent, QFormLayout *form)
 {
        QLineEdit *const name_edit = new QLineEdit(parent);
index e2ed37fd444b6c37507ffe667e4bf83a3579c72b..72f8e8a8986a092d82870c666e64d8a361c8bb3a 100644 (file)
@@ -162,6 +162,8 @@ protected:
 
        void add_colour_option(QWidget *parent, QFormLayout *form);
 
+       void create_popup_form();
+
        virtual void populate_popup_form(QWidget *parent, QFormLayout *form);
 
 private:
@@ -202,6 +204,7 @@ protected:
 
        QSizeF _text_size;
 
+private:
        pv::widgets::Popup *_popup;
        QFormLayout *_popup_form;
 };