Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8250 from elpaso/indicators-refactoring
[needs-docs] Indicators refactoring + bad layers indicator
- Loading branch information
Showing
15 changed files
with
565 additions
and
503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.