X-Git-Url: http://woldlab.caltech.edu/gitweb/?a=blobdiff_plain;f=qui%2Fmotif_editor%2FMotifEditor.cpp;h=acde2d3af74c8a756bb9e05f4855748215f69138;hb=f88eea68b95773eb5683dcca6cf3fa59b9f00036;hp=ea10650ee84aea7cfdf68fcd55e78e81ef334e66;hpb=9526360687d8a092ad5583d8c7de789b5bf0ba9b;p=mussa.git diff --git a/qui/motif_editor/MotifEditor.cpp b/qui/motif_editor/MotifEditor.cpp index ea10650..acde2d3 100644 --- a/qui/motif_editor/MotifEditor.cpp +++ b/qui/motif_editor/MotifEditor.cpp @@ -9,13 +9,15 @@ using namespace std; MotifEditor::MotifEditor(MussaRef m, QWidget *parent) : QWidget(parent), analysis(m), - editor_layout(new QVBoxLayout(parent)), - button_layout(new QHBoxLayout(parent)), - table(new QTableView(this)), - delegate(new MotifEditorDelegate(this)), - applyButton(new QPushButton("apply")), + editor_layout(0), + button_layout(0), + table(0), + delegate(0), + applyButton(0), model(0) { + setupWidgets(); + assert (m != 0); const set &motif = analysis->motifs(); vector motif_seq(motif.begin(), motif.end()); @@ -35,16 +37,30 @@ MotifEditor::MotifEditor(MussaRef m, QWidget *parent) updateModel(); } +void MotifEditor::setupWidgets() +{ + editor_layout = new QVBoxLayout(this); + button_layout = new QHBoxLayout(this); + table = new QTableView(this); + delegate = new MotifEditorDelegate(this); + applyButton = new QPushButton("apply"); +} + 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 + // DET 2007mar30 (can this if statement ever be true? it doesn't look + // like there's a way to change the analysis?) + 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(); }