ticket:195
My previous implementation kept destroying and recreating the motif
editing dialog box. This version only deletes the motif editor when
MussaWindow.clear() is called.
void MussaWindow::clear()
{
void MussaWindow::clear()
{
+ if (motif_editor != 0) {
+ motif_editor->hide();
+ delete motif_editor;
+ }
+
aligned_windows.clear();
browser->clear();
}
aligned_windows.clear();
browser->clear();
}
void MussaWindow::editMotifs()
{
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()));
void MotifEditor::updateModel()
{
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) {
- // 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();
}
table->setModel(model);
updateView();
}
#include <QColor>
MotifModel::MotifModel(MussaRef m, QObject *parent)
#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();
{
const std::set<Sequence>& motif_set = m->motifs();
boost::shared_ptr<AnnotationColors> cm = m->colorMapper();
+const MussaRef MotifModel::getAnalysis() const {
+ return analysis;
+}
+
void MotifModel::assign(
MotifModel::size_type num,
const MotifElement& val
void MotifModel::assign(
MotifModel::size_type num,
const MotifElement& val
typedef model_type::const_iterator const_iterator;
enum cell_names { EnabledCell, ColorCell, NameCell, SequenceCell };
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
//! \@{
//! \defgroup VectorInterface
//! \addtogroup VectorInterface
//! \@{
// const QModelIndex& parent=QModelIndex());
//! \@}
private:
// const QModelIndex& parent=QModelIndex());
//! \@}
private: