Skip to content
Permalink
Browse files

Fix #11285 (improve symbol levels dialog for long symbol labels) - by…

… Salvatore Larosa
  • Loading branch information
wonder-sk committed Oct 2, 2014
1 parent c5652a5 commit f652afb9fac246742d7a131bcd9b6b7f7156709f
@@ -67,6 +67,9 @@ QgsSymbolLevelsV2Dialog::QgsSymbolLevelsV2Dialog( QgsLegendSymbolList list, bool
{
setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/symbolLevelsDlg/geometry" ).toByteArray() );

tableLevels->setItemDelegate( new SpinBoxDelegate( this ) );

chkEnable->setChecked( usingSymbolLevels );
@@ -84,23 +87,23 @@ QgsSymbolLevelsV2Dialog::QgsSymbolLevelsV2Dialog( QgsLegendSymbolList list, bool
for ( int i = 0; i < mList.count(); i++ )
{
QgsSymbolV2* sym = mList[i].second;
QString label = mList[i].first;

// set icons for the rows
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( sym, QSize( 16, 16 ) );
tableLevels->setVerticalHeaderItem( i, new QTableWidgetItem( icon, label ) );
tableLevels->setVerticalHeaderItem( i, new QTableWidgetItem( icon, QString() ) );

// find out max. number of layers per symbol
int layers = sym->symbolLayerCount();
if ( layers > maxLayers )
maxLayers = layers;
}

tableLevels->setColumnCount( maxLayers );
tableLevels->setColumnCount( maxLayers + 1 );
tableLevels->setHorizontalHeaderItem( 0, new QTableWidgetItem( QString() ) );
for ( int i = 0; i < maxLayers; i++ )
{
QString name = tr( "Layer %1" ).arg( i );
tableLevels->setHorizontalHeaderItem( i, new QTableWidgetItem( name ) );
tableLevels->setHorizontalHeaderItem( i + 1, new QTableWidgetItem( name ) );
}

mMaxLayers = maxLayers;
@@ -115,11 +118,21 @@ QgsSymbolLevelsV2Dialog::QgsSymbolLevelsV2Dialog( QgsLegendSymbolList list, bool
connect( tableLevels, SIGNAL( cellChanged( int, int ) ), this, SLOT( renderingPassChanged( int, int ) ) );
}

QgsSymbolLevelsV2Dialog::~QgsSymbolLevelsV2Dialog()
{
QSettings settings;
settings.setValue( "/Windows/symbolLevelsDlg/geometry", saveGeometry() );
}

void QgsSymbolLevelsV2Dialog::populateTable()
{
for ( int row = 0; row < mList.count(); row++ )
{
QgsSymbolV2* sym = mList[row].second;
QString label = mList[row].first;
QTableWidgetItem *itemLabel = new QTableWidgetItem( label );
itemLabel->setFlags( itemLabel->flags() ^ Qt::ItemIsEditable );
tableLevels->setItem( row, 0, itemLabel );
for ( int layer = 0; layer < mMaxLayers; layer++ )
{
QTableWidgetItem* item;
@@ -134,7 +147,8 @@ void QgsSymbolLevelsV2Dialog::populateTable()
QIcon icon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( sl, QgsSymbolV2::MM, QSize( 16, 16 ) );
item = new QTableWidgetItem( icon, QString::number( sl->renderingPass() ) );
}
tableLevels->setItem( row, layer, item );
tableLevels->setItem( row, layer + 1, item );
tableLevels->resizeColumnToContents( 0 );
}
}

@@ -157,7 +171,6 @@ void QgsSymbolLevelsV2Dialog::setDefaultLevels()
}
}


bool QgsSymbolLevelsV2Dialog::usingLevels() const
{
return chkEnable->isChecked();
@@ -168,9 +181,9 @@ void QgsSymbolLevelsV2Dialog::renderingPassChanged( int row, int column )
if ( row < 0 || row >= mList.count() )
return;
QgsSymbolV2* sym = mList[row].second;
if ( column < 0 || column >= sym->symbolLayerCount() )
if ( column < 0 || column > sym->symbolLayerCount() )
return;
sym->symbolLayer( column )->setRenderingPass( tableLevels->item( row, column )->text().toInt() );
sym->symbolLayer( column - 1 )->setRenderingPass( tableLevels->item( row, column )->text().toInt() );
}

void QgsSymbolLevelsV2Dialog::setForceOrderingEnabled( bool enabled )
@@ -30,6 +30,8 @@ class GUI_EXPORT QgsSymbolLevelsV2Dialog : public QDialog, private Ui::QgsSymbol
// @note not available in python bindings
QgsSymbolLevelsV2Dialog( QgsLegendSymbolList list, bool usingSymbolLevels, QWidget* parent = NULL );

~QgsSymbolLevelsV2Dialog();

bool usingLevels() const;

// used by rule-based renderer (to hide checkbox to enable/disable ordering)
@@ -32,7 +32,14 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QTableWidget" name="tableLevels"/>
<widget class="QTableWidget" name="tableLevels">
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
</widget>
</item>
<item row="3" column="0">
<widget class="QDialogButtonBox" name="buttonBox">

0 comments on commit f652afb

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