Add window titles
authorDiane Trout <diane@caltech.edu>
Tue, 3 Oct 2006 21:36:10 +0000 (21:36 +0000)
committerDiane Trout <diane@caltech.edu>
Tue, 3 Oct 2006 21:36:10 +0000 (21:36 +0000)
this patch adds window titles to most of the windows that Mussa will
popup. I refactored the code that figured out a reasonble title name
from MussaWindow and put it into Mussa.

This did mean that the SubanalysisWindow now needed its own copy
of a MussaRef so it could ask the analysis for its name.

alg/mussa.cpp
alg/mussa.hpp
alg/test/test_mussa.cpp
qui/MussaAlignedWindow.cpp
qui/MussaAlignedWindow.hpp
qui/MussaWindow.cpp
qui/SubanalysisWindow.cpp
qui/SubanalysisWindow.hpp
qui/motif_editor/MotifEditor.cpp
qui/mussa_setup_dialog/MussaSetupDialog.cpp

index 7226e43f2b6c26b732d527ccbc0b2e4905e9ded2..c93990b72e81ef371cdcb615d234231c5ac3a466 100644 (file)
@@ -62,6 +62,11 @@ boost::filesystem::path Mussa::get_analysis_path() const
   return analysis_path;
 }
 
+void Mussa::set_analysis_path(boost::filesystem::path pathname)
+{
+  analysis_path = pathname;
+}
+
 // set all parameters to null state
 void
 Mussa::clear()
@@ -102,11 +107,23 @@ Mussa::set_name(string a_name)
   dirty = true;
 }
 
-string Mussa::get_name()
+string Mussa::get_name() const
 {
   return analysis_name;
 }
 
+string Mussa::get_title() const
+{
+  fs::path analysis_path = get_analysis_path();
+  if (not analysis_path.empty()) {
+    return analysis_path.native_file_string();
+  } else if (get_name().size() > 0) {
+    return get_name();
+  } else {
+    return std::string("Unnamed");
+  }
+}
+
 int 
 Mussa::size() const
 {
index 84fcd92ab9a0670416048a14b323c104202811c6..cc806073fd92658475ad85608f77af7d10fae7b5 100644 (file)
@@ -54,6 +54,8 @@ public:
     void load(boost::filesystem::path ana_path);
     // ! return path to the where the analysis is stored
     boost::filesystem::path get_analysis_path() const;
+    //! set analysis path
+    void set_analysis_path(boost::filesystem::path);
 
     //! clear parameters and initialize data lists
     void clear();
@@ -66,7 +68,11 @@ public:
     //! set analysis name
     void set_name(std::string a_name);
     //! return name for this analysis
-    std::string get_name();
+    std::string get_name() const;
+    //! return a reasonable window title for this analysis
+    /*! this returns the "variable" portion for a title
+     */
+    std::string get_title() const;
 
     //! return number of sequences in this analyzis
     /*! this returns either the_seqs.size() or seq_files.size()
index bebb38d2548e2cec34b43d642ac73c33627ec413..068d44b5015dabc7d35d5add142eb9b82909028e 100644 (file)
@@ -50,6 +50,20 @@ BOOST_AUTO_TEST_CASE( mussa_simple )
   BOOST_CHECK_EQUAL(m.get_analysis_mode(), Mussa::TransitiveNway);
 }
 
+BOOST_AUTO_TEST_CASE ( mussa_title )
+{
+  Mussa m;
+  
+  BOOST_CHECK_EQUAL( m.get_title(), "Unnamed");
+  string foo("foo");
+  m.set_name(foo);
+  BOOST_CHECK_EQUAL( m.get_title(), foo);
+  string foopath_name("/my/silly/path");
+  fs::path foopath(foopath_name);
+  m.set_analysis_path(foopath);
+  BOOST_CHECK_EQUAL( m.get_title(), foopath_name);
+}
+
 BOOST_AUTO_TEST_CASE( mussa_analysis_name )
 {
   Mussa m;
index 4daa5d8a6068be9b280f39560b1002d1e952eb98..9d6ff3f640248efd3a1a6617a473bb825576a395 100644 (file)
@@ -56,6 +56,8 @@ MussaAlignedWindow::MussaAlignedWindow(MussaRef m,
   message << "Selected " << selected_paths.size() << " paths";
   statusBar()->showMessage(message.str().c_str(), 5000);
   browser.updatePosition();
+  
+  updateTitle();
 }
 
 void MussaAlignedWindow::setupActions()
@@ -199,6 +201,15 @@ void MussaAlignedWindow::update()
   browser.update();
 }
 
+void MussaAlignedWindow::updateTitle()
+{
+  std::string title("Sequence View: ");
+  if (analysis) {
+    title += analysis->get_title();
+  }
+  setWindowTitle(title.c_str());
+}
+
 void MussaAlignedWindow::computeMatchLines()
 {
   browser.clear_links();
index f67e5b32c2cc0537ae728249ffd83cdec4cdb31c..6f6aaf83eee8aaf6022a3e0dbb4005c8f5b36f59 100644 (file)
@@ -41,6 +41,9 @@ public slots:
 
   //! just force updating the window
   void update();
+  
+  //! set the title based on the analysis
+  void updateTitle();
 
 protected:
   // figure out what Alignments we have (needed for setupAlignmentMenus)
index 01702309e1938aaa0bedd697ab6ecf55c33640b0..09d6ee9ba891b19fe06e6d1b76fc5647817acfb7 100644 (file)
@@ -35,7 +35,7 @@ MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) :
   default_dir(QDir::home().absolutePath().toStdString(), fs::native),
   motif_editor(0),
   setup_analysis_dialog(new MussaSetupDialog(this)),
-  subanalysis_window(new SubanalysisWindow),
+  subanalysis_window(new SubanalysisWindow(analysis)),
   browser(new SequenceBrowserWidget(this)),  
   mussaViewTB(new QToolBar("Path Views")),
   zoom(new ZoomWidget),
@@ -720,11 +720,6 @@ MussaWindow::updateProgress(const string& description, int current, int max)
 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());
-    } 
+    setWindowTitle(analysis->get_title().c_str());
   }
 }
index 34ef9aa9b0b2dbe8b778d69bdd22b46d4a28abfe..1ecbcbca28d80b40c7f12b6b63e5c54507716e1e 100644 (file)
@@ -8,8 +8,9 @@
 #include <QHBoxLayout>
 #include <QGridLayout>
 
-SubanalysisWindow::SubanalysisWindow(QWidget *parent)
+SubanalysisWindow::SubanalysisWindow(MussaRef m, QWidget *parent)
   : QWidget(parent),
+    analysis(m),
     window(0),
     threshold(0),
     table(0),
@@ -56,6 +57,8 @@ SubanalysisWindow::SubanalysisWindow(QWidget *parent)
           this, SLOT(modelUpdated(const QModelIndex&, int, int)));
   connect(&model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), 
           this, SLOT(modelUpdated(const QModelIndex&, int, int)));
+          
+  updateTitle();        
 }
 
 SequenceLocationModel& SubanalysisWindow::getModel()
@@ -105,3 +108,12 @@ void SubanalysisWindow::modelUpdated(const QModelIndex&, int, int )
   // if the model is empty we shouldn't be able to click ok
   if (ok) ok->setEnabled(not model.empty());
 }
+
+void SubanalysisWindow::updateTitle()
+{
+  std::string title("Subanalysis: ");
+  if (analysis) {
+    title += analysis->get_title();
+  }
+  setWindowTitle(title.c_str());  
+}
\ No newline at end of file
index 0bf32949c8f489ce82c5857c164a7f4531bbd8b6..9d9ef731db486d041ef1ce83718ed6fe60984388 100644 (file)
@@ -8,13 +8,14 @@
 #include <QWidget>
 
 #include "qui/SequenceLocationModel.hpp"
+#include "alg/mussa.hpp"
 
 class SubanalysisWindow : public QWidget
 {
   Q_OBJECT 
 
 public: 
-  SubanalysisWindow(QWidget *parent = 0);
+  SubanalysisWindow(MussaRef m, QWidget *parent = 0);
 
   //! return a modifiable reference to our SequenceLocationModel
   SequenceLocationModel& getModel();
@@ -26,8 +27,12 @@ public slots:
   void run();
   //! provide a way for the model to tell us to update our gui
   void modelUpdated(const QModelIndex&, int, int);
+  //! update our title
+  void updateTitle();
 
-private:  
+private:
+  //! keep track of what analysis we're attached to
+  MussaRef analysis;
   QSpinBox *window;
   QSpinBox *threshold;
   QTableView *table;
index e5e559eeb04bcbea5b5abe51be3ac5491993d5c6..93178d673faf069bfea426f025f3ca85c47c8436 100644 (file)
@@ -79,10 +79,11 @@ void MotifEditor::updateMotifs()
 
 void MotifEditor::updateTitle() 
 {
-  QString title("Motif Editor: ");
-  title.append(analysis->get_name().c_str());
-  setWindowTitle(title);
-  
+  std::string title("Motif Editor: ");
+  if (analysis) {
+    title += analysis->get_title();
+  }
+  setWindowTitle(title.c_str());
 }
 
 void MotifEditor::updateView()
index dcbd17957267e9906a7348659dc3fe7452642bb7..3d214d1ad131292b4d9c58b97aa3119d876d2044 100644 (file)
@@ -11,6 +11,7 @@ MussaSetupDialog::MussaSetupDialog(QWidget *parent, Qt::WFlags f)
   : QDialog(parent, f),
     setupWidget(0)
 {
+  setWindowTitle("Define New Analysis");
   setupWidget = new MussaSetupWidget;
 
   connect(setupWidget, SIGNAL(createButtonPushed()),