Skip to content

Commit

Permalink
Merge pull request #192 from dakcarto/update-rulebasestyles-gui-2
Browse files Browse the repository at this point in the history
Update to usability of rule-based styles widgets.
  • Loading branch information
dakcarto committed Jul 29, 2012
2 parents 5b44fbf + 26a4f80 commit 1eeb537
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp
Expand Up @@ -26,6 +26,7 @@
#include "qstring.h"

#include <QMenu>
#include <QSettings>
#include <QTreeWidgetItem>
#include <QVBoxLayout>
#include <QMessageBox>
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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() );
}


///////////

Expand All @@ -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() )
{
Expand Down Expand Up @@ -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() )
{
Expand Down
3 changes: 3 additions & 0 deletions src/gui/symbology-ng/qgsrulebasedrendererv2widget.h
Expand Up @@ -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 );
Expand Down
3 changes: 3 additions & 0 deletions src/ui/qgsrendererrulepropsdialogbase.ui
Expand Up @@ -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">
Expand Down
6 changes: 6 additions & 0 deletions src/ui/qgsrulebasedrendererv2widget.ui
Expand Up @@ -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>
Expand Down

0 comments on commit 1eeb537

Please sign in to comment.