Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
added temporal layer indicators
- Loading branch information
1 parent
89b654e
commit 1b53cbc
Showing
8 changed files
with
428 additions
and
0 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.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/*************************************************************************** | ||
qgslayertreeviewprojecttimeindicator.cpp | ||
--------------- | ||
begin : February 2020 | ||
copyright : (C) 2020 by Samweli Mwakisambwe | ||
email : samweli at kartoza dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* 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 "qgslayertreeviewprojecttimeindicator.h" | ||
#include "qgslayertreeview.h" | ||
#include "qgslayertree.h" | ||
#include "qgslayertreemodel.h" | ||
#include "qgslayertreeutils.h" | ||
#include "qgsrasterlayer.h" | ||
#include "qgisapp.h" | ||
|
||
QgsLayerTreeViewProjectTimeIndicatorProvider::QgsLayerTreeViewProjectTimeIndicatorProvider( QgsLayerTreeView *view ) | ||
: QgsLayerTreeViewIndicatorProvider( view ) | ||
{ | ||
} | ||
|
||
void QgsLayerTreeViewProjectTimeIndicatorProvider::connectSignals( QgsMapLayer *layer ) | ||
{ | ||
if ( !( qobject_cast<QgsVectorLayer *>( layer ) || qobject_cast<QgsRasterLayer *>( layer ) ) ) | ||
return; | ||
QgsMapLayer *mapLayer = layer; | ||
connect( mapLayer, &QgsMapLayer::dataSourceChanged, this, &QgsLayerTreeViewProjectTimeIndicatorProvider::onLayerChanged ); | ||
|
||
if ( mapLayer && mapLayer->dataProvider() && mapLayer->dataProvider()->temporalCapabilities() ) | ||
{ | ||
mLayer = mapLayer; | ||
QgsRasterDataProvider *provider = qobject_cast<QgsRasterDataProvider *>( mapLayer->dataProvider() ); | ||
connect( provider, &QgsRasterDataProvider::statusChanged, | ||
this, &QgsLayerTreeViewProjectTimeIndicatorProvider::onLayerChanged ); | ||
} | ||
} | ||
|
||
void QgsLayerTreeViewProjectTimeIndicatorProvider::onIndicatorClicked( const QModelIndex &index ) | ||
{ | ||
Q_UNUSED( index ) | ||
} | ||
|
||
bool QgsLayerTreeViewProjectTimeIndicatorProvider::acceptLayer( QgsMapLayer *layer ) | ||
{ | ||
if ( !layer ) | ||
return false; | ||
if ( layer->temporalProperties() && | ||
layer->temporalProperties()->temporalSource() == | ||
QgsMapLayerTemporalProperties::TemporalSource::Project ) | ||
return true; | ||
return false; | ||
} | ||
|
||
QString QgsLayerTreeViewProjectTimeIndicatorProvider::iconName( QgsMapLayer *layer ) | ||
{ | ||
Q_UNUSED( layer ) | ||
return QStringLiteral( "/mIndicatorTimeFromProject.svg" ); | ||
} | ||
|
||
QString QgsLayerTreeViewProjectTimeIndicatorProvider::tooltipText( QgsMapLayer *layer ) | ||
{ | ||
Q_UNUSED( layer ) | ||
return tr( "<b>Temporal layer using Project time </b>" ); | ||
} | ||
|
||
void QgsLayerTreeViewProjectTimeIndicatorProvider::onLayerChanged() | ||
{ | ||
QgsMapLayer *mapLayer = qobject_cast<QgsMapLayer *>( sender() ); | ||
QgsMapLayer *mapLayerFromIndicator = qobject_cast<QgsMapLayer *>( mLayer ); | ||
|
||
if ( !mapLayer ) | ||
{ | ||
if ( !mapLayerFromIndicator ) | ||
return; | ||
else | ||
updateLayerIndicator( mapLayerFromIndicator ); | ||
} | ||
else | ||
updateLayerIndicator( mapLayer ); | ||
} | ||
|
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,53 @@ | ||
/*************************************************************************** | ||
qgslayertreeviewprojecttimeindicator.h | ||
--------------- | ||
begin : February 2020 | ||
copyright : (C) 2020 by Samweli Mwakisambwe | ||
email : samweli at kartoza dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* 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 QGSLAYERTREEVIEWPROJECTTIMEINDICATOR_H | ||
#define QGSLAYERTREEVIEWPROJECTTIMEINDICATOR_H | ||
|
||
|
||
#include "qgslayertreeviewindicatorprovider.h" | ||
|
||
/** | ||
* Adds indicators for showing temporal layers that are using project time to set their | ||
* current active temporal range. | ||
*/ | ||
class QgsLayerTreeViewProjectTimeIndicatorProvider : public QgsLayerTreeViewIndicatorProvider | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit QgsLayerTreeViewProjectTimeIndicatorProvider( QgsLayerTreeView *view ); | ||
|
||
protected: | ||
void connectSignals( QgsMapLayer *layer ) override; | ||
|
||
protected slots: | ||
|
||
void onIndicatorClicked( const QModelIndex &index ) override; | ||
|
||
//! Adds/removes indicator of a layer | ||
void onLayerChanged(); | ||
|
||
private: | ||
bool acceptLayer( QgsMapLayer *layer ) override; | ||
QString iconName( QgsMapLayer *layer ) override; | ||
QString tooltipText( QgsMapLayer *layer ) override; | ||
|
||
QgsMapLayer *mLayer = nullptr; | ||
}; | ||
|
||
#endif // QGSLAYERTREEVIEWPROJECTTIMEINDICATOR_H |
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,89 @@ | ||
/*************************************************************************** | ||
qgslayertreeviewtemporalindicator.cpp | ||
--------------- | ||
begin : February 2020 | ||
copyright : (C) 2020 by Samweli Mwakisambwe | ||
email : samweli at kartoza dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* 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 "qgslayertreeviewtemporalindicator.h" | ||
#include "qgslayertreeview.h" | ||
#include "qgslayertree.h" | ||
#include "qgslayertreemodel.h" | ||
#include "qgslayertreeutils.h" | ||
#include "qgsrasterlayer.h" | ||
#include "qgisapp.h" | ||
|
||
QgsLayerTreeViewTemporalIndicatorProvider::QgsLayerTreeViewTemporalIndicatorProvider( QgsLayerTreeView *view ) | ||
: QgsLayerTreeViewIndicatorProvider( view ) | ||
{ | ||
} | ||
|
||
void QgsLayerTreeViewTemporalIndicatorProvider::connectSignals( QgsMapLayer *layer ) | ||
{ | ||
if ( !( qobject_cast<QgsVectorLayer *>( layer ) || qobject_cast<QgsRasterLayer *>( layer ) ) ) | ||
return; | ||
QgsMapLayer *mapLayer = layer; | ||
connect( mapLayer, &QgsMapLayer::dataSourceChanged, this, &QgsLayerTreeViewTemporalIndicatorProvider::onLayerChanged ); | ||
|
||
if ( mapLayer && mapLayer->dataProvider() ) | ||
{ | ||
mLayer = mapLayer; | ||
QgsRasterDataProvider *provider = qobject_cast<QgsRasterDataProvider *>( mapLayer->dataProvider() ); | ||
connect( provider, &QgsRasterDataProvider::statusChanged, | ||
this, &QgsLayerTreeViewTemporalIndicatorProvider::onLayerChanged ); | ||
} | ||
} | ||
|
||
void QgsLayerTreeViewTemporalIndicatorProvider::onIndicatorClicked( const QModelIndex &index ) | ||
{ | ||
Q_UNUSED( index ) | ||
} | ||
|
||
bool QgsLayerTreeViewTemporalIndicatorProvider::acceptLayer( QgsMapLayer *layer ) | ||
{ | ||
if ( !layer ) | ||
return false; | ||
if ( layer->temporalProperties() && | ||
layer->temporalProperties()->temporalSource() == | ||
QgsMapLayerTemporalProperties::TemporalSource::Layer ) | ||
return true; | ||
return false; | ||
} | ||
|
||
QString QgsLayerTreeViewTemporalIndicatorProvider::iconName( QgsMapLayer *layer ) | ||
{ | ||
Q_UNUSED( layer ); | ||
return QStringLiteral( "/mIndicatorTemporal.svg" ); | ||
} | ||
|
||
QString QgsLayerTreeViewTemporalIndicatorProvider::tooltipText( QgsMapLayer *layer ) | ||
{ | ||
Q_UNUSED( layer ); | ||
return tr( "<b>Temporal layer</b>" ); | ||
} | ||
|
||
void QgsLayerTreeViewTemporalIndicatorProvider::onLayerChanged() | ||
{ | ||
QgsMapLayer *mapLayer = qobject_cast<QgsMapLayer *>( sender() ); | ||
QgsMapLayer *mapLayerFromIndicator = qobject_cast<QgsMapLayer *>( mLayer ); | ||
|
||
if ( !mapLayer ) | ||
{ | ||
if ( !mapLayerFromIndicator ) | ||
return; | ||
else | ||
updateLayerIndicator( mapLayerFromIndicator ); | ||
} | ||
else | ||
updateLayerIndicator( mapLayer ); | ||
} |
Oops, something went wrong.