1 #include "qui/SubanalysisWindow.hpp"
2 #include "qui/MussaWindow.hpp"
4 #include "mussa_exceptions.hpp"
5 #include "alg/mussa.hpp"
11 SubanalysisWindow::SubanalysisWindow(QWidget *parent)
19 QGridLayout *parameterLayout = new QGridLayout;
21 QLabel *thresholdLabel = new QLabel(tr("threshold (bp)"));
22 parameterLayout->addWidget(thresholdLabel, 0, 0);
23 threshold = new QSpinBox(this);
24 threshold->setValue(8);
25 parameterLayout->addWidget(threshold, 1, 0);
26 QLabel *windowLabel = new QLabel(tr("window (bp)"));
27 parameterLayout->addWidget(windowLabel, 0, 1);
28 window = new QSpinBox(this);
30 parameterLayout->addWidget(window, 1, 1);
32 ok = new QPushButton(tr("&OK"), this);
33 ok->setEnabled( false );
34 connect(ok, SIGNAL(clicked()), this, SLOT(run()));
36 cancel = new QPushButton(tr("Cancel"), this);
37 connect(cancel, SIGNAL(clicked()), this, SLOT(abort()));
39 table = new QTableView(this);
40 table->setModel(&model);
43 QHBoxLayout *buttonLayout = new QHBoxLayout;
44 buttonLayout->addWidget(ok);
45 buttonLayout->addWidget(cancel);
47 // layout verticle space
48 QVBoxLayout *verticalLayout = new QVBoxLayout;
49 verticalLayout->addLayout(parameterLayout);
50 verticalLayout->addWidget(table);
51 verticalLayout->addLayout(buttonLayout);
52 setLayout(verticalLayout);
54 // now that we're all setup lets get notices when we're updated
55 connect(&model, SIGNAL(rowsInserted(const QModelIndex&, int, int)),
56 this, SLOT(modelUpdated(const QModelIndex&, int, int)));
57 connect(&model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
58 this, SLOT(modelUpdated(const QModelIndex&, int, int)));
61 SequenceLocationModel& SubanalysisWindow::getModel()
66 void SubanalysisWindow::abort()
72 void SubanalysisWindow::run()
74 if (window == 0 or threshold == 0) {
75 throw std::runtime_error("SubanalysisWindow misconstructed");
78 if (model.size() == 0) {
79 throw std::runtime_error("It shouldn't be possible to call run with an "
83 std::auto_ptr<Mussa> m(new Mussa);
85 for(SequenceLocationModel::iterator itor = model.begin();
89 // append_sequence from a const Sequence & will make a copy
90 // for the shared pointer.
91 m->append_sequence(itor->getSelectedSequence());
94 m->set_window(window->value());
95 m->set_threshold(threshold->value());
97 MussaWindow *mw = new MussaWindow(m.get());
103 void SubanalysisWindow::modelUpdated(const QModelIndex&, int, int )
105 // if the model is empty we shouldn't be able to click ok
106 if (ok) ok->setEnabled(not model.empty());