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
newMenu->addAction(browser->getCopySelectedSequenceAsStringAction());
newMenu->addAction(browser->getCopySelectedSequenceAsFastaAction());
newMenu->addAction(createSubAnalysisAction);
+ newMenu->addAction(browser->getEditSequencePropertiesAction());
newMenu = menuBar()->addMenu(tr("&View"));
newMenu->addAction(viewMussaAlignmentAction);
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)
return copySelectedSequenceAsStringAction;
}
+QAction *SequenceBrowser::getEditSequencePropertiesAction()
+{
+ return editSequencePropertiesAction;
+}
+
QSize SequenceBrowser::sizeHint() const
{
return QSize(viewportPixelWidth(), viewportPixelHeight());
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();
}
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();
return scrollable_browser->browser().getCopySelectedSequenceAsFastaAction();
}
+QAction *SequenceBrowserWidget::getEditSequencePropertiesAction()
+{
+ return scrollable_browser->browser().getEditSequencePropertiesAction();
+}
+
void SequenceBrowserWidget::copySelectedSequenceAsFasta()
{
scrollable_browser->browser().copySelectedSequenceAsFasta();
QAction *getCopySelectedSequenceAsFastaAction();
//! return our string copy action (reference stored internally)
QAction *getCopySelectedSequenceAsStringAction();
+ //! return sequence properties edit action
+ QAction *getEditSequencePropertiesAction();
QSize sizeHint() const;
: 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;
return model;
}
-void PropertiesWindow::cancel()
+void PropertiesWindow::close()
{
model.clear();
hide();
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()
//! 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;
};
#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)
{
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;
+ }
+}
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
//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
buttonLayout->addWidget(ok);
buttonLayout->addWidget(cancel);
- // layout verticle space
+ // layout vertical space
QVBoxLayout *verticalLayout = new QVBoxLayout;
verticalLayout->addLayout(parameterLayout);
verticalLayout->addWidget(table);