add updateTitle
authorDiane Trout <diane@caltech.edu>
Mon, 2 Oct 2006 23:12:05 +0000 (23:12 +0000)
committerDiane Trout <diane@caltech.edu>
Mon, 2 Oct 2006 23:12:05 +0000 (23:12 +0000)
localize the code for updating the MussaWindow title.

qui/MussaWindow.cpp
qui/MussaWindow.hpp

index a079974dd5666005aef4d0f49171fa4dc6735cff..8fa878e549bdcdd3a290861fa9393c1f6dbb6c91 100644 (file)
@@ -93,6 +93,7 @@ MussaWindow::MussaWindow(Mussa *analysis_, QWidget *parent) :
   statusBar()->showMessage("Welcome to mussa", 2000);
   connect(analysis, SIGNAL(progress(const std::string&, int, int)),
           this, SLOT(updateProgress(const std::string&, int, int)));
+  updateTitle();
   updateAnalysis();
 }
 
@@ -103,7 +104,7 @@ void MussaWindow::setAnalysis(Mussa *new_analysis)
     clear();
     delete analysis;
     analysis = new_analysis;
-    setWindowTitle(analysis->get_name().c_str());
+    updateTitle();
     updateAnalysis();
   }
 }
@@ -482,7 +483,7 @@ void MussaWindow::loadMupa()
     m->load_mupa_file(converted_path);
     m->analyze();
     setAnalysis(m);
-    setWindowTitle(converted_path.native_file_string().c_str());
+    updateTitle();
     // grab the path ignoring the mupa file portion
     default_dir = converted_path.branch_path();
   } catch (mussa_load_error e) {
@@ -522,11 +523,11 @@ void MussaWindow::loadSavedAnalysis()
     if (analysis->empty()) {
       // our current window is empty so load and replace.
       setAnalysis(m);
-      setWindowTitle(converted_path.native_file_string().c_str());
+      updateTitle();
       default_dir = converted_path.branch_path();
     } else {
       MussaWindow *win = new MussaWindow(m);
-      win->setWindowTitle(converted_path.native_file_string().c_str());
+      updateTitle();
       win->default_dir = converted_path.branch_path();
       win->show();
     }
@@ -715,3 +716,15 @@ MussaWindow::updateProgress(const string& description, int current, int max)
   }
   qApp->processEvents();
 }
+
+void MussaWindow::updateTitle()
+{
+  if (analysis) {
+    fs::path analysis_path = analysis->get_analysis_path();
+    if (not analysis_path.empty()) {
+      setWindowTitle(analysis_path.native_file_string().c_str());
+    } else if (analysis->get_name().size() > 0) {
+      setWindowTitle(analysis->get_name().c_str());
+    } 
+  }
+}
index 83692d394fdc9fd30e852959e1d64c6ec8183982..5adabde7a81553e7c808e7bebd1a42cb1b52c057 100644 (file)
@@ -56,6 +56,8 @@ public slots:
   void saveAnalysis();
   //! save an analysis after prompting for new name
   void saveAnalysisAs();
+  //! try to conver the mussa analysis_path to a title
+  void updateTitle();
   //\@}
 
   //! \defgroup MotifHandling Handling of motif lists