add implementation for save motif menu item
authorDiane Trout <diane@caltech.edu>
Thu, 12 Oct 2006 01:00:59 +0000 (01:00 +0000)
committerDiane Trout <diane@caltech.edu>
Thu, 12 Oct 2006 01:00:59 +0000 (01:00 +0000)
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

index 10dded3cea4b83831f24767f7059be56bac88526..4e281fcb6ff7fcc2cc331e80202edde61d0755f4 100644 (file)
@@ -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()
 {