Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rulebased rendering gui tweaks #79

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ QgsRuleBasedRendererV2Widget::QgsRuleBasedRendererV2Widget( QgsVectorLayer* laye
setupUi( this );

treeRules->setRenderer( mRenderer );
treeRules->setSelectionMode(QAbstractItemView::SingleSelection);
mRefineMenu = new QMenu( btnRefineRule );
mRefineMenu->addAction( tr( "Add scales" ), this, SLOT( refineRuleScales() ) );
mRefineMenu->addAction( tr( "Add categories" ), this, SLOT( refineRuleCategories() ) );
Expand Down Expand Up @@ -202,15 +203,20 @@ void QgsRuleBasedRendererV2Widget::increasePriority()
{
if ( rule_index > 0 ) // do not increase priority of first rule
{
// we need the string width of the index (which is a string) for finding it back
int indexWidth = item->data(4, Qt::EditRole).toString().length();
mRenderer->swapRules( rule_index, rule_index - 1 );
treeRules->populateRules();
// TODO: find out where the moved rule goes and reselect it (at least for non-grouped display)
// maybe based on the following functions :
// findItems(QString(rule_index - 1), Qt::MatchExactly, 4).first.index)
// setCurrentItem, setSelected, scrollToItem
QList<QTreeWidgetItem *> items = treeRules->findItems(
QString("%1").arg(rule_index, indexWidth), Qt::MatchExactly, 4 );
if (items.length()==1)
{
treeRules->setCurrentItem(items.first());
}
}
}

}
treeRules->sortByColumn(4, Qt::AscendingOrder); // busy with priority: more clear if we order by prio now
}


Expand All @@ -227,10 +233,19 @@ void QgsRuleBasedRendererV2Widget::decreasePriority()
{
if ( rule_index + 1 < mRenderer->ruleCount() ) // do not increase priority of last rule
{
// we need the string width of the index (which is a string) for finding it back
int indexWidth = item->data(4, Qt::EditRole).toString().length();
mRenderer->swapRules( rule_index, rule_index + 1 );
treeRules->populateRules();
QList<QTreeWidgetItem *> items = treeRules->findItems(
QString("%1").arg(rule_index+2, indexWidth), Qt::MatchExactly, 4 );
if (items.length()==1)
{
treeRules->setCurrentItem(items.first());
}
}
}
treeRules->sortByColumn(4, Qt::AscendingOrder); // busy with priority: more clear if we order by prio now
}


Expand Down