void AMDataSourcesEditor::onSetViewIndexChanged(const QModelIndex &selected, const QModelIndex &deselected) {

	removeDetailEditor();

	// Nothing selected?
	////////////////////////
	if(!selected.isValid()) {
		nameEdit_->clear();
		descriptionEdit_->clear();
		descriptionEdit_->setReadOnly(true);
		addDataSourceButton_->setDisabled(true);
		return;
	}

	addDataSourceButton_->setEnabled(true);

	// Scan selected? (No selected data source)
	/////////////////////////
	if(!selected.parent().isValid()) {
		nameEdit_->clear();
		descriptionEdit_->clear();
		descriptionEdit_->setReadOnly(true);
		return;
	}


	// Data source selected.
	/////////////////

	// Remove old connection to the data source description.
	int oldSi = deselected.parent().row();
	int oldDi = deselected.row();
	AMDataSource *oldDataSource = model_->dataSourceAt(oldSi, oldDi);
	if (oldDataSource)
		disconnect(oldDataSource->signalSource(), SIGNAL(infoChanged()), this, SLOT(onDataSourceDescriptionChanged()));

	// Setup new data source.
	int si = selected.parent().row();
	int di = selected.row();
	AMDataSource* dataSource = model_->dataSourceAt(si, di);
	if(!dataSource)
		return;

	connect(dataSource->signalSource(), SIGNAL(infoChanged()), this, SLOT(onDataSourceDescriptionChanged()));

	nameEdit_->setText(dataSource->name());
	descriptionEdit_->setText(dataSource->description());
	descriptionEdit_->setReadOnly(false);

	installDetailEditor(dataSource->createEditorWidget());

	// Set the new selected data source as the exclusive view preference.
	model_->setExclusiveDataSourceByName(dataSource->name());
}
Beispiel #2
0
void AMAnalysisBlock::onInputSourceDeleted(void* deletedSource) {
	// this implementation is just like calling setInputDataSources() with an empty list, except we don't want to call deregisterObserver() on the deleted input source. (In a single-threaded situation, this would be okay, but if the deleted() signal came through a queued signal-slot connection, then that object might already be deleted)
	for(int i=0; i<inputDataSourceCount(); i++) {
		AMDataSource* oldSource = inputDataSourceAt(i);
		if(oldSource != deletedSource) {
			disconnect(oldSource->signalSource(), SIGNAL(deleted(void*)), this, SLOT(onInputSourceDeleted(void*)));
			oldSource->deregisterObserver(this);
		}
	}
Beispiel #3
0
bool AMAnalysisBlock::setInputDataSources(const QList<AMDataSource*>& dataSources) {
	// if a non-empty set of data sources has been provided, and they are not acceptable, return false.  (An empty list must always be acceptable)
	if(!dataSources.isEmpty() && !areInputDataSourcesAcceptable(dataSources)) {
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -98, QString("There was an error connecting the input data sources to this analysis component '%1: %2'. The data sources provided weren't acceptable. This can happen if they have the wrong dimension, don't provide enough data, etc.").arg(name()).arg(description())));
		return false;
	}

	for(int i=0; i<inputDataSourceCount(); i++) {
		AMDataSource* oldSource = inputDataSourceAt(i);
		disconnect(oldSource->signalSource(), SIGNAL(deleted(void*)), this, SLOT(onInputSourceDeleted(void*)));
		oldSource->deregisterObserver(this);
	}

	for(int i=0; i<dataSources.count(); i++) {
		AMDataSource* newSource = dataSources.at(i);
		connect(newSource->signalSource(), SIGNAL(deleted(void*)), this, SLOT(onInputSourceDeleted(void*)));
		dataSources.at(i)->registerObserver(this);
	}

	setInputDataSourcesImplementation(dataSources);

	emit inputSourcesChanged();
	return true;
}