Skip to content

Commit

Permalink
[composer] Rename getHeaderLabels to headerLabels and make it public …
Browse files Browse the repository at this point in the history
…for composer text/attribute tables.
  • Loading branch information
nyalldawson committed Apr 28, 2014
1 parent 98fac79 commit e0c6402
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
3 changes: 0 additions & 3 deletions python/core/composer/qgscomposerattributetable.sip
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ class QgsComposerAttributeTable : QgsComposerTable
// @note not available in python bindings
// QList<QPair<int, bool> > sortAttributes() const;

protected:
virtual QMap<int, QString> getHeaderLabels() const;

signals:
/**This signal is emitted if the maximum number of feature changes (interactively)*/
void maximumNumberOfFeaturesChanged( int n );
Expand Down
2 changes: 1 addition & 1 deletion python/core/composer/qgscomposertable.sip
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class QgsComposerTable: QgsComposerItem
protected:
/**Retrieves feature attributes*/
// virtual bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps );
virtual QMap<int, QString> getHeaderLabels() const;

/**Calculate the maximum width values of the vector attributes*/
// virtual bool calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList< QMap<int, QVariant> >& attributeMaps ) const;
/**Adapts the size of the item frame to match the content*/
Expand Down
4 changes: 0 additions & 4 deletions python/core/composer/qgscomposertexttable.sip
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@ class QgsComposerTextTable: QgsComposerTable
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
bool readXML( const QDomElement& itemElem, const QDomDocument& doc );

protected:
//! @note not available in python bindings
// bool getFeatureAttributes( QList< QMap<int, QVariant> >& attributes );
QMap<int, QString> getHeaderLabels() const;
};
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerattributetable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ bool QgsComposerAttributeTable::getFeatureAttributes( QList<QgsAttributeMap> &at
return true;
}

QMap<int, QString> QgsComposerAttributeTable::getHeaderLabels() const
QMap<int, QString> QgsComposerAttributeTable::headerLabels() const
{
QMap<int, QString> header;
if ( mVectorLayer )
Expand Down
5 changes: 2 additions & 3 deletions src/core/composer/qgscomposerattributetable.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,14 @@ class CORE_EXPORT QgsComposerAttributeTable: public QgsComposerTable
*/
QList<QPair<int, bool> > sortAttributes() const { return mSortInformation; }

QMap<int, QString> headerLabels() const;

protected:
/**Retrieves feature attributes
* @note not available in python bindings
*/
bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps );

//! @note not available in python bindings
QMap<int, QString> getHeaderLabels() const;

private:
/**Associated vector layer*/
QgsVectorLayer* mVectorLayer;
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposertable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void QgsComposerTable::paint( QPainter* painter, const QStyleOptionGraphicsItem*
double currentX = mGridStrokeWidth;
double currentY;

QMap<int, QString> headerMap = getHeaderLabels();
QMap<int, QString> headerMap = headerLabels();
QMap<int, QString>::const_iterator columnIt = headerMap.constBegin();

for ( ; columnIt != headerMap.constEnd(); ++columnIt )
Expand Down Expand Up @@ -229,7 +229,7 @@ bool QgsComposerTable::tableReadXML( const QDomElement& itemElem, const QDomDocu
bool QgsComposerTable::calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeMaps ) const
{
maxWidthMap.clear();
QMap<int, QString> headerMap = getHeaderLabels();
QMap<int, QString> headerMap = headerLabels();
QMap<int, QString>::const_iterator headerIt = headerMap.constBegin();
for ( ; headerIt != headerMap.constEnd(); ++headerIt )
{
Expand Down
10 changes: 9 additions & 1 deletion src/core/composer/qgscomposertable.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ class CORE_EXPORT QgsComposerTable: public QgsComposerItem
void setGridColor( const QColor& c ) { mGridColor = c; }
QColor gridColor() const { return mGridColor; }

/*Returns the text used in the column headers for the table.
* @returns QMap of int to QString, where the int is the column index (starting at 0),
* and the string is the text to use for the column's header
* @note added in 2.3
* @note not available in python bindings
*/
virtual QMap<int, QString> headerLabels() const { return QMap<int, QString>(); } //= 0;

public slots:

/**Refreshes the attributes shown in the table by querying the vector layer for new data.
Expand Down Expand Up @@ -97,7 +105,7 @@ class CORE_EXPORT QgsComposerTable: public QgsComposerItem
/**Retrieves feature attributes*/
//! @note not available in python bindings
virtual bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps ) { Q_UNUSED( attributeMaps ); return false; }
virtual QMap<int, QString> getHeaderLabels() const { return QMap<int, QString>(); } //= 0;

/**Calculate the maximum width values of the vector attributes*/
virtual bool calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeMaps ) const;
/**Adapts the size of the item frame to match the content*/
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposertexttable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool QgsComposerTextTable::getFeatureAttributes( QList<QgsAttributeMap>& attribu
return true;
}

QMap<int, QString> QgsComposerTextTable::getHeaderLabels() const
QMap<int, QString> QgsComposerTextTable::headerLabels() const
{
QMap<int, QString> header;
QStringList::const_iterator it = mHeaderLabels.constBegin();
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposertexttable.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class CORE_EXPORT QgsComposerTextTable: public QgsComposerTable
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
bool readXML( const QDomElement& itemElem, const QDomDocument& doc );

QMap<int, QString> headerLabels() const;

protected:
//! @note not available in python bindings
bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps );

QMap<int, QString> getHeaderLabels() const;

private:
/**Column titles*/
QStringList mHeaderLabels;
Expand Down

0 comments on commit e0c6402

Please sign in to comment.