X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fviews%2Fdecoder_binary%2Fview.cpp;h=5f55b19104d9449e12fc4556861c7546f04be46c;hb=HEAD;hp=b5daaf0f84ef472dd7586cb9ab423a13cec6f156;hpb=009fc9ae42ecccd3802f549b39c19a2ba895959d;p=pulseview.git diff --git a/pv/views/decoder_binary/view.cpp b/pv/views/decoder_binary/view.cpp index b5daaf0f..6e61fa3a 100644 --- a/pv/views/decoder_binary/view.cpp +++ b/pv/views/decoder_binary/view.cpp @@ -110,7 +110,11 @@ View::View(Session &session, bool is_main_view, QMainWindow *parent) : save_action_->setText(tr("&Save...")); save_action_->setIcon(QIcon::fromTheme("document-save-as", QIcon(":/icons/document-save-as.png"))); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + save_action_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S)); +#else save_action_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S)); +#endif connect(save_action_, SIGNAL(triggered(bool)), this, SLOT(on_actionSave_triggered())); @@ -129,9 +133,17 @@ View::View(Session &session, bool is_main_view, QMainWindow *parent) : parent->setSizePolicy(hex_view_->sizePolicy()); // TODO Must be updated when selected widget changes + // Set up metadata event handler + session_.metadata_obj_manager()->add_observer(this); + reset_view_state(); } +View::~View() +{ + session_.metadata_obj_manager()->remove_observer(this); +} + ViewType View::get_type() const { return ViewTypeDecoderBinary; @@ -319,10 +331,18 @@ void View::save_data_as_hex_dump(bool with_offset, bool with_ascii) const while (offset < selection.second) { size_t end = std::min((uint64_t)(selection.second), offset + n); offset = hex_view_->create_hex_line(offset, end, &s, with_offset, with_ascii); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + out_stream << s << Qt::endl; +#else out_stream << s << endl; +#endif } +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + out_stream << Qt::endl; +#else out_stream << endl; +#endif if (out_stream.status() != QTextStream::Ok) { QMessageBox msg(parent_); @@ -466,6 +486,25 @@ void View::on_actionSave_triggered(QAction* action) } } +void View::on_metadata_object_changed(MetadataObject* obj, + MetadataValueType value_type) +{ + // Check if we need to update the model's data range. We only work on the + // end sample value because the start sample value is updated first and + // we need both + if ((obj->type() == MetadataObjMainViewRange) && + (value_type == MetadataValueEndSample)) { + + int64_t start_sample = obj->value(MetadataValueStartSample).toLongLong(); + int64_t end_sample = obj->value(MetadataValueEndSample).toLongLong(); + + hex_view_->set_visible_sample_range(start_sample, end_sample); + } + + if (obj->type() == MetadataObjMousePos) + hex_view_->set_highlighted_data_sample(obj->value(MetadataValueStartSample).toLongLong()); +} + void View::perform_delayed_view_update() { if (signal_ && !binary_data_exists_)