Skip to content

Commit

Permalink
Only refresh canvas when needed on drop event
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jun 6, 2013
1 parent e7ea582 commit 46fedf9
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/app/qgisapp.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ void QgisApp::dragEnterEvent( QDragEnterEvent *event )


void QgisApp::dropEvent( QDropEvent *event ) void QgisApp::dropEvent( QDropEvent *event )
{ {
mMapCanvas->freeze();
// get the file list // get the file list
QList<QUrl>::iterator i; QList<QUrl>::iterator i;
QList<QUrl>urls = event->mimeData()->urls(); QList<QUrl>urls = event->mimeData()->urls();
Expand All @@ -817,6 +818,7 @@ void QgisApp::dropEvent( QDropEvent *event )
openFile( fileName ); openFile( fileName );
} }
} }

if ( QgsMimeDataUtils::isUriList( event->mimeData() ) ) if ( QgsMimeDataUtils::isUriList( event->mimeData() ) )
{ {
QgsMimeDataUtils::UriList lst = QgsMimeDataUtils::decodeUriList( event->mimeData() ); QgsMimeDataUtils::UriList lst = QgsMimeDataUtils::decodeUriList( event->mimeData() );
Expand All @@ -832,7 +834,8 @@ void QgisApp::dropEvent( QDropEvent *event )
} }
} }
} }

mMapCanvas->freeze(false);
mMapCanvas->refresh();
event->acceptProposedAction(); event->acceptProposedAction();
} }


Expand Down Expand Up @@ -2486,6 +2489,7 @@ void QgisApp::addVectorLayer()


bool QgisApp::addVectorLayers( QStringList const & theLayerQStringList, const QString& enc, const QString dataSourceType ) bool QgisApp::addVectorLayers( QStringList const & theLayerQStringList, const QString& enc, const QString dataSourceType )
{ {
bool wasfrozen = mMapCanvas->isFrozen();
QList<QgsMapLayer *> myList; QList<QgsMapLayer *> myList;
foreach ( QString src, theLayerQStringList ) foreach ( QString src, theLayerQStringList )
{ {
Expand Down Expand Up @@ -2590,10 +2594,13 @@ bool QgisApp::addVectorLayers( QStringList const & theLayerQStringList, const QS
// update UI // update UI
qApp->processEvents(); qApp->processEvents();


// draw the map // Only update the map if we frozen in this method
mMapCanvas->freeze( false ); // Let the caller do it otherwise
mMapCanvas->refresh(); if ( !wasfrozen )

{
mMapCanvas->freeze( false );
mMapCanvas->refresh();
}
// Let render() do its own cursor management // Let render() do its own cursor management
// QApplication::restoreOverrideCursor(); // QApplication::restoreOverrideCursor();


Expand Down Expand Up @@ -6743,6 +6750,8 @@ QgsVectorLayer* QgisApp::addVectorLayer( QString vectorLayerPath, QString baseNa
return NULL; return NULL;
} }


bool wasfrozen = mMapCanvas->isFrozen();

mMapCanvas->freeze(); mMapCanvas->freeze();


// Let render() do its own cursor management // Let render() do its own cursor management
Expand Down Expand Up @@ -6797,9 +6806,13 @@ QgsVectorLayer* QgisApp::addVectorLayer( QString vectorLayerPath, QString baseNa
// update UI // update UI
qApp->processEvents(); qApp->processEvents();


// draw the map // Only update the map if we frozen in this method
mMapCanvas->freeze( false ); // Let the caller do it otherwise
mMapCanvas->refresh(); if ( !wasfrozen )
{
mMapCanvas->freeze( false );
mMapCanvas->refresh();
}


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

0 comments on commit 46fedf9

Please sign in to comment.