QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
qgsrasterlayertemporalpropertieswidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrasterlayertemporalpropertieswidget.h
3 ------------------------------
4 begin : January 2020
5 copyright : (C) 2020 by Samweli Mwakisambwe
6 email : samweli at kartoza dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSRASTERLAYERTEMPORALPROPERTIESWIDGET_H
19#define QGSRASTERLAYERTEMPORALPROPERTIESWIDGET_H
20
21#include "ui_qgsrasterlayertemporalpropertieswidgetbase.h"
22#include "qgis_gui.h"
23#include "qgsrange.h"
24#include <QStyledItemDelegate>
25
26class QgsRasterLayer;
29
30#ifndef SIP_RUN
32class QgsRasterBandFixedTemporalRangeModel : public QAbstractItemModel
33{
34 Q_OBJECT
35
36 public:
37
38 QgsRasterBandFixedTemporalRangeModel( QObject *parent );
39 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
40 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
41 QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override;
42 QModelIndex parent( const QModelIndex &child ) const override;
43 Qt::ItemFlags flags( const QModelIndex &index ) const override;
44 QVariant data( const QModelIndex &index, int role ) const override;
45 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
46 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
47
48 void setLayerData( QgsRasterLayer *layer, const QMap<int, QgsDateTimeRange > &ranges );
49 QMap<int, QgsDateTimeRange > rangeData() const { return mRanges; }
50
51 private:
52
53 int mBandCount = 0;
54 QMap<int, QString > mBandNames;
55 QMap<int, QgsDateTimeRange > mRanges;
56};
57
58class QgsFixedTemporalRangeDelegate : public QStyledItemDelegate
59{
60 Q_OBJECT
61
62 public:
63
64 QgsFixedTemporalRangeDelegate( QObject *parent );
65
66 protected:
67 QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem & /*option*/, const QModelIndex &index ) const override;
68 void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override;
69
70};
72#endif
73
82class GUI_EXPORT QgsRasterLayerTemporalPropertiesWidget : public QWidget, private Ui::QgsRasterLayerTemporalPropertiesWidgetBase
83{
84 Q_OBJECT
85 public:
86
90 QgsRasterLayerTemporalPropertiesWidget( QWidget *parent = nullptr, QgsRasterLayer *layer = nullptr );
91
95 void saveTemporalProperties();
96
100 void syncToLayer();
101
107 void addWidget( QgsMapLayerConfigWidget *widget SIP_TRANSFER );
108
109 private slots:
110 void temporalGroupBoxChecked( bool checked );
111 void modeChanged();
112 void calculateRangeByExpression( bool isUpper );
113
114 private:
115 QgsExpressionContext createExpressionContextForBand( int band ) const;
116
120 QgsRasterLayer *mLayer = nullptr;
121 QVBoxLayout *mExtraWidgetLayout = nullptr;
122
123 QList< QgsMapLayerConfigWidget * > mExtraWidgets;
124
125 QgsRasterBandFixedTemporalRangeModel *mFixedRangePerBandModel = nullptr;
126 QString mFixedRangeLowerExpression;
127 QString mFixedRangeUpperExpression;
128};
129#endif // QGSRASTERLAYERTEMPORALPROPERTIESWIDGET_H
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
A panel widget that can be shown in the map style dock.
A widget for configuring the temporal properties for a raster layer.
Represents a raster layer.
#define SIP_TRANSFER
Definition qgis_sip.h:36