Skip to content
Permalink
Browse files

Merge pull request #8250 from elpaso/indicators-refactoring

[needs-docs] Indicators refactoring + bad layers indicator
  • Loading branch information
elpaso committed Oct 24, 2018
2 parents 1ab7dec + a83d9c9 commit ceaaade6a815d5bd76fe5fabe2794b77965f8749
@@ -718,6 +718,7 @@
<file>themes/default/mActionReverseLine.svg</file>
<file>themes/default/mActionAdd3DMap.svg</file>
<file>themes/default/mIndicatorNonRemovable.svg</file>
<file>themes/default/mIndicatorBadLayer.svg</file>
<file>themes/default/mIconFolder.svg</file>
<file>themes/default/mIconFolderHome.svg</file>
<file>themes/default/mIconFolderLink.svg</file>
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="16"
width="16"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="mIndicatorBadLayer.svg">
<metadata
id="metadata12">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs10" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="2399"
inkscape:window-height="1418"
id="namedview8"
showgrid="false"
inkscape:zoom="83.4386"
inkscape:cx="12.748756"
inkscape:cy="5.9247031"
inkscape:window-x="435"
inkscape:window-y="344"
inkscape:window-maximized="0"
inkscape:current-layer="svg2" />
<path
style="fill:none;fill-rule:evenodd;stroke:#2c2c2c;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.70588237"
d="M 2.8164423,12.943861 7.9702617,3.8470446 13.222692,12.94452 Z"
id="path4178"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 7.9012131,6.7183861 0,3.5932209"
id="path4180"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1"
d="m 7.8899553,11.212798 c 0.011985,0.131834 0.00197,0.201347 0.00197,0.201347"
id="path4182"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</svg>
@@ -60,10 +60,12 @@ SET(QGIS_APP_SRCS
qgslabelinggui.cpp
qgslabelingwidget.cpp
qgslayercapabilitiesmodel.cpp
qgslayertreeviewindicatorprovider.cpp
qgslayertreeviewembeddedindicator.cpp
qgslayertreeviewfilterindicator.cpp
qgslayertreeviewmemoryindicator.cpp
qgslayertreeviewnonremovableindicator.cpp
qgslayertreeviewbadlayerindicator.cpp
qgsmapcanvasdockwidget.cpp
qgsmaplayerstylecategoriesmodel.cpp
qgsmaplayerstyleguiutils.cpp
@@ -289,10 +291,12 @@ SET (QGIS_APP_MOC_HDRS
qgslabelingwidget.h
qgslabelpropertydialog.h
qgslayercapabilitiesmodel.h
qgslayertreeviewindicatorprovider.h
qgslayertreeviewembeddedindicator.h
qgslayertreeviewmemoryindicator.h
qgslayertreeviewfilterindicator.h
qgslayertreeviewnonremovableindicator.h
qgslayertreeviewbadlayerindicator.h
qgsmapcanvasdockwidget.h
qgsmaplayerstylecategoriesmodel.h
qgsmaplayerstyleguiutils.h
@@ -209,6 +209,7 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
#include "qgslayertreeviewembeddedindicator.h"
#include "qgslayertreeviewfilterindicator.h"
#include "qgslayertreeviewmemoryindicator.h"
#include "qgslayertreeviewbadlayerindicator.h"
#include "qgslayertreeviewnonremovableindicator.h"
#include "qgslayout.h"
#include "qgslayoutatlas.h"
@@ -3891,6 +3892,7 @@ void QgisApp::initLayerTreeView()
new QgsLayerTreeViewFilterIndicatorProvider( mLayerTreeView ); // gets parented to the layer view
new QgsLayerTreeViewEmbeddedIndicatorProvider( mLayerTreeView ); // gets parented to the layer view
new QgsLayerTreeViewMemoryIndicatorProvider( mLayerTreeView ); // gets parented to the layer view
new QgsLayerTreeViewBadLayerIndicatorProvider( mLayerTreeView ); // gets parented to the layer view
new QgsLayerTreeViewNonRemovableIndicatorProvider( mLayerTreeView ); // gets parented to the layer view

setupLayerTreeViewFromSettings();
@@ -0,0 +1,59 @@
/***************************************************************************
qgslayertreeviewbadlayerindicatorprovider.cpp - QgsLayerTreeViewBadLayerIndicatorProvider
---------------------
begin : 17.10.2018
copyright : (C) 2018 by Alessandro Pasotti
email : elpaso@itopen.it
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgslayertreeviewbadlayerindicator.h"
#include "qgslayertree.h"
#include "qgslayertreeview.h"
#include "qgslayertreeutils.h"
#include "qgslayertreemodel.h"
#include "qgsvectorlayer.h"
#include "qgisapp.h"

QgsLayerTreeViewBadLayerIndicatorProvider::QgsLayerTreeViewBadLayerIndicatorProvider( QgsLayerTreeView *view )
: QgsLayerTreeViewIndicatorProvider( view )
{
}

void QgsLayerTreeViewBadLayerIndicatorProvider::onIndicatorClicked( const QModelIndex &index )
{
QgsLayerTreeNode *node = mLayerTreeView->layerTreeModel()->index2node( index );
if ( !QgsLayerTree::isLayer( node ) )
return;

QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( QgsLayerTree::toLayer( node )->layer() );
if ( !vlayer )
return;

// TODO: open source select dialog
}

QString QgsLayerTreeViewBadLayerIndicatorProvider::iconName( QgsMapLayer *layer )
{
Q_UNUSED( layer );
return QStringLiteral( "/mIndicatorBadLayer.svg" );
}

QString QgsLayerTreeViewBadLayerIndicatorProvider::tooltipText( QgsMapLayer *layer )
{
Q_UNUSED( layer );
// TODO, click here to set a new data source.
return tr( "<b>Bad layer!</b><br>Layer data source could not be found." );
}

bool QgsLayerTreeViewBadLayerIndicatorProvider::acceptLayer( QgsMapLayer *layer )
{
return ! layer->isValid();
}
@@ -0,0 +1,41 @@
/***************************************************************************
qgslayertreeviewbadlayerindicatorprovider.h - QgsLayerTreeViewBadLayerIndicatorProvider
---------------------
begin : 17.10.2018
copyright : (C) 2018 by Alessandro Pasotti
email : elpaso@itopen.it
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLAYERTREEVIEWBADLAYERINDICATORPROVIDER_H
#define QGSLAYERTREEVIEWBADLAYERINDICATORPROVIDER_H

#include "qgslayertreeviewindicatorprovider.h"

#include <QObject>


//! Indicators for bad layers
class QgsLayerTreeViewBadLayerIndicatorProvider : public QgsLayerTreeViewIndicatorProvider
{
Q_OBJECT

public:
explicit QgsLayerTreeViewBadLayerIndicatorProvider( QgsLayerTreeView *view );

protected slots:
void onIndicatorClicked( const QModelIndex &index ) override;

private:
QString iconName( QgsMapLayer *layer ) override;
QString tooltipText( QgsMapLayer *layer ) override;
bool acceptLayer( QgsMapLayer *layer ) override;
};

#endif // QGSLAYERTREEVIEWBADLAYERINDICATORPROVIDER_H

0 comments on commit ceaaade

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