2 * This file is part of the PulseView project.
4 * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 #include <QMessageBox>
24 #include "pv/session.hpp"
26 #include "storeprogress.hpp"
30 using std::shared_ptr;
33 using Glib::VariantBase;
38 StoreProgress::StoreProgress(const QString &file_name,
39 const shared_ptr<sigrok::OutputFormat> output_format,
40 const map<string, VariantBase> &options,
41 const pair<uint64_t, uint64_t> sample_range,
42 const Session &session, QWidget *parent) :
43 QProgressDialog(tr("Saving..."), tr("Cancel"), 0, 0, parent),
44 session_(file_name.toStdString(), output_format, options, sample_range,
47 connect(&session_, SIGNAL(progress_updated()),
48 this, SLOT(on_progress_updated()));
49 connect(&session_, SIGNAL(store_successful()),
50 &session, SLOT(on_data_saved()));
53 StoreProgress::~StoreProgress()
58 void StoreProgress::run()
66 void StoreProgress::show_error()
68 QMessageBox msg(parentWidget());
69 msg.setText(tr("Failed to save session."));
70 msg.setInformativeText(session_.error());
71 msg.setStandardButtons(QMessageBox::Ok);
72 msg.setIcon(QMessageBox::Warning);
76 void StoreProgress::closeEvent(QCloseEvent*)
81 void StoreProgress::on_progress_updated()
83 const pair<int, int> p = session_.progress();
84 assert(p.first <= p.second);
90 const QString err = session_.error();