Skip to content

Commit

Permalink
Move rules up/down instead of inc/dec priorities
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Nov 26, 2011
1 parent 81ec790 commit 4a5d442
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 40 deletions.
16 changes: 8 additions & 8 deletions src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp
Expand Up @@ -68,17 +68,17 @@ QgsRuleBasedRendererV2Widget::QgsRuleBasedRendererV2Widget( QgsVectorLayer* laye
btnAddRule->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.png" ) ) ); btnAddRule->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.png" ) ) );
btnEditRule->setIcon( QIcon( QgsApplication::iconPath( "symbologyEdit.png" ) ) ); btnEditRule->setIcon( QIcon( QgsApplication::iconPath( "symbologyEdit.png" ) ) );
btnRemoveRule->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.png" ) ) ); btnRemoveRule->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.png" ) ) );
btnIncreasePriority->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.png" ) ) ); btnMoveUp->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.png" ) ) );
btnDecreasePriority->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.png" ) ) ); btnMoveDown->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.png" ) ) );


connect( treeRules, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( editRule() ) ); connect( treeRules, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( editRule() ) );
connect( treeRules, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( contextMenuViewCategories( const QPoint& ) ) ); connect( treeRules, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( contextMenuViewCategories( const QPoint& ) ) );


connect( btnAddRule, SIGNAL( clicked() ), this, SLOT( addRule() ) ); connect( btnAddRule, SIGNAL( clicked() ), this, SLOT( addRule() ) );
connect( btnEditRule, SIGNAL( clicked() ), this, SLOT( editRule() ) ); connect( btnEditRule, SIGNAL( clicked() ), this, SLOT( editRule() ) );
connect( btnRemoveRule, SIGNAL( clicked() ), this, SLOT( removeRule() ) ); connect( btnRemoveRule, SIGNAL( clicked() ), this, SLOT( removeRule() ) );
connect( btnIncreasePriority, SIGNAL( clicked() ), this, SLOT( increasePriority() ) ); connect( btnMoveUp, SIGNAL( clicked() ), this, SLOT( moveUp() ) );
connect( btnDecreasePriority, SIGNAL( clicked() ), this, SLOT( decreasePriority() ) ); connect( btnMoveDown, SIGNAL( clicked() ), this, SLOT( moveDown() ) );


connect( radNoGrouping, SIGNAL( clicked() ), this, SLOT( setGrouping() ) ); connect( radNoGrouping, SIGNAL( clicked() ), this, SLOT( setGrouping() ) );
connect( radGroupFilter, SIGNAL( clicked() ), this, SLOT( setGrouping() ) ); connect( radGroupFilter, SIGNAL( clicked() ), this, SLOT( setGrouping() ) );
Expand Down Expand Up @@ -180,7 +180,7 @@ void QgsRuleBasedRendererV2Widget::removeRule()
} }




void QgsRuleBasedRendererV2Widget::increasePriority() void QgsRuleBasedRendererV2Widget::moveUp()
{ {
QTreeWidgetItem * item = treeRules->currentItem(); QTreeWidgetItem * item = treeRules->currentItem();
if ( ! item ) return; // No rule selected, exit if ( ! item ) return; // No rule selected, exit
Expand All @@ -191,7 +191,7 @@ void QgsRuleBasedRendererV2Widget::increasePriority()
} }
else else
{ {
if ( rule_index > 0 ) // do not increase priority of first rule if ( rule_index > 0 ) // do not move up the first rule
{ {
mRenderer->swapRules( rule_index, rule_index - 1 ); mRenderer->swapRules( rule_index, rule_index - 1 );
treeRules->populateRules(); treeRules->populateRules();
Expand All @@ -205,7 +205,7 @@ void QgsRuleBasedRendererV2Widget::increasePriority()
} }




void QgsRuleBasedRendererV2Widget::decreasePriority() void QgsRuleBasedRendererV2Widget::moveDown()
{ {
QTreeWidgetItem * item = treeRules->currentItem(); QTreeWidgetItem * item = treeRules->currentItem();
if ( ! item ) return; // No rule selected, exit if ( ! item ) return; // No rule selected, exit
Expand All @@ -216,7 +216,7 @@ void QgsRuleBasedRendererV2Widget::decreasePriority()
} }
else else
{ {
if ( rule_index + 1 < mRenderer->ruleCount() ) // do not increase priority of last rule if ( rule_index + 1 < mRenderer->ruleCount() ) // do not move down the last rule
{ {
mRenderer->swapRules( rule_index, rule_index + 1 ); mRenderer->swapRules( rule_index, rule_index + 1 );
treeRules->populateRules(); treeRules->populateRules();
Expand Down
4 changes: 2 additions & 2 deletions src/gui/symbology-ng/qgsrulebasedrendererv2widget.h
Expand Up @@ -78,8 +78,8 @@ class GUI_EXPORT QgsRuleBasedRendererV2Widget : public QgsRendererV2Widget, priv
void addRule(); void addRule();
void editRule(); void editRule();
void removeRule(); void removeRule();
void increasePriority(); void moveUp();
void decreasePriority(); void moveDown();


void setGrouping(); void setGrouping();


Expand Down
34 changes: 4 additions & 30 deletions src/ui/qgsrulebasedrendererv2widget.ui
Expand Up @@ -10,27 +10,18 @@
<height>401</height> <height>401</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QgsRendererRulesTreeWidget" name="treeRules"> <widget class="QgsRendererRulesTreeWidget" name="treeRules">
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum> <enum>Qt::CustomContextMenu</enum>
</property> </property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="selectionMode"> <property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum> <enum>QAbstractItemView::ExtendedSelection</enum>
</property> </property>
<property name="rootIsDecorated"> <property name="rootIsDecorated">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="headerHidden"> <property name="headerHidden">
<bool>false</bool> <bool>false</bool>
</property> </property>
Expand All @@ -48,28 +39,11 @@
<property name="text"> <property name="text">
<string>Min. scale</string> <string>Min. scale</string>
</property> </property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column> </column>
<column> <column>
<property name="text"> <property name="text">
<string>Max. scale</string> <string>Max. scale</string>
</property> </property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column>
<property name="text">
<string>Priority</string>
</property>
<property name="toolTip">
<string>Priority when symbol levels are enabled (only first matching rule will be applied)</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column> </column>
</widget> </widget>
</item> </item>
Expand Down Expand Up @@ -104,16 +78,16 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="btnIncreasePriority"> <widget class="QPushButton" name="btnMoveUp">
<property name="text"> <property name="text">
<string>Increase priority</string> <string>Move up</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="btnDecreasePriority"> <widget class="QPushButton" name="btnMoveDown">
<property name="text"> <property name="text">
<string>Decrease priority</string> <string>Move down</string>
</property> </property>
</widget> </widget>
</item> </item>
Expand Down

0 comments on commit 4a5d442

Please sign in to comment.