MainWindow: Add selection_only parameter to export_file()
[pulseview.git] / pv / mainwindow.cpp
index 195c460a1de90f3aea20b3fb4af9745a6a34103b..aca5acf3dde3c72c2935e181e7dae147ecd2f18f 100644 (file)
@@ -134,6 +134,11 @@ QAction* MainWindow::action_save_as() const
        return action_save_as_;
 }
 
+QAction* MainWindow::action_save_selection_as() const
+{
+       return action_save_selection_as_;
+}
+
 QAction* MainWindow::action_connect() const
 {
        return action_connect_;
@@ -218,10 +223,13 @@ void MainWindow::select_device(shared_ptr<devices::Device> device)
        }
 }
 
-void MainWindow::export_file(shared_ptr<OutputFormat> format)
+void MainWindow::export_file(shared_ptr<OutputFormat> format,
+       bool selection_only)
 {
        using pv::dialogs::StoreProgress;
 
+       (void)selection_only;
+
        // Stop any currently running capture session
        session_.stop_capture();
 
@@ -666,20 +674,6 @@ void MainWindow::save_selection_to_file()
        // Stop any currently running capture session
        session_.stop_capture();
 
-       // Get sample rate
-       double samplerate = 0.0;
-
-       for (const shared_ptr<pv::data::SignalData> d : session_.get_data()) {
-               assert(d);
-               const vector< shared_ptr<pv::data::Segment> > segments =
-                       d->segments();
-               for (const shared_ptr<pv::data::Segment> &s : segments)
-                       samplerate = std::max(samplerate, s->samplerate());
-       }
-
-       if (samplerate == 0.0)
-               samplerate = 1;
-
        // Verify that the cursors are active and fetch their values
        if (!view_->cursors()->enabled()) {
                show_session_error(tr("Missing Cursors"), tr("You need to set the " \
@@ -688,6 +682,8 @@ void MainWindow::save_selection_to_file()
                return;
        }
 
+       const double samplerate = session_.get_samplerate();
+
        const pv::util::Timestamp& start_time = view_->cursors()->first()->time();
        const pv::util::Timestamp& end_time = view_->cursors()->second()->time();