Finish off setting sequence offset user interface
authorDiane Trout <diane@caltech.edu>
Wed, 22 Nov 2006 20:24:21 +0000 (20:24 +0000)
committerDiane Trout <diane@caltech.edu>
Wed, 22 Nov 2006 20:24:21 +0000 (20:24 +0000)
ticket:111
I thought it would be better for the edit sequence properties action to live
under the main edit menu, instead of the popup menu.

Also I decided to use apply/close instead of ok/cancel as it seemed better
to make fiddling with the offset interactive.

And yes I probably should implement some graphical way of aligning the
sequences instead of just typing in offsets.

alg/glseqbrowser.hpp
qui/MussaWindow.cpp
qui/seqbrowser/SequenceBrowser.cpp
qui/seqbrowser/SequenceBrowser.hpp
qui/seqbrowser/SequenceBrowserWidget.cpp
qui/seqbrowser/SequenceBrowserWidget.hpp
qui/seqbrowser/seqproperties/PropertiesWindow.cpp
qui/seqbrowser/seqproperties/PropertiesWindow.hpp
qui/seqbrowser/seqproperties/SequencePropertiesModel.cpp
qui/seqbrowser/seqproperties/SequencePropertiesModel.hpp
qui/subanalysis/SubanalysisWindow.cpp

index 5cc06720f20837ecbc32b1a56d57d283ee86f406..86439fce8f8b847fd07f0c5e49106b72c973751e 100644 (file)
@@ -211,12 +211,12 @@ private:
   float viewport_center;
   double zoom_level;
   boost::shared_ptr<AnnotationColors> color_mapper;
-  //! container of all the GlSequences loaded into our scene
-  std::vector<boost::shared_ptr<GlSequence> > track_container;
   //! counter for each path added to us via connect
   int pathid;
 
 protected:
+  //! container of all the GlSequences loaded into our scene
+  std::vector<boost::shared_ptr<GlSequence> > track_container;
   //! where to draw our box (world coordinates)
   rect<float> selectedRegion;
   //! true if we have a selection
index 768d244569ceb610d793e9354edff9fd632738c2..9325a8201e5a069304eed8c3b2ed0cee7f831c19 100644 (file)
@@ -260,6 +260,7 @@ void MussaWindow::setupMainMenu()
   newMenu->addAction(browser->getCopySelectedSequenceAsStringAction());
   newMenu->addAction(browser->getCopySelectedSequenceAsFastaAction());
   newMenu->addAction(createSubAnalysisAction);
+  newMenu->addAction(browser->getEditSequencePropertiesAction());
  
   newMenu = menuBar()->addMenu(tr("&View"));
   newMenu->addAction(viewMussaAlignmentAction);
index 7dab0203177b616ed6a74c8b4b32c161d9040852..0f2868eb23e1cc6d144e6bbed4e847a76eb21f52 100644 (file)
@@ -32,9 +32,9 @@ SequenceBrowser::SequenceBrowser(QWidget *parent)
   connect(copySelectedSequenceAsStringAction, SIGNAL(triggered()), 
           this, SLOT(copySelectedSequenceAsString()));
   popupMenu->addAction(copySelectedSequenceAsStringAction);
-  connect(editSequencePropertiesAction, SIGNAL(triggered()),
+  // connect edit properties action
+  connect(editSequencePropertiesAction, SIGNAL(triggered()), 
           this, SLOT(editSequenceProperties()));
-  popupMenu->addAction(editSequencePropertiesAction);
 }
 
 SequenceBrowser::SequenceBrowser(const SequenceBrowser& sb, QWidget *parent)
@@ -64,6 +64,11 @@ QAction *SequenceBrowser::getCopySelectedSequenceAsStringAction()
   return copySelectedSequenceAsStringAction;
 }
 
+QAction *SequenceBrowser::getEditSequencePropertiesAction()
+{
+  return editSequencePropertiesAction;
+}
+
 QSize SequenceBrowser::sizeHint() const
 {
   return QSize(viewportPixelWidth(), viewportPixelHeight());
@@ -145,8 +150,15 @@ void SequenceBrowser::displayContextMenu(const QPoint& point)
 
 void SequenceBrowser::editSequenceProperties()
 {
-  PropertiesWindowRef new_properties(new PropertiesWindow(sequences()));
+  // if there's a previous window, disconnect its signal
+  if (properties) {
+    disconnect(properties.get(), SIGNAL(propertiesChanged()),
+               this, SLOT(updateGL()));
+  }
+  PropertiesWindowRef new_properties(new PropertiesWindow(track_container));
   properties = new_properties;
+  connect(properties.get(), SIGNAL(propertiesChanged()),
+          this, SLOT(updateGL()));
   properties->show();
 }
 
index 37e95fb672349758cfda17ab125608ec81fbf3e7..9da5e8cb723a4e8bd3da2397397ec2ee048a9998 100644 (file)
@@ -39,8 +39,10 @@ public:
   QMenu *getPopupMenu();
   //! return our copy action (reference stored internally)
   QAction *getCopySelectedSequenceAsFastaAction();
-  //! return reference to copy sequence action
+  //! return copy sequence action
   QAction *getCopySelectedSequenceAsStringAction();
+  //! return view sequence properties action
+  QAction *getEditSequencePropertiesAction();
 
 public slots:
   void copySelectedSequenceAsFasta();
index f6f7f6f0ea5cbaec18e30c90e1e80802c560eb04..e8277d052cdbd1f45413c09d6794c8269b534008 100644 (file)
@@ -97,6 +97,11 @@ QAction *SequenceBrowserWidget::getCopySelectedSequenceAsFastaAction()
   return scrollable_browser->browser().getCopySelectedSequenceAsFastaAction();
 }
 
+QAction *SequenceBrowserWidget::getEditSequencePropertiesAction()
+{
+  return scrollable_browser->browser().getEditSequencePropertiesAction();
+}
+
 void SequenceBrowserWidget::copySelectedSequenceAsFasta()
 {
   scrollable_browser->browser().copySelectedSequenceAsFasta();
index 030f1da7651ed54addf81a5cbb0b53e21c04bc9d..2b47d412a8945c8dfb7d65e431ec1021433782af 100644 (file)
@@ -28,6 +28,8 @@ public:
   QAction *getCopySelectedSequenceAsFastaAction();
   //! return our string copy action (reference stored internally)
   QAction *getCopySelectedSequenceAsStringAction();
+  //! return sequence properties edit action
+  QAction *getEditSequencePropertiesAction();
 
   QSize sizeHint() const;
     
index 45427b933b5b65adb62ad72aea8842a4ce8b41ad..a47b7101e9aa502b15533303019d8f661d32dca5 100644 (file)
@@ -14,26 +14,27 @@ PropertiesWindow::PropertiesWindow(/* MussaRef m, */
   : QWidget(parent),
     /* analysis(m), */
     table(0),
-    okButton(0),
-    cancelButton(0),
+    applyButton(0),
+    closeButton(0),
     model(glseqs)
 {
   QGridLayout *parameterLayout = new QGridLayout;
 
-  okButton = new QPushButton(tr("&OK"), this);
-  okButton->setEnabled( false );
-  connect(okButton, SIGNAL(clicked()), this, SLOT(apply()));
+  applyButton = new QPushButton(tr("&Apply"), this);
+  applyButton->setFocusPolicy(Qt::StrongFocus);
+  applyButton->setEnabled( not model.empty() );
+  connect(applyButton, SIGNAL(clicked()), this, SLOT(apply()));
 
-  cancelButton = new QPushButton(tr("Cancel"), this);
-  connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
+  closeButton = new QPushButton(tr("Close"), this);
+  connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
 
   table = new QTableView(this);
   table->setModel(&model);
 
   // layout buttons
   QHBoxLayout *buttonLayout = new QHBoxLayout;
-  buttonLayout->addWidget(okButton);
-  buttonLayout->addWidget(cancelButton);
+  buttonLayout->addWidget(applyButton);
+  buttonLayout->addWidget(closeButton);
 
   // layout verticle space
   QVBoxLayout *verticalLayout = new QVBoxLayout;
@@ -55,7 +56,7 @@ SequencePropertiesModel& PropertiesWindow::getModel()
   return model;
 }
 
-void PropertiesWindow::cancel()
+void PropertiesWindow::close()
 {
   model.clear();
   hide();
@@ -63,19 +64,14 @@ void PropertiesWindow::cancel()
 
 void PropertiesWindow::apply()
 {
-  std::cout << "implement PropertiesWindow::apply" << std::endl;
-  
-  for(SequencePropertiesModel::iterator itor = model.begin();
-      itor != model.end();
-      ++itor)
-  {
-  }
+  model.saveChanges();
+  emit propertiesChanged();
 }
 
 void PropertiesWindow::modelUpdated(const QModelIndex&, int, int )
 {
   // if the model is empty we shouldn't be able to click ok
-  if (okButton) okButton->setEnabled(not model.empty());
+  if (applyButton) applyButton->setEnabled(not model.empty());
 }
 
 void PropertiesWindow::updateTitle()
index f369af2014e0ebf9ac8a1495eef8b7c342d99ad1..ed293837616951880731394972f49306c404036c 100644 (file)
@@ -26,18 +26,22 @@ public slots:
   //! create a subanalysis and run it
   void apply();
   //! clear our model and close the window
-  void cancel();
+  void close();
   //! provide a way for the model to tell us to update our gui
   void modelUpdated(const QModelIndex&, int, int);
   //! update our title
   void updateTitle();
-
+  
+signals:
+  //! the user saved their changes
+  void propertiesChanged();
+  
 private:
   //! keep track of what analysis we're attached to
   MussaRef analysis;
   QTableView *table;
-  QPushButton *okButton;
-  QPushButton *cancelButton;
+  QPushButton *applyButton;
+  QPushButton *closeButton;
 
   SequencePropertiesModel model;
 };
index b4fc3b238e3db3f934fd5d233ac406ce20b558b5..9be40dbf2b8b378d9d1a623cda73386f81263491 100644 (file)
@@ -1,6 +1,6 @@
 #include "qui/seqbrowser/seqproperties/SequencePropertiesModel.hpp"
 
-SequencePropertiesModel::SequencePropertiesModel(model_type& orig, QObject *parent) 
+SequencePropertiesModel::SequencePropertiesModel(model_type orig, QObject *parent) 
   : QAbstractTableModel(parent),
     original_sequences(orig)
 {
@@ -205,4 +205,18 @@ Qt::ItemFlags SequencePropertiesModel::flags(const QModelIndex& index) const
     return QAbstractItemModel::flags(index);
   else
     return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
-}
\ No newline at end of file
+}
+
+void SequencePropertiesModel::saveChanges()
+{
+  const_iterator orig_seq_i = original_sequences.begin();
+  const_iterator new_seq_i = sequences.begin();
+
+  while(orig_seq_i != original_sequences.end() or new_seq_i != sequences.end())
+  {
+    // copy over properties
+    (*orig_seq_i)->setX((*new_seq_i)->x());
+    ++orig_seq_i;
+    ++new_seq_i;
+  }
+}
index f5ea351f35c950fefe6a98701de79924ccd88037..85c7e899c43e28e7e13155b65c8c46d447435dc0 100644 (file)
@@ -18,7 +18,7 @@ class SequencePropertiesModel : public QAbstractTableModel
     typedef model_type::iterator iterator; 
     typedef model_type::const_iterator const_iterator; 
 
-    SequencePropertiesModel(model_type& model, QObject *parent = 0);
+    SequencePropertiesModel(model_type model, QObject *parent = 0);
 
     //! \defgroup VectorInterface
     //! \addtogroup VectorInterface
@@ -69,9 +69,14 @@ class SequencePropertiesModel : public QAbstractTableModel
     //bool removeRows(int row, int count,
     //                const QModelIndex& parent=QModelIndex());
     //! \@}
+
+  public slots:
+    //! update the original sequence with our changes    
+    void saveChanges();
+    
   private:
     model_type sequences;
-    model_type& original_sequences;
+    model_type original_sequences;
 };
 
 #endif
index 056ba9b4918be196dad7eb6ecd73d6c122e2cf3d..fec991c75e4bf614b605ae6824743add819a3726 100644 (file)
@@ -46,7 +46,7 @@ SubanalysisWindow::SubanalysisWindow(MussaRef m, QWidget *parent)
   buttonLayout->addWidget(ok);
   buttonLayout->addWidget(cancel);
 
-  // layout verticle space
+  // layout vertical space
   QVBoxLayout *verticalLayout = new QVBoxLayout;
   verticalLayout->addLayout(parameterLayout);
   verticalLayout->addWidget(table);