pass default_dir around
[mussa.git] / qui / MussaWindow.cpp
index 005cc1629625fea0ac619f0975fd32478ecadf60..36727a1635dd617670561688798bd5d789e0d855 100644 (file)
@@ -32,11 +32,11 @@ using namespace std;
 MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) :
   QMainWindow(parent),
   analysis(analysis_),
-  default_dir(QDir::home().absolutePath()),
+  default_dir(new QDir(QDir::home().absolutePath())),
   motif_editor(0),
   setup_analysis_dialog(new MussaSetupDialog(this)),
   subanalysis_window(new SubanalysisWindow(analysis)),
-  browser(new SequenceBrowserWidget(this)),  
+  browser(new SequenceBrowserWidget(default_dir, this)),  
   mussaViewTB(new QToolBar("Path Views")),
   zoom(new ZoomWidget),
   threshold(new ThresholdWidget),
@@ -354,7 +354,7 @@ void MussaWindow::saveAnalysisAs()
   std::auto_ptr<QFileDialog> dialog(new QFileDialog(this));
   dialog->setAcceptMode(QFileDialog::AcceptSave);
   dialog->setFileMode(QFileDialog::AnyFile);
-  dialog->setDirectory(default_dir);
+  dialog->setDirectory(*default_dir);
 
   QStringList fileNames;
   if (not dialog->exec()) {
@@ -381,7 +381,7 @@ void MussaWindow::saveAnalysisAs()
   }
   analysis->save(save_path);
   fs::path normalized_path = (save_path / "..").normalize();   
-  default_dir = normalized_path.native_directory_string().c_str();
+  default_dir->setPath(normalized_path.native_directory_string().c_str());
 }
 
 bool MussaWindow::isClearingAnalysisSafe()
@@ -431,7 +431,7 @@ void MussaWindow::loadMotifList()
   QString filter("Motif list(*.txt *.mtl)");
   QString path = QFileDialog::getOpenFileName(this,
                                               caption, 
-                                              default_dir.absolutePath(),
+                                              default_dir->absolutePath(),
                                               filter);
   // user hit cancel?
   if (path.isNull()) 
@@ -440,7 +440,7 @@ void MussaWindow::loadMotifList()
   try {
     fs::path converted_path(path.toStdString(), fs::native);
     analysis->load_motifs(converted_path);
-    default_dir = converted_path.branch_path().native_directory_string().c_str();
+    default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
     emit changedMotifs();
   } catch (runtime_error e) {
     QString msg("Unable to load ");
@@ -457,7 +457,7 @@ void MussaWindow::saveMotifList()
   QString filter("Motif list(*.txt *.mtl)");
   QString path = QFileDialog::getSaveFileName(this,
                                               caption, 
-                                              default_dir.absolutePath(),
+                                              default_dir->absolutePath(),
                                               filter);
   // user hit cancel?
   if (path.isNull()) 
@@ -466,7 +466,7 @@ void MussaWindow::saveMotifList()
   try {
     fs::path converted_path(path.toStdString(), fs::native);
     analysis->save_motifs(converted_path);
-    default_dir = converted_path.branch_path().native_directory_string().c_str();
+    default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
   } catch (runtime_error e) {
     QString msg("Unable to save ");
     msg += path;
@@ -482,7 +482,7 @@ void MussaWindow::loadMupa()
   QString mupa_path = QFileDialog::getOpenFileName(
                          this,
                          caption, 
-                         default_dir.absolutePath(),
+                         default_dir->absolutePath(),
                          filter
                       );
   // user hit cancel?
@@ -503,7 +503,7 @@ void MussaWindow::loadMupa()
     setAnalysis(m);
     updateTitle();
     // grab the path ignoring the mupa file portion
-    default_dir = converted_path.branch_path().native_directory_string().c_str();
+    default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
   } catch (mussa_load_error e) {
     QString msg("Unable to load ");
     msg += mupa_path;
@@ -520,7 +520,7 @@ void MussaWindow::loadSavedAnalysis()
   QString muway_dir = QFileDialog::getExistingDirectory(
                         this,
                         caption, 
-                        default_dir.absolutePath()
+                        default_dir->absolutePath()
                      );
   // user hit cancel?
   if (muway_dir.isNull()) 
@@ -541,11 +541,11 @@ void MussaWindow::loadSavedAnalysis()
       // our current window is empty so load and replace.
       setAnalysis(m);
       updateTitle();
-      default_dir = converted_path.branch_path().native_directory_string().c_str();
+      default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
     } else {
       MussaWindow *win = new MussaWindow(m);
       updateTitle();
-      win->default_dir = converted_path.branch_path().native_directory_string().c_str();
+      win->default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
       win->show();
     }
   } catch (mussa_load_error e) {
@@ -641,7 +641,7 @@ void MussaWindow::viewMussaAlignment()
                                      "first"));
   } else {
     MussaAlignedWindowRef ma_win( 
-      new MussaAlignedWindow(analysis, selected_paths, subanalysis_window)
+      new MussaAlignedWindow(analysis, default_dir, selected_paths, subanalysis_window)
     );
 
     aligned_windows.push_back(ma_win);