QGIS API Documentation 3.41.0-Master (3440c17df1d)
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:
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 QMetaType::Type type, QString *errorMessage SIP_OUT = nullptr );
94
105 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;
106
110 bool removeField( const int position, QString *errorMessage SIP_OUT = nullptr );
111
115 bool removeColorOrRamp( QString *errorMessage SIP_OUT = nullptr );
116
120 bool insertRow( const int position, const QVariantList &rowData, QString *errorMessage SIP_OUT = nullptr );
121
125 bool insertColor( int position, QString *errorMessage SIP_OUT = nullptr );
126
130 bool insertRamp( int position, QString *errorMessage SIP_OUT = nullptr );
131
135 bool removeRow( const int position, QString *errorMessage SIP_OUT = nullptr );
136
137 private:
138
139 QgsRasterAttributeTable *mRat = nullptr;
140 bool mEditable = false;
141
142 // Checks for rat not nullptr and editable state
143 bool editChecks( QString *errorMessage = nullptr );
144
145 QString ratColorHeaderName( ) const;
146
147 // QAbstractItemModel interface
148 public:
149 int rowCount( const QModelIndex &parent ) const override;
150 int columnCount( const QModelIndex &parent ) const override;
151 QVariant data( const QModelIndex &index, int role ) const override;
152 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
153 QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
154 Qt::ItemFlags flags( const QModelIndex &index ) const override;
155
156
157};
158
159#endif // QGSRASTERATTRIBUTETABLEMODEL_H
RasterAttributeTableFieldUsage
The RasterAttributeTableFieldUsage enum represents the usage of a Raster Attribute Table field.
Definition qgis.h:1434
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