16#ifndef QGSRASTERATTRIBUTETABLEWIDGET_H
17#define QGSRASTERATTRIBUTETABLEWIDGET_H
20#include "ui_qgsrasterattributetablewidgetbase.h"
27#include <QStyledItemDelegate>
34class QSortFilterProxyModel;
40class ColorDelegate :
public QStyledItemDelegate
45 ColorDelegate( QObject *parent =
nullptr )
46 : QStyledItemDelegate( parent ) {};
49 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
50 void setEditorData( QWidget *editor,
const QModelIndex &index )
const override;
51 void setModelData( QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index )
const override;
54class ColorAlphaDelegate :
public ColorDelegate
59 ColorAlphaDelegate( QObject *parent =
nullptr )
60 : ColorDelegate( parent ) {};
63 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
66class ColorRampDelegate :
public QStyledItemDelegate
71 ColorRampDelegate( QObject *parent =
nullptr )
72 : QStyledItemDelegate( parent ) {};
75 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
76 void setEditorData( QWidget *editor,
const QModelIndex &index )
const override;
77 void setModelData( QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index )
const override;
78 void paint( QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
84class ColorRampAlphaDelegate :
public ColorRampDelegate
89 ColorRampAlphaDelegate( QObject *parent =
nullptr )
90 : ColorRampDelegate( parent ) {};
93 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
97class LocalizedDoubleDelegate :
public QgsLocaleAwareNumericLineEditDelegate
102 LocalizedDoubleDelegate( QWidget *parent =
nullptr )
103 : QgsLocaleAwareNumericLineEditDelegate(
Qgis::DataType::Float64, parent ) {};
106 QString displayText(
const QVariant &value,
const QLocale &locale )
const override;
118class GUI_EXPORT QgsRasterAttributeTableWidget :
public QgsPanelWidget,
private Ui::QgsRasterAttributeTableWidgetBase
129 explicit QgsRasterAttributeTableWidget( QWidget *parent
SIP_TRANSFERTHIS =
nullptr,
QgsRasterLayer *rasterLayer =
nullptr,
const int bandNumber = 0 );
136 void setRasterLayer(
QgsRasterLayer *rasterLayer,
const int bandNumber = 0 );
141 bool isDirty()
const;
154 void rendererChanged();
168 bool setEditable(
bool editable,
bool allowCancel =
true );
176 void bandChanged(
const int index );
181 std::unique_ptr<QgsRasterAttributeTable> mAttributeTableBuffer;
183 int mCurrentBand = 0;
184 bool mEditable =
false;
186 std::unique_ptr<QgsRasterAttributeTableModel> mModel;
188 QAction *mActionToggleEditing =
nullptr;
189 QAction *mActionAddColumn =
nullptr;
190 QAction *mActionRemoveColumn =
nullptr;
191 QAction *mActionAddRow =
nullptr;
192 QAction *mActionRemoveRow =
nullptr;
193 QAction *mActionSaveChanges =
nullptr;
196 QSortFilterProxyModel *mProxyModel =
nullptr;
198 void init(
int bandNumber = 0 );
199 void updateButtons();
The Qgis class provides global constants for use throughout the application.
MessageLevel
Level for messages This will be used both for message log and message bar in application.
@ Info
Information message.
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
A bar for displaying non-blocking messages to the user.
The QgsRasterAttributeTable class represents a Raster Attribute Table (RAT).
Represents a raster layer.