~ubuntu-branches/ubuntu/utopic/qgis/utopic

« back to all changes in this revision

Viewing changes to src/core/composer/qgscomposertable.h

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-04-24 15:12:20 UTC
  • mfrom: (3.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20120424151220-r88g00af5fpn5fc3
Tags: 1.7.4+1.7.5~20120320-1
The "Sometimes they come back" release.

* Branching from Qgis tree and adapting to current Debian Policy and
  standards. The target tree is currently set to release-1.7.
  (closes: #661491, #606304, #615683, #616182, #600308)
* Policy bumped to 3.9.3.
* Moving to debhelper compatibility level 9.
* Source format is now 3.0 with quilt support.
* Merged with 2bf42287 upstream git snapshot.
* Migrated to dh_python2 instead of python-central.
  (closes: #617048)
* Snapshot in qgis.org release-1.7: c936d031
* Added an automagic creation of a lintian override for sqlite embedding.
  This is required for uploading currently.
* Added missing ${misc:Depends} to make lintian happy.
* Copyright notes updated and debian/copyright moved to format 1.0.
* More licenses notices now reported in debian/copyright. Thanks ftpmasters.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                         qgscomposertable.h
 
3
                         ------------------
 
4
    begin                : January 2010
 
5
    copyright            : (C) 2010 by Marco Hugentobler
 
6
    email                : marco at hugis dot net
 
7
 ***************************************************************************/
 
8
 
 
9
/***************************************************************************
 
10
 *                                                                         *
 
11
 *   This program is free software; you can redistribute it and/or modify  *
 
12
 *   it under the terms of the GNU General Public License as published by  *
 
13
 *   the Free Software Foundation; either version 2 of the License, or     *
 
14
 *   (at your option) any later version.                                   *
 
15
 *                                                                         *
 
16
 ***************************************************************************/
 
17
 
 
18
#ifndef QGSCOMPOSERTABLE_H
 
19
#define QGSCOMPOSERTABLE_H
 
20
 
 
21
#include "qgscomposeritem.h"
 
22
#include "qgsfeature.h"
 
23
#include <QSet>
 
24
 
 
25
 
 
26
 
 
27
/**A class to display feature attributes in the print composer*/
 
28
class CORE_EXPORT QgsComposerTable: public QgsComposerItem
 
29
{
 
30
  public:
 
31
    QgsComposerTable( QgsComposition* composition );
 
32
    virtual ~QgsComposerTable();
 
33
 
 
34
    /** return correct graphics item type. Added in v1.7 */
 
35
    virtual int type() const { return ComposerTable; }
 
36
 
 
37
    /** \brief Reimplementation of QCanvasItem::paint*/
 
38
    virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
 
39
 
 
40
    virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const = 0;
 
41
    virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc ) = 0;
 
42
 
 
43
    void setLineTextDistance( double d ) { mLineTextDistance = d; }
 
44
    double lineTextDistance() const { return mLineTextDistance; }
 
45
 
 
46
    void setHeaderFont( const QFont& f ) { mHeaderFont = f;}
 
47
    QFont headerFont() const { return mHeaderFont; }
 
48
 
 
49
    void setContentFont( const QFont& f ) { mContentFont = f; }
 
50
    QFont contentFont() const { return mContentFont; }
 
51
 
 
52
    void setShowGrid( bool show ) { mShowGrid = show;}
 
53
    bool showGrid() const { return mShowGrid; }
 
54
 
 
55
    void setGridStrokeWidth( double w ) { mGridStrokeWidth = w; }
 
56
    double gridStrokeWidth() const { return mGridStrokeWidth; }
 
57
 
 
58
    void setGridColor( const QColor& c ) { mGridColor = c; }
 
59
    QColor gridColor() const { return mGridColor; }
 
60
 
 
61
    /**Adapts the size of the frame to match the content. This is normally done in the paint method, but sometimes \
 
62
    it needs to be done before the first render*/
 
63
    void adjustFrameToSize();
 
64
 
 
65
  protected:
 
66
    /**Distance between table lines and text*/
 
67
    double mLineTextDistance;
 
68
 
 
69
    QFont mHeaderFont;
 
70
    QFont mContentFont;
 
71
 
 
72
    bool mShowGrid;
 
73
    double mGridStrokeWidth;
 
74
    QColor mGridColor;
 
75
 
 
76
    /**Retrieves feature attributes*/
 
77
    virtual bool getFeatureAttributes( QList<QgsAttributeMap>& attributes ) {return false;} //= 0;
 
78
    virtual QMap<int, QString> getHeaderLabels() const { return QMap<int, QString>(); } //= 0;
 
79
    /**Calculate the maximum width values of the vector attributes*/
 
80
    virtual bool calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeList ) const;
 
81
    /**Adapts the size of the item frame to match the content*/
 
82
    void adaptItemFrame( const QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeList );
 
83
    void drawHorizontalGridLines( QPainter* p, int nAttributes );
 
84
    void drawVerticalGridLines( QPainter* p, const QMap<int, double>& maxWidthMap );
 
85
 
 
86
    bool tableWriteXML( QDomElement& itemElem, QDomDocument& doc ) const;
 
87
    bool tableReadXML( const QDomElement& itemElem, const QDomDocument& doc );
 
88
};
 
89
 
 
90
#endif // QGSCOMPOSERTABLE_H