Skip to content
Permalink
Browse files

GUI tweaks for rule-based renderer widget and symbol level dialog

  • Loading branch information
wonder-sk committed Jan 23, 2012
1 parent 0c5e591 commit 63d6a0ad85a533619dacb9d53bd2bf470dfe4bdb
@@ -141,7 +141,7 @@ void QgsRendererV2Widget::changeSymbolSize()

void QgsRendererV2Widget::showSymbolLevelsDialog( QgsFeatureRendererV2* r )
{
QgsSymbolV2List symbols = r->symbols();
QgsLegendSymbolList symbols = r->legendSymbolItems();

QgsSymbolLevelsV2Dialog dlg( symbols, r->usingSymbolLevels(), this );

@@ -326,9 +326,11 @@ void QgsRuleBasedRendererV2Widget::refreshSymbolView()

void QgsRuleBasedRendererV2Widget::setRenderingOrder()
{
QgsSymbolV2List symbols = mRenderer->symbols();
QgsLegendSymbolList lst = mRenderer->legendSymbolItems();

QgsSymbolLevelsV2Dialog dlg( lst, true, this );
dlg.setForceOrderingEnabled( true );

QgsSymbolLevelsV2Dialog dlg( symbols, true, this );
dlg.exec();
}

@@ -48,8 +48,8 @@ class SpinBoxDelegate : public QItemDelegate

////////////////

QgsSymbolLevelsV2Dialog::QgsSymbolLevelsV2Dialog( QgsSymbolV2List symbols, bool usingSymbolLevels, QWidget* parent )
: QDialog( parent ), mSymbols( symbols )
QgsSymbolLevelsV2Dialog::QgsSymbolLevelsV2Dialog( QgsLegendSymbolList list, bool usingSymbolLevels, QWidget* parent )
: QDialog( parent ), mList( list ), mForceOrderingEnabled( false )
{
setupUi( this );

@@ -60,14 +60,15 @@ QgsSymbolLevelsV2Dialog::QgsSymbolLevelsV2Dialog( QgsSymbolV2List symbols, bool
connect( chkEnable, SIGNAL( clicked() ), this, SLOT( updateUi() ) );

int maxLayers = 0;
tableLevels->setRowCount( symbols.count() );
for ( int i = 0; i < symbols.count(); i++ )
tableLevels->setRowCount( list.count() );
for ( int i = 0; i < list.count(); i++ )
{
QgsSymbolV2* sym = symbols[i];
QgsSymbolV2* sym = list[i].second;
QString label = list[i].first;

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

// find out max. number of layers per symbol
int layers = sym->symbolLayerCount();
@@ -96,9 +97,9 @@ QgsSymbolLevelsV2Dialog::QgsSymbolLevelsV2Dialog( QgsSymbolV2List symbols, bool

void QgsSymbolLevelsV2Dialog::populateTable()
{
for ( int row = 0; row < mSymbols.count(); row++ )
for ( int row = 0; row < mList.count(); row++ )
{
QgsSymbolV2* sym = mSymbols[row];
QgsSymbolV2* sym = mList[row].second;
for ( int layer = 0; layer < mMaxLayers; layer++ )
{
QTableWidgetItem* item;
@@ -109,7 +110,9 @@ void QgsSymbolLevelsV2Dialog::populateTable()
}
else
{
item = new QTableWidgetItem( QString::number( sym->symbolLayer( layer )->renderingPass() ) );
QgsSymbolLayerV2* sl = sym->symbolLayer( layer );
QIcon icon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( sl, QgsSymbolV2::MM, QSize( 16, 16 ) );
item = new QTableWidgetItem( icon, QString::number( sl->renderingPass() ) );
}
tableLevels->setItem( row, layer, item );
}
@@ -149,3 +152,15 @@ void QgsSymbolLevelsV2Dialog::renderingPassChanged( int row, int column )
return;
sym->symbolLayer( column )->setRenderingPass( tableLevels->item( row, column )->text().toInt() );
}

void QgsSymbolLevelsV2Dialog::setForceOrderingEnabled( bool enabled )
{
mForceOrderingEnabled = enabled;
if ( enabled )
{
chkEnable->setChecked( true );
chkEnable->hide();
}
else
chkEnable->show();
}
@@ -14,9 +14,13 @@ class GUI_EXPORT QgsSymbolLevelsV2Dialog : public QDialog, private Ui::QgsSymbol
Q_OBJECT
public:
QgsSymbolLevelsV2Dialog( QgsSymbolV2List symbols, bool usingSymbolLevels, QWidget* parent = NULL );
QgsSymbolLevelsV2Dialog( QgsLegendSymbolList list, bool usingSymbolLevels, QWidget* parent = NULL );

bool usingLevels() const;

// used by rule-based renderer (to hide checkbox to enable/disable ordering)
void setForceOrderingEnabled( bool enabled );

public slots:
void updateUi();

@@ -30,6 +34,9 @@ class GUI_EXPORT QgsSymbolLevelsV2Dialog : public QDialog, private Ui::QgsSymbol
//! maximal number of layers from all symbols
int mMaxLayers;
QgsSymbolV2List mSymbols;
QgsLegendSymbolList mList;
//! whether symbol layers always should be used (default false)
bool mForceOrderingEnabled;
};

#endif // QGSSYMBOLLEVELSV2DIALOG_H
@@ -10,9 +10,28 @@
<height>401</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTreeView" name="viewRules">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnAddRule">
<property name="text">
@@ -42,55 +61,27 @@
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnRenderingOrder">
<property name="text">
<string>Rendering order...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnRenderingOrder">
<property name="text">
<string>Rendering order...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QTreeView" name="viewRules">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>

0 comments on commit 63d6a0a

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