QGIS API Documentation 3.41.0-Master (cea29feecf2)
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 QgsRasterBandFixedTemporalRangeModel( QObject *parent );
38 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
39 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
40 QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override;
41 QModelIndex parent( const QModelIndex &child ) const override;
42 Qt::ItemFlags flags( const QModelIndex &index ) const override;
43 QVariant data( const QModelIndex &index, int role ) const override;
44 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
45 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
46
47 void setLayerData( QgsRasterLayer *layer, const QMap<int, QgsDateTimeRange> &ranges );
48 QMap<int, QgsDateTimeRange> rangeData() const { return mRanges; }
49
50 private:
51 int mBandCount = 0;
52 QMap<int, QString> mBandNames;
53 QMap<int, QgsDateTimeRange> mRanges;
54};
55
56class QgsFixedTemporalRangeDelegate : public QStyledItemDelegate
57{
58 Q_OBJECT
59
60 public:
61 QgsFixedTemporalRangeDelegate( QObject *parent );
62
63 protected:
64 QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem & /*option*/, const QModelIndex &index ) const override;
65 void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override;
66};
68#endif
69
78class GUI_EXPORT QgsRasterLayerTemporalPropertiesWidget : public QWidget, private Ui::QgsRasterLayerTemporalPropertiesWidgetBase
79{
80 Q_OBJECT
81 public:
85 QgsRasterLayerTemporalPropertiesWidget( QWidget *parent = nullptr, QgsRasterLayer *layer = nullptr );
86
90 void saveTemporalProperties();
91
95 void syncToLayer();
96
102 void addWidget( QgsMapLayerConfigWidget *widget SIP_TRANSFER );
103
104 private slots:
105 void temporalGroupBoxChecked( bool checked );
106 void modeChanged();
107 void calculateRangeByExpression( bool isUpper );
108
109 private:
110 QgsExpressionContext createExpressionContextForBand( int band ) const;
111
115 QgsRasterLayer *mLayer = nullptr;
116 QVBoxLayout *mExtraWidgetLayout = nullptr;
117
118 QList<QgsMapLayerConfigWidget *> mExtraWidgets;
119
120 QgsRasterBandFixedTemporalRangeModel *mFixedRangePerBandModel = nullptr;
121 QString mFixedRangeLowerExpression;
122 QString mFixedRangeUpperExpression;
123};
124#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