Skip to content
Permalink
Browse files

Scroll to newly added entries in paletted renderer widget

  • Loading branch information
nyalldawson committed Jun 11, 2017
1 parent ad6c46f commit f5a0243c9dc763e66cc3a21554a9c2b7a4db557e
Showing with 8 additions and 4 deletions.
  1. +7 −3 src/gui/raster/qgspalettedrendererwidget.cpp
  2. +1 −1 src/gui/raster/qgspalettedrendererwidget.h
@@ -213,7 +213,9 @@ void QgsPalettedRendererWidget::addEntry()
{
color = ramp->color( 1.0 );
}
mModel->addEntry( color );
QModelIndex newEntry = mModel->addEntry( color );
mTreeView->scrollTo( newEntry );
mTreeView->selectionModel()->select( newEntry, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
connect( mModel, &QgsPalettedRendererModel::classesChanged, this, &QgsPalettedRendererWidget::widgetChanged );
emit widgetChanged();
}
@@ -785,10 +787,12 @@ bool QgsPalettedRendererModel::dropMimeData( const QMimeData *data, Qt::DropActi
return true;
}

void QgsPalettedRendererModel::addEntry( const QColor &color )
QModelIndex QgsPalettedRendererModel::addEntry( const QColor &color )
{
insertRow( rowCount() );
setData( index( mData.count() - 1, 1 ), color );
QModelIndex newRow = index( mData.count() - 1, 1 );
setData( newRow, color );
return newRow;
}

void QgsPalettedRendererModel::deleteAll()
@@ -160,7 +160,7 @@ class QgsPalettedRendererModel : public QAbstractItemModel
QMimeData *mimeData( const QModelIndexList &indexes ) const override;
bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;

void addEntry( const QColor &color );
QModelIndex addEntry( const QColor &color );

public slots:

0 comments on commit f5a0243

Please sign in to comment.
You can’t perform that action at this time.