mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Fix clazy qfileinfo-exists warnings
From the clazy docs: Finds places using QFileInfo("foo").exists() instead of the faster version QFileInfo::exists("foo"). According to Qt's docs: "Using this function is faster than using QFileInfo(file).exists() for file system access."
This commit is contained in:
parent
ef5110732b
commit
f2672151c2
@ -84,7 +84,7 @@ void QgsOSMImportDialog::dbFileNameChanged( const QString& fileName )
|
||||
void QgsOSMImportDialog::onOK()
|
||||
{
|
||||
// output file exists?
|
||||
if ( QFileInfo( editDbFileName->text() ).exists() )
|
||||
if ( QFileInfo::exists( editDbFileName->text() ) )
|
||||
{
|
||||
int res = QMessageBox::question( this, tr( "OpenStreetMap import" ), tr( "Output database file exists already. Overwrite?" ), QMessageBox::Yes | QMessageBox::No );
|
||||
if ( res != QMessageBox::Yes )
|
||||
|
@ -1765,7 +1765,7 @@ void QgisApp::createActions()
|
||||
mActionReportaBug->setShortcut( QString() );
|
||||
#endif
|
||||
|
||||
mActionHelpContents->setEnabled( QFileInfo( QgsApplication::pkgDataPath() + "/doc/index.html" ).exists() );
|
||||
mActionHelpContents->setEnabled( QFileInfo::exists( QgsApplication::pkgDataPath() + "/doc/index.html" ) );
|
||||
|
||||
connect( mActionHelpContents, SIGNAL( triggered() ), this, SLOT( helpContents() ) );
|
||||
connect( mActionHelpAPI, SIGNAL( triggered() ), this, SLOT( apiDocumentation() ) );
|
||||
@ -9185,7 +9185,7 @@ void QgisApp::helpContents()
|
||||
|
||||
void QgisApp::apiDocumentation()
|
||||
{
|
||||
if ( QFileInfo( QgsApplication::pkgDataPath() + "/doc/api/index.html" ).exists() )
|
||||
if ( QFileInfo::exists( QgsApplication::pkgDataPath() + "/doc/api/index.html" ) )
|
||||
{
|
||||
openURL( "api/index.html" );
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ QString QgsHandleBadLayers::filename( int row )
|
||||
|
||||
void QgsHandleBadLayers::setFilename( int row, const QString& filename )
|
||||
{
|
||||
if ( !QFileInfo( filename ).exists() )
|
||||
if ( !QFileInfo::exists( filename ) )
|
||||
return;
|
||||
|
||||
QString type = mLayerList->item( row, 1 )->text();
|
||||
|
@ -48,7 +48,7 @@ QList< QPair<QString, QString> > QgsGPSDetector::availablePorts()
|
||||
{
|
||||
for ( int i = 0; i < 10; ++i )
|
||||
{
|
||||
if ( QFileInfo( linuxDev.arg( i ) ).exists() )
|
||||
if ( QFileInfo::exists( linuxDev.arg( i ) ) )
|
||||
{
|
||||
devs << QPair<QString, QString>( linuxDev.arg( i ), linuxDev.arg( i ) );
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ void QgsCodeEditorPython::setSciLexerPython()
|
||||
}
|
||||
else if ( mAPISFilesList.length() == 1 && mAPISFilesList[0].right( 3 ) == "pap" )
|
||||
{
|
||||
if ( !QFileInfo( mAPISFilesList[0] ).exists() )
|
||||
if ( !QFileInfo::exists( mAPISFilesList[0] ) )
|
||||
{
|
||||
QgsDebugMsg( QString( "The apis file %1 not found" ).arg( mAPISFilesList.at( 0 ) ) );
|
||||
return;
|
||||
@ -86,7 +86,7 @@ void QgsCodeEditorPython::setSciLexerPython()
|
||||
{
|
||||
for ( int i = 0; i < mAPISFilesList.size(); i++ )
|
||||
{
|
||||
if ( !QFileInfo( mAPISFilesList[i] ).exists() )
|
||||
if ( !QFileInfo::exists( mAPISFilesList[i] ) )
|
||||
{
|
||||
QgsDebugMsg( QString( "The apis file %1 was not found" ).arg( mAPISFilesList.at( i ) ) );
|
||||
return;
|
||||
|
@ -308,7 +308,7 @@ QString QgsProjectionSelector::selectedProj4String()
|
||||
if ( srsId.toLong() >= USER_CRS_START_ID )
|
||||
{
|
||||
databaseFileName = QgsApplication::qgisUserDbFilePath();
|
||||
if ( !QFileInfo( databaseFileName ).exists() ) //its unlikely that this condition will ever be reached
|
||||
if ( !QFileInfo::exists( databaseFileName ) ) //its unlikely that this condition will ever be reached
|
||||
return QString();
|
||||
}
|
||||
else //must be a system projection then
|
||||
@ -372,7 +372,7 @@ QString QgsProjectionSelector::getSelectedExpression( const QString& expression
|
||||
if ( lvi->text( QGIS_CRS_ID_COLUMN ).toLong() >= USER_CRS_START_ID )
|
||||
{
|
||||
databaseFileName = QgsApplication::qgisUserDbFilePath();
|
||||
if ( !QFileInfo( databaseFileName ).exists() )
|
||||
if ( !QFileInfo::exists( databaseFileName ) )
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
@ -483,7 +483,7 @@ void QgsProjectionSelector::loadUserCrsList( QSet<QString> *crsFilter )
|
||||
// if it doesnt exist we copy it in from the global resources dir
|
||||
|
||||
//return straight away if the user has not created any custom projections
|
||||
if ( !QFileInfo( databaseFileName ).exists() )
|
||||
if ( !QFileInfo::exists( databaseFileName ) )
|
||||
{
|
||||
QgsDebugMsg( "Users qgis.db not found...skipping" );
|
||||
mUserProjListDone = true;
|
||||
@ -566,7 +566,7 @@ void QgsProjectionSelector::loadCrsList( QSet<QString> *crsFilter )
|
||||
//read only filesystem because otherwise sqlite will try
|
||||
//to create the db file on the fly
|
||||
|
||||
if ( !QFileInfo( mSrsDatabaseFileName ).exists() )
|
||||
if ( !QFileInfo::exists( mSrsDatabaseFileName ) )
|
||||
{
|
||||
mProjListDone = true;
|
||||
return;
|
||||
@ -888,7 +888,7 @@ long QgsProjectionSelector::getLargestCrsIdMatch( const QString& theSql )
|
||||
|
||||
//check the db is available
|
||||
QString databaseFileName = QgsApplication::qgisUserDbFilePath();
|
||||
if ( QFileInfo( databaseFileName ).exists() ) //only bother trying to open if the file exists
|
||||
if ( QFileInfo::exists( databaseFileName ) ) //only bother trying to open if the file exists
|
||||
{
|
||||
result = sqlite3_open_v2( databaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
|
||||
if ( result )
|
||||
|
@ -2036,7 +2036,7 @@ void QgsSvgMarkerSymbolLayerWidget::on_mFileToolButton_clicked()
|
||||
|
||||
void QgsSvgMarkerSymbolLayerWidget::on_mFileLineEdit_textEdited( const QString& text )
|
||||
{
|
||||
if ( !QFileInfo( text ).exists() )
|
||||
if ( !QFileInfo::exists( text ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -2047,7 +2047,7 @@ void QgsSvgMarkerSymbolLayerWidget::on_mFileLineEdit_textEdited( const QString&
|
||||
|
||||
void QgsSvgMarkerSymbolLayerWidget::on_mFileLineEdit_editingFinished()
|
||||
{
|
||||
if ( !QFileInfo( mFileLineEdit->text() ).exists() )
|
||||
if ( !QFileInfo::exists( mFileLineEdit->text() ) )
|
||||
{
|
||||
QUrl url( mFileLineEdit->text() );
|
||||
if ( !url.isValid() )
|
||||
|
@ -670,7 +670,7 @@ bool QgsDelimitedTextSourceSelect::validate()
|
||||
{
|
||||
message = tr( "Please select an input file" );
|
||||
}
|
||||
else if ( ! QFileInfo( txtFilePath->text() ).exists() )
|
||||
else if ( ! QFileInfo::exists( txtFilePath->text() ) )
|
||||
{
|
||||
message = tr( "File %1 does not exist" ).arg( txtFilePath->text() );
|
||||
}
|
||||
|
@ -759,7 +759,7 @@ void QgsGrass::setMapsetSearchPathWatcher()
|
||||
|
||||
QString searchFilePath = getDefaultMapsetPath() + "/SEARCH_PATH";
|
||||
|
||||
if ( QFileInfo( searchFilePath ).exists() )
|
||||
if ( QFileInfo::exists( searchFilePath ) )
|
||||
{
|
||||
QgsDebugMsg( "add watcher on SEARCH_PATH file " + searchFilePath );
|
||||
mMapsetSearchPathWatcher->addPath( searchFilePath );
|
||||
@ -781,7 +781,7 @@ void QgsGrass::onSearchPathFileChanged( const QString & path )
|
||||
{
|
||||
// changed or removed
|
||||
loadMapsetSearchPath();
|
||||
if ( !QFileInfo( searchFilePath ).exists() ) // removed
|
||||
if ( !QFileInfo::exists( searchFilePath ) ) // removed
|
||||
{
|
||||
// reset watcher to mapset
|
||||
setMapsetSearchPathWatcher();
|
||||
@ -790,7 +790,7 @@ void QgsGrass::onSearchPathFileChanged( const QString & path )
|
||||
else
|
||||
{
|
||||
// mapset directory changed
|
||||
if ( QFileInfo( searchFilePath ).exists() ) // search path file added
|
||||
if ( QFileInfo::exists( searchFilePath ) ) // search path file added
|
||||
{
|
||||
loadMapsetSearchPath();
|
||||
setMapsetSearchPathWatcher();
|
||||
|
@ -804,7 +804,7 @@ bool QgsGrassExternal::import()
|
||||
QString cmd = QgsGrass::gisbase() + "/bin/r.external";
|
||||
QStringList arguments;
|
||||
|
||||
if ( QFileInfo( mSource ).exists() )
|
||||
if ( QFileInfo::exists( mSource ) )
|
||||
{
|
||||
arguments << "input=" + mSource;
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ bool QgsGrassVectorMap::mapOutdated()
|
||||
{
|
||||
// If the cidx file has been deleted, the map is currently being modified
|
||||
// by an external tool. Do not update until the cidx file has been recreated.
|
||||
if ( !QFileInfo( dp + "/cidx" ).exists() )
|
||||
if ( !QFileInfo::exists( dp + "/cidx" ) )
|
||||
{
|
||||
QgsDebugMsg( "The map is being modified and is unavailable : " + mGrassObject.toString() );
|
||||
return false;
|
||||
|
@ -298,7 +298,7 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
|
||||
if ( suffix == "dbf" )
|
||||
{
|
||||
QString pathShp = thePath.left( thePath.count() - 4 ) + ".shp";
|
||||
if ( QFileInfo( pathShp ).exists() )
|
||||
if ( QFileInfo::exists( pathShp ) )
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ void TestQgsWcsPublicServers::test()
|
||||
QString myPath = myVersionDirPath + '/' + myCoverage.identifier;
|
||||
QString myLogPath = myPath + ".log";
|
||||
|
||||
if ( QFileInfo( myLogPath ).exists() && !mForce )
|
||||
if ( QFileInfo::exists( myLogPath ) && !mForce )
|
||||
{
|
||||
//QMap<QString, QString> log = readLog( myLogPath );
|
||||
//if ( !log.value( "identifier" ).isEmpty() && log.value( "error" ).isEmpty() ) continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user