From: Diane Trout Date: Wed, 22 Nov 2006 20:24:21 +0000 (+0000) Subject: Finish off setting sequence offset user interface X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=mussa.git;a=commitdiff_plain;h=a6104dae2b44645826ee3e83c8444ba012b928ac Finish off setting sequence offset user interface 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. --- diff --git a/alg/glseqbrowser.hpp b/alg/glseqbrowser.hpp index 5cc0672..86439fc 100644 --- a/alg/glseqbrowser.hpp +++ b/alg/glseqbrowser.hpp @@ -211,12 +211,12 @@ private: float viewport_center; double zoom_level; boost::shared_ptr color_mapper; - //! container of all the GlSequences loaded into our scene - std::vector > 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 > track_container; //! where to draw our box (world coordinates) rect selectedRegion; //! true if we have a selection diff --git a/qui/MussaWindow.cpp b/qui/MussaWindow.cpp index 768d244..9325a82 100644 --- a/qui/MussaWindow.cpp +++ b/qui/MussaWindow.cpp @@ -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); diff --git a/qui/seqbrowser/SequenceBrowser.cpp b/qui/seqbrowser/SequenceBrowser.cpp index 7dab020..0f2868e 100644 --- a/qui/seqbrowser/SequenceBrowser.cpp +++ b/qui/seqbrowser/SequenceBrowser.cpp @@ -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(); } diff --git a/qui/seqbrowser/SequenceBrowser.hpp b/qui/seqbrowser/SequenceBrowser.hpp index 37e95fb..9da5e8c 100644 --- a/qui/seqbrowser/SequenceBrowser.hpp +++ b/qui/seqbrowser/SequenceBrowser.hpp @@ -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(); diff --git a/qui/seqbrowser/SequenceBrowserWidget.cpp b/qui/seqbrowser/SequenceBrowserWidget.cpp index f6f7f6f..e8277d0 100644 --- a/qui/seqbrowser/SequenceBrowserWidget.cpp +++ b/qui/seqbrowser/SequenceBrowserWidget.cpp @@ -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(); diff --git a/qui/seqbrowser/SequenceBrowserWidget.hpp b/qui/seqbrowser/SequenceBrowserWidget.hpp index 030f1da..2b47d41 100644 --- a/qui/seqbrowser/SequenceBrowserWidget.hpp +++ b/qui/seqbrowser/SequenceBrowserWidget.hpp @@ -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; diff --git a/qui/seqbrowser/seqproperties/PropertiesWindow.cpp b/qui/seqbrowser/seqproperties/PropertiesWindow.cpp index 45427b9..a47b710 100644 --- a/qui/seqbrowser/seqproperties/PropertiesWindow.cpp +++ b/qui/seqbrowser/seqproperties/PropertiesWindow.cpp @@ -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() diff --git a/qui/seqbrowser/seqproperties/PropertiesWindow.hpp b/qui/seqbrowser/seqproperties/PropertiesWindow.hpp index f369af2..ed29383 100644 --- a/qui/seqbrowser/seqproperties/PropertiesWindow.hpp +++ b/qui/seqbrowser/seqproperties/PropertiesWindow.hpp @@ -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; }; diff --git a/qui/seqbrowser/seqproperties/SequencePropertiesModel.cpp b/qui/seqbrowser/seqproperties/SequencePropertiesModel.cpp index b4fc3b2..9be40db 100644 --- a/qui/seqbrowser/seqproperties/SequencePropertiesModel.cpp +++ b/qui/seqbrowser/seqproperties/SequencePropertiesModel.cpp @@ -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; + } +} diff --git a/qui/seqbrowser/seqproperties/SequencePropertiesModel.hpp b/qui/seqbrowser/seqproperties/SequencePropertiesModel.hpp index f5ea351..85c7e89 100644 --- a/qui/seqbrowser/seqproperties/SequencePropertiesModel.hpp +++ b/qui/seqbrowser/seqproperties/SequencePropertiesModel.hpp @@ -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 diff --git a/qui/subanalysis/SubanalysisWindow.cpp b/qui/subanalysis/SubanalysisWindow.cpp index 056ba9b..fec991c 100644 --- a/qui/subanalysis/SubanalysisWindow.cpp +++ b/qui/subanalysis/SubanalysisWindow.cpp @@ -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);