Navigation Menu

Skip to content

Commit

Permalink
enable/disable buttons in QgsRuleBasedRendererV2Widget based on selec…
Browse files Browse the repository at this point in the history
…tion

also made a tooltip and a label more precise
  • Loading branch information
SebDieBln committed Nov 26, 2015
1 parent 5387fd1 commit b498094
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions python/gui/symbology-ng/qgsrulebasedrendererv2widget.sip
Expand Up @@ -79,6 +79,7 @@ class QgsRuleBasedRendererV2Widget : QgsRendererV2Widget
void setRenderingOrder();

void currentRuleChanged( const QModelIndex& current = QModelIndex(), const QModelIndex& previous = QModelIndex() );
void selectedRulesChanged();

void saveSectionWidth( int section, int oldSize, int newSize );
void restoreSectionWidths();
Expand Down
11 changes: 10 additions & 1 deletion src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp
Expand Up @@ -95,6 +95,7 @@ QgsRuleBasedRendererV2Widget::QgsRuleBasedRendererV2Widget( QgsVectorLayer* laye
connect( viewRules, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( contextMenuViewCategories( const QPoint& ) ) );

connect( viewRules->selectionModel(), SIGNAL( currentChanged( QModelIndex, QModelIndex ) ), this, SLOT( currentRuleChanged( QModelIndex, QModelIndex ) ) );
connect( viewRules->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), this, SLOT( selectedRulesChanged() ) );

connect( btnAddRule, SIGNAL( clicked() ), this, SLOT( addRule() ) );
connect( btnEditRule, SIGNAL( clicked() ), this, SLOT( editRule() ) );
Expand All @@ -105,6 +106,7 @@ QgsRuleBasedRendererV2Widget::QgsRuleBasedRendererV2Widget( QgsVectorLayer* laye
connect( btnRenderingOrder, SIGNAL( clicked() ), this, SLOT( setRenderingOrder() ) );

currentRuleChanged();
selectedRulesChanged();

// store/restore header section widths
connect( viewRules->header(), SIGNAL( sectionResized( int, int, int ) ), this, SLOT( saveSectionWidth( int, int, int ) ) );
Expand Down Expand Up @@ -200,7 +202,7 @@ void QgsRuleBasedRendererV2Widget::removeRule()
void QgsRuleBasedRendererV2Widget::currentRuleChanged( const QModelIndex& current, const QModelIndex& previous )
{
Q_UNUSED( previous );
btnRefineRule->setEnabled( current.isValid() );
btnEditRule->setEnabled( current.isValid() );
}


Expand Down Expand Up @@ -578,6 +580,13 @@ void QgsRuleBasedRendererV2Widget::countFeatures()
mModel->setFeatureCounts( countMap );
}

void QgsRuleBasedRendererV2Widget::selectedRulesChanged()
{
bool enabled = !viewRules->selectionModel()->selectedIndexes().isEmpty();
btnRefineRule->setEnabled( enabled );
btnRemoveRule->setEnabled( enabled );
}

///////////

QgsRendererRulePropsDialog::QgsRendererRulePropsDialog( QgsRuleBasedRendererV2::Rule* rule, QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent , QgsMapCanvas* mapCanvas )
Expand Down
1 change: 1 addition & 0 deletions src/gui/symbology-ng/qgsrulebasedrendererv2widget.h
Expand Up @@ -126,6 +126,7 @@ class GUI_EXPORT QgsRuleBasedRendererV2Widget : public QgsRendererV2Widget, priv
void setRenderingOrder();

void currentRuleChanged( const QModelIndex& current = QModelIndex(), const QModelIndex& previous = QModelIndex() );
void selectedRulesChanged();

void saveSectionWidth( int section, int oldSize, int newSize );
void restoreSectionWidths();
Expand Down
6 changes: 3 additions & 3 deletions src/ui/qgsrulebasedrendererv2widget.ui
Expand Up @@ -64,7 +64,7 @@
<item>
<widget class="QPushButton" name="btnEditRule">
<property name="toolTip">
<string>Edit rule</string>
<string>Edit current rule</string>
</property>
<property name="text">
<string/>
Expand All @@ -78,7 +78,7 @@
<item>
<widget class="QPushButton" name="btnRemoveRule">
<property name="toolTip">
<string>Remove rule</string>
<string>Remove selected rules</string>
</property>
<property name="text">
<string/>
Expand All @@ -95,7 +95,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>Refine current rules</string>
<string>Refine selected rules</string>
</property>
<property name="checkable">
<bool>false</bool>
Expand Down

0 comments on commit b498094

Please sign in to comment.