parameterLayout->addWidget(window, 1, 1);
ok = new QPushButton(tr("&OK"), this);
+ ok->setEnabled( false );
connect(ok, SIGNAL(clicked()), this, SLOT(run()));
+
cancel = new QPushButton(tr("Cancel"), this);
connect(cancel, SIGNAL(clicked()), this, SLOT(abort()));
+
table = new QTableView(this);
table->setModel(&model);
verticalLayout->addWidget(table);
verticalLayout->addLayout(buttonLayout);
setLayout(verticalLayout);
+
+ // now that we're all setup lets get notices when we're updated
+ connect(&model, SIGNAL(rowsInserted(const QModelIndex&, int, int)),
+ this, SLOT(modelUpdated(const QModelIndex&, int, int)));
+ connect(&model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
+ this, SLOT(modelUpdated(const QModelIndex&, int, int)));
}
SequenceLocationModel& SubanalysisWindow::getModel()
void SubanalysisWindow::run()
{
- if (window == 0 or threshold == 0)
+ if (window == 0 or threshold == 0) {
throw std::runtime_error("SubanalysisWindow misconstructed");
+ }
+
+ if (model.size() == 0) {
+ throw std::runtime_error("It shouldn't be possible to call run with an "
+ "empty model now.");
+ }
std::auto_ptr<Mussa> m(new Mussa);
hide();
}
+void SubanalysisWindow::modelUpdated(const QModelIndex&, int, int )
+{
+ // if the model is empty we shouldn't be able to click ok
+ if (ok) ok->setEnabled(not model.empty());
+}