+ p.setRenderHint(QPainter::Antialiasing, true);
+}
+
+void Trace::add_colour_option(QWidget *parent, QFormLayout *form)
+{
+ using pv::widgets::ColourButton;
+
+ ColourButton *const colour_button = new ColourButton(
+ TracePalette::Rows, TracePalette::Cols, parent);
+ colour_button->set_palette(TracePalette::Colours);
+ colour_button->set_colour(base_->colour());
+ connect(colour_button, SIGNAL(selected(const QColor&)),
+ this, SLOT(on_colouredit_changed(const QColor&)));
+
+ 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 we delete after the event was handled. This way, the layout
+ // and all widgets contained therein are deleted after the event was
+ // handled, leaving the parent popup_ time to handle the change.
+ if (popup_form_) {
+ QWidget *suicidal = new QWidget();
+ suicidal->setLayout(popup_form_);
+ suicidal->deleteLater();
+ }
+
+ // 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);
+ name_edit->setText(base_->name());
+ connect(name_edit, SIGNAL(textChanged(const QString&)),
+ this, SLOT(on_nameedit_changed(const QString&)));
+ form->addRow(tr("Name"), name_edit);
+
+ add_colour_option(parent, form);
+}
+
+void Trace::set_name(QString name)
+{
+ base_->set_name(name);
+}
+
+void Trace::set_colour(QColor colour)
+{
+ base_->set_colour(colour);
+}
+
+void Trace::on_name_changed(const QString &text)
+{
+ /* This event handler is called by SignalBase when the name was changed there */
+ (void)text;
+
+ if (owner_) {
+ owner_->extents_changed(true, false);
+ owner_->row_item_appearance_changed(true, false);
+ }
+}
+
+void Trace::on_colour_changed(const QColor &colour)
+{
+ /* This event handler is called by SignalBase when the colour was changed there */
+ (void)colour;
+
+ if (owner_)
+ owner_->row_item_appearance_changed(true, true);
+}
+
+void Trace::on_popup_closed()
+{
+ popup_ = nullptr;
+ popup_form_ = nullptr;
+}
+
+void Trace::on_nameedit_changed(const QString &name)
+{
+ /* This event handler notifies SignalBase that the name changed */
+ set_name(name);
+}
+
+void Trace::on_colouredit_changed(const QColor &colour)
+{
+ /* This event handler notifies SignalBase that the colour changed */
+ set_colour(colour);