QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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:
39 explicit QgsRasterAttributeTableModel( QgsRasterAttributeTable *rat, QObject *parent SIP_TRANSFERTHIS = nullptr );
40
44 bool editable() const;
45
49 void setEditable( bool editable );
50
54 bool hasColor() const;
55
59 bool hasRamp() const;
60
64 QStringList headerNames() const;
65
69 QString headerTooltip( const int section ) const;
70
74 bool isValid( QString *errorMessage SIP_OUT = nullptr );
75
79 bool isDirty();
80
81 // Raster Attribute Table operations
82
92 bool insertField( const int position, const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QMetaType::Type type, QString *errorMessage SIP_OUT = nullptr );
93
104 Q_DECL_DEPRECATED bool insertField( const int position, const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QVariant::Type type, QString *errorMessage SIP_OUT = nullptr ) SIP_DEPRECATED;
105
109 bool removeField( const int position, QString *errorMessage SIP_OUT = nullptr );
110
114 bool removeColorOrRamp( QString *errorMessage SIP_OUT = nullptr );
115
119 bool insertRow( const int position, const QVariantList &rowData, QString *errorMessage SIP_OUT = nullptr );
120
124 bool insertColor( int position, QString *errorMessage SIP_OUT = nullptr );
125
129 bool insertRamp( int position, QString *errorMessage SIP_OUT = nullptr );
130
134 bool removeRow( const int position, QString *errorMessage SIP_OUT = nullptr );
135
136 private:
137 QgsRasterAttributeTable *mRat = nullptr;
138 bool mEditable = false;
139
140 // Checks for rat not nullptr and editable state
141 bool editChecks( QString *errorMessage = nullptr );
142
143 QString ratColorHeaderName() const;
144
145 // QAbstractItemModel interface
146 public:
147 int rowCount( const QModelIndex &parent ) const override;
148 int columnCount( const QModelIndex &parent ) const override;
149 QVariant data( const QModelIndex &index, int role ) const override;
150 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
151 QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
152 Qt::ItemFlags flags( const QModelIndex &index ) const override;
153};
154
155#endif // QGSRASTERATTRIBUTETABLEMODEL_H
RasterAttributeTableFieldUsage
The RasterAttributeTableFieldUsage enum represents the usage of a Raster Attribute Table field.
Definition qgis.h:1479
The QgsRasterAttributeTableModel class manages a QgsRasterAttributeTable.
The QgsRasterAttributeTable class represents a Raster Attribute Table (RAT).
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_OUT
Definition qgis_sip.h:58