4 changes: 0 additions & 4 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -321,16 +321,12 @@ ENDIF (POSTGRES_FOUND)

IF (HAVE_SPATIALITE)
SET (QGIS_APP_SRCS ${QGIS_APP_SRCS}
spatialite/qgsspatialitesourceselect.cpp
spatialite/qgsnewspatialitelayerdialog.cpp
spatialite/qgsspatialitesridsdialog.cpp
spatialite/qgsspatialitetablemodel.cpp
)
SET (QGIS_APP_MOC_HDRS ${QGIS_APP_MOC_HDRS}
spatialite/qgsspatialitesourceselect.h
spatialite/qgsnewspatialitelayerdialog.h
spatialite/qgsspatialitesridsdialog.h
spatialite/qgsspatialitetablemodel.h
)
ENDIF (HAVE_SPATIALITE)

Expand Down
9 changes: 7 additions & 2 deletions src/app/legend/qgslegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,12 @@ void QgsLegend::refreshLayerSymbology( QString key, bool expandItem )
}

//store the current item
QModelIndex currentItemIndex( currentIndex() );
QTreeWidgetItem* current = currentItem();
// in case the current item is a child of the layer, use the layer as current item
// because otherwise we would set an invalid item as current item
// (in refreshSymbology the symbology items are removed and new ones are added)
if ( current->parent() == theLegendLayer )
current = current->parent();

double widthScale = 1.0;
if ( mMapCanvas && mMapCanvas->map() )
Expand All @@ -1763,7 +1768,7 @@ void QgsLegend::refreshLayerSymbology( QString key, bool expandItem )
theLegendLayer->refreshSymbology( key, widthScale );

//restore the current item again
setCurrentIndex( currentItemIndex );
setCurrentItem( current );
adjustIconSize();
setItemExpanded( theLegendLayer, expandItem );//make sure the symbology items are visible
}
Expand Down
60 changes: 7 additions & 53 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ extern "C"
{
#include <spatialite.h>
}
#include "spatialite/qgsspatialitesourceselect.h"
#include "spatialite/qgsnewspatialitelayerdialog.h"
#endif

Expand Down Expand Up @@ -2346,62 +2345,17 @@ void QgisApp::addSpatiaLiteLayer()
}

// show the SpatiaLite dialog

QgsSpatiaLiteSourceSelect *dbs = new QgsSpatiaLiteSourceSelect( this );

mMapCanvas->freeze();

if ( dbs->exec() )
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( QString( "spatialite" ), this ) );
if ( !dbs )
{
// Let render() do its own cursor management
// QApplication::setOverrideCursor(Qt::WaitCursor);


// repaint the canvas if it was covered by the dialog

// add files to the map canvas
QStringList tables = dbs->selectedTables();

QApplication::setOverrideCursor( Qt::WaitCursor );

// for each selected table, connect to the database and build a canvasitem for it
QStringList::Iterator it = tables.begin();
while ( it != tables.end() )
{
// create the layer
QgsDataSourceURI uri( *it );
QgsVectorLayer *layer = new QgsVectorLayer( uri.uri(), uri.table(), "spatialite" );
if ( layer->isValid() )
{
// register this layer with the central layers registry
QgsMapLayerRegistry::instance()->addMapLayer( layer );
}
else
{
QgsDebugMsg(( *it ) + " is an invalid layer - not loaded" );
QMessageBox::critical( this, tr( "Invalid Layer" ), tr( "%1 is an invalid layer and cannot be loaded." ).arg( *it ) );
delete layer;
}
//qWarning("incrementing iterator");
++it;
}

QApplication::restoreOverrideCursor();

statusBar()->showMessage( mMapCanvas->extent().toString( 2 ) );
QMessageBox::warning( this, tr( "SpatiaLite" ), tr( "Cannot get SpatiaLite select dialog from provider." ) );
return;
}
connect( dbs , SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
this , SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
dbs->exec();
delete dbs;

// update UI
qApp->processEvents();

// draw the map
mMapCanvas->freeze( false );
mMapCanvas->refresh();

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

} // QgisApp::addSpatiaLiteLayer()
#endif

Expand Down
Loading