QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
23#include "qgis_gui.h"
24#include "qgsrange.h"
25
26#include <QStyledItemDelegate>
27
28class QgsRasterLayer;
31
32#ifndef SIP_RUN
34class QgsRasterBandFixedTemporalRangeModel : public QAbstractItemModel
35{
36 Q_OBJECT
37
38 public:
39 QgsRasterBandFixedTemporalRangeModel( QObject *parent );
40 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
41 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
42 QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override;
43 QModelIndex parent( const QModelIndex &child ) const override;
44 Qt::ItemFlags flags( const QModelIndex &index ) const override;
45 QVariant data( const QModelIndex &index, int role ) const override;
46 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
47 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
48
49 void setLayerData( QgsRasterLayer *layer, const QMap<int, QgsDateTimeRange> &ranges );
50 QMap<int, QgsDateTimeRange> rangeData() const { return mRanges; }
51
52 private:
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 QgsFixedTemporalRangeDelegate( QObject *parent );
64
65 protected:
66 QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem & /*option*/, const QModelIndex &index ) const override;
67 void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override;
68};
70#endif
71
79
80class GUI_EXPORT QgsRasterLayerTemporalPropertiesWidget : public QWidget, private Ui::QgsRasterLayerTemporalPropertiesWidgetBase
81{
82 Q_OBJECT
83 public:
87 QgsRasterLayerTemporalPropertiesWidget( QWidget *parent = nullptr, QgsRasterLayer *layer = nullptr );
88
93
97 void syncToLayer();
98
105
106 private slots:
107 void temporalGroupBoxChecked( bool checked );
108 void modeChanged();
109 void calculateRangeByExpression( bool isUpper );
110
111 private:
112 QgsExpressionContext createExpressionContextForBand( int band ) const;
113
117 QgsRasterLayer *mLayer = nullptr;
118 QVBoxLayout *mExtraWidgetLayout = nullptr;
119
120 QList<QgsMapLayerConfigWidget *> mExtraWidgets;
121
122 QgsRasterBandFixedTemporalRangeModel *mFixedRangePerBandModel = nullptr;
123 QString mFixedRangeLowerExpression;
124 QString mFixedRangeUpperExpression;
125};
126#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.
void addWidget(QgsMapLayerConfigWidget *widget)
Adds a child widget to the properties widget.
void syncToLayer()
Updates the widget state to match the current layer state.
void saveTemporalProperties()
Save widget temporal properties inputs.
QgsRasterLayerTemporalPropertiesWidget(QWidget *parent=nullptr, QgsRasterLayer *layer=nullptr)
Constructor for QgsRasterLayerTemporalPropertiesWidget.
Represents a raster layer.
#define SIP_TRANSFER
Definition qgis_sip.h:36