void QgsGlobePluginDialog::on_elevationAdd_clicked()
{
  QString errorText;
  bool validationResult = validateResource( elevationCombo->currentText(), elevationPath->text(), errorText );

  QMessageBox msgBox;
  msgBox.setText( errorText );
  msgBox.setInformativeText( tr( "Do you want to add the datasource anyway?" ) );
  msgBox.setIcon( QMessageBox::Warning );
  msgBox.setStandardButtons( QMessageBox::Ok | QMessageBox::Cancel );
  msgBox.setDefaultButton( QMessageBox::Cancel );

  if ( validationResult || msgBox.exec() == QMessageBox::Ok )
  {
    int i = elevationDatasourcesWidget->rowCount();
    QTableWidgetItem *type = new QTableWidgetItem( elevationCombo->currentText() );
    QTableWidgetItem *uri = new QTableWidgetItem( elevationPath->text() );
    QTableWidgetItem* cache = new QTableWidgetItem();
    cache->setCheckState(( elevationCombo->currentText() == "Worldwind" ) ? Qt::Checked : Qt::Unchecked ); //worldwind_cache will be active
    elevationDatasourcesWidget->setRowCount( 1 + i );
    elevationDatasourcesWidget->setItem( i, 0, type );
    elevationDatasourcesWidget->setItem( i, 1, cache );
    elevationDatasourcesWidget->setItem( i, 2, uri );
    elevationDatasourcesWidget->setCurrentItem( type, QItemSelectionModel::Clear );
  }
}
Beispiel #2
0
ResourceHandle ResourceManager::loadResource(ResourceLoadOptions& options)
{
	if( !archive ) return ResourceHandle(HandleInvalid);

	Path fileExt = PathGetFileExtension(options.name);
	
	// If the file has no extension, search for one with the same
	// name but with known resource loadable file extensions.

	if(fileExt.empty() && !findResource(options))
	{
		LogError("Could not find matching file for '%s'", options.name.c_str());
		return ResourceHandle(HandleInvalid);
	}

	// Check if the resource is already loaded.
	ResourceHandle handle = getResource(options.name);
	if( handle ) return handle;

	if( !validateResource(options.name) )
		return ResourceHandle(HandleInvalid);

	Resource* resource = prepareResource(options);
	
	if( !resource )
		return ResourceHandle(HandleInvalid); 

	handle = ResourceHandleCreate(resource);
	
	if(handle == HandleInvalid)
		return ResourceHandle(HandleInvalid);

	// Register the decoded resource in the map.
	Path base = PathGetFile(options.name);
	auto key = MurmurHash64(base.c_str(), base.size(), 0);
	resources.set(key, handle);

	decodeResource(options);

	return handle;
}