22 #include <QTableWidgetItem>
23 #include <QItemDelegate>
32 QWidget *
createEditor( QWidget *parent,
const QStyleOptionViewItem & ,
const QModelIndex & )
const override
34 QSpinBox *editor =
new QSpinBox( parent );
35 editor->setMinimum( 0 );
36 editor->setMaximum( 999 );
42 int value = index.model()->data( index, Qt::EditRole ).toInt();
43 QSpinBox *spinBox =
static_cast<QSpinBox*
>( editor );
44 spinBox->setValue( value );
47 void setModelData( QWidget *editor, QAbstractItemModel *model,
const QModelIndex &
index )
const override
49 QSpinBox *spinBox =
static_cast<QSpinBox*
>( editor );
50 spinBox->interpretText();
51 int value = spinBox->value();
53 model->setData( index, value, Qt::EditRole );
56 void updateEditorGeometry( QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex & )
const override
58 editor->setGeometry( option.rect );
66 : QDialog( parent ), mList( list ), mForceOrderingEnabled( false )
71 restoreGeometry( settings.value(
"/Windows/symbolLevelsDlg/geometry" ).toByteArray() );
75 chkEnable->setChecked( usingSymbolLevels );
77 connect( chkEnable, SIGNAL( clicked() ),
this, SLOT(
updateUi() ) );
86 tableLevels->setRowCount(
mList.count() );
87 for (
int i = 0; i <
mList.count(); i++ )
93 tableLevels->setVerticalHeaderItem( i,
new QTableWidgetItem( icon, QString() ) );
97 if ( layers > maxLayers )
101 tableLevels->setColumnCount( maxLayers + 1 );
102 tableLevels->setHorizontalHeaderItem( 0,
new QTableWidgetItem( QString() ) );
103 for (
int i = 0; i < maxLayers; i++ )
105 QString name =
tr(
"Layer %1" ).arg( i );
106 tableLevels->setHorizontalHeaderItem( i + 1,
new QTableWidgetItem( name ) );
113 if ( !usingSymbolLevels )
118 connect( tableLevels, SIGNAL( cellChanged(
int,
int ) ),
this, SLOT(
renderingPassChanged(
int,
int ) ) );
124 settings.setValue(
"/Windows/symbolLevelsDlg/geometry", saveGeometry() );
129 for (
int row = 0; row <
mList.count(); row++ )
132 QString label =
mList[row].first;
133 QTableWidgetItem *itemLabel =
new QTableWidgetItem( label );
134 itemLabel->setFlags( itemLabel->flags() ^ Qt::ItemIsEditable );
135 tableLevels->setItem( row, 0, itemLabel );
136 for (
int layer = 0; layer <
mMaxLayers; layer++ )
138 QTableWidgetItem* item;
141 item =
new QTableWidgetItem();
142 item->setFlags( Qt::ItemFlags() );
148 item =
new QTableWidgetItem( icon, QString::number( sl->
renderingPass() ) );
150 tableLevels->setItem( row, layer + 1, item );
151 tableLevels->resizeColumnToContents( 0 );
159 tableLevels->setEnabled( chkEnable->isChecked() );
164 for (
int i = 0; i <
mList.count(); i++ )
176 return chkEnable->isChecked();
181 if ( row < 0 || row >=
mList.count() )
194 chkEnable->setChecked(
true );