void MussaWindow::clear()
{
+ if (motif_editor != 0) {
+ motif_editor->hide();
+ delete motif_editor;
+ }
+
aligned_windows.clear();
browser->clear();
}
void MussaWindow::editMotifs()
{
- if (motif_editor != 0) {
- motif_editor->hide();
- delete motif_editor;
+ if (not motif_editor) {
+ motif_editor = new MotifEditor(analysis);
+ connect(motif_editor, SIGNAL(changedMotifs()),
+ this, SLOT(updateAnnotations()));
}
- motif_editor = new MotifEditor(analysis);
- connect(motif_editor, SIGNAL(changedMotifs()),
- this, SLOT(updateAnnotations()));
motif_editor->show();
}
void MotifEditor::updateModel()
{
- MotifModel *new_model = new MotifModel(analysis);
-
- // if there was an old model, delete it
- if (model) {
+ // if our current analysis doesn't match the one in our
+ // model, we probalby changed the analysis.
+ // so delete and restart
+ if (model and model->getAnalysis() != analysis) {
delete model;
}
- // update the QTableView
- model = new_model;
+
+ // if we don't have a model, create a new one
+ if (not model) {
+ model = new MotifModel(analysis);
+ }
table->setModel(model);
updateView();
}
#include <QColor>
MotifModel::MotifModel(MussaRef m, QObject *parent)
- : QAbstractTableModel(parent)
+ : analysis(m),
+ QAbstractTableModel(parent)
{
const std::set<Sequence>& motif_set = m->motifs();
boost::shared_ptr<AnnotationColors> cm = m->colorMapper();
push_empty();
}
+const MussaRef MotifModel::getAnalysis() const {
+ return analysis;
+}
+
void MotifModel::assign(
MotifModel::size_type num,
const MotifElement& val
typedef model_type::const_iterator const_iterator;
enum cell_names { EnabledCell, ColorCell, NameCell, SequenceCell };
+
+ //! return what analysis we were attached to
+ const MussaRef getAnalysis() const;
+
//! \defgroup VectorInterface
//! \addtogroup VectorInterface
//! \@{
// const QModelIndex& parent=QModelIndex());
//! \@}
private:
+ MussaRef analysis;
model_type motifs;
};