2009-12-07 17:14:41 +00:00
|
|
|
|
|
|
|
/** \ingroup gui
|
|
|
|
Handler for missing layers within project.
|
|
|
|
|
|
|
|
Gives user a chance to select path to the missing layers.
|
|
|
|
*/
|
|
|
|
class QgsProjectBadLayerGuiHandler : QObject, QgsProjectBadLayerHandler
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsprojectbadlayerguihandler.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
QgsProjectBadLayerGuiHandler();
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Implementation of the handler */
|
2015-10-26 22:46:14 +11:00
|
|
|
virtual void handleBadLayers( const QList<QDomNode>& layers, const QDomDocument& projectDom );
|
2009-12-07 17:14:41 +00:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/** Flag to store the Ignore button press of MessageBox used by QgsLegend */
|
|
|
|
static bool mIgnore;
|
2014-05-27 23:22:50 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
//! file data representation
|
|
|
|
enum DataType { IS_VECTOR, IS_RASTER, IS_BOGUS };
|
|
|
|
|
|
|
|
//! the three flavors for data
|
|
|
|
enum ProviderType { IS_FILE, IS_DATABASE, IS_URL, IS_Unknown };
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns data type associated with the given QgsProject file Dom node
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* The Dom node should represent the state associated with a specific layer.
|
|
|
|
*/
|
2014-05-27 23:22:50 +02:00
|
|
|
DataType dataType( QDomNode & layerNode );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return the data source for the given layer
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* The QDomNode is a QgsProject Dom node corresponding to a map layer state.
|
|
|
|
*
|
|
|
|
* Essentially dumps datasource tag.
|
|
|
|
*/
|
2014-05-27 23:22:50 +02:00
|
|
|
QString dataSource( QDomNode & layerNode );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return the physical storage type associated with the given layer
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* The QDomNode is a QgsProject Dom node corresponding to a map layer state.
|
|
|
|
*
|
|
|
|
* If the provider tag is "ogr", then it's a file type.
|
|
|
|
*
|
|
|
|
* However, if the layer is a raster, then there won't be a
|
|
|
|
* provider tag. It will always have an associated file.
|
|
|
|
*
|
|
|
|
* If the layer doesn't fall into either of the previous two categories, then
|
|
|
|
* it's either a database or URL. If the datasource tag has "url=", then it's
|
|
|
|
* URL based and if it has "dbname=">, then the layer data is in a database.
|
|
|
|
*/
|
2014-05-27 23:22:50 +02:00
|
|
|
ProviderType providerType( QDomNode & layerNode );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Set the datasource element to the new value */
|
2014-05-27 23:22:50 +02:00
|
|
|
void setDataSource( QDomNode & layerNode, const QString &dataSource );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** This is used to locate files that have moved or otherwise are missing */
|
2014-05-27 23:22:50 +02:00
|
|
|
bool findMissingFile( const QString &fileFilters, QDomNode &layerNode );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Find relocated data source for the given layer
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* This QDom object represents a QgsProject node that maps to a specific layer.
|
|
|
|
*
|
|
|
|
* @param fileFilters file filters to use
|
|
|
|
* @param constLayerNode QDom node containing layer project information
|
|
|
|
*
|
|
|
|
* @todo
|
|
|
|
*
|
|
|
|
* XXX Only implemented for file based layers. It will need to be extended for
|
|
|
|
* XXX other data source types such as databases.
|
|
|
|
*/
|
2014-05-27 23:22:50 +02:00
|
|
|
bool findLayer( const QString &fileFilters, const QDomNode &constLayerNode );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Find relocated data sources for given layers
|
2016-02-14 03:50:23 +01:00
|
|
|
* These QDom objects represent QgsProject nodes that map to specific layers.
|
|
|
|
*/
|
2014-05-27 23:22:50 +02:00
|
|
|
void findLayers( const QString &fileFilters, const QList<QDomNode> &layerNodes );
|
|
|
|
|
2009-12-07 17:14:41 +00:00
|
|
|
};
|