Skip to content
Permalink
Browse files

Fixed #3006 and added a convenience spin box for setting symbol level…

…s (constrained to 0-999)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14454 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Oct 30, 2010
1 parent 8202c00 commit 551edf25a334f4e8998338cea1341fd2d16948b3
Showing with 45 additions and 0 deletions.
  1. +2 −0 src/core/qgsvectorlayer.cpp
  2. +43 −0 src/gui/symbology-ng/qgssymbollevelsv2dialog.cpp
@@ -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() ) );

0 comments on commit 551edf2

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