[QGIS Commit] r10244 - in trunk/qgis: python/core python/gui src/app src/gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Feb 27 08:57:26 EST 2009


Author: mhugent
Date: 2009-02-27 08:57:26 -0500 (Fri, 27 Feb 2009)
New Revision: 10244

Added:
   trunk/qgis/python/core/qgscomposeritem.sip
   trunk/qgis/python/core/qgscomposerlabel.sip
   trunk/qgis/python/core/qgscomposerlegend.sip
   trunk/qgis/python/core/qgscomposermap.sip
   trunk/qgis/python/core/qgscomposerpicture.sip
   trunk/qgis/python/core/qgscomposerscalebar.sip
   trunk/qgis/python/core/qgscomposition.sip
   trunk/qgis/python/core/qgslegendmodel.sip
   trunk/qgis/python/core/qgspaperitem.sip
   trunk/qgis/python/core/qgsscalebarstyle.sip
   trunk/qgis/python/gui/qgscomposerview.sip
Modified:
   trunk/qgis/python/core/core.sip
   trunk/qgis/python/gui/gui.sip
   trunk/qgis/python/gui/qgisinterface.sip
   trunk/qgis/src/app/qgisappinterface.cpp
   trunk/qgis/src/app/qgisappinterface.h
   trunk/qgis/src/gui/qgisinterface.h
   trunk/qgis/src/gui/qgscomposerview.cpp
   trunk/qgis/src/gui/qgscomposerview.h
Log:
Python bindings for composer classes

Modified: trunk/qgis/python/core/core.sip
===================================================================
--- trunk/qgis/python/core/core.sip	2009-02-27 09:10:16 UTC (rev 10243)
+++ trunk/qgis/python/core/core.sip	2009-02-27 13:57:26 UTC (rev 10244)
@@ -11,6 +11,16 @@
 
 %Include qgis.sip
 %Include qgsapplication.sip
+%Include qgscomposeritem.sip
+%Include qgscomposerlabel.sip
+%Include qgscomposerlegend.sip
+%Include qgscomposermap.sip
+%Include qgscomposerpicture.sip
+%Include qgscomposerscalebar.sip
+%Include qgscomposition.sip
+%Include qgslegendmodel.sip
+%Include qgspaperitem.sip
+%Include qgsscalebarstyle.sip
 %Include qgscontexthelp.sip
 %Include qgscontinuouscolorrenderer.sip
 %Include qgscontrastenhancement.sip

Added: trunk/qgis/python/core/qgscomposeritem.sip
===================================================================
--- trunk/qgis/python/core/qgscomposeritem.sip	                        (rev 0)
+++ trunk/qgis/python/core/qgscomposeritem.sip	2009-02-27 13:57:26 UTC (rev 10244)
@@ -0,0 +1,166 @@
+/** \ingroup MapComposer
+ * A item that forms part of a map composition.
+ */
+class QgsComposerItem: QGraphicsRectItem
+{
+%TypeHeaderCode
+#include <qgscomposeritem.h>
+%End
+
+  public:
+
+    /**Describes the action (move or resize in different directon) to be done during mouse move*/
+    enum MouseMoveAction
+    {
+      MoveItem,
+      ResizeUp,
+      ResizeDown,
+      ResizeLeft,
+      ResizeRight,
+      ResizeLeftUp,
+      ResizeRightUp,
+      ResizeLeftDown,
+      ResizeRightDown
+    };
+
+    enum ItemPositionMode
+    {
+      UpperLeft,
+      UpperMiddle,
+      UpperRight,
+      MiddleLeft,
+      Middle,
+      MiddleRight,
+      LowerLeft,
+      LowerMiddle,
+      LowerRight
+    };
+
+    /**Constructor
+     @param manageZValue true if the z-Value of this object should be managed by mComposition*/
+    QgsComposerItem( QgsComposition* composition, bool manageZValue = true );
+    /**Constructor with box position and composer object
+     @param manageZValue true if the z-Value of this object should be managed by mComposition*/
+    QgsComposerItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition, bool manageZValue = true );
+    virtual ~QgsComposerItem();
+
+    /** \brief Set selected, selected item should be highlighted */
+    virtual void setSelected( bool s );
+
+    /** \brief Is selected */
+    virtual bool selected();
+
+    /** stores state in project */
+    virtual bool writeSettings();
+
+    /** read state from project */
+    virtual bool readSettings();
+
+    /** delete settings from project file  */
+    virtual bool removeSettings();
+
+    /**Moves item in canvas coordinates*/
+    void move( double dx, double dy );
+
+    /**Move Content of item. Does nothing per default (but implemented in composer map)
+       @param dx move in x-direction (canvas coordinates)
+       @param dy move in y-direction(canvas coordinates)*/
+    virtual void moveContent( double dx, double dy );
+
+    /**Zoom content of item. Does nothing per default (but implemented in composer map)
+     @param delta value from wheel event that describes magnitude and direction (positive /negative number)
+    @param x x-position of mouse cursor (in item coordinates)
+    @param y y-position of mouse cursor (in item coordinates)*/
+    virtual void zoomContent( int delta, double x, double y );
+
+    /**Moves the item to a new position (in canvas coordinates)*/
+    void setItemPosition( double x, double y, ItemPositionMode itemPoint = UpperLeft );
+
+    /**Sets this items bound in scene coordinates such that 1 item size units
+     corresponds to 1 scene size unit*/
+    virtual void setSceneRect( const QRectF& rectangle );
+
+    /** stores state in Dom node
+     * @param node is Dom node corresponding to 'Composer' tag
+     * @param temp write template file
+     */
+    virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const = 0;
+
+    /**Writes parameter that are not subclass specific in document. Usually called from writeXML methods of subclasses*/
+    bool _writeXML( QDomElement& itemElem, QDomDocument& doc ) const;
+
+    /** sets state from Dom document
+     * @param itemElem is Dom node corresponding to item tag
+     */
+    virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc ) = 0;
+
+    /**Reads parameter that are not subclass specific in document. Usually called from readXML methods of subclasses*/
+    bool _readXML( const QDomElement& itemElem, const QDomDocument& doc );
+
+
+
+    bool frame() const;
+    void setFrame( bool drawFrame );
+
+    /**Composite operations for item groups do nothing per default*/
+    virtual void addItem( QgsComposerItem* item );
+    virtual void removeItems();
+
+    const QgsComposition* composition() const;
+
+    //functions that encapsulate the workaround for the Qt font bug (that is to scale the font size up and then scale the
+    //painter down by the same factor for drawing
+
+    /**Draws Text. Takes care about all the composer specific issues (calculation to pixel, scaling of font and painter
+     to work arount the Qt font bug)*/
+    void drawText( QPainter* p, int x, int y, const QString& text, const QFont& font ) const;
+
+    /**Like the above, but with a rectangle for multiline text*/
+    void drawText( QPainter* p, const QRectF& rect, const QString& text, const QFont& font ) const;
+
+    /**Returns the font width in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
+    double textWidthMillimeters( const QFont& font, const QString& text ) const;
+
+    /**Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
+    double fontAscentMillimeters( const QFont& font ) const;
+
+    /**Calculates font to from point size to pixel size*/
+    double pixelFontSize( double pointSize ) const;
+
+    /**Returns a font where size is in pixel and font size is upscaled with FONT_WORKAROUND_SCALE*/
+    QFont scaledFontPixelSize( const QFont& font ) const;
+
+  protected:
+
+    //event handlers
+    virtual void mouseMoveEvent( QGraphicsSceneMouseEvent * event );
+    virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
+    virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event );
+
+    virtual void hoverMoveEvent( QGraphicsSceneHoverEvent * event );
+
+    /**Finds out the appropriate cursor for the current mouse position in the widget (e.g. move in the middle, resize at border)*/
+    Qt::CursorShape cursorForPosition( const QPointF& itemCoordPos );
+
+    /**Finds out which mouse move action to choose depending on the cursor position inside the widget*/
+    QgsComposerItem::MouseMoveAction mouseMoveActionForPosition( const QPointF& itemCoordPos );
+
+    /**Changes the rectangle of an item depending on current mouse action (resize or move)
+     @param currentPosition current position of mouse cursor
+     @param mouseMoveStartPos cursor position at the start of the current mouse action
+     @param originalItem Item position at the start of the mouse action
+     @param dx x-Change of mouse cursor
+     @param dy y-Change of mouse cursor
+     @param changeItem Item to change size (can be the same as originalItem or a differen one)
+    */
+    void changeItemRectangle( const QPointF& currentPosition, const QPointF& mouseMoveStartPos, const QGraphicsRectItem* originalItem, double dx, double dy, QGraphicsRectItem* changeItem );
+
+    /**Draw selection boxes around item*/
+    virtual void drawSelectionBoxes( QPainter* p );
+
+    /**Draw black frame around item*/
+    virtual void drawFrame( QPainter* p );
+
+    /**Draw background*/
+    virtual void drawBackground( QPainter* p );
+};
\ No newline at end of file

Added: trunk/qgis/python/core/qgscomposerlabel.sip
===================================================================
--- trunk/qgis/python/core/qgscomposerlabel.sip	                        (rev 0)
+++ trunk/qgis/python/core/qgscomposerlabel.sip	2009-02-27 13:57:26 UTC (rev 10244)
@@ -0,0 +1,36 @@
+/** \ingroup MapComposer
+ * A label that can be placed onto a map composition.
+ */
+class QgsComposerLabel: QgsComposerItem
+{
+%TypeHeaderCode
+#include "qgscomposerlabel.h"
+%End
+  public:
+    QgsComposerLabel( QgsComposition *composition );
+    ~QgsComposerLabel();
+
+    /** \brief Reimplementation of QCanvasItem::paint*/
+    void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
+
+    /**resizes the widget such that the text fits to the item. Keeps top left point*/
+    void adjustSizeToText();
+
+    QString text();
+    void setText( const QString& text );
+    QFont font() const;
+    void setFont( const QFont& f );
+    double margin();
+    void setMargin( double m );
+
+    /** stores state in Dom node
+       * @param node is Dom node corresponding to 'Composer' tag
+       * @param temp write template file
+       */
+    bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
+
+    /** sets state from Dom document
+       * @param node is Dom node corresponding to 'ComposerLabel' tag
+       */
+    bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
+};
\ No newline at end of file

Added: trunk/qgis/python/core/qgscomposerlegend.sip
===================================================================
--- trunk/qgis/python/core/qgscomposerlegend.sip	                        (rev 0)
+++ trunk/qgis/python/core/qgscomposerlegend.sip	2009-02-27 13:57:26 UTC (rev 10244)
@@ -0,0 +1,97 @@
+/** \ingroup MapComposer
+ * A legend that can be placed onto a map composition
+ */
+class QgsComposerLegend: QObject, QgsComposerItem
+{
+%TypeHeaderCode
+#include <qgscomposerlegend.h>
+%End
+
+  public:
+    QgsComposerLegend( QgsComposition* composition );
+    ~QgsComposerLegend();
+
+    /** \brief Reimplementation of QCanvasItem::paint*/
+    void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
+
+    /**Paints the legend and calculates its size. If painter is 0, only size is calculated*/
+    QSizeF paintAndDetermineSize( QPainter* painter );
+
+    /**Sets item box to the whole content*/
+    void adjustBoxSize();
+
+    /**Returns pointer to the legend model*/
+    QgsLegendModel* model();
+
+    //setters and getters
+    void setTitle( const QString& t );
+    QString title() const;
+
+    QFont titleFont() const;
+    void setTitleFont( const QFont& f );
+
+    QFont layerFont() const;
+    void setLayerFont( const QFont& f );
+
+    QFont itemFont() const;
+    void setItemFont( const QFont& f );
+
+    double boxSpace() const;
+    void setBoxSpace( double s );
+
+    double layerSpace() const;
+    void setLayerSpace( double s );
+
+    double symbolSpace() const;
+    void setSymbolSpace( double s );
+
+    double iconLabelSpace() const;
+    void setIconLabelSpace( double s );
+
+    double symbolWidth() const;
+    void setSymbolWidth( double w );
+
+    double symbolHeight() const;
+    void setSymbolHeight( double h );
+
+    /**Updates the model and all legend entries*/
+    void updateLegend();
+
+    /** stores state in Dom node
+       * @param elem is Dom element corresponding to 'Composer' tag
+       * @param temp write template file
+       */
+    bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
+
+    /** sets state from Dom document
+       * @param itemElem is Dom node corresponding to item tag
+       */
+    bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
+
+  public slots:
+    /**Data changed*/
+    void synchronizeWithModel();
+
+  protected:
+
+
+  private:
+    QgsComposerLegend(); //forbidden
+
+    /**Draws child items of a layer item
+       @param layerItem parent model item (layer)
+       @param currentYCoord in/out: current y position of legend item
+       @param maxXCoord in/out: maximum x-coordinate of the whole legend
+    */
+    void drawLayerChildItems( QPainter* p, QStandardItem* layerItem, double& currentYCoord, double& maxXCoord );
+
+    /**Draws a symbol at the current y position and returns the new x position. Returns real symbol height, because for points,
+     it is possible that it differs from mSymbolHeight*/
+    void drawSymbol( QPainter* p, QgsSymbol* s, double currentYCoord, double& currentXPosition, double& symbolHeight ) const;
+    void drawPointSymbol( QPainter*, QgsSymbol* s, double currentYCoord, double& currentXPosition, double& symbolHeight ) const;
+    void drawLineSymbol( QPainter*, QgsSymbol* s, double currentYCoord, double& currentXPosition ) const;
+    void drawPolygonSymbol( QPainter* p, QgsSymbol* s, double currentYCoord, double& currentXPosition ) const;
+
+    /**Helper function that lists ids of layers contained in map canvas*/
+    QStringList layerIdList() const;
+};
\ No newline at end of file

Added: trunk/qgis/python/core/qgscomposermap.sip
===================================================================
--- trunk/qgis/python/core/qgscomposermap.sip	                        (rev 0)
+++ trunk/qgis/python/core/qgscomposermap.sip	2009-02-27 13:57:26 UTC (rev 10244)
@@ -0,0 +1,117 @@
+/** \ingroup MapComposer
+ *  \class QgsComposerMap
+ *  \brief Object representing map window.
+ */
+// NOTE: QgsComposerMapBase must be first, otherwise does not compile
+class QgsComposerMap : QObject, QgsComposerItem
+{
+%TypeHeaderCode
+#include <qgscomposermap.h>
+%End
+
+  public:
+    /** Constructor. */
+    QgsComposerMap( QgsComposition *composition, int x, int y, int width, int height );
+    /** Constructor. Settings are read from project. */
+    QgsComposerMap( QgsComposition *composition );
+    ~QgsComposerMap();
+
+    /** \brief Preview style  */
+    enum PreviewMode
+    {
+      Cache = 0,   // Use raster cache
+      Render,      // Render the map
+      Rectangle    // Display only rectangle
+    };
+
+    /** \brief Draw to paint device
+    @param extent map extent
+    @param size size in scene coordinates
+    @param dpi scene dpi*/
+    void draw( QPainter *painter, const QgsRectangle& extent, const QSize& size, int dpi );
+
+    /** \brief Reimplementation of QCanvasItem::paint - draw on canvas */
+    void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
+
+    /** \brief Create cache image */
+    void cache();
+
+    /** \brief Get identification number*/
+    int id() const;
+
+    /**True if a draw is already in progress*/
+    bool isDrawing() const;
+
+    /** resizes an item in x- and y direction (canvas coordinates)*/
+    void resize( double dx, double dy );
+
+    /**Move content of map
+       @param dx move in x-direction (item and canvas coordinates)
+       @param dy move in y-direction (item and canvas coordinates)*/
+    void moveContent( double dx, double dy );
+
+    /**Zoom content of map
+     @param delta value from wheel event that describes magnitude and direction (positive /negative number)
+    @param x x-coordinate of mouse position in item coordinates
+    @param y y-coordinate of mouse position in item coordinates*/
+    void zoomContent( int delta, double x, double y );
+
+    /**Sets new scene rectangle bounds and recalculates hight and extent*/
+    void setSceneRect( const QRectF& rectangle );
+
+    /** \brief Scale */
+    double scale() const;
+
+    /**Sets new scale and changes only mExtent*/
+    void setNewScale( double scaleDenominator );
+
+    /**Sets new Extent and changes width, height (and implicitely also scale)*/
+    void setNewExtent( const QgsRectangle& extent );
+
+    PreviewMode previewMode();
+    void setPreviewMode( PreviewMode m );
+
+    // Set cache outdated
+    void setCacheUpdated( bool u = false );
+
+    QgsRectangle extent() const;
+
+    const QgsMapRenderer* mapRenderer() const;
+
+    /**Sets offset values to shift image (useful for live updates when moving item content)*/
+    void setOffset( double xOffset, double yOffset );
+
+    /**True if composer map renders a WMS layer*/
+    bool containsWMSLayer() const;
+
+    /** stores state in Dom node
+     * @param elem is Dom element corresponding to 'Composer' tag
+     * @param temp write template file
+     */
+    bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
+
+    /** sets state from Dom document
+     * @param itemElem is Dom node corresponding to 'ComposerMap' tag
+     */
+    bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
+
+  public slots:
+
+    /**Called if map canvas has changed*/
+    void updateCachedImage( );
+    /**Call updateCachedImage if item is in render mode*/
+    void renderModeUpdateCachedImage();
+
+  signals:
+    /**Is emitted when width/height is changed as a result of user interaction*/
+    void extentChanged();
+
+  private:
+
+    /**Establishes signal/slot connection for update in case of layer change*/
+    void connectUpdateSlot();
+
+    /**Returns the zoom factor of the graphics view. If no
+     graphics view exists, the default 1 is returned*/
+    double horizontalViewScaleFactor() const;
+};
\ No newline at end of file

Added: trunk/qgis/python/core/qgscomposerpicture.sip
===================================================================
--- trunk/qgis/python/core/qgscomposerpicture.sip	                        (rev 0)
+++ trunk/qgis/python/core/qgscomposerpicture.sip	2009-02-27 13:57:26 UTC (rev 10244)
@@ -0,0 +1,51 @@
+/** \ingroup MapComposer
+ * A composer class that displays svg files or raster format (jpg, png, ...)
+ * */
+class QgsComposerPicture: QObject, QgsComposerItem
+{
+
+%TypeHeaderCode
+#include "qgscomposerpicture.h"
+%End
+
+  public:
+    QgsComposerPicture( QgsComposition *composition );
+    ~QgsComposerPicture();
+
+    /**Reimplementation of QCanvasItem::paint*/
+    void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
+
+    /**Sets the source file of the image (may be svg or a raster format)*/
+    void setPictureFile( const QString& path );
+    QString pictureFile() const;
+
+    /**Sets this items bound in scene coordinates such that 1 item size units
+       corresponds to 1 scene size unit*/
+    void setSceneRect( const QRectF& rectangle );
+
+    void setRotation( double rotation );
+
+    double rotation() const;
+
+    /** stores state in Dom node
+       * @param node is Dom node corresponding to 'Composer' tag
+       * @param temp write template file
+       */
+    bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
+
+    /** sets state from Dom document
+      * @param itemElem is Dom node corresponding to item tag
+      */
+    bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
+
+  private:
+
+    //default constructor is forbidden
+    QgsComposerPicture();
+    /**Updates content of current image using svg generator*/
+    void updateImageFromSvg();
+
+  signals:
+    /**Tell the configuration widget that the settings need to be updated*/
+    void settingsChanged();
+};
\ No newline at end of file

Added: trunk/qgis/python/core/qgscomposerscalebar.sip
===================================================================
--- trunk/qgis/python/core/qgscomposerscalebar.sip	                        (rev 0)
+++ trunk/qgis/python/core/qgscomposerscalebar.sip	2009-02-27 13:57:26 UTC (rev 10244)
@@ -0,0 +1,101 @@
+/** \ingroup MapComposer
+ * A scale bar item that can be added to a map composition.
+ */
+
+class QgsComposerScaleBar: QObject, QgsComposerItem
+{
+%TypeHeaderCode
+#include "qgscomposerscalebar.h"
+%End
+  public:
+
+    QgsComposerScaleBar( QgsComposition* composition );
+    ~QgsComposerScaleBar();
+
+    /** \brief Reimplementation of QCanvasItem::paint*/
+    void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
+
+    //getters and setters
+    int numSegments() const;
+    void setNumSegments( int nSegments );
+
+    int numSegmentsLeft() const;
+    void setNumSegmentsLeft( int nSegmentsLeft );
+
+    double numUnitsPerSegment() const;
+    void setNumUnitsPerSegment( double units );
+
+    double numMapUnitsPerScaleBarUnit() const;
+    void setNumMapUnitsPerScaleBarUnit( double d );
+
+    QString unitLabeling() const;
+    void setUnitLabeling( const QString& label );
+
+    QFont font() const;
+
+    void setFont( const QFont& font );
+
+    QPen pen() const;
+    void setPen( const QPen& pen );
+
+    QBrush brush() const;
+    void setBrush( const QBrush& brush );
+
+    double height() const;
+    void setHeight( double h );
+
+    void setComposerMap( const QgsComposerMap* map );
+    const QgsComposerMap* composerMap();
+
+    double labelBarSpace() const;
+    void setLabelBarSpace( double space );
+
+    double boxContentSpace() const;
+    void setBoxContentSpace( double space );
+
+    double segmentMillimeters() const;
+
+    /**Apply default settings (scale bar 1/5 of map item width)*/
+    void applyDefaultSettings();
+
+    /**Sets style by name
+     @param styleName (untranslated) style name. Possibilities are: 'Single Box', 'Double Box', 'Line Ticks Middle', 'Line Ticks Down', 'Line Ticks Up', 'Numeric'*/
+    void setStyle( const QString& styleName );
+
+    /**Returns style name*/
+    QString style() const;
+
+    /**Returns the x - positions of the segment borders (in item coordinates) and the width
+     of the segment*/
+    void segmentPositions( QList<QPair<double, double> >& posWidthList ) const;
+
+    /**Sets box size suitable to content*/
+    void adjustBoxSize();
+
+    /**Adjusts box size and calls QgsComposerItem::update()*/
+    void update();
+
+    /**Returns string of first label (important for drawing, labeling, size calculation*/
+    QString firstLabelString() const;
+
+    /** stores state in Dom node
+       * @param elem is Dom element corresponding to 'Composer' tag
+       * @param temp write template file
+       */
+    bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
+
+    /** sets state from Dom document
+       * @param itemElem is Dom node corresponding to item tag
+       */
+    bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
+
+
+  public slots:
+    void updateSegmentSize();
+    /**Sets mCompositionMap to 0 if the map is deleted*/
+    void invalidateCurrentMap();
+
+  protected:
+    /**Calculates with of a segment in mm and stores it in mSegmentMillimeters*/
+    void refreshSegmentMillimeters();
+};
\ No newline at end of file

Added: trunk/qgis/python/core/qgscomposition.sip
===================================================================
--- trunk/qgis/python/core/qgscomposition.sip	                        (rev 0)
+++ trunk/qgis/python/core/qgscomposition.sip	2009-02-27 13:57:26 UTC (rev 10244)
@@ -0,0 +1,143 @@
+/** \ingroup MapComposer
+ * Graphics scene for map printing. The class manages the paper item which always
+ * is the item in the back (z-value 0). It maintains the z-Values of the items and stores
+ * them in a list in ascending z-Order. This list can be changed to lower/raise items one position
+ * or to bring them to front/back.
+ * */
+class QgsComposition: QGraphicsScene
+{
+%TypeHeaderCode
+#include <qgscomposition.h>
+%End
+  public:
+
+    /** \brief Plot type */
+    enum PlotStyle
+    {
+      Preview = 0, // Use cache etc
+      Print,       // Render well
+      Postscript   // Fonts need different scaling!
+    };
+
+    /**Style to draw the snapping grid*/
+    enum GridStyle
+    {
+      Solid,
+      Dots,
+      Crosses
+    };
+
+    QgsComposition( QgsMapRenderer* mapRenderer );
+    ~QgsComposition();
+
+    /**Changes size of paper item*/
+    void setPaperSize( double width, double height );
+
+    /**Returns height of paper item*/
+    double paperHeight() const;
+
+    /**Returns width of paper item*/
+    double paperWidth() const;
+
+    void setSnapToGridEnabled( bool b );
+    bool snapToGridEnabled() const;
+
+    void setSnapGridResolution( double r );
+    double snapGridResolution() const;
+
+    void setSnapGridOffsetX( double offset );
+    double snapGridOffsetX() const;
+
+    void setSnapGridOffsetY( double offset );
+    double snapGridOffsetY() const;
+
+    void setGridPen( const QPen& p );
+    const QPen& gridPen() const;
+
+    void setGridStyle( GridStyle s );
+    GridStyle gridStyle() const;
+
+    /**Returns the topmose composer item. Ignores mPaperItem*/
+    QgsComposerItem* composerItemAt( const QPointF & position );
+
+    QList<QgsComposerItem*> selectedComposerItems();
+
+    /**Returns pointers to all composer maps in the scene*/
+    //todo: needs a new mapping for QList<const T*> ?
+    //QList<const QgsComposerMap*> composerMapItems() const;
+
+    /**Returns the composer map with specified id
+     @return id or 0 pointer if the composer map item does not exist*/
+    const QgsComposerMap* getComposerMapById( int id ) const;
+
+    int printResolution() const;
+    void setPrintResolution( int dpi );
+
+    bool printAsRaster() const;
+    void setPrintAsRaster(bool enabled);
+
+    /**Returns pointer to map renderer of qgis map canvas*/
+    QgsMapRenderer* mapRenderer();
+
+    QgsComposition::PlotStyle plotStyle();
+    void setPlotStyle( QgsComposition::PlotStyle style );
+
+    /**Returns the pixel font size for a font that has point size set.
+     The result depends on the resolution (dpi) and of the preview mode. Each item that sets
+    a font should call this function before drawing text*/
+    int pixelFontSize( double pointSize ) const;
+
+    /**Does the inverse calculation and returns points for pixels (equals to mm in QgsComposition)*/
+    double pointFontSize( int pixelSize ) const;
+
+    /**Writes settings to xml (paper dimension)*/
+    bool writeXML( QDomElement& composerElem, QDomDocument& doc );
+
+    /**Reads settings from xml file*/
+    bool readXML( const QDomElement& compositionElem, const QDomDocument& doc );
+
+    /**Adds item to z list. Usually called from constructor of QgsComposerItem*/
+    void addItemToZList( QgsComposerItem* item );
+    /**Removes item from z list. Usually called from destructor of QgsComposerItem*/
+    void removeItemFromZList( QgsComposerItem* item );
+
+    //functions to move selected items in hierarchy
+    void raiseSelectedItems();
+    void raiseItem( QgsComposerItem* item );
+    void lowerSelectedItems();
+    void lowerItem( QgsComposerItem* item );
+    void moveSelectedItemsToTop();
+    void moveItemToTop( QgsComposerItem* item );
+    void moveSelectedItemsToBottom();
+    void moveItemToBottom( QgsComposerItem* item );
+
+    //functions to align selected items
+    void alignSelectedItemsLeft();
+    void alignSelectedItemsHCenter();
+    void alignSelectedItemsRight();
+    void alignSelectedItemsTop();
+    void alignSelectedItemsVCenter();
+    void alignSelectedItemsBottom();
+
+    /**Sorts the zList. The only time where this function needs to be called is from QgsComposer
+     after reading all the items from xml file*/
+    void sortZList();
+
+    /**Snaps a scene coordinate point to grid*/
+    QPointF snapPointToGrid( const QPointF& scenePoint ) const;
+
+  private:
+   
+
+    QgsComposition(); //default constructor is forbidden
+
+    /**Reset z-values of items based on position in z list*/
+    void updateZValues();
+
+    /**Returns the bounding rectangle of the selected items in scene coordinates
+     @return 0 in case of success*/
+    int boundingRectOfSelectedItems( QRectF& bRect );
+
+    void loadGridAppearanceSettings();
+    void saveGridAppearanceSettings();
+};
\ No newline at end of file

Added: trunk/qgis/python/core/qgslegendmodel.sip
===================================================================
--- trunk/qgis/python/core/qgslegendmodel.sip	                        (rev 0)
+++ trunk/qgis/python/core/qgslegendmodel.sip	2009-02-27 13:57:26 UTC (rev 10244)
@@ -0,0 +1,54 @@
+/** \ingroup MapComposer
+ * A model that provides layers as root items. The classification items are
+ * children of the layer items.
+ */
+
+class QgsLegendModel: QStandardItemModel
+{
+%TypeHeaderCode
+#include <qgslegendmodel.h>
+%End
+
+  public:
+    QgsLegendModel();
+    ~QgsLegendModel();
+
+    void setLayerSet( const QStringList& layerIds );
+
+    /**Tries to automatically update a model entry (e.g. a whole layer or only a single item)*/
+    void updateItem( QStandardItem* item );
+    /**Updates the whole symbology of a layer*/
+    void updateLayer( QStandardItem* layerItem );
+    /**Tries to update a single classification item*/
+    void updateVectorClassificationItem( QStandardItem* classificationItem, QgsSymbol* symbol, QString itemText );
+    void updateRasterClassificationItem( QStandardItem* classificationItem );
+
+    bool writeXML( QDomElement& composerLegendElem, QDomDocument& doc ) const;
+    bool readXML( const QDomElement& legendModelElem, const QDomDocument& doc );
+
+  public slots:
+    void removeLayer( const QString& layerId );
+    void addLayer( QgsMapLayer* theMapLayer );
+
+  signals:
+    void layersChanged();
+
+  private:
+    /**Adds classification items of vector layers
+     @return 0 in case of success*/
+    int addVectorLayerItems( QStandardItem* layerItem, QgsMapLayer* vlayer );
+
+    /**Adds item of raster layer
+     @return 0 in case of success*/
+    int addRasterLayerItem( QStandardItem* layerItem, QgsMapLayer* rlayer );
+
+    /**Insert a symbol into QgsLegendModel symbol storage*/
+    void insertSymbol( QgsSymbol* s );
+    /**Removes and deletes a symbol*/
+    void removeSymbol( QgsSymbol* s );
+    /**Removes and deletes all stored symbols*/
+    void removeAllSymbols();
+
+    /**Creates a model item for a vector symbol. The calling function takes ownership*/
+    QStandardItem* itemFromSymbol( QgsSymbol* s );
+};
\ No newline at end of file

Added: trunk/qgis/python/core/qgspaperitem.sip
===================================================================
--- trunk/qgis/python/core/qgspaperitem.sip	                        (rev 0)
+++ trunk/qgis/python/core/qgspaperitem.sip	2009-02-27 13:57:26 UTC (rev 10244)
@@ -0,0 +1,29 @@
+/**Item representing the paper. May draw the snapping grid lines if composition is in
+ preview mode*/
+class QgsPaperItem: QgsComposerItem
+{
+%TypeHeaderCode
+#include <qgspaperitem.h>
+%End
+  public:
+    QgsPaperItem( QgsComposition* c );
+    QgsPaperItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition );
+    ~QgsPaperItem();
+
+    /** \brief Reimplementation of QCanvasItem::paint*/
+    void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
+
+    /** stores state in Dom node
+       * @param node is Dom node corresponding to 'Composer' tag
+       * @param temp write template file
+       */
+    bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
+
+    /** sets state from Dom document
+     * @param itemElem is Dom node corresponding to item tag
+     */
+    bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
+
+  private:
+    QgsPaperItem();
+};
\ No newline at end of file

Added: trunk/qgis/python/core/qgsscalebarstyle.sip
===================================================================
--- trunk/qgis/python/core/qgsscalebarstyle.sip	                        (rev 0)
+++ trunk/qgis/python/core/qgsscalebarstyle.sip	2009-02-27 13:57:26 UTC (rev 10244)
@@ -0,0 +1,24 @@
+/** \ingroup MapComposer
+ * Abstraction of composer scale bar style. Subclasses draw themselves, have the
+possibility to implement custom labeling and calculate corresponding box size.
+*/
+class QgsScaleBarStyle
+{
+%TypeHeaderCode
+#include "qgsscalebarstyle.h"
+%End
+  public:
+    QgsScaleBarStyle( const QgsComposerScaleBar* bar );
+    virtual ~QgsScaleBarStyle();
+
+    /**Draws the style
+     @param xOffset offset to account for centered labeling*/
+    virtual void draw( QPainter* p, double xOffset = 0 ) const = 0; //to do by every subclass
+    virtual void drawLabels( QPainter* p ) const; //default implementation provided
+    virtual QRectF calculateBoxSize() const; //default implementation provided
+    virtual QString name() const = 0; //return name of the style
+    //virtual QIcon styleIcon() const = 0;
+
+  private:
+    QgsScaleBarStyle(); //default constructor forbidden
+};
\ No newline at end of file

Modified: trunk/qgis/python/gui/gui.sip
===================================================================
--- trunk/qgis/python/gui/gui.sip	2009-02-27 09:10:16 UTC (rev 10243)
+++ trunk/qgis/python/gui/gui.sip	2009-02-27 13:57:26 UTC (rev 10244)
@@ -8,6 +8,7 @@
 %Import core/core.sip
 
 %Include qgisinterface.sip
+%Include qgscomposerview.sip
 %Include qgsencodingfiledialog.sip
 %Include qgsgenericprojectionselector.sip
 %Include qgsmapcanvas.sip

Modified: trunk/qgis/python/gui/qgisinterface.sip
===================================================================
--- trunk/qgis/python/gui/qgisinterface.sip	2009-02-27 09:10:16 UTC (rev 10243)
+++ trunk/qgis/python/gui/qgisinterface.sip	2009-02-27 13:57:26 UTC (rev 10244)
@@ -75,9 +75,10 @@
 
     /** Return pointers to the composer views of the running instance (currently only one)*/
     //virtual QList<QgsComposerView*> composerViews()=0;
-    
-    //virtual QList< QPair<QMainWindow*, QgsComposerView*> > composerList() = 0;
 
+    /**Return mainwindows / composer views of running composer instances (currently only one)*/
+    virtual QList<QgsComposerView*> activeComposers() = 0;
+
     /** Add action to the plugins menu */
     virtual void addPluginToMenu(QString name, QAction* action)=0;
     /** Remove action from the plugins menu */

Added: trunk/qgis/python/gui/qgscomposerview.sip
===================================================================
--- trunk/qgis/python/gui/qgscomposerview.sip	                        (rev 0)
+++ trunk/qgis/python/gui/qgscomposerview.sip	2009-02-27 13:57:26 UTC (rev 10244)
@@ -0,0 +1,93 @@
+/** \ingroup MapComposer
+ * \ingroup gui
+ * Widget to display the composer items. Manages the composer tools and the
+ * mouse/key events.
+ * Creates the composer items according to the current map tools and keeps track
+ * of the rubber band item.
+ */
+class QgsComposerView: QGraphicsView
+{
+%TypeHeaderCode
+#include "qgscomposerview.h"
+%End
+
+  public:
+
+    /**Current tool*/
+    enum Tool
+    {
+      Select = 0,      // Select/Move item
+      AddMap,          // add new map
+      AddLegend, // add vector legend
+      AddLabel,        // add label
+      AddScalebar,     // add scalebar
+      AddPicture,       // add raster/vector picture
+      MoveItemContent //move content of item (e.g. content of map)
+    };
+
+    QgsComposerView( QWidget* parent = 0, const char* name = 0, Qt::WFlags f = 0 );
+
+    /**Add an item group containing the selected items*/
+    void groupItems();
+
+    /**Ungroups the selected items*/
+    void ungroupItems();
+
+    QgsComposerView::Tool currentTool() const;
+    void setCurrentTool( QgsComposerView::Tool t );
+
+    /**Sets composition (derived from QGraphicsScene)*/
+    void setComposition( QgsComposition* c );
+    /**Returns the composition or 0 in case of error*/
+    QgsComposition* composition();
+    
+    /**Adds label to the graphics scene and advices composer to create a widget for it (through signal)*/
+    void addComposerLabel( QgsComposerLabel* label /Transfer/);
+    /**Adds map to the graphics scene and advices composer to create a widget for it (through signal)*/
+    void addComposerMap( QgsComposerMap* map /Transfer/);
+    /**Adds scale bar to the graphics scene and advices composer to create a widget for it (through signal)*/
+    void addComposerScaleBar( QgsComposerScaleBar* scaleBar /Transfer/);
+    /**Adds legend to the graphics scene and advices composer to create a widget for it (through signal)*/
+    void addComposerLegend( QgsComposerLegend* legend /Transfer/);
+    /**Adds picture to the graphics scene and advices composer to create a widget for it (through signal)*/
+    void addComposerPicture( QgsComposerPicture* picture );
+
+    /**Returns the composer main window*/
+    QMainWindow* composerWindow();
+
+  protected:
+    void mousePressEvent( QMouseEvent* );
+    void mouseReleaseEvent( QMouseEvent* );
+    void mouseMoveEvent( QMouseEvent* );
+
+    void keyPressEvent( QKeyEvent * e );
+    void keyReleaseEvent( QKeyEvent * e );
+
+    void wheelEvent( QWheelEvent* event );
+
+  private:
+    
+
+  public slots:
+    /**For QgsComposerItemGroup to send its signals to QgsComposer (or other classes that keep track of input widgets)*/
+    void sendItemRemovedSignal( QgsComposerItem* item );
+
+  signals:
+    /**Is emitted when selected item changed. If 0, no item is selected*/
+    void selectedItemChanged( const QgsComposerItem* selected );
+    /**Ist emittted when new composer label has been added to the view*/
+    void composerLabelAdded( QgsComposerLabel* label );
+    /**Is emitted when new composer map has been added to the view*/
+    void composerMapAdded( QgsComposerMap* map );
+    /**Is emitted when new composer scale bar has been added*/
+    void composerScaleBarAdded( QgsComposerScaleBar* scalebar );
+    /**Is emitted when a new composer legend has been added*/
+    void composerLegendAdded( QgsComposerLegend* legend );
+    /**Is emitted when a new composer picture has been added*/
+    void composerPictureAdded( QgsComposerPicture* picture );
+    /**Is emitted when a composer item has been removed from the scene*/
+    void itemRemoved( QgsComposerItem* );
+    /**Current action (e.g. adding composer map) has been finished. The purpose of this signal is that
+     QgsComposer may set the selection tool again*/
+    void actionFinished();
+};

Modified: trunk/qgis/src/app/qgisappinterface.cpp
===================================================================
--- trunk/qgis/src/app/qgisappinterface.cpp	2009-02-27 09:10:16 UTC (rev 10243)
+++ trunk/qgis/src/app/qgisappinterface.cpp	2009-02-27 13:57:26 UTC (rev 10244)
@@ -139,8 +139,7 @@
   return qgis;
 }
 
-#if 0
-QList<QgsComposerView*> QgisAppInterface::composerViews()
+QList<QgsComposerView*> QgisAppInterface::activeComposers()
 {
   QList<QgsComposerView*> composerViewList;
   if(qgis)
@@ -157,27 +156,7 @@
   }
   return composerViewList;
 }
-#endif //0
 
-QList< QPair<QMainWindow*, QgsComposerView*> > QgisAppInterface::composerList()
-{
-
-QList< QPair<QMainWindow*, QgsComposerView*> > composerList;
-  if(qgis)
-  {
-    QgsComposer* c = qgis->printComposer();
-    if(c)
-    {
-      QgsComposerView* v = c->view();
-      if(v)
-      {
-        composerList.push_back(qMakePair((QMainWindow*)(c), v));
-      }
-    }
-  }
-  return composerList;
-}
-
 void QgisAppInterface::addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget )
 {
   qgis->addDockWidget( area, dockwidget );

Modified: trunk/qgis/src/app/qgisappinterface.h
===================================================================
--- trunk/qgis/src/app/qgisappinterface.h	2009-02-27 09:10:16 UTC (rev 10243)
+++ trunk/qgis/src/app/qgisappinterface.h	2009-02-27 13:57:26 UTC (rev 10244)
@@ -92,11 +92,8 @@
     */
     QWidget * mainWindow();
 
-    /** Return pointers to the composer views of the running instance (currently only one)*/
-    //QList<QgsComposerView*> composerViews();
+    QList<QgsComposerView*> activeComposers();
 
-    QList< QPair<QMainWindow*, QgsComposerView*> > composerList();
-
     /** Add action to the plugins menu */
     void addPluginToMenu( QString name, QAction* action );
     /** Remove action from the plugins menu */

Modified: trunk/qgis/src/gui/qgisinterface.h
===================================================================
--- trunk/qgis/src/gui/qgisinterface.h	2009-02-27 09:10:16 UTC (rev 10243)
+++ trunk/qgis/src/gui/qgisinterface.h	2009-02-27 13:57:26 UTC (rev 10244)
@@ -107,11 +107,8 @@
     /** Return a pointer to the main window (instance of QgisApp in case of QGIS) */
     virtual QWidget * mainWindow() = 0;
 
-    /** Return pointers to composer main windows*/
-    //virtual QList<QgsComposerView*> composerViews() = 0;
-
     /**Return mainwindows / composer views of running composer instances (currently only one)*/
-    //virtual QList< QPair<QMainWindow*, QgsComposerView*> > composerList() = 0;
+    virtual QList<QgsComposerView*> activeComposers() = 0;
 
     /** Add action to the plugins menu */
     virtual void addPluginToMenu( QString name, QAction* action ) = 0;

Modified: trunk/qgis/src/gui/qgscomposerview.cpp
===================================================================
--- trunk/qgis/src/gui/qgscomposerview.cpp	2009-02-27 09:10:16 UTC (rev 10243)
+++ trunk/qgis/src/gui/qgscomposerview.cpp	2009-02-27 13:57:26 UTC (rev 10244)
@@ -15,6 +15,7 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <QMainWindow>
 #include <QMouseEvent>
 #include <QKeyEvent>
 
@@ -97,12 +98,8 @@
       QgsComposerLabel* newLabelItem = new QgsComposerLabel( composition() );
       newLabelItem->setText( "Quantum GIS" );
       newLabelItem->adjustSizeToText();
-      scene()->addItem( newLabelItem );
-      emit composerLabelAdded( newLabelItem );
-      scene()->clearSelection();
       newLabelItem->setSceneRect( QRectF( snappedScenePoint.x(), snappedScenePoint.y(), newLabelItem->rect().width(), newLabelItem->rect().height() ) );
-      newLabelItem->setSelected( true );
-      emit selectedItemChanged( newLabelItem );
+      addComposerLabel(newLabelItem);
       emit actionFinished();
     }
     break;
@@ -110,46 +107,24 @@
     case AddScalebar:
     {
       QgsComposerScaleBar* newScaleBar = new QgsComposerScaleBar( composition() );
-
-      //take first available map...
-      QList<const QgsComposerMap*> mapItemList = composition()->composerMapItems();
-      if ( mapItemList.size() > 0 )
-      {
-        newScaleBar->setComposerMap( mapItemList.at( 0 ) );
-      }
-
+      addComposerScaleBar(newScaleBar);
       newScaleBar->setSceneRect( QRectF( snappedScenePoint.x(), snappedScenePoint.y(), 20, 20 ) );
-      newScaleBar->applyDefaultSettings(); //4 segments, 1/5 of composer map width
-      scene()->addItem( newScaleBar );
-      emit composerScaleBarAdded( newScaleBar );
-      scene()->clearSelection();
-      newScaleBar->setSelected( true );
-      emit selectedItemChanged( newScaleBar );
-      emit actionFinished();
+     emit actionFinished();
     }
     break;
 
     case AddLegend:
     {
       QgsComposerLegend* newLegend = new QgsComposerLegend( composition() );
-      scene()->addItem( newLegend );
-      emit composerLegendAdded( newLegend );
-      scene()->clearSelection();
+      addComposerLegend(newLegend);
       newLegend->setSceneRect( QRectF( snappedScenePoint.x(), snappedScenePoint.y(), newLegend->rect().width(), newLegend->rect().height() ) );
-      newLegend->setSelected( true );
-      emit selectedItemChanged( newLegend );
-      emit actionFinished();
       break;
     }
     case AddPicture:
     {
       QgsComposerPicture* newPicture = new QgsComposerPicture( composition() );
-      scene()->addItem( newPicture );
-      emit composerPictureAdded( newPicture );
-      scene()->clearSelection();
+      addComposerPicture(newPicture);
       newPicture->setSceneRect( QRectF( snappedScenePoint.x(), snappedScenePoint.y(), 30, 30 ) );
-      newPicture->setSelected( true );
-      emit selectedItemChanged( newPicture );
       emit actionFinished();
     }
 
@@ -205,16 +180,9 @@
 
       QgsComposerMap* composerMap = new QgsComposerMap( composition(), mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height() );
       composerMap->setPreviewMode( QgsComposerMap::Rectangle );
-
-      emit composerMapAdded( composerMap );
-      scene()->addItem( composerMap );
-      scene()->clearSelection();
-
+      addComposerMap(composerMap);
       scene()->removeItem( mRubberBandItem );
       delete mRubberBandItem;
-
-      composerMap->setSelected( true );
-      emit selectedItemChanged( composerMap );
       emit actionFinished();
     }
     break;
@@ -371,6 +339,59 @@
   return 0;
 }
 
+void QgsComposerView::addComposerLabel( QgsComposerLabel* label)
+{
+   composition()->addItem(label);
+   emit composerLabelAdded(label);
+   scene()->clearSelection();
+   label->setSelected( true );
+   emit selectedItemChanged(label);
+}
+
+void QgsComposerView::addComposerMap( QgsComposerMap* map)
+{
+  scene()->addItem( map );
+  emit composerMapAdded( map );
+  scene()->clearSelection();
+  map->setSelected( true );
+  emit selectedItemChanged( map );
+}
+
+void QgsComposerView::addComposerScaleBar( QgsComposerScaleBar* scaleBar)
+{
+  //take first available map...
+  QList<const QgsComposerMap*> mapItemList = composition()->composerMapItems();
+  if ( mapItemList.size() > 0 )
+  {
+    scaleBar->setComposerMap( mapItemList.at( 0 ) );
+   }
+   scaleBar->applyDefaultSettings(); //4 segments, 1/5 of composer map width
+   scene()->addItem( scaleBar );
+   emit composerScaleBarAdded( scaleBar );
+   scene()->clearSelection();
+   scaleBar->setSelected( true );
+   emit selectedItemChanged( scaleBar );
+}
+
+void QgsComposerView::addComposerLegend( QgsComposerLegend* legend)
+{
+  scene()->addItem( legend );
+  emit composerLegendAdded( legend );
+  scene()->clearSelection();
+  legend->setSelected( true );
+  emit selectedItemChanged( legend );
+  emit actionFinished();
+}
+
+void QgsComposerView::addComposerPicture( QgsComposerPicture* picture )
+{
+   scene()->addItem( picture );
+   emit composerPictureAdded( picture );
+   scene()->clearSelection();
+   picture->setSelected( true );
+   emit selectedItemChanged( picture );
+}
+
 void QgsComposerView::groupItems()
 {
   if ( !composition() )
@@ -426,3 +447,25 @@
   emit itemRemoved( item );
 }
 
+QMainWindow* QgsComposerView::composerWindow()
+{
+  QObject* composerObject = 0;
+  QObject* currentObject = parent();
+  if(!currentObject)
+  {
+    return dynamic_cast<QMainWindow*>(currentObject);
+  }
+
+  while(true)
+  {
+    if(currentObject->parent() == 0)
+    {
+      composerObject = currentObject;
+      break;
+    }
+    currentObject = currentObject->parent();
+  }
+
+ return dynamic_cast<QMainWindow*>(composerObject);
+}
+

Modified: trunk/qgis/src/gui/qgscomposerview.h
===================================================================
--- trunk/qgis/src/gui/qgscomposerview.h	2009-02-27 09:10:16 UTC (rev 10243)
+++ trunk/qgis/src/gui/qgscomposerview.h	2009-02-27 13:57:26 UTC (rev 10244)
@@ -21,6 +21,7 @@
 #include <QGraphicsView>
 
 class QKeyEvent;
+class QMainWindow;
 class QMouseEvent;
 class QgsComposition;
 class QgsComposerItem;
@@ -71,6 +72,20 @@
     /**Returns the composition or 0 in case of error*/
     QgsComposition* composition();
 
+    /**Adds label to the graphics scene and advices composer to create a widget for it (through signal)*/
+    void addComposerLabel( QgsComposerLabel* label);
+    /**Adds map to the graphics scene and advices composer to create a widget for it (through signal)*/
+    void addComposerMap( QgsComposerMap* map);
+    /**Adds scale bar to the graphics scene and advices composer to create a widget for it (through signal)*/
+    void addComposerScaleBar( QgsComposerScaleBar* scaleBar);
+    /**Adds legend to the graphics scene and advices composer to create a widget for it (through signal)*/
+    void addComposerLegend( QgsComposerLegend* legend);
+    /**Adds picture to the graphics scene and advices composer to create a widget for it (through signal)*/
+    void addComposerPicture( QgsComposerPicture* picture );
+
+    /**Returns the composer main window*/
+    QMainWindow* composerWindow();
+
   protected:
     void mousePressEvent( QMouseEvent* );
     void mouseReleaseEvent( QMouseEvent* );



More information about the QGIS-commit mailing list