]> sigrok.org Git - pulseview.git/commitdiff
StoreSession: Added an OutputFormat parameter
authorJoel Holdsworth <redacted>
Sat, 17 Jan 2015 20:00:03 +0000 (20:00 +0000)
committerUwe Hermann <redacted>
Tue, 27 Jan 2015 15:28:31 +0000 (16:28 +0100)
pv/dialogs/storeprogress.cpp
pv/dialogs/storeprogress.hpp
pv/mainwindow.cpp
pv/storesession.cpp
pv/storesession.hpp

index b041dcdb1508455576399f824121c8598db743c8..dff8950ac1993ac3d8c157cab87f0cfaffca0c54 100644 (file)
@@ -28,9 +28,10 @@ namespace pv {
 namespace dialogs {
 
 StoreProgress::StoreProgress(const QString &file_name,
+       const std::shared_ptr<sigrok::OutputFormat> 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()));
index 92634b4247110d1c781d78ccaaa3d188d388914f..6bb2292e53641174a996959ea6b894867b6ebf26 100644 (file)
@@ -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<sigrok::OutputFormat> output_format,
+               const Session &session, QWidget *parent = 0);
 
        virtual ~StoreProgress();
 
index 0dd9a09f194ea3cb7da233d90008798be845043f..039f4aeb7b3c9871f66cd8ebddf78ca69cc0d5c8 100644 (file)
@@ -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();
 }
 
index 2168cdc78b4d4f56c5f5a6e28cb8e3344a4b5e1c..ad106bb9f5882f79f72f965b2d2822ca7e7d958b 100644 (file)
@@ -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<OutputFormat> &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<Glib::ustring>::create(file_name_)}});
                auto meta = context->create_meta_packet(
index 9094ca12eb154ffb5f51ea5efb593c6fabd452c9..ce737f34e3c9bba0ba079589e15daf27f81bf8ea 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdint.h>
 
 #include <atomic>
+#include <memory>
 #include <mutex>
 #include <string>
 #include <thread>
@@ -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<sigrok::OutputFormat> &output_format,
                const Session &session);
 
        ~StoreSession();
@@ -73,6 +76,7 @@ Q_SIGNALS:
 
 private:
        const std::string file_name_;
+       const std::shared_ptr<sigrok::OutputFormat> output_format_;
        const Session &session_;
 
        std::shared_ptr<sigrok::Output> output_;