QGIS API Documentation 3.29.0-Master (19d7edcfed)
qgsrasterattributetablemodel.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrasterattributetablemodel.h - QgsRasterAttributeTableModel
3
4 ---------------------
5 begin : 29.9.2022
6 copyright : (C) 2022 by Alessandro Pasotti
7 email : elpaso at itopen dot it
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSRASTERATTRIBUTETABLEMODEL_H
17#define QGSRASTERATTRIBUTETABLEMODEL_H
18
19#include "qgis_gui.h"
21#include "qgis_sip.h"
22
23#include <QAbstractTableModel>
24#include <QObject>
25
31class GUI_EXPORT QgsRasterAttributeTableModel : public QAbstractTableModel
32{
33 Q_OBJECT
34
35 public:
36
40 explicit QgsRasterAttributeTableModel( QgsRasterAttributeTable *rat, QObject *parent SIP_TRANSFERTHIS = nullptr );
41
45 bool editable() const;
46
50 void setEditable( bool editable );
51
55 bool hasColor() const;
56
60 bool hasRamp() const;
61
65 QStringList headerNames( ) const;
66
70 QString headerTooltip( const int section ) const;
71
75 bool isValid( QString *errorMessage SIP_OUT = nullptr );
76
80 bool isDirty( );
81
82 // Raster Attribute Table operations
83
93 bool insertField( const int position, const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QVariant::Type type, QString *errorMessage SIP_OUT = nullptr );
94
98 bool removeField( const int position, QString *errorMessage SIP_OUT = nullptr );
99
103 bool removeColorOrRamp( QString *errorMessage SIP_OUT = nullptr );
104
108 bool insertRow( const int position, const QVariantList &rowData, QString *errorMessage SIP_OUT = nullptr );
109
113 bool insertColor( int position, QString *errorMessage SIP_OUT = nullptr );
114
118 bool insertRamp( int position, QString *errorMessage SIP_OUT = nullptr );
119
123 bool removeRow( const int position, QString *errorMessage SIP_OUT = nullptr );
124
125 private:
126
127 QgsRasterAttributeTable *mRat = nullptr;
128 bool mEditable = false;
129
130 // Checks for rat not nullptr and editable state
131 bool editChecks( QString *errorMessage = nullptr );
132
133 QString ratColorHeaderName( ) const;
134
135 // QAbstractItemModel interface
136 public:
137 int rowCount( const QModelIndex &parent ) const override;
138 int columnCount( const QModelIndex &parent ) const override;
139 QVariant data( const QModelIndex &index, int role ) const override;
140 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
141 QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
142 Qt::ItemFlags flags( const QModelIndex &index ) const override;
143
144
145};
146
147#endif // QGSRASTERATTRIBUTETABLEMODEL_H
RasterAttributeTableFieldUsage
Flags which control behavior of raster renderers.
Definition: qgis.h:786
The QgsRasterAttributeTableModel class manages a QgsRasterAttributeTable.
The QgsRasterAttributeTable class represents a Raster Attribute Table (RAT).
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_OUT
Definition: qgis_sip.h:58