Skip to content
Permalink
Browse files

added temporal layer indicators

  • Loading branch information
Samweli authored and nyalldawson committed Mar 6, 2020
1 parent 89b654e commit 1b53cbc2407ab38c345b95164fd8b3d44fa5fce6
@@ -822,6 +822,8 @@
<file>themes/default/mActionEditModelComponent.svg</file>
<file>themes/default/mIconModelOutput.svg</file>
<file>themes/default/mIconModelInput.svg</file>
<file>themes/default/mIndicatorTemporal.svg</file>
<file>themes/default/mIndicatorTimeFromProject.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
@@ -0,0 +1,62 @@
<?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"
version="1.1"
id="svg8"
sodipodi:docname="mIndicatorTemporal.svg"
inkscape:version="0.92.4 (unknown)">
<metadata
id="metadata14">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs12" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1299"
inkscape:window-height="713"
id="namedview10"
showgrid="false"
inkscape:zoom="12.146392"
inkscape:cx="5.1528251"
inkscape:cy="12.452661"
inkscape:window-x="67"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg8" />
<ellipse
id="path3719"
cx="7.9417672"
cy="8.183919"
rx="6.6066852"
ry="6.4209695"
style="fill:none;fill-opacity:1;stroke:#2c2c2c;stroke-width:0.95829916;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.70588235" />
<path
inkscape:connector-curvature="0"
style="fill:#888a85;stroke:#2c2c2c;stroke-width:0.681;stroke-linecap:round;stroke-opacity:0.70588237;stroke-miterlimit:4;stroke-dasharray:none"
d="M 7.8644646,8.2807865 V 4.652793 M 10.245049,9.7363455 7.8673247,8.2861182"
id="path4" />
</svg>
@@ -0,0 +1,82 @@
<?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"
width="19"
height="18"
version="1.1"
id="svg14"
sodipodi:docname="mIndicatorTimeFromProject.svg"
inkscape:version="0.92.4 (unknown)">
<defs
id="defs18" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="723"
inkscape:window-height="480"
id="namedview16"
showgrid="false"
inkscape:zoom="13.111111"
inkscape:cx="9.5"
inkscape:cy="9"
inkscape:window-x="67"
inkscape:window-y="27"
inkscape:window-maximized="0"
inkscape:current-layer="svg14" />
<metadata
id="metadata2">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
stroke="#2c2c2c"
id="g12">
<ellipse
cx="9.4975"
cy="8.8467"
rx="6.3142"
ry="6.0988"
fill="none"
stroke-opacity=".70588"
stroke-width=".91304"
id="ellipse4" />
<path
d="m9.3032 8.945v-3.4459m2.2752 4.8284-2.2725-1.3775"
fill="#888a85"
stroke-linecap="round"
stroke-opacity=".70588"
stroke-width=".64884"
id="path6" />
<path
d="m5.2753 1.0247-3.9496 0.00398v15.874h3.9605"
fill="none"
stroke-opacity=".70588"
stroke-width="1.0404px"
id="path8" />
<path
d="m13.982 16.891 3.9495-0.02558-0.08682-15.874-3.9605 0.021661"
fill="none"
stroke-opacity=".70588"
stroke-width="1.0404px"
id="path10" />
</g>
</svg>
@@ -49,6 +49,7 @@ SET(QGIS_APP_SRCS
qgslayertreeviewnocrsindicator.cpp
qgslayertreeviewnonremovableindicator.cpp
qgslayertreeviewbadlayerindicator.cpp
qgslayertreeviewtemporalindicator.cpp
qgsmapcanvasdockwidget.cpp
qgsmapsavedialog.cpp
qgsprojectlistitemdelegate.cpp
@@ -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 );
}

@@ -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
@@ -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 );
}

0 comments on commit 1b53cbc

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