Skip to content

Commit 6c148d0

Browse files
author
mhugent
committedJan 28, 2010
[FEATURE]: possibility to show only visible features in composer table or all features
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12840 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

5 files changed

+63
-27
lines changed

5 files changed

+63
-27
lines changed
 

‎src/app/composer/qgscomposertablewidget.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,15 @@ void QgsComposerTableWidget::updateGuiElements()
281281
{
282282
mShowGridCheckBox->setCheckState( Qt::Unchecked );
283283
}
284+
285+
if ( mComposerTable->displayOnlyVisibleFeatures() )
286+
{
287+
mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Checked );
288+
}
289+
else
290+
{
291+
mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Unchecked );
292+
}
284293
blockAllSignals( false );
285294
}
286295

@@ -293,6 +302,7 @@ void QgsComposerTableWidget::blockAllSignals( bool b )
293302
mGridColorButton->blockSignals( b );
294303
mGridStrokeWidthSpinBox->blockSignals( b );
295304
mShowGridCheckBox->blockSignals( b );
305+
mShowOnlyVisibleFeaturesCheckBox->blockSignals( b );
296306
}
297307

298308
void QgsComposerTableWidget::setMaximumNumberOfFeatures( int n )
@@ -302,5 +312,16 @@ void QgsComposerTableWidget::setMaximumNumberOfFeatures( int n )
302312
mMaximumColumnsSpinBox->blockSignals( false );
303313
}
304314

315+
void QgsComposerTableWidget::on_mShowOnlyVisibleFeaturesCheckBox_stateChanged( int state )
316+
{
317+
if ( !mComposerTable )
318+
{
319+
return;
320+
}
321+
322+
bool showOnlyVisibleFeatures = ( state == Qt::Checked );
323+
mComposerTable->setDisplayOnlyVisibleFeatures( showOnlyVisibleFeatures );
324+
mComposerTable->update();
325+
}
305326

306327

‎src/app/composer/qgscomposertablewidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class QgsComposerTableWidget: public QWidget, private Ui::QgsComposerTableWidget
4848
void on_mHeaderFontPushButton_clicked();
4949
void on_mContentFontPushButton_clicked();
5050
void on_mShowGridCheckBox_stateChanged( int state );
51+
void on_mShowOnlyVisibleFeaturesCheckBox_stateChanged( int state );
5152

5253
/**Inserts a new maximum number of features into the spin box (without the spinbox emitting a signal)*/
5354
void setMaximumNumberOfFeatures( int n );

‎src/core/composer/qgscomposertable.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <QPainter>
2424

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

2929
}
@@ -175,6 +175,7 @@ bool QgsComposerTable::writeXML( QDomElement& elem, QDomDocument & doc ) const
175175
composerTableElem.setAttribute( "gridColorGreen", mGridColor.green() );
176176
composerTableElem.setAttribute( "gridColorBlue", mGridColor.blue() );
177177
composerTableElem.setAttribute( "showGrid", mShowGrid );
178+
composerTableElem.setAttribute( "showOnlyVisibleFeatures", mShowOnlyVisibleFeatures );
178179

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

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

322324
QgsRectangle selectionRect;
323-
if ( mComposerMap )
325+
if ( mComposerMap && mShowOnlyVisibleFeatures )
324326
{
325327
selectionRect = mComposerMap->extent();
326328
}

‎src/core/composer/qgscomposertable.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class CORE_EXPORT QgsComposerTable: public QgsComposerItem
6666
void setGridColor( const QColor& c ) { mGridColor = c; }
6767
QColor gridColor() const { return mGridColor; }
6868

69+
void setDisplayOnlyVisibleFeatures( bool b ) { mShowOnlyVisibleFeatures = b; }
70+
bool displayOnlyVisibleFeatures() const { return mShowOnlyVisibleFeatures; }
71+
6972
QSet<int> displayAttributes() const { return mDisplayAttributes; }
7073
void setDisplayAttributes( const QSet<int>& attr ) { mDisplayAttributes = attr;}
7174

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

95100
/**List of attribute indices to display (or all attributes if list is empty)*/
96101
QSet<int> mDisplayAttributes;

‎src/ui/qgscomposertablewidgetbase.ui

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>258</width>
10-
<height>317</height>
9+
<width>269</width>
10+
<height>346</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -24,8 +24,8 @@
2424
<rect>
2525
<x>0</x>
2626
<y>0</y>
27-
<width>240</width>
28-
<height>273</height>
27+
<width>251</width>
28+
<height>302</height>
2929
</rect>
3030
</property>
3131
<attribute name="label">
@@ -53,7 +53,27 @@
5353
</property>
5454
</widget>
5555
</item>
56+
<item row="1" column="1">
57+
<spacer name="horizontalSpacer">
58+
<property name="orientation">
59+
<enum>Qt::Horizontal</enum>
60+
</property>
61+
<property name="sizeHint" stdset="0">
62+
<size>
63+
<width>40</width>
64+
<height>20</height>
65+
</size>
66+
</property>
67+
</spacer>
68+
</item>
5669
<item row="2" column="0" colspan="2">
70+
<widget class="QCheckBox" name="mShowOnlyVisibleFeaturesCheckBox">
71+
<property name="text">
72+
<string>Show only visible features</string>
73+
</property>
74+
</widget>
75+
</item>
76+
<item row="3" column="0" colspan="2">
5777
<layout class="QHBoxLayout" name="horizontalLayout_3">
5878
<item>
5979
<widget class="QLabel" name="mComposerMapLabel">
@@ -67,7 +87,7 @@
6787
</item>
6888
</layout>
6989
</item>
70-
<item row="3" column="0" colspan="2">
90+
<item row="4" column="0" colspan="2">
7191
<layout class="QHBoxLayout" name="horizontalLayout_2">
7292
<item>
7393
<widget class="QLabel" name="mMaxNumFeaturesLabel">
@@ -81,7 +101,7 @@
81101
</item>
82102
</layout>
83103
</item>
84-
<item row="4" column="0" colspan="2">
104+
<item row="5" column="0" colspan="2">
85105
<layout class="QHBoxLayout" name="horizontalLayout">
86106
<item>
87107
<widget class="QLabel" name="mMarginLabel">
@@ -95,14 +115,14 @@
95115
</item>
96116
</layout>
97117
</item>
98-
<item row="5" column="0">
118+
<item row="6" column="0" colspan="2">
99119
<widget class="QCheckBox" name="mShowGridCheckBox">
100120
<property name="text">
101121
<string>Show grid</string>
102122
</property>
103123
</widget>
104124
</item>
105-
<item row="6" column="0" colspan="2">
125+
<item row="7" column="0" colspan="2">
106126
<layout class="QHBoxLayout" name="horizontalLayout_5">
107127
<item>
108128
<widget class="QLabel" name="mGridStrokeWidthLabel">
@@ -116,14 +136,14 @@
116136
</item>
117137
</layout>
118138
</item>
119-
<item row="7" column="0">
139+
<item row="8" column="0">
120140
<widget class="QLabel" name="mGridColorLabel">
121141
<property name="text">
122142
<string>Grid color</string>
123143
</property>
124144
</widget>
125145
</item>
126-
<item row="7" column="1">
146+
<item row="8" column="1">
127147
<widget class="QgsColorButton" name="mGridColorButton">
128148
<property name="sizePolicy">
129149
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@@ -136,33 +156,20 @@
136156
</property>
137157
</widget>
138158
</item>
139-
<item row="8" column="0">
159+
<item row="9" column="0">
140160
<widget class="QPushButton" name="mHeaderFontPushButton">
141161
<property name="text">
142162
<string>Header Font...</string>
143163
</property>
144164
</widget>
145165
</item>
146-
<item row="8" column="1">
166+
<item row="9" column="1">
147167
<widget class="QPushButton" name="mContentFontPushButton">
148168
<property name="text">
149169
<string>Content Font...</string>
150170
</property>
151171
</widget>
152172
</item>
153-
<item row="1" column="1">
154-
<spacer name="horizontalSpacer">
155-
<property name="orientation">
156-
<enum>Qt::Horizontal</enum>
157-
</property>
158-
<property name="sizeHint" stdset="0">
159-
<size>
160-
<width>40</width>
161-
<height>20</height>
162-
</size>
163-
</property>
164-
</spacer>
165-
</item>
166173
</layout>
167174
</widget>
168175
</widget>

0 commit comments

Comments
 (0)
Please sign in to comment.