Skip to content

Commit

Permalink
Remove unreachable code
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 12, 2021
1 parent 0015228 commit e736899
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 119 deletions.
4 changes: 2 additions & 2 deletions src/app/georeferencer/qgsgeorefmainwindow.cpp
Expand Up @@ -347,11 +347,11 @@ void QgsGeoreferencerMainWindow::doGeoreference()
{
if ( mModifiedRasterFileName.isEmpty() )
{
QgisApp::instance()->addRasterLayer( mRasterFileName, QFileInfo( mRasterFileName ).completeBaseName() );
QgisApp::instance()->addRasterLayer( mRasterFileName, QFileInfo( mRasterFileName ).completeBaseName(), QString() );
}
else
{
QgisApp::instance()->addRasterLayer( mModifiedRasterFileName, QFileInfo( mModifiedRasterFileName ).completeBaseName() );
QgisApp::instance()->addRasterLayer( mModifiedRasterFileName, QFileInfo( mModifiedRasterFileName ).completeBaseName(), QString() );
}

// showMessageInLog(tr("Modified raster saved in"), mModifiedRasterFileName);
Expand Down
99 changes: 4 additions & 95 deletions src/app/qgisapp.cpp
Expand Up @@ -2352,7 +2352,6 @@ void QgisApp::dataSourceManager( const QString &pageName )
connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::showStatusMessage, this, &QgisApp::showStatusMessage );
connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::addDatabaseLayers, this, &QgisApp::addDatabaseLayers );
connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::replaceSelectedVectorLayer, this, &QgisApp::replaceSelectedVectorLayer );
connect( mDataSourceManagerDialog, static_cast<void ( QgsDataSourceManagerDialog::* )()>( &QgsDataSourceManagerDialog::addRasterLayer ), this, static_cast<void ( QgisApp::* )()>( &QgisApp::addRasterLayer ) );
connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::handleDropUriList, this, &QgisApp::handleDropUriList );
connect( this, &QgisApp::newProject, mDataSourceManagerDialog, &QgsDataSourceManagerDialog::updateProjectHome );
connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::openFile, this, &QgisApp::openFile );
Expand Down Expand Up @@ -6008,7 +6007,7 @@ bool QgisApp::askUserForZipItemLayers( const QString &path )
QgsDebugMsgLevel( QStringLiteral( "item path=%1 provider=%2" ).arg( item->path(), layerItem->providerKey() ), 2 );
if ( layerItem->providerKey() == QLatin1String( "gdal" ) )
{
if ( addRasterLayer( item->path(), QFileInfo( item->name() ).completeBaseName() ) )
if ( addRasterLayer( item->path(), QFileInfo( item->name() ).completeBaseName(), QString() ) )
ok = true;
}
else if ( layerItem->providerKey() == QLatin1String( "ogr" ) )
Expand Down Expand Up @@ -6727,7 +6726,7 @@ void QgisApp::showRasterCalculator()
case QgsRasterCalculator::Success:
if ( d.addLayerToProject() )
{
addRasterLayer( d.outputFile(), QFileInfo( d.outputFile() ).completeBaseName() );
addRasterLayer( d.outputFile(), QFileInfo( d.outputFile() ).completeBaseName(), QString() );
}
visibleMessageBar()->pushMessage( tr( "Raster calculator" ),
tr( "Calculation complete." ),
Expand Down Expand Up @@ -15743,74 +15742,7 @@ void QgisApp::renameView()
}
}

/////////////////////////////////////////////////////////////////
//
//
// Only functions relating to raster layer management in this
// section (look for a similar comment block to this to find
// the end of this section).
//
// Tim Sutton
//
//
/////////////////////////////////////////////////////////////////


// this is a slot for action from GUI to open and add raster layers
void QgisApp::addRasterLayer()
{
QStringList selectedFiles;
QString e;//only for parameter correctness
QString title = tr( "Open a GDAL Supported Raster Data Source" );
QgsGuiUtils::openFilesRememberingFilter( QStringLiteral( "lastRasterFileFilter" ), mRasterFileFilter, selectedFiles, e,
title );

if ( selectedFiles.isEmpty() )
{
// no files were selected, so just bail
return;
}

addRasterLayers( selectedFiles );

}

//
// This is the method that does the actual work of adding a raster layer - the others
// here simply create a raster layer object and delegate here. It is the responsibility
// of the calling method to manage things such as the frozen state of the mapcanvas and
// using waitcursors etc. - this method won't and SHOULDN'T do it
//
bool QgisApp::addRasterLayer( QgsRasterLayer *rasterLayer )
{
Q_CHECK_PTR( rasterLayer );

if ( ! rasterLayer )
{
// XXX insert meaningful whine to the user here; although be
// XXX mindful that a null layer may mean exhausted memory resources
return false;
}

if ( !rasterLayer->isValid() )
{
delete rasterLayer;
return false;
}

// register this layer with the central layers registry
QList<QgsMapLayer *> myList;
myList << rasterLayer;
QgsProject::instance()->addMapLayers( myList );

askUserForDatumTransform( rasterLayer->crs(), QgsProject::instance()->crs(), rasterLayer );

return true;
}

QgsRasterLayer *QgisApp::addRasterLayerPrivate(
const QString &uri, const QString &name, const QString &providerKey,
bool guiWarning )
QgsRasterLayer *QgisApp::addRasterLayerPrivate( const QString &uri, const QString &name, const QString &providerKey, bool guiWarning )
{
QString shortName = name;
QRegularExpression reRasterFile( QStringLiteral( "^/vsi(.+/)*([^ ]+)( .+)?$" ), QRegularExpression::CaseInsensitiveOption );
Expand All @@ -15827,14 +15759,7 @@ QgsRasterLayer *QgisApp::addRasterLayerPrivate(
return addLayerPrivate< QgsRasterLayer >( QgsMapLayerType::RasterLayer, uri, shortName, providerKey, guiWarning );
}

QgsRasterLayer *QgisApp::addRasterLayer(
QString const &rasterFile, QString const &baseName, bool guiWarning )
{
return addRasterLayerPrivate( rasterFile, baseName, QString(), guiWarning );
}

QgsRasterLayer *QgisApp::addRasterLayer(
QString const &uri, QString const &baseName, QString const &providerKey )
QgsRasterLayer *QgisApp::addRasterLayer( QString const &uri, QString const &baseName, QString const &providerKey )
{
return addRasterLayerPrivate( uri, baseName, providerKey, true );
}
Expand Down Expand Up @@ -15928,22 +15853,6 @@ bool QgisApp::addRasterLayers( QStringList const &fileNameQStringList, bool guiW

}




///////////////////////////////////////////////////////////////////
//
//
//
//
// RASTER ONLY RELATED FUNCTIONS BLOCK ENDS....
//
//
//
//
///////////////////////////////////////////////////////////////////


QgsPluginLayer *QgisApp::addPluginLayer( const QString &uri, const QString &baseName, const QString &providerKey )
{
QgsPluginLayer *layer = QgsApplication::pluginLayerRegistry()->createLayer( providerKey, uri );
Expand Down
19 changes: 0 additions & 19 deletions src/app/qgisapp.h
Expand Up @@ -212,13 +212,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgisApp( QgisApp const & ) = delete;
QgisApp &operator=( QgisApp const & ) = delete;

/**
* Open a raster layer for the given file
* \returns FALSE if unable to open a raster layer for rasterFile
* \note This is essentially a simplified version of the above
*/
QgsRasterLayer *addRasterLayer( const QString &rasterFile, const QString &baseName, bool guiWarning = true );

/**
* Returns and adjusted uri for the layer based on current and available CRS as well as the last selected image format
* \since QGIS 2.8
Expand Down Expand Up @@ -1752,12 +1745,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
*/
void activateDeactivateLayerRelatedActions( QgsMapLayer *layer );

/**
* \brief Open one or more raster layers and add to the map
* Will prompt user for file names using a file selection dialog
*/
void addRasterLayer();

void selectionChanged( QgsMapLayer *layer );

void extentChanged();
Expand Down Expand Up @@ -2098,12 +2085,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
*/
QList< QgsMapLayer * > askUserForOGRSublayers( QgsVectorLayer *&layerTransferOwnership, const QStringList &subLayers );

/**
* Add a raster layer to the map (passed in as a ptr).
* It won't force a refresh.
*/
bool addRasterLayer( QgsRasterLayer *rasterLayer );

QgsMapLayer *addSublayers( const QList< QgsProviderSublayerDetails> &layers, const QString &baseName, const QString &groupName );

//! Open a raster layer - this is the generic function which takes all parameters
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappinterface.cpp
Expand Up @@ -150,7 +150,7 @@ QgsRasterLayer *QgisAppInterface::addRasterLayer( const QString &rasterLayerPath
QFileInfo fi( rasterLayerPath );
nonNullBaseName = fi.completeBaseName();
}
return qgis->addRasterLayer( rasterLayerPath, nonNullBaseName );
return qgis->addRasterLayer( rasterLayerPath, nonNullBaseName, QString() );
}

QgsRasterLayer *QgisAppInterface::addRasterLayer( const QString &url, const QString &baseName, const QString &providerKey )
Expand Down
2 changes: 0 additions & 2 deletions src/gui/qgsdatasourcemanagerdialog.h
Expand Up @@ -115,8 +115,6 @@ class GUI_EXPORT QgsDataSourceManagerDialog : public QgsOptionsDialogBase, priva
void addRasterLayers( const QStringList &layersList );
//! Emitted when a raster layer was selected for addition: for signal forwarding to QgisApp
void addRasterLayer( const QString &uri, const QString &baseName, const QString &providerKey );
//! Emitted when the user wants to select a raster layer: for signal forwarding to QgisApp
void addRasterLayer();

//! Emitted when a vector layer was selected for addition: for signal forwarding to QgisApp
void addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey );
Expand Down

0 comments on commit e736899

Please sign in to comment.