]> sigrok.org Git - pulseview.git/commitdiff
MainWindow: Added format parameters to load_file
authorJoel Holdsworth <redacted>
Sat, 28 Mar 2015 13:25:41 +0000 (13:25 +0000)
committerUwe Hermann <redacted>
Thu, 11 Jun 2015 18:38:48 +0000 (20:38 +0200)
pv/devices/inputfile.cpp
pv/devices/inputfile.hpp
pv/mainwindow.cpp
pv/mainwindow.hpp

index 411877473b9bf30e235b990243c574f7418c1a61..e92bf208bf17989039bed7b4dbbbbe277f49093f 100644 (file)
@@ -34,9 +34,9 @@ InputFile::InputFile(const std::shared_ptr<sigrok::Context> &context,
        const std::string &file_name,
        std::shared_ptr<sigrok::InputFormat> format,
        const std::map<std::string, Glib::VariantBase> &options) :
+       File(file_name),
        context_(context),
        input_(format->create_input(options)),
-       file_name_(file_name),
        interrupt_(false) {
        if (!input_)
                throw QString("Failed to create input");
index 55688fd453394f4bd00980a75456fbc76b26f918..588ccdf243e39c87ca52583678249b17cb42167e 100644 (file)
 
 #include <libsigrokcxx/libsigrokcxx.hpp>
 
-#include "device.hpp"
+#include "file.hpp"
 
 namespace pv {
 namespace devices {
 
-class InputFile final : public Device
+class InputFile final : public File
 {
 private:
        static const std::streamsize BufferSize;
@@ -52,7 +52,6 @@ public:
 private:
        const std::shared_ptr<sigrok::Context> context_;
        const std::shared_ptr<sigrok::Input> input_;
-       const std::string file_name_;
 
        std::atomic<bool> interrupt_;
 };
index ac5372a6f46d295468699ca95460cbab647720ef..a339b19a1b8b3963c59a21a1d075a4493effdb2f 100644 (file)
@@ -46,6 +46,7 @@
 
 #include "devicemanager.hpp"
 #include "devices/hardwaredevice.hpp"
+#include "devices/inputfile.hpp"
 #include "devices/sessionfile.hpp"
 #include "dialogs/about.hpp"
 #include "dialogs/connect.hpp"
@@ -76,6 +77,7 @@ using boost::algorithm::join;
 
 using sigrok::Error;
 using sigrok::OutputFormat;
+using sigrok::InputFormat;
 
 namespace pv {
 
@@ -525,17 +527,26 @@ void MainWindow::keyReleaseEvent(QKeyEvent *event)
        QMainWindow::keyReleaseEvent(event);
 }
 
-void MainWindow::load_file(QString file_name)
+void MainWindow::load_file(QString file_name,
+       std::shared_ptr<sigrok::InputFormat> format,
+       const std::map<std::string, Glib::VariantBase> &options)
 {
        const QString errorMessage(
                QString("Failed to load file %1").arg(file_name));
        const QString infoMessage;
 
        try {
-               session_.set_device(
-                       shared_ptr<devices::Device>(new devices::SessionFile(
-                               device_manager_.context(),
-                               file_name.toStdString())));
+               if (format)
+                       session_.set_device(shared_ptr<devices::Device>(
+                               new devices::InputFile(
+                                       device_manager_.context(),
+                                       file_name.toStdString(),
+                                       format, options)));
+               else
+                       session_.set_device(shared_ptr<devices::Device>(
+                               new devices::SessionFile(
+                                       device_manager_.context(),
+                                       file_name.toStdString())));
        } catch(Error e) {
                show_session_error(tr("Failed to load ") + file_name, e.what());
                session_.set_default_device();
index 1779712f4c93aa9edc5b2182930454021f5099a1..35ccf0655d10b4e37699f87d47d9f308cb007822 100644 (file)
 #define PULSEVIEW_PV_MAINWINDOW_HPP
 
 #include <list>
+#include <map>
 #include <memory>
 
+#include <glibmm/variant.h>
+
 #include <QMainWindow>
 
 #include "session.hpp"
@@ -33,6 +36,7 @@ struct srd_decoder;
 class QVBoxLayout;
 
 namespace sigrok {
+class InputFormat;
 class OutputFormat;
 }
 
@@ -119,7 +123,10 @@ private:
        void keyReleaseEvent(QKeyEvent *event);
 
 private Q_SLOTS:
-       void load_file(QString file_name);
+       void load_file(QString file_name,
+               std::shared_ptr<sigrok::InputFormat> format = nullptr,
+               const std::map<std::string, Glib::VariantBase> &options =
+                       std::map<std::string, Glib::VariantBase>());
 
        void show_session_error(
                const QString text, const QString info_text);