18 #ifndef QGSPALETTEDRENDERERWIDGET_H 
   19 #define QGSPALETTEDRENDERERWIDGET_H 
   27 #include "ui_qgspalettedrendererwidgetbase.h" 
   31 #include <QSortFilterProxyModel> 
   34 class QgsLocaleAwareNumericLineEditDelegate;
 
   43 class QgsPalettedRendererClassGatherer: 
public QThread
 
   56       mFeedbackMutex.lock();
 
   59       mFeedbackMutex.unlock();
 
   65     bool wasCanceled()
 const { 
return mWasCanceled; }
 
   74     void collectedClasses();
 
   80     void progressChanged( 
double progress );
 
   86     std::unique_ptr< QgsColorRamp > mRamp;
 
   90     QMutex mFeedbackMutex;
 
   94 class QgsPalettedRendererModel : 
public QAbstractItemModel
 
  107     QgsPalettedRendererModel( QObject *parent = 
nullptr );
 
  114     QModelIndex index( 
int row, 
int column, 
const QModelIndex &parent = QModelIndex() ) 
const override;
 
  115     QModelIndex parent( 
const QModelIndex &index ) 
const override;
 
  116     int columnCount( 
const QModelIndex &parent = QModelIndex() ) 
const override;
 
  117     int rowCount( 
const QModelIndex &parent = QModelIndex() ) 
const override;
 
  118     QVariant data( 
const QModelIndex &index, 
int role = Qt::DisplayRole ) 
const override;
 
  119     QVariant headerData( 
int section, Qt::Orientation orientation, 
int role ) 
const override;
 
  120     bool setData( 
const QModelIndex &index, 
const QVariant &value, 
int role = Qt::EditRole ) 
override;
 
  121     Qt::ItemFlags flags( 
const QModelIndex &index ) 
const override;
 
  122     bool removeRows( 
int row, 
int count, 
const QModelIndex &parent = QModelIndex() ) 
override;
 
  123     bool insertRows( 
int row, 
int count, 
const QModelIndex &parent = QModelIndex() ) 
override;
 
  124     Qt::DropActions supportedDropActions() 
const override;
 
  125     QStringList mimeTypes() 
const override;
 
  126     QMimeData *mimeData( 
const QModelIndexList &indexes ) 
const override;
 
  127     bool dropMimeData( 
const QMimeData *data, Qt::DropAction action, 
int row, 
int column, 
const QModelIndex &parent ) 
override;
 
  129     QModelIndex addEntry( 
const QColor &color );
 
  137     void classesChanged();
 
  146 class QgsPalettedRendererProxyModel: 
public QSortFilterProxyModel
 
  152     QgsPalettedRendererProxyModel( QObject *parent = 0 )
 
  153       : QSortFilterProxyModel( parent )
 
  162     bool lessThan( 
const QModelIndex &left, 
const QModelIndex &right )
 const override 
  164       const QModelIndex lv { left.model()->index( left.row(), 
static_cast<int>( QgsPalettedRendererModel::Column::ValueColumn ), left.parent() ) };
 
  165       const QModelIndex rv { right.model()->index( right.row(), 
static_cast<int>( QgsPalettedRendererModel::Column::ValueColumn ), right.parent() ) };
 
  166       const double leftData { sourceModel()->data( lv ).toDouble( ) };
 
  167       const double rightData { sourceModel()->data( rv ).toDouble( ) };
 
  168       return leftData < rightData;
 
  199     QMenu *mContextMenu = 
nullptr;
 
  200     QMenu *mAdvancedMenu = 
nullptr;
 
  201     QAction *mLoadFromLayerAction = 
nullptr;
 
  202     QgsPalettedRendererModel *mModel = 
nullptr;
 
  203     QgsPalettedRendererProxyModel *mProxyModel = 
nullptr;
 
  206     QgsPalettedRendererClassGatherer *mGatherer = 
nullptr;
 
  210     QgsLocaleAwareNumericLineEditDelegate *mValueDelegate = 
nullptr;
 
  212     void setSelectionColor( const QItemSelection &selection, const QColor &color );
 
  219     void changeOpacity();
 
  221     void applyColorRamp();
 
  222     void loadColorTable();
 
  223     void saveColorTable();
 
  225     void loadFromLayer();
 
  226     void bandChanged( 
int band );
 
  228     void gatheredClasses();
 
  229     void gathererThreadFinished();
 
  234 #endif // QGSPALETTEDRENDERERWIDGET_H