+ list<SequenceLocation> result;
+ SequenceLocationModel& model = subanalysis_window->getModel();
+ browser->copySelectedTracksAsSeqLocation(result);
+ for(list<SequenceLocation>::iterator result_itor = result.begin();
+ result_itor != result.end();
+ ++result_itor)
+ {
+ model.push_back(*result_itor);
+ }
+
+ if (not subanalysis_window->isVisible()) {
+ subanalysis_window->show();
+ }
+}
+
+void MussaWindow::saveAnalysis()
+{
+ // if we've got an analysis
+ if (analysis and not analysis->empty()) {
+ // if it doesn't have a name we need to pick one
+ if (analysis->get_analysis_path().empty()) {
+ saveAnalysisAs();
+ } else {
+ // if we've got a name, has it changed any?
+ // this doesn't work when a sequence changes something (like its
+ // name)
+ //else if (analysis->is_dirty())
+ try {
+ analysis->save();
+ } catch (std::exception e) {
+ QMessageBox::critical(this,
+ tr("Mussa Save Error"),
+ tr(e.what()),
+ QMessageBox::Ok, 0, 0);
+ }
+
+ }
+ }
+}
+
+void MussaWindow::saveAnalysisAs()
+{
+ std::auto_ptr<QFileDialog> dialog(new QFileDialog(this));
+ dialog->setAcceptMode(QFileDialog::AcceptSave);
+ dialog->setFileMode(QFileDialog::AnyFile);
+ dialog->setDirectory(*default_dir);
+
+ QStringList fileNames;
+ if (not dialog->exec()) {
+ return;
+ }
+ fileNames = dialog->selectedFiles();
+
+ if (fileNames.size() != 1) {
+ return;
+ }
+ try {
+ fs::path save_path(fileNames[0].toStdString(), fs::native);
+ // do you want to overwrite?
+ if (fs::exists(save_path) and
+ QMessageBox::question(
+ this,
+ tr("Overwrite File? -- Mussa"),
+ tr("A file called %1 already exists"
+ "do you want to overwrite it?")
+ .arg(fileNames[0]),
+ tr("&Yes"), tr("&No"),
+ QString(), 0, 1)
+ ) {
+ return;
+ }
+ analysis->save(save_path);
+ fs::path normalized_path = (save_path / "..").normalize();
+ default_dir->setPath(normalized_path.native_directory_string().c_str());
+ } catch (std::exception e) {
+ QMessageBox::critical(this,
+ tr("Mussa Save Error"),
+ tr(e.what()),
+ QMessageBox::Ok, 0, 0);
+ }
+}
+
+bool MussaWindow::isClearingAnalysisSafe()
+{
+ if (analysis and not analysis->empty() and analysis->is_dirty()) {
+ switch (QMessageBox::question(
+ this,
+ tr("Save Unsaved Changes -- Mussa"),
+ tr("There are unsaved changes,\ndo you want to save?"),
+ tr("&Yes"), tr("&No"), tr("&Cancel"),
+ 0, 2)) {
+ case 0:
+ // save
+ saveAnalysis();
+ break;
+ case 1:
+ // don't save
+ break;
+ case 2:
+ // don't replace
+ return false;
+ break;
+ default:
+ // error
+ throw runtime_error("isClearingAnalysis QMesageBox failure");
+ }
+ }
+ // if we're here we've been saved and can replace
+ return true;