Quantum GIS API Documentation  1.8
src/gui/qgscomposerview.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                          qgscomposerview.h
00003                              -------------------
00004     begin                : January 2005
00005     copyright            : (C) 2005 by Radim Blazek
00006     email                : [email protected]
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 #ifndef QGSCOMPOSERVIEW_H
00018 #define QGSCOMPOSERVIEW_H
00019 
00020 #include <QGraphicsView>
00021 #include "qgsaddremoveitemcommand.h"
00022 
00023 class QDomDocument;
00024 class QDomElement;
00025 class QKeyEvent;
00026 class QMainWindow;
00027 class QMouseEvent;
00028 class QgsComposition;
00029 class QgsComposerArrow;
00030 class QgsComposerItem;
00031 class QgsComposerLabel;
00032 class QgsComposerLegend;
00033 class QgsComposerMap;
00034 class QgsComposerPicture;
00035 class QgsComposerScaleBar;
00036 class QgsComposerShape;
00037 class QgsComposerAttributeTable;
00038 
00046 class GUI_EXPORT QgsComposerView: public QGraphicsView
00047 {
00048     Q_OBJECT
00049 
00050   public:
00051 
00053     enum Tool
00054     {
00055       Select = 0,      // Select/Move item
00056       AddArrow,         //add arrow
00057       AddMap,          // add new map
00058       AddLegend, // add vector legend
00059       AddLabel,        // add label
00060       AddScalebar,     // add scalebar
00061       AddPicture,       // add raster/vector picture
00062       AddRectangle,
00063       AddEllipse,
00064       AddTriangle,
00065       AddTable, //add attribute table
00066       MoveItemContent //move content of item (e.g. content of map)
00067     };
00068 
00069     QgsComposerView( QWidget* parent = 0, const char* name = 0, Qt::WFlags f = 0 );
00070 
00072     void groupItems();
00073 
00075     void ungroupItems();
00076 
00077     QgsComposerView::Tool currentTool() const {return mCurrentTool;}
00078     void setCurrentTool( QgsComposerView::Tool t ) {mCurrentTool = t;}
00079 
00081     void setComposition( QgsComposition* c );
00083     QgsComposition* composition();
00084 
00086     QMainWindow* composerWindow();
00087 
00088     void setPaintingEnabled( bool enabled ) { mPaintingEnabled = enabled; }
00089     bool paintingEnabled() const { return mPaintingEnabled; }
00090 
00091   protected:
00092     void mousePressEvent( QMouseEvent* );
00093     void mouseReleaseEvent( QMouseEvent* );
00094     void mouseMoveEvent( QMouseEvent* );
00095     void mouseDoubleClickEvent( QMouseEvent* e );
00096 
00097     void keyPressEvent( QKeyEvent * e );
00098     void keyReleaseEvent( QKeyEvent * e );
00099 
00100     void wheelEvent( QWheelEvent* event );
00101 
00102     void paintEvent( QPaintEvent* event );
00103 
00104     void hideEvent( QHideEvent* e );
00105     void showEvent( QShowEvent* e );
00106 
00107   private:
00109     bool mShiftKeyPressed;
00111     QgsComposerView::Tool mCurrentTool;
00113     QGraphicsRectItem* mRubberBandItem;
00115     QGraphicsLineItem* mRubberBandLineItem;
00117     QgsComposerItem* mMoveContentItem;
00119     QPointF mMoveContentStartPos;
00121     QPointF mRubberBandStartPos;
00122 
00123     bool mPaintingEnabled;
00124 
00126     void addShape( Tool currentTool );
00127 
00128     //void connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c );
00129 
00130   signals:
00132     void selectedItemChanged( QgsComposerItem* selected );
00133     void itemRemoved( QgsComposerItem* );
00136     void actionFinished();
00137 
00139     void composerViewShow( QgsComposerView* );
00141     void composerViewHide( QgsComposerView* );
00142 };
00143 
00144 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines