Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fixes #11285
diff --git a/src/gui/symbology-ng/qgssymbollevelsv2dialog.cpp b/src/gui/symbology-ng/qgssymbollevelsv2dialog.cpp
index f899df2..4f8482f 100644
--- a/src/gui/symbology-ng/qgssymbollevelsv2dialog.cpp
+++ b/src/gui/symbology-ng/qgssymbollevelsv2dialog.cpp
@@ -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,11 +87,10 @@ 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, "" ) );
// find out max. number of layers per symbol
int layers = sym->symbolLayerCount();
@@ -96,11 +98,12 @@ QgsSymbolLevelsV2Dialog::QgsSymbolLevelsV2Dialog( QgsLegendSymbolList list, bool
maxLayers = layers;
}
- tableLevels->setColumnCount( maxLayers );
+ tableLevels->setColumnCount( maxLayers + 1 );
+ tableLevels->setHorizontalHeaderItem( 0, new QTableWidgetItem( "" ) );
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,20 @@ 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 );
for ( int layer = 0; layer < mMaxLayers; layer++ )
{
QTableWidgetItem* item;
@@ -134,7 +146,9 @@ 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, itemLabel );
+ 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 )
diff --git a/src/gui/symbology-ng/qgssymbollevelsv2dialog.h b/src/gui/symbology-ng/qgssymbollevelsv2dialog.h
index c4b86bb..d004606 100644
--- a/src/gui/symbology-ng/qgssymbollevelsv2dialog.h
+++ b/src/gui/symbology-ng/qgssymbollevelsv2dialog.h
@@ -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)
diff --git a/src/ui/qgssymbollevelsv2dialogbase.ui b/src/ui/qgssymbollevelsv2dialogbase.ui
index b491459..3476d30 100644
--- a/src/ui/qgssymbollevelsv2dialogbase.ui
+++ b/src/ui/qgssymbollevelsv2dialogbase.ui
@@ -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">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.