+ format_(format),
+ options_(options),
+ interrupt_(false)
+{
+}
+
+InputFile::InputFile(const shared_ptr<sigrok::Context> &context,
+ QSettings &settings):
+ File(""),
+ context_(context),
+ interrupt_(false)
+{
+ file_name_ = settings.value("filename").toString().toStdString();
+
+ QString format_name = settings.value("format").toString();
+
+ // Find matching format
+ const map<string, shared_ptr<InputFormat> > formats = context->input_formats();
+
+ try {
+ format_ = formats.at(format_name.toStdString());
+
+ // Restore all saved options
+ int options = settings.value("options").toInt();
+
+ for (int i = 0; i < options; i++) {
+ settings.beginGroup("option" + QString::number(i));
+ QString name = settings.value("name").toString();
+ options_[name.toStdString()] = GlobalSettings::restore_variantbase(settings);
+ settings.endGroup();
+ }
+
+ } catch (out_of_range&) {
+ qWarning() << "Could not find input format" << format_name <<
+ "needed to restore session input file";
+ }
+}
+
+void InputFile::save_meta_to_settings(QSettings &settings)
+{
+ settings.setValue("filename", QString::fromStdString(file_name_));
+
+ settings.setValue("format", QString::fromStdString(format_->name()));
+
+ settings.setValue("options", (int)options_.size());
+
+ int i = 0;
+ for (pair<string, Glib::VariantBase> option : options_) {
+ settings.beginGroup("option" + QString::number(i));
+ settings.setValue("name", QString::fromStdString(option.first));
+ GlobalSettings::store_variantbase(settings, option.second);
+ settings.endGroup();
+ i++;
+ }
+}
+
+void InputFile::open()
+{
+ if (session_)
+ close();
+ else
+ session_ = context_->create_session();
+
+ if (!format_)
+ return;
+
+ input_ = format_->create_input(options_);
+