Skip to content
Permalink
Browse files

QgsProject: cleanup of read/write method + removal of unused bad laye…

…r handler class
  • Loading branch information
wonder-sk committed Jan 4, 2017
1 parent 8a16632 commit 6c5956b22b2fe31669ac14238be4c32d061497f5
@@ -262,6 +262,7 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
- QgsMapLayerRegistry. Its functionality has been moved to QgsProject.
- QgsMapRenderer. It has been replaced by QgsMapRendererJob with subclasses and QgsMapSettings.
- QgsPseudoColorShader. This shader has been broken for some time and was replaced by QgsSingleBandPseudoColorRenderer.
- QgsProjectBadLayerGuiHandler was removed. It was unused in QGIS code and barely useful. Implement your own QgsProjectBadLayerHandler subclass if needed.
- QgsRendererV2DataDefinedMenus was removed. Use QgsDataDefinedButton instead.
- QgsLegacyHelpers.
- QgsProviderCountCalcEvent and QgsProviderExtentCalcEvent. These classes were unused in QGIS core and unmaintained.
@@ -1381,6 +1382,10 @@ QgsProject {#qgis_api_break_3_0_QgsProject}
- title( const QString & title ) was removed. Use setTitle() instead.
- dirty( bool b ) was removed. Use setDirty() instead.
- clearProperties() was removed. Use clear() instead.
- read( QDomNode& layerNode ) was renamed to readLayer( const QDomNode& layerNode ).
- read( const QFileInfo& file ) was replaced by read( const QString& filename ).
- write( const QFileInfo& file ) was replaced by write( const QString& filename ).


QgsProjectPropertyValue {#qgis_api_break_3_0_QgsProjectPropertyValue}
-----------------------
@@ -106,53 +106,37 @@ class QgsProject : QObject, QgsExpressionContextGenerator
*/
void clear();

/** Reads a project file.
/** Reads given project file from the given file.
* @param file name of project file to read
* @note Any current plug-in state is erased
* @note Calling read() performs the following operations:
*
* - Gets the extents
* - Creates maplayers
* - Registers maplayers
*
* @note it's presumed that the caller has already reset the map canvas, map registry, and legend
* @returns true if project file has been read successfully
*/
bool read( const QFileInfo& file );
bool read( const QString& filename );

/** Reads the current project file.
* @note Any current plug-in state is erased
* @note Calling read() performs the following operations:
*
* - Gets the extents
* - Creates maplayers
* - Registers maplayers
*
* @note it's presumed that the caller has already reset the map canvas, map registry, and legend
/** Reads the project from its currently associated file (see fileName() ).
* @returns true if project file has been read successfully
*/
bool read();

/** Reads the layer described in the associated DOM node.
*
* @param layerNode represents a QgsProject DOM node that encodes a specific layer.
*
* QgsProject raises an exception when one of the QgsProject::read()
* implementations fails. Since the read()s are invoked from qgisapp,
* then qgisapp handles the exception. It prompts the user for the new
* location of the data, if any. If there is a new location, the DOM
* node associated with the layer has its datasource tag corrected.
* Then that node is passed to this member function to be re-opened.
* @note This method is mainly for use by QgsProjectBadLayerHandler subclasses
* that may fix definition of bad layers with the user's help in GUI. Calling
* this method with corrected DOM node adds the layer back to the project.
*
* @param layerNode represents a QgsProject DOM node that encodes a specific layer.
*/
bool read( QDomNode& layerNode );
bool write(const QString& filename);
bool readLayer( const QDomNode& layerNode );

/** Writes the project to a file.
* @param file destination file
/**
* Writes the project to a file.
* @param filename destination file
* @note calling this implicitly sets the project's filename (see setFileName() )
* @note isDirty() will be set to false if project is successfully written
* @returns true if project was written successfully
*
* \note Added in QGIS 3.0
*/
bool write( const QFileInfo& file );
bool write( const QString& filename );

/** Writes the project to its current associated file (see fileName() ).
* @note isDirty() will be set to false if project is successfully written
@@ -32,7 +32,6 @@ class QgsProjectBadLayerHandler
* log.
*
* @note Added in QGIS 3.0
* @see QgsProjectBadLayerGuiHandler
*/
virtual void handleBadLayers( const QList<QDomNode>& layers );
virtual ~QgsProjectBadLayerHandler();
@@ -140,7 +140,6 @@
%Include qgspluginmanagerinterface.sip
%Include qgspresetcolorrampdialog.sip
%Include qgsprevieweffect.sip
%Include qgsprojectbadlayerguihandler.sip
%Include qgsprojectionselectionwidget.sip
%Include qgsprojectionselector.sip
%Include qgsquerybuilder.sip

This file was deleted.

@@ -369,7 +369,7 @@ void QgsHandleBadLayers::apply()
QString datasource = item->text();

node.namedItem( QStringLiteral( "datasource" ) ).toElement().firstChild().toText().setData( datasource );
if ( QgsProject::instance()->read( node ) )
if ( QgsProject::instance()->readLayer( node ) )
{
mLayerList->removeRow( i-- );
}
@@ -973,7 +973,7 @@ void QgsOptions::on_cbxProjectDefaultNew_toggled( bool checked )
void QgsOptions::on_pbnProjectDefaultSetCurrent_clicked()
{
QString fileName = QgsApplication::qgisSettingsDirPath() + QStringLiteral( "project_default.qgs" );
if ( QgsProject::instance()->write( QFileInfo( fileName ) ) )
if ( QgsProject::instance()->write( fileName ) )
{
QMessageBox::information( nullptr, tr( "Save default project" ), tr( "Current project saved as default" ) );
}
@@ -757,9 +757,9 @@ bool QgsProject::addLayer( const QDomElement &layerElem, QList<QDomNode> &broken
}
}

bool QgsProject::read( const QFileInfo& file )
bool QgsProject::read( const QString& filename )
{
mFile.setFileName( file.filePath() );
mFile.setFileName( filename );

return read();
}
@@ -1123,7 +1123,7 @@ void QgsProject::cleanTransactionGroups( bool force )
emit transactionGroupsChanged();
}

bool QgsProject::read( QDomNode &layerNode )
bool QgsProject::readLayer( const QDomNode& layerNode )
{
QList<QDomNode> brokenNodes;
QList< QPair< QgsVectorLayer*, QDomElement > > vectorLayerList;
@@ -1154,13 +1154,6 @@ bool QgsProject::write( const QString& filename )
return write();
}

bool QgsProject::write( QFileInfo const &file )
{
mFile.setFileName( file.filePath() );

return write();
}

bool QgsProject::write()
{
clearError();
@@ -166,44 +166,26 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
*/
void clear();

/** Reads a project file.
/** Reads given project file from the given file.
* @param file name of project file to read
* @note Any current plug-in state is erased
* @note Calling read() performs the following operations:
*
* - Gets the extents
* - Creates maplayers
* - Registers maplayers
*
* @note it's presumed that the caller has already reset the map canvas, map registry, and legend
* @returns true if project file has been read successfully
*/
bool read( const QFileInfo& file );
bool read( const QString& filename );

/** Reads the current project file.
* @note Any current plug-in state is erased
* @note Calling read() performs the following operations:
*
* - Gets the extents
* - Creates maplayers
* - Registers maplayers
*
* @note it's presumed that the caller has already reset the map canvas, map registry, and legend
/** Reads the project from its currently associated file (see fileName() ).
* @returns true if project file has been read successfully
*/
bool read();

/** Reads the layer described in the associated DOM node.
*
* @param layerNode represents a QgsProject DOM node that encodes a specific layer.
*
* QgsProject raises an exception when one of the QgsProject::read()
* implementations fails. Since the read()s are invoked from qgisapp,
* then qgisapp handles the exception. It prompts the user for the new
* location of the data, if any. If there is a new location, the DOM
* node associated with the layer has its datasource tag corrected.
* Then that node is passed to this member function to be re-opened.
* @note This method is mainly for use by QgsProjectBadLayerHandler subclasses
* that may fix definition of bad layers with the user's help in GUI. Calling
* this method with corrected DOM node adds the layer back to the project.
*
* @param layerNode represents a QgsProject DOM node that encodes a specific layer.
*/
bool read( QDomNode& layerNode );
bool readLayer( const QDomNode& layerNode );

/**
* Writes the project to a file.
@@ -216,14 +198,6 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
*/
bool write( const QString& filename );

/** Writes the project to a file.
* @param file destination file
* @note calling this implicitly sets the project's filename (see setFileName() )
* @note isDirty() will be set to false if project is successfully written
* @returns true if project was written successfully
*/
bool write( const QFileInfo& file );

/** Writes the project to its current associated file (see fileName() ).
* @note isDirty() will be set to false if project is successfully written
* @returns true if project was written successfully
@@ -35,7 +35,6 @@ class CORE_EXPORT QgsProjectBadLayerHandler
* log.
*
* @note Added in QGIS 3.0
* @see QgsProjectBadLayerGuiHandler
*/
virtual void handleBadLayers( const QList<QDomNode>& layers );
virtual ~QgsProjectBadLayerHandler() = default;
@@ -287,7 +287,6 @@ SET(QGIS_GUI_SRCS
qgspluginmanagerinterface.cpp
qgspresetcolorrampdialog.cpp
qgsprevieweffect.cpp
qgsprojectbadlayerguihandler.cpp
qgsprojectionselectionwidget.cpp
qgsprojectionselector.cpp
qgsquerybuilder.cpp
@@ -450,7 +449,6 @@ SET(QGIS_GUI_MOC_HDRS
qgspluginmanagerinterface.h
qgspresetcolorrampdialog.h
qgsprevieweffect.h
qgsprojectbadlayerguihandler.h
qgsprojectionselectionwidget.h
qgsprojectionselector.h
qgsquerybuilder.h

0 comments on commit 6c5956b

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