QGIS API Documentation  master-59fd5e0
src/core/composer/qgscomposerattributetable.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                          qgscomposerattributetable.h
00003                          ---------------------------
00004     begin                : April 2010
00005     copyright            : (C) 2010 by Marco Hugentobler
00006     email                : marco at hugis dot net
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef QGSCOMPOSERATTRIBUTETABLE_H
00019 #define QGSCOMPOSERATTRIBUTETABLE_H
00020 
00021 #include "qgscomposertable.h"
00022 
00023 class QgsComposerMap;
00024 class QgsVectorLayer;
00025 
00027 class CORE_EXPORT QgsComposerAttributeTableCompare
00028 {
00029   public:
00030     QgsComposerAttributeTableCompare();
00031     bool operator()( const QgsAttributes& m1, const QgsAttributes& m2 );
00032     void setSortColumn( int col ) { mCurrentSortColumn = col; }
00033     void setAscending( bool asc ) { mAscending = asc; }
00034   private:
00035     int mCurrentSortColumn;
00036     bool mAscending;
00037 };
00038 
00040 class CORE_EXPORT QgsComposerAttributeTable: public QgsComposerTable
00041 {
00042     Q_OBJECT
00043   public:
00044     QgsComposerAttributeTable( QgsComposition* composition );
00045     ~QgsComposerAttributeTable();
00046 
00048     virtual int type() const { return ComposerAttributeTable; }
00049 
00051     virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
00052 
00053     bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
00054     bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
00055 
00056     void setVectorLayer( QgsVectorLayer* vl );
00057     const QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
00058 
00059     void setComposerMap( const QgsComposerMap* map );
00060     const QgsComposerMap* composerMap() const { return mComposerMap; }
00061 
00062     void setMaximumNumberOfFeatures( int nr ) { mMaximumNumberOfFeatures = nr; }
00063     int maximumNumberOfFeatures() const { return mMaximumNumberOfFeatures; }
00064 
00065     void setDisplayOnlyVisibleFeatures( bool b ) { mShowOnlyVisibleFeatures = b; }
00066     bool displayOnlyVisibleFeatures() const { return mShowOnlyVisibleFeatures; }
00067 
00068     QSet<int> displayAttributes() const { return mDisplayAttributes; }
00069     void setDisplayAttributes( const QSet<int>& attr ) { mDisplayAttributes = attr;}
00070 
00071     QMap<int, QString> fieldAliasMap() const { return mFieldAliasMap; }
00072     void setFieldAliasMap( const QMap<int, QString>& map ) { mFieldAliasMap = map; }
00073 
00075     void setSceneRect( const QRectF& rectangle );
00076 
00077     // @note not available in python bindings
00078     void setSortAttributes( const QList<QPair<int, bool> > att ) { mSortInformation = att; }
00079 
00080     // @note not available in python bindings
00081     QList<QPair<int, bool> > sortAttributes() const { return mSortInformation; }
00082 
00083   protected:
00087     bool getFeatureAttributes( QList<QgsAttributes>& attributes );
00088 
00090     QMap<int, QString> getHeaderLabels() const;
00091 
00092   private:
00094     QgsVectorLayer* mVectorLayer;
00096     const QgsComposerMap* mComposerMap;
00098     int mMaximumNumberOfFeatures;
00099 
00101     bool mShowOnlyVisibleFeatures;
00102 
00104     QSet<int> mDisplayAttributes;
00106     QMap<int, QString> mFieldAliasMap;
00107 
00109     QList< QPair<int, bool> > mSortInformation;
00110 
00112     void initializeAliasMap();
00114     QString attributeDisplayName( int attributeIndex, const QString& name ) const;
00115 
00116   private slots:
00118     void removeLayer( QString layerId );
00119 
00120   signals:
00122     void maximumNumberOfFeaturesChanged( int n );
00123 };
00124 
00125 #endif // QGSCOMPOSERATTRIBUTETABLE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines