18 #ifndef QGSPALETTEDRENDERERWIDGET_H
19 #define QGSPALETTEDRENDERERWIDGET_H
27 #include "ui_qgspalettedrendererwidgetbase.h"
31 #include <QSortFilterProxyModel>
34 class QgsLocaleAwareNumericLineEditDelegate;
43 class QgsPalettedRendererClassGatherer:
public QThread
50 , mBandNumber( bandNumber )
52 , mClasses( existingClasses )
53 , mWasCanceled( false )
62 mFeedbackMutex.lock();
65 mFeedbackMutex.unlock();
71 bool wasCanceled()
const {
return mWasCanceled; }
80 void collectedClasses();
86 void progressChanged(
double progress );
92 std::unique_ptr< QgsColorRamp > mRamp;
96 QMutex mFeedbackMutex;
100 class QgsPalettedRendererModel :
public QAbstractItemModel
113 QgsPalettedRendererModel( QObject *parent =
nullptr );
120 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
121 QModelIndex parent(
const QModelIndex &index )
const override;
122 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
123 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
124 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
125 QVariant headerData(
int section, Qt::Orientation orientation,
int role )
const override;
126 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
override;
127 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
128 bool removeRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
129 bool insertRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
130 Qt::DropActions supportedDropActions()
const override;
131 QStringList mimeTypes()
const override;
132 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
133 bool dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
override;
135 QModelIndex addEntry(
const QColor &color );
143 void classesChanged();
152 class QgsPalettedRendererProxyModel:
public QSortFilterProxyModel
158 QgsPalettedRendererProxyModel( QObject *parent = 0 )
159 : QSortFilterProxyModel( parent )
168 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override
170 const QModelIndex lv { left.model()->index( left.row(),
static_cast<int>( QgsPalettedRendererModel::Column::ValueColumn ), left.parent() ) };
171 const QModelIndex rv { right.model()->index( right.row(),
static_cast<int>( QgsPalettedRendererModel::Column::ValueColumn ), right.parent() ) };
172 const double leftData { sourceModel()->data( lv ).toDouble( ) };
173 const double rightData { sourceModel()->data( rv ).toDouble( ) };
174 return leftData < rightData;
202 QMenu *mContextMenu =
nullptr;
203 QMenu *mAdvancedMenu =
nullptr;
204 QAction *mLoadFromLayerAction =
nullptr;
205 QgsPalettedRendererModel *mModel =
nullptr;
206 QgsPalettedRendererProxyModel *mProxyModel =
nullptr;
209 QgsPalettedRendererClassGatherer *mGatherer =
nullptr;
213 QgsLocaleAwareNumericLineEditDelegate *mValueDelegate =
nullptr;
215 void setSelectionColor(
const QItemSelection &selection,
const QColor &color );
222 void changeOpacity();
224 void applyColorRamp();
225 void loadColorTable();
226 void saveColorTable();
228 void loadFromLayer();
229 void bandChanged(
int band );
231 void gatheredClasses();
232 void gathererThreadFinished();
Abstract base class for color ramps.
Base class for all map layer types.
QList< QgsPalettedRasterRenderer::Class > ClassData
Map of value to class properties.
Feedback object tailored for raster block reading.
Represents a raster layer.
Raster renderer pipe that applies colors to a raster.
A rectangle specified with double values.
Properties of a single value class.