Skip to content
Permalink
Browse files

[FEATURE]: possibility to show only visible features in composer tabl…

…e or all features

git-svn-id: http://svn.osgeo.org/qgis/trunk@12840 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Jan 28, 2010
1 parent 2d07997 commit 7e272d2c84cddc6cb437212aca88d91e0cdc2b27
@@ -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 );
}

@@ -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 )
@@ -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();
}


@@ -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 );
@@ -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 )
{

}
@@ -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 )
{
@@ -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();
@@ -320,7 +322,7 @@ bool QgsComposerTable::getFeatureAttributes( QList<QgsAttributeMap>& attributes
attributes.clear();

QgsRectangle selectionRect;
if ( mComposerMap )
if ( mComposerMap && mShowOnlyVisibleFeatures )
{
selectionRect = mComposerMap->extent();
}
@@ -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;}

@@ -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;
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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>

0 comments on commit 7e272d2

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