[composer] Rename getHeaderLabels to headerLabels and make it public for composer text/attribute tables.

This commit is contained in:
Nyall Dawson 2014-04-28 19:00:42 +10:00
parent 98fac7957e
commit e0c64028b5
9 changed files with 18 additions and 18 deletions

View File

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

View File

@ -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*/

View File

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

View File

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

View File

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

View File

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

View File

@ -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.
@ -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*/

View File

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

View File

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