mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Fixed #3006 and added a convenience spin box for setting symbol levels (constrained to 0-999)
git-svn-id: http://svn.osgeo.org/qgis/trunk@14454 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
b21f5e6efc
commit
1494e42f52
@ -840,6 +840,8 @@ void QgsVectorLayer::drawRendererV2Levels( QgsRenderContext& rendererContext, bo
|
||||
for ( int j = 0; j < sym->symbolLayerCount(); j++ )
|
||||
{
|
||||
int level = sym->symbolLayer( j )->renderingPass();
|
||||
if ( level < 0 || level >= 1000 ) // ignore invalid levels
|
||||
continue;
|
||||
QgsSymbolV2LevelItem item( sym, j );
|
||||
while ( level >= levels.count() ) // append new empty levels
|
||||
levels.append( QgsSymbolV2Level() );
|
||||
|
@ -6,12 +6,55 @@
|
||||
#include "qgssymbolv2.h"
|
||||
|
||||
#include <QTableWidgetItem>
|
||||
#include <QItemDelegate>
|
||||
#include <QSpinBox>
|
||||
|
||||
// delegate used from Qt Spin Box example
|
||||
class SpinBoxDelegate : public QItemDelegate
|
||||
{
|
||||
public:
|
||||
SpinBoxDelegate(QObject *parent = 0) : QItemDelegate(parent) {}
|
||||
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem & /*option*/, const QModelIndex &/*index*/) const
|
||||
{
|
||||
QSpinBox *editor = new QSpinBox(parent);
|
||||
editor->setMinimum(0);
|
||||
editor->setMaximum(999);
|
||||
return editor;
|
||||
}
|
||||
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
{
|
||||
int value = index.model()->data(index, Qt::EditRole).toInt();
|
||||
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
|
||||
spinBox->setValue(value);
|
||||
}
|
||||
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||
{
|
||||
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
|
||||
spinBox->interpretText();
|
||||
int value = spinBox->value();
|
||||
|
||||
model->setData(index, value, Qt::EditRole);
|
||||
}
|
||||
|
||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex & /*index*/) const
|
||||
{
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
////////////////
|
||||
|
||||
QgsSymbolLevelsV2Dialog::QgsSymbolLevelsV2Dialog( QgsSymbolV2List symbols, bool usingSymbolLevels, QWidget* parent )
|
||||
: QDialog( parent ), mSymbols( symbols )
|
||||
{
|
||||
setupUi( this );
|
||||
|
||||
tableLevels->setItemDelegate( new SpinBoxDelegate(this) );
|
||||
|
||||
chkEnable->setChecked( usingSymbolLevels );
|
||||
|
||||
connect( chkEnable, SIGNAL( clicked() ), this, SLOT( updateUi() ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user