Skip to content

Commit

Permalink
[FEATURE]: possibility to show only visible features in composer tabl…
Browse files Browse the repository at this point in the history
…e or all features

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12840 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jan 28, 2010
1 parent e3d9079 commit 6c148d0
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 27 deletions.
21 changes: 21 additions & 0 deletions src/app/composer/qgscomposertablewidget.cpp
Expand Up @@ -281,6 +281,15 @@ void QgsComposerTableWidget::updateGuiElements()
{
mShowGridCheckBox->setCheckState( Qt::Unchecked );
}

if ( mComposerTable->displayOnlyVisibleFeatures() )
{
mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Checked );
}
else
{
mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Unchecked );
}
blockAllSignals( false );
}

Expand All @@ -293,6 +302,7 @@ void QgsComposerTableWidget::blockAllSignals( bool b )
mGridColorButton->blockSignals( b );
mGridStrokeWidthSpinBox->blockSignals( b );
mShowGridCheckBox->blockSignals( b );
mShowOnlyVisibleFeaturesCheckBox->blockSignals( b );
}

void QgsComposerTableWidget::setMaximumNumberOfFeatures( int n )
Expand All @@ -302,5 +312,16 @@ void QgsComposerTableWidget::setMaximumNumberOfFeatures( int n )
mMaximumColumnsSpinBox->blockSignals( false );
}

void QgsComposerTableWidget::on_mShowOnlyVisibleFeaturesCheckBox_stateChanged( int state )
{
if ( !mComposerTable )
{
return;
}

bool showOnlyVisibleFeatures = ( state == Qt::Checked );
mComposerTable->setDisplayOnlyVisibleFeatures( showOnlyVisibleFeatures );
mComposerTable->update();
}


1 change: 1 addition & 0 deletions src/app/composer/qgscomposertablewidget.h
Expand Up @@ -48,6 +48,7 @@ class QgsComposerTableWidget: public QWidget, private Ui::QgsComposerTableWidget
void on_mHeaderFontPushButton_clicked();
void on_mContentFontPushButton_clicked();
void on_mShowGridCheckBox_stateChanged( int state );
void on_mShowOnlyVisibleFeaturesCheckBox_stateChanged( int state );

/**Inserts a new maximum number of features into the spin box (without the spinbox emitting a signal)*/
void setMaximumNumberOfFeatures( int n );
Expand Down
6 changes: 4 additions & 2 deletions src/core/composer/qgscomposertable.cpp
Expand Up @@ -23,7 +23,7 @@
#include <QPainter>

QgsComposerTable::QgsComposerTable( QgsComposition* composition ): QgsComposerItem( composition ), mVectorLayer( 0 ), mComposerMap( 0 ), \
mMaximumNumberOfFeatures( 5 ), mLineTextDistance( 1.0 ), mShowGrid( true ), mGridStrokeWidth( 0.5 ), mGridColor( QColor( 0, 0, 0 ) )
mMaximumNumberOfFeatures( 5 ), mLineTextDistance( 1.0 ), mShowGrid( true ), mGridStrokeWidth( 0.5 ), mGridColor( QColor( 0, 0, 0 ) ), mShowOnlyVisibleFeatures( true )
{

}
Expand Down Expand Up @@ -175,6 +175,7 @@ bool QgsComposerTable::writeXML( QDomElement& elem, QDomDocument & doc ) const
composerTableElem.setAttribute( "gridColorGreen", mGridColor.green() );
composerTableElem.setAttribute( "gridColorBlue", mGridColor.blue() );
composerTableElem.setAttribute( "showGrid", mShowGrid );
composerTableElem.setAttribute( "showOnlyVisibleFeatures", mShowOnlyVisibleFeatures );

if ( mComposerMap )
{
Expand Down Expand Up @@ -229,6 +230,7 @@ bool QgsComposerTable::readXML( const QDomElement& itemElem, const QDomDocument&
mLineTextDistance = itemElem.attribute( "lineTextDist", "1.0" ).toDouble();
mGridStrokeWidth = itemElem.attribute( "gridStrokeWidth", "0.5" ).toDouble();
mShowGrid = itemElem.attribute( "showGrid", "1" ).toInt();
mShowOnlyVisibleFeatures = itemElem.attribute( "showOnlyVisibleFeatures", "1" ).toInt();

//grid color
int gridRed = itemElem.attribute( "gridColorRed", "0" ).toInt();
Expand Down Expand Up @@ -320,7 +322,7 @@ bool QgsComposerTable::getFeatureAttributes( QList<QgsAttributeMap>& attributes
attributes.clear();

QgsRectangle selectionRect;
if ( mComposerMap )
if ( mComposerMap && mShowOnlyVisibleFeatures )
{
selectionRect = mComposerMap->extent();
}
Expand Down
5 changes: 5 additions & 0 deletions src/core/composer/qgscomposertable.h
Expand Up @@ -66,6 +66,9 @@ class CORE_EXPORT QgsComposerTable: public QgsComposerItem
void setGridColor( const QColor& c ) { mGridColor = c; }
QColor gridColor() const { return mGridColor; }

void setDisplayOnlyVisibleFeatures( bool b ) { mShowOnlyVisibleFeatures = b; }
bool displayOnlyVisibleFeatures() const { return mShowOnlyVisibleFeatures; }

QSet<int> displayAttributes() const { return mDisplayAttributes; }
void setDisplayAttributes( const QSet<int>& attr ) { mDisplayAttributes = attr;}

Expand All @@ -91,6 +94,8 @@ class CORE_EXPORT QgsComposerTable: public QgsComposerItem
bool mShowGrid;
double mGridStrokeWidth;
QColor mGridColor;
/**Shows only the features that are visible in the associated composer map (true by default)*/
bool mShowOnlyVisibleFeatures;

/**List of attribute indices to display (or all attributes if list is empty)*/
QSet<int> mDisplayAttributes;
Expand Down
57 changes: 32 additions & 25 deletions src/ui/qgscomposertablewidgetbase.ui
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>258</width>
<height>317</height>
<width>269</width>
<height>346</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -24,8 +24,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>240</width>
<height>273</height>
<width>251</width>
<height>302</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -53,7 +53,27 @@
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="mShowOnlyVisibleFeaturesCheckBox">
<property name="text">
<string>Show only visible features</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="mComposerMapLabel">
Expand All @@ -67,7 +87,7 @@
</item>
</layout>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="mMaxNumFeaturesLabel">
Expand All @@ -81,7 +101,7 @@
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="mMarginLabel">
Expand All @@ -95,14 +115,14 @@
</item>
</layout>
</item>
<item row="5" column="0">
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="mShowGridCheckBox">
<property name="text">
<string>Show grid</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="mGridStrokeWidthLabel">
Expand All @@ -116,14 +136,14 @@
</item>
</layout>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="mGridColorLabel">
<property name="text">
<string>Grid color</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QgsColorButton" name="mGridColorButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
Expand All @@ -136,33 +156,20 @@
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QPushButton" name="mHeaderFontPushButton">
<property name="text">
<string>Header Font...</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QPushButton" name="mContentFontPushButton">
<property name="text">
<string>Content Font...</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
Expand Down

0 comments on commit 6c148d0

Please sign in to comment.