Skip to content
Permalink
Browse files

Merge pull request #33270 from roya0045/handler_v2

[UX][feature??] add progress bar to the auto layer finder
  • Loading branch information
m-kuhn committed Dec 18, 2019
2 parents 630d0da + 5ce38d6 commit 79c7ca30ee3667cbb4510b09fc90e4eada9166ca
Showing with 13 additions and 2 deletions.
  1. +12 −1 src/app/qgshandlebadlayers.cpp
  2. +1 −1 src/app/qgshandlebadlayers.h
@@ -40,6 +40,7 @@
#include <QDialogButtonBox>
#include <QUrl>
#include <QDir>
#include <QProgressDialog>

void QgsHandleBadLayersHandler::handleBadLayers( const QList<QDomNode> &layers )
{
@@ -72,7 +73,6 @@ void QgsHandleBadLayersHandler::handleBadLayers( const QList<QDomNode> &layers )
QApplication::restoreOverrideCursor();
}


QgsHandleBadLayers::QgsHandleBadLayers( const QList<QDomNode> &layers )
: QDialog( QgisApp::instance() )
, mLayers( layers )
@@ -537,6 +537,9 @@ void QgsHandleBadLayers::autoFind()
}

const QList<int> constLayersToFind = layersToFind;

QProgressDialog progressDialog( QObject::tr( "Searching files" ), 0, 1, layersToFind.size(), this, Qt::Dialog );

for ( int i : constLayersToFind )
{
int idx = mLayerList->item( i, 0 )->data( Qt::UserRole ).toInt();
@@ -552,6 +555,13 @@ void QgsHandleBadLayers::autoFind()
const QString longName = dataInfo.fileName();
QString provider = node.namedItem( QStringLiteral( "provider" ) ).toElement().text();
const QString fileType = mLayerList->item( i, 2 )->text();

progressDialog.setValue( i );
QChar sentenceEnd = ( name.length() > 15 ) ? QChar( 0x2026 ) : '.';
progressDialog.setLabelText( QObject::tr( "Searching for file: %1 \n [ %2 of %3 ] " ).arg( name.left( 15 ) + sentenceEnd,
QString::number( i + 1 ), QString::number( layersToFind.size() ) ) );
progressDialog.open();

if ( provider.toLower() == QStringLiteral( "none" ) )
{
if ( fileType == QStringLiteral( "raster" ) )
@@ -643,6 +653,7 @@ void QgsHandleBadLayers::autoFind()
item->setForeground( QBrush( Qt::red ) );
}
}

}

QgsProject::instance()->layerTreeRegistryBridge()->setEnabled( false );
@@ -43,7 +43,6 @@ class APP_EXPORT QgsHandleBadLayersHandler

};


class QPushButton;

class APP_EXPORT QgsHandleBadLayers
@@ -94,6 +93,7 @@ class APP_EXPORT QgsHandleBadLayers
*/
QString checkBasepath( const QString &layerId, const QString &newPath, const QString &fileName );


};

#endif

0 comments on commit 79c7ca3

Please sign in to comment.
You can’t perform that action at this time.