From: Joel Holdsworth Date: Sat, 17 Jan 2015 20:00:03 +0000 (+0000) Subject: StoreSession: Added an OutputFormat parameter X-Git-Tag: pulseview-0.3.0~248 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4764bc4d14069978282c9cf43aad03d7558aeb9f;p=pulseview.git StoreSession: Added an OutputFormat parameter --- diff --git a/pv/dialogs/storeprogress.cpp b/pv/dialogs/storeprogress.cpp index b041dcdb..dff8950a 100644 --- a/pv/dialogs/storeprogress.cpp +++ b/pv/dialogs/storeprogress.cpp @@ -28,9 +28,10 @@ namespace pv { namespace dialogs { StoreProgress::StoreProgress(const QString &file_name, + const std::shared_ptr output_format, const Session &session, QWidget *parent) : QProgressDialog(tr("Saving..."), tr("Cancel"), 0, 0, parent), - session_(file_name.toStdString(), session) + session_(file_name.toStdString(), output_format, session) { connect(&session_, SIGNAL(progress_updated()), this, SLOT(on_progress_updated())); diff --git a/pv/dialogs/storeprogress.hpp b/pv/dialogs/storeprogress.hpp index 92634b42..6bb2292e 100644 --- a/pv/dialogs/storeprogress.hpp +++ b/pv/dialogs/storeprogress.hpp @@ -39,8 +39,9 @@ class StoreProgress : public QProgressDialog Q_OBJECT public: - StoreProgress(const QString &file_name, const Session &session, - QWidget *parent = 0); + StoreProgress(const QString &file_name, + const std::shared_ptr output_format, + const Session &session, QWidget *parent = 0); virtual ~StoreProgress(); diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 0dd9a09f..039f4aeb 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -527,7 +527,9 @@ void MainWindow::on_actionSaveAs_triggered() const QString abs_path = QFileInfo(file_name).absolutePath(); settings.setValue(SettingSaveDirectory, abs_path); - StoreProgress *dlg = new StoreProgress(file_name, session_, this); + StoreProgress *dlg = new StoreProgress(file_name, + device_manager_.context()->output_formats()["srzip"], + session_, this); dlg->run(); } diff --git a/pv/storesession.cpp b/pv/storesession.cpp index 2168cdc7..ad106bb9 100644 --- a/pv/storesession.cpp +++ b/pv/storesession.cpp @@ -47,14 +47,16 @@ using std::vector; using sigrok::ConfigKey; using sigrok::Error; +using sigrok::OutputFormat; namespace pv { const size_t StoreSession::BlockSize = 1024 * 1024; StoreSession::StoreSession(const std::string &file_name, - const Session &session) : + const shared_ptr &output_format, const Session &session) : file_name_(file_name), + output_format_(output_format), session_(session), interrupt_(false), units_stored_(0), @@ -121,9 +123,8 @@ bool StoreSession::start() // Begin storing try { auto context = session_.session()->context(); - auto output_format = context->output_formats()["srzip"]; auto device = session_.device(); - output_ = output_format->create_output(device, + output_ = output_format_->create_output(device, {{"filename", Glib::Variant::create(file_name_)}}); auto meta = context->create_meta_packet( diff --git a/pv/storesession.hpp b/pv/storesession.hpp index 9094ca12..ce737f34 100644 --- a/pv/storesession.hpp +++ b/pv/storesession.hpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -32,6 +33,7 @@ namespace sigrok { class Output; +class OutputFormat; } namespace pv { @@ -51,6 +53,7 @@ private: public: StoreSession(const std::string &file_name, + const std::shared_ptr &output_format, const Session &session); ~StoreSession(); @@ -73,6 +76,7 @@ Q_SIGNALS: private: const std::string file_name_; + const std::shared_ptr output_format_; const Session &session_; std::shared_ptr output_;