16#ifndef QGSRASTERATTRIBUTETABLEWIDGET_H
17#define QGSRASTERATTRIBUTETABLEWIDGET_H
20#include "ui_qgsrasterattributetablewidgetbase.h"
27#include <QStyledItemDelegate>
34class QSortFilterProxyModel;
40class ColorDelegate:
public QStyledItemDelegate
47 ColorDelegate( QObject *parent =
nullptr ): QStyledItemDelegate( parent ) {};
50 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
51 void setEditorData( QWidget *editor,
const QModelIndex &index )
const override;
52 void setModelData( QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index )
const override;
55class ColorAlphaDelegate:
public ColorDelegate
62 ColorAlphaDelegate( QObject *parent =
nullptr ): ColorDelegate( parent ) {};
65 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
68class ColorRampDelegate:
public QStyledItemDelegate
75 ColorRampDelegate( QObject *parent =
nullptr ): QStyledItemDelegate( parent ) {};
78 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
79 void setEditorData( QWidget *editor,
const QModelIndex &index )
const override;
80 void setModelData( QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index )
const override;
81 void paint( QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
89class ColorRampAlphaDelegate:
public ColorRampDelegate
96 ColorRampAlphaDelegate( QObject *parent =
nullptr ): ColorRampDelegate( parent ) {};
99 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
103class LocalizedDoubleDelegate:
public QgsLocaleAwareNumericLineEditDelegate
110 LocalizedDoubleDelegate( QWidget *parent =
nullptr ): QgsLocaleAwareNumericLineEditDelegate(
Qgis::DataType::Float64, parent ) {};
113 QString displayText(
const QVariant &value,
const QLocale &locale )
const override;
126class GUI_EXPORT QgsRasterAttributeTableWidget :
public QgsPanelWidget,
private Ui::QgsRasterAttributeTableWidgetBase
138 explicit QgsRasterAttributeTableWidget( QWidget *parent
SIP_TRANSFERTHIS =
nullptr,
QgsRasterLayer *rasterLayer =
nullptr,
const int bandNumber = 0 );
145 void setRasterLayer(
QgsRasterLayer *rasterLayer,
const int bandNumber = 0 );
150 bool isDirty( )
const;
163 void rendererChanged( );
177 bool setEditable(
bool editable,
bool allowCancel =
true );
186 void bandChanged(
const int index );
188 void setDelegates( );
191 std::unique_ptr<QgsRasterAttributeTable> mAttributeTableBuffer;
193 int mCurrentBand = 0;
194 bool mEditable =
false;
196 std::unique_ptr<QgsRasterAttributeTableModel> mModel;
198 QAction *mActionToggleEditing =
nullptr;
199 QAction *mActionAddColumn =
nullptr;
200 QAction *mActionRemoveColumn =
nullptr;
201 QAction *mActionAddRow =
nullptr;
202 QAction *mActionRemoveRow =
nullptr;
203 QAction *mActionSaveChanges =
nullptr;
206 QSortFilterProxyModel *mProxyModel =
nullptr;
208 void init(
int bandNumber = 0 );
209 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.