2 changes: 2 additions & 0 deletions src/core/qgsproviderregistry.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ QgsDataProvider *QgsProviderRegistry::provider( QString const & providerKey, QSt
{
QgsLogger::warning( "Unable to instantiate the data provider plugin" );

delete dataProvider;

myLib->unload();
delete myLib;
return 0;
Expand Down
1 change: 0 additions & 1 deletion src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2800,7 +2800,6 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
else
{
QgsDebugMsg( " unable to get data provider" );

return false;
}

Expand Down
29 changes: 24 additions & 5 deletions src/plugins/delimited_text/qgsdelimitedtextplugingui.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ QgsDelimitedTextPluginGui::QgsDelimitedTextPluginGui( QgisInterface * _qI, QWidg
cmbWktField->setDisabled( true );

connect( txtFilePath, SIGNAL( textChanged( QString ) ), this, SLOT( updateFieldsAndEnable() ) );
connect( decimalPoint, SIGNAL( textChanged( QString ) ), this, SLOT( updateFieldsAndEnable() ) );

connect( delimiterSelection, SIGNAL( toggled( bool ) ), this, SLOT( updateFieldsAndEnable() ) );
connect( delimiterPlain, SIGNAL( toggled( bool ) ), this, SLOT( updateFieldsAndEnable() ) );
Expand Down Expand Up @@ -110,6 +111,11 @@ void QgsDelimitedTextPluginGui::on_buttonBox_accepted()
url.addQueryItem( "delimiter", txtDelimiter->text() );
url.addQueryItem( "delimiterType", delimiterType );

if ( !decimalPoint->text().isEmpty() )
{
url.addQueryItem( "decimalPoint", decimalPoint->text() );
}

if ( geomTypeXY->isChecked() )
{
if ( !cmbXField->currentText().isEmpty() && !cmbYField->currentText().isEmpty() )
Expand Down Expand Up @@ -258,6 +264,9 @@ void QgsDelimitedTextPluginGui::updateFieldLists()
cmbYField->setEnabled( false );
cmbWktField->setEnabled( false );

// clear the sample text box
tblSample->clear();

if ( ! haveValidFileAndDelimiters() )
return;

Expand Down Expand Up @@ -374,7 +383,6 @@ void QgsDelimitedTextPluginGui::updateFieldLists()
cmbYField->setEnabled( isXY );
cmbWktField->setEnabled( ! isXY );


connect( cmbXField, SIGNAL( currentIndexChanged( int ) ), this, SLOT( enableAccept() ) );
connect( cmbYField, SIGNAL( currentIndexChanged( int ) ), this, SLOT( enableAccept() ) );
connect( cmbWktField, SIGNAL( currentIndexChanged( int ) ), this, SLOT( enableAccept() ) );
Expand All @@ -383,9 +391,6 @@ void QgsDelimitedTextPluginGui::updateFieldLists()
connect( geomTypeXY, SIGNAL( toggled( bool ) ), cmbWktField, SLOT( setDisabled( bool ) ) );
}

// clear the sample text box
tblSample->clear();

tblSample->setColumnCount( fieldList.size() );
tblSample->setHorizontalHeaderLabels( fieldList );

Expand All @@ -400,7 +405,21 @@ void QgsDelimitedTextPluginGui::updateFieldLists()

for ( int i = 0; i < tblSample->columnCount(); i++ )
{
tblSample->setItem( counter, i, new QTableWidgetItem( i < values.size() ? values[i] : "" ) );
QString value = i < values.size() ? values[i] : "";
bool ok = true;
if ( i == indexX || i == indexY )
{
if ( !decimalPoint->text().isEmpty() )
{
value.replace( decimalPoint->text(), "." );
}

value.toDouble( &ok );
}
QTableWidgetItem *item = new QTableWidgetItem( value );
if ( !ok )
item->setTextColor( Qt::red );
tblSample->setItem( counter, i, item );
}

counter++;
Expand Down
10 changes: 10 additions & 0 deletions src/plugins/delimited_text/qgsdelimitedtextpluginguibase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,16 @@
</property>
</spacer>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="decimalPoint"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Decimal point</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
49 changes: 25 additions & 24 deletions src/plugins/globe/globe_plugin.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,25 @@ static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;

//constructor
GlobePlugin::GlobePlugin( QgisInterface* theQgisInterface )
: QgisPlugin( sName, sDescription, sPluginVersion, sPluginType ),
mQGisIface( theQgisInterface ),
mQActionPointer( NULL ),
mQActionSettingsPointer( NULL ),
viewer(),
mQDockWidget( tr( "Globe" ) ),
mSettingsDialog( &viewer, theQgisInterface->mainWindow(), QgisGui::ModalDialogFlags ),
mQgisMapLayer( 0 ),
mTileSource( 0 ),
mElevationManager( NULL ),
mObjectPlacer( NULL )
: QgisPlugin( sName, sDescription, sPluginVersion, sPluginType )
, mQGisIface( theQgisInterface )
, mQActionPointer( NULL )
, mQActionSettingsPointer( NULL )
, viewer()
, mQgisMapLayer( 0 )
, mTileSource( 0 )
, mElevationManager( NULL )
, mObjectPlacer( NULL )
{
mIsGlobeRunning = false;
//needed to be "seen" by other plugins by doing
//iface.mainWindow().findChild( QObject, "globePlugin" )
//needed until https://trac.osgeo.org/qgis/changeset/15224
this->setObjectName( "globePlugin" );
this->setParent( theQgisInterface->mainWindow() );

mSettingsDialog = new QgsGlobePluginDialog( &viewer, theQgisInterface->mainWindow(), QgisGui::ModalDialogFlags );
mQDockWidget = new QDockWidgetGlobe( tr( "Globe" ), theQgisInterface->mainWindow() );
}

//destructor
Expand Down Expand Up @@ -190,19 +191,19 @@ void GlobePlugin::initGui()
//Add menu
mQGisIface->addPluginToMenu( tr( "&Globe" ), mQActionPointer );
mQGisIface->addPluginToMenu( tr( "&Globe" ), mQActionSettingsPointer );
mQDockWidget.setWidget( &viewer );
mQDockWidget->setWidget( &viewer );

connect( mQGisIface->mapCanvas() , SIGNAL( extentsChanged() ),
this, SLOT( extentsChanged() ) );
connect( mQGisIface->mapCanvas(), SIGNAL( layersChanged() ),
this, SLOT( layersChanged() ) );
connect( &mSettingsDialog, SIGNAL( elevationDatasourcesChanged() ),
connect( mSettingsDialog, SIGNAL( elevationDatasourcesChanged() ),
this, SLOT( layersChanged() ) );
connect( mQGisIface->mainWindow(), SIGNAL( projectRead() ), this,
SLOT( projectReady() ) );
connect( mQGisIface, SIGNAL( newProjectCreated() ), this,
SLOT( blankProjectReady() ) );
connect( &mQDockWidget, SIGNAL( globeClosed() ), this,
connect( mQDockWidget, SIGNAL( globeClosed() ), this,
SLOT( setGlobeNotRunning() ) );
connect( this, SIGNAL( xyCoordinates( const QgsPoint & ) ),
mQGisIface->mapCanvas(), SIGNAL( xyCoordinates( const QgsPoint & ) ) );
Expand All @@ -214,7 +215,7 @@ void GlobePlugin::run()
if ( !getenv( "OSGNOTIFYLEVEL" ) ) osgEarth::setNotifyLevel( osg::DEBUG_INFO );
#endif

mQGisIface->addDockWidget( Qt::RightDockWidgetArea, &mQDockWidget );
mQGisIface->addDockWidget( Qt::RightDockWidgetArea, mQDockWidget );

viewer.show();

Expand Down Expand Up @@ -266,8 +267,8 @@ void GlobePlugin::run()

void GlobePlugin::settings()
{
mSettingsDialog.updatePointLayers();
if ( mSettingsDialog.exec() )
mSettingsDialog->updatePointLayers();
if ( mSettingsDialog->exec() )
{
//viewer stereo settings set by mSettingsDialog and stored in QSettings
}
Expand Down Expand Up @@ -324,12 +325,12 @@ void GlobePlugin::setupMap()
mObjectPlacer = new osgEarth::Util::ObjectPlacer( mMapNode );

// place 3D model on point layer
if ( mSettingsDialog.modelLayer() && !mSettingsDialog.modelPath().isEmpty() )
if ( mSettingsDialog->modelLayer() && !mSettingsDialog->modelPath().isEmpty() )
{
osg::Node* model = osgDB::readNodeFile( mSettingsDialog.modelPath().toStdString() );
osg::Node* model = osgDB::readNodeFile( mSettingsDialog->modelPath().toStdString() );
if ( model )
{
QgsVectorLayer* layer = mSettingsDialog.modelLayer();
QgsVectorLayer* layer = mSettingsDialog->modelLayer();
QgsAttributeList fetchAttributes;
layer->select( fetchAttributes ); //TODO: select only visible features
QgsFeature feature;
Expand All @@ -346,13 +347,13 @@ void GlobePlugin::setupMap()
void GlobePlugin::projectReady()
{
blankProjectReady();
mSettingsDialog.readElevationDatasources();
mSettingsDialog->readElevationDatasources();
}

void GlobePlugin::blankProjectReady()
{ //needs at least http://trac.osgeo.org/qgis/changeset/14452
mSettingsDialog.elevationDatasources()->clearContents();
mSettingsDialog.elevationDatasources()->setRowCount( 0 );
mSettingsDialog->elevationDatasources()->clearContents();
mSettingsDialog->elevationDatasources()->setRowCount( 0 );
}

void GlobePlugin::showCurrentCoordinates( double lon, double lat )
Expand Down Expand Up @@ -696,7 +697,7 @@ void GlobePlugin::layersChanged()
// Add elevation layers
QSettings settings;
QString cacheDirectory = settings.value( "cache/directory", QgsApplication::qgisSettingsDirPath() + "cache" ).toString();
QTableWidget* table = mSettingsDialog.elevationDatasources();
QTableWidget* table = mSettingsDialog->elevationDatasources();
for ( int i = 0; i < table->rowCount(); ++i )
{
QString type = table->item( i, 0 )->text();
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/globe/globe_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ class GlobePlugin : public QObject, public QgisPlugin
//! OSG Viewer
QgsOsgViewer viewer;
//! Dock widget for viewer
QDockWidgetGlobe mQDockWidget;
QDockWidgetGlobe *mQDockWidget;
//! Settings Dialog
QgsGlobePluginDialog mSettingsDialog;
QgsGlobePluginDialog *mSettingsDialog;
//! OSG root node
osg::Group* mRootNode;
//! Map node
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/globe/globe_plugin_dialog.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ QgsGlobePluginDialog::~QgsGlobePluginDialog()
QString QgsGlobePluginDialog::openRasterFile()
{
//see http://www.gdal.org/formats_list.html
const char* filter = "GDAL files (*.dem *.tif *.tiff *.jpg *.jpeg *.asc) \
;;DEM files (*.dem) \
;;All files (*.*)";
QString filter = tr( "GDAL files" ) + " (*.dem *.tif *.tiff *.jpg *.jpeg *.asc);;"
+ tr( "DEM files" ) + " (*.dem);;"
+ tr( "All files" ) + " (*.*)";
QString path = QFileDialog::getOpenFileName( this,
tr( "Open raster file" ),
QDir::homePath(),
tr( filter ) );
filter );

return path;
}
Expand Down
22 changes: 20 additions & 2 deletions src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri )
mSkipLines = url.queryItemValue( "skipLines" ).toInt();
if ( url.hasQueryItem( "crs" ) )
mCrs.createFromString( url.queryItemValue( "crs" ) );
if ( url.hasQueryItem( "decimalPoint" ) )
mDecimalPoint = url.queryItemValue( "decimalPoint" );

QgsDebugMsg( "Data source uri is " + uri );
QgsDebugMsg( "Delimited text file is: " + mFileName );
Expand Down Expand Up @@ -367,6 +369,13 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri )
QString sX = parts[mXFieldIndex];
QString sY = parts[mYFieldIndex];


if ( !mDecimalPoint.isEmpty() )
{
sX.replace( mDecimalPoint, "." );
sY.replace( mDecimalPoint, "." );
}

bool xOk = false;
bool yOk = false;
double x = sX.toDouble( &xOk );
Expand Down Expand Up @@ -502,9 +511,18 @@ bool QgsDelimitedTextProvider::nextFeature( QgsFeature& feature )
}
else if ( mXFieldIndex >= 0 && mYFieldIndex >= 0 )
{
QString sX = tokens[mXFieldIndex];
QString sY = tokens[mYFieldIndex];

if ( !mDecimalPoint.isEmpty() )
{
sX.replace( mDecimalPoint, "." );
sY.replace( mDecimalPoint, "." );
}

bool xOk, yOk;
double x = tokens[mXFieldIndex].toDouble( &xOk );
double y = tokens[mYFieldIndex].toDouble( &yOk );
double x = sX.toDouble( &xOk );
double y = sY.toDouble( &yOk );
if ( xOk && yOk )
{
mFid++;
Expand Down
1 change: 1 addition & 0 deletions src/providers/delimitedtext/qgsdelimitedtextprovider.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class QgsDelimitedTextProvider : public QgsVectorDataProvider
long mNumberFeatures;
int mSkipLines;
int mFirstDataLine; // Actual first line of data (accounting for blank lines)
QString mDecimalPoint;

//! Storage for any lines in the file that couldn't be loaded
QStringList mInvalidLines;
Expand Down