Skip to content

Commit

Permalink
Merge pull request #33270 from roya0045/handler_v2
Browse files Browse the repository at this point in the history
[UX][feature??] add progress bar to the auto layer finder
  • Loading branch information
m-kuhn committed Dec 18, 2019
2 parents 630d0da + 5ce38d6 commit 79c7ca3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/app/qgshandlebadlayers.cpp
Expand Up @@ -40,6 +40,7 @@
#include <QDialogButtonBox>
#include <QUrl>
#include <QDir>
#include <QProgressDialog>

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


QgsHandleBadLayers::QgsHandleBadLayers( const QList<QDomNode> &layers )
: QDialog( QgisApp::instance() )
, mLayers( layers )
Expand Down Expand Up @@ -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();
Expand All @@ -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" ) )
Expand Down Expand Up @@ -643,6 +653,7 @@ void QgsHandleBadLayers::autoFind()
item->setForeground( QBrush( Qt::red ) );
}
}

}

QgsProject::instance()->layerTreeRegistryBridge()->setEnabled( false );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgshandlebadlayers.h
Expand Up @@ -43,7 +43,6 @@ class APP_EXPORT QgsHandleBadLayersHandler

};


class QPushButton;

class APP_EXPORT QgsHandleBadLayers
Expand Down Expand Up @@ -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.