Skip to content
Permalink
Browse files

Update to usability of rule-based styles widgets.

Rule-based tree widget:
* Label and expression header sections have a larger initial width of 200, with new minimum width of 100 for all sections.
* Resizing of first 3 sections are saved to/restored from QSettings. Last section stretches, so is not saved/restored.
* All items now have tool tips of their content (good for small screens).

Rule editing dialog:
* Expanded width for initial form fields
* Added tool tips for expression and description fields.
  • Loading branch information
dakcarto committed Jul 8, 2012
1 parent 81abf7f commit 26a4f80260481c963e956503dc79e57a262dc13d
@@ -26,6 +26,7 @@
#include "qstring.h"

#include <QMenu>
#include <QSettings>
#include <QTreeWidgetItem>
#include <QVBoxLayout>
#include <QMessageBox>
@@ -89,6 +90,12 @@ QgsRuleBasedRendererV2Widget::QgsRuleBasedRendererV2Widget( QgsVectorLayer* laye
connect( btnRenderingOrder, SIGNAL( clicked() ), this, SLOT( setRenderingOrder() ) );

currentRuleChanged();

// store/restore header section widths
connect( viewRules->header(), SIGNAL( sectionResized( int, int, int ) ), this, SLOT( saveSectionWidth( int, int, int ) ) );

restoreSectionWidths();

}

QgsRuleBasedRendererV2Widget::~QgsRuleBasedRendererV2Widget()
@@ -367,6 +374,27 @@ void QgsRuleBasedRendererV2Widget::setRenderingOrder()
dlg.exec();
}

void QgsRuleBasedRendererV2Widget::saveSectionWidth( int section, int oldSize, int newSize )
{
Q_UNUSED( oldSize );
// skip last section, as it stretches
if ( section == 3 )
return;
QSettings settings;
QString path = "/Windows/RuleBasedTree/sectionWidth/" + QString::number( section );
settings.setValue( path, newSize );
}

void QgsRuleBasedRendererV2Widget::restoreSectionWidths()
{
QSettings settings;
QString path = "/Windows/RuleBasedTree/sectionWidth/";
QHeaderView* head = viewRules->header();
head->resizeSection( 0, settings.value( path + QString::number( 0 ), 200 ).toInt() );
head->resizeSection( 1, settings.value( path + QString::number( 1 ), 200 ).toInt() );
head->resizeSection( 2, settings.value( path + QString::number( 2 ), 100 ).toInt() );
}


///////////

@@ -379,8 +407,10 @@ QgsRendererRulePropsDialog::QgsRendererRulePropsDialog( QgsRuleBasedRendererV2::
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );

editFilter->setText( mRule->filterExpression() );
editFilter->setToolTip( mRule->filterExpression() );
editLabel->setText( mRule->label() );
editDescription->setText( mRule->description() );
editDescription->setToolTip( mRule->description() );

if ( mRule->dependsOnScale() )
{
@@ -518,7 +548,7 @@ QVariant QgsRuleBasedRendererV2Model::data( const QModelIndex &index, int role )

QgsRuleBasedRendererV2::Rule* rule = ruleForIndex( index );

if ( role == Qt::DisplayRole )
if ( role == Qt::DisplayRole || role == Qt::ToolTipRole )
{
switch ( index.column() )
{
@@ -107,6 +107,9 @@ class GUI_EXPORT QgsRuleBasedRendererV2Widget : public QgsRendererV2Widget, priv

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

void saveSectionWidth( int section, int oldSize, int newSize );
void restoreSectionWidths();

protected:

void refineRule( int type );
@@ -16,6 +16,9 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_1">
<property name="text">
@@ -37,6 +37,12 @@
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<attribute name="headerMinimumSectionSize">
<number>100</number>
</attribute>
<attribute name="headerStretchLastSection">
<bool>true</bool>
</attribute>
</widget>
</item>
<item>

0 comments on commit 26a4f80

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