Quantum GIS API Documentation
1.7.4
|
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 QgsComposerAttributeTableCompare 00028 { 00029 public: 00030 QgsComposerAttributeTableCompare(); 00031 bool operator()( const QgsAttributeMap& m1, const QgsAttributeMap& 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 );// { mVectorLayer = 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 void setSortAttributes( const QList<QPair<int, bool> > att ) { mSortInformation = att; } 00078 QList<QPair<int, bool> > sortAttributes() const { return mSortInformation; } 00079 00080 protected: 00082 bool getFeatureAttributes( QList<QgsAttributeMap>& attributes ); 00083 QMap<int, QString> getHeaderLabels() const; 00084 00085 private: 00087 QgsVectorLayer* mVectorLayer; 00089 const QgsComposerMap* mComposerMap; 00091 int mMaximumNumberOfFeatures; 00092 00094 bool mShowOnlyVisibleFeatures; 00095 00097 QSet<int> mDisplayAttributes; 00099 QMap<int, QString> mFieldAliasMap; 00100 00102 QList< QPair<int, bool> > mSortInformation; 00103 00105 void initializeAliasMap(); 00107 QString attributeDisplayName( int attributeIndex, const QString& name ) const; 00108 00109 private slots: 00111 void removeLayer( QString layerId ); 00112 00113 signals: 00115 void maximumNumerOfFeaturesChanged( int n ); 00116 }; 00117 00118 #endif // QGSCOMPOSERATTRIBUTETABLE_H