change default_dir to a QDir
authorDiane Trout <diane@caltech.edu>
Fri, 13 Oct 2006 00:52:08 +0000 (00:52 +0000)
committerDiane Trout <diane@caltech.edu>
Fri, 13 Oct 2006 00:52:08 +0000 (00:52 +0000)
from a boost::filesystem::path, this should make it
easier to pass around.

qui/MussaWindow.cpp
qui/MussaWindow.hpp

index c34c003c2ae27b01b82cafb006c2fdd35f3fb148..005cc1629625fea0ac619f0975fd32478ecadf60 100644 (file)
@@ -32,7 +32,7 @@ using namespace std;
 MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) :
   QMainWindow(parent),
   analysis(analysis_),
-  default_dir(QDir::home().absolutePath().toStdString(), fs::native),
+  default_dir(QDir::home().absolutePath()),
   motif_editor(0),
   setup_analysis_dialog(new MussaSetupDialog(this)),
   subanalysis_window(new SubanalysisWindow(analysis)),
@@ -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(QDir(default_dir.native_directory_string().c_str()));
+  dialog->setDirectory(default_dir);
 
   QStringList fileNames;
   if (not dialog->exec()) {
@@ -380,7 +380,8 @@ void MussaWindow::saveAnalysisAs()
     return;
   }
   analysis->save(save_path);
-  default_dir = (save_path / "..").normalize();
+  fs::path normalized_path = (save_path / "..").normalize();   
+  default_dir = normalized_path.native_directory_string().c_str();
 }
 
 bool MussaWindow::isClearingAnalysisSafe()
@@ -428,10 +429,9 @@ void MussaWindow::loadMotifList()
 {
   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,
                                               caption, 
-                                              default_qdir.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();
+    default_dir = converted_path.branch_path().native_directory_string().c_str();
     emit changedMotifs();
   } catch (runtime_error e) {
     QString msg("Unable to load ");
@@ -455,10 +455,9 @@ void MussaWindow::saveMotifList()
 {
   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(),
+                                              default_dir.absolutePath(),
                                               filter);
   // user hit cancel?
   if (path.isNull()) 
@@ -467,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();
+    default_dir = converted_path.branch_path().native_directory_string().c_str();
   } catch (runtime_error e) {
     QString msg("Unable to save ");
     msg += path;
@@ -480,12 +479,10 @@ void MussaWindow::loadMupa()
 {
   QString caption("Load a mussa parameter file");
   QString filter("Mussa Parameters (*.mupa)");
-  QDir default_qdir(QDir(default_dir.native_directory_string().c_str()));
-
   QString mupa_path = QFileDialog::getOpenFileName(
                          this,
                          caption, 
-                         default_qdir.absolutePath(),
+                         default_dir.absolutePath(),
                          filter
                       );
   // user hit cancel?
@@ -506,7 +503,7 @@ void MussaWindow::loadMupa()
     setAnalysis(m);
     updateTitle();
     // grab the path ignoring the mupa file portion
-    default_dir = converted_path.branch_path();
+    default_dir = converted_path.branch_path().native_directory_string().c_str();
   } catch (mussa_load_error e) {
     QString msg("Unable to load ");
     msg += mupa_path;
@@ -519,12 +516,11 @@ void MussaWindow::loadMupa()
 
 void MussaWindow::loadSavedAnalysis()
 {
-  QDir default_qdir(QDir(default_dir.native_directory_string().c_str()));
   QString caption("Load a previously run analysis");
   QString muway_dir = QFileDialog::getExistingDirectory(
                         this,
                         caption, 
-                        default_qdir.absolutePath()
+                        default_dir.absolutePath()
                      );
   // user hit cancel?
   if (muway_dir.isNull()) 
@@ -545,11 +541,11 @@ void MussaWindow::loadSavedAnalysis()
       // our current window is empty so load and replace.
       setAnalysis(m);
       updateTitle();
-      default_dir = converted_path.branch_path();
+      default_dir = converted_path.branch_path().native_directory_string().c_str();
     } else {
       MussaWindow *win = new MussaWindow(m);
       updateTitle();
-      win->default_dir = converted_path.branch_path();
+      win->default_dir = converted_path.branch_path().native_directory_string().c_str();
       win->show();
     }
   } catch (mussa_load_error e) {
index ce34717386cd35091ce532e8a5268c997ead4bcb..aff3c6ffbc9ef8d326556ac42bf95cc70fa2bb4e 100644 (file)
@@ -4,6 +4,7 @@
 #include <list>
 #include <boost/shared_ptr.hpp>
 
+#include <QDir>
 #include <QMainWindow>
 #include <QPixmap>
 #include <QProgressDialog>
@@ -99,7 +100,7 @@ protected:
   //! shared_ptr to our analysis
   MussaRef analysis;
   //! the default directory we should loand and save from
-  boost::filesystem::path default_dir;
+  QDir default_dir;
   std::list<boost::shared_ptr<MussaAlignedWindow> > aligned_windows;
   MotifEditor *motif_editor;
   MussaSetupDialog *setup_analysis_dialog;