From 19b7fd464416b565bb32ee294b675f9c3da1e920 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Thu, 12 Oct 2006 01:00:59 +0000 Subject: [PATCH] add implementation for save motif menu item ticket:133 this adds part of the save motif code. I still need to save motifs that are attached to an analysis. --- qui/MussaWindow.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/qui/MussaWindow.cpp b/qui/MussaWindow.cpp index 10dded3..4e281fc 100644 --- a/qui/MussaWindow.cpp +++ b/qui/MussaWindow.cpp @@ -426,7 +426,7 @@ void MussaWindow::editMotifs() void MussaWindow::loadMotifList() { - QString caption("Load a motif list"); + QString caption("Mussa Load Motifs"); QString filter("Motif list(*.txt *.mtl)"); QDir default_qdir(default_dir.native_directory_string().c_str()); QString path = QFileDialog::getOpenFileName(this, @@ -447,15 +447,34 @@ void MussaWindow::loadMotifList() msg += path; msg += "\n"; msg += e.what(); - QMessageBox::warning(this, "Load Motifs", msg); + QMessageBox::warning(this, caption, msg); } - assert (analysis != 0); } void MussaWindow::saveMotifList() { - NotImplementedBox(); -} + QString caption("Mussa Save Motifs"); + QString filter("Motif list(*.txt *.mtl)"); + QDir default_qdir(default_dir.native_directory_string().c_str()); + QString path = QFileDialog::getSaveFileName(this, + caption, + default_qdir.absolutePath(), + filter); + // user hit cancel? + if (path.isNull()) + return; + // try to load safely + try { + fs::path converted_path(path.toStdString(), fs::native); + analysis->save_motifs(converted_path); + default_dir = converted_path.branch_path(); + } catch (runtime_error e) { + QString msg("Unable to save "); + msg += path; + msg += "\n"; + msg += e.what(); + QMessageBox::warning(this, caption, msg); + }} void MussaWindow::loadMupa() { -- 2.30.2