|
QGIS API Documentation
master-59fd5e0
|
00001 /*************************************************************************** 00002 qgscomposerview.h 00003 ------------------- 00004 begin : January 2005 00005 copyright : (C) 2005 by Radim Blazek 00006 email : blazek@itc.it 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 QgsComposerRuler; 00036 class QgsComposerScaleBar; 00037 class QgsComposerShape; 00038 class QgsComposerAttributeTable; 00039 00047 class GUI_EXPORT QgsComposerView: public QGraphicsView 00048 { 00049 Q_OBJECT 00050 00051 public: 00052 00054 enum Tool 00055 { 00056 Select = 0, // Select/Move item 00057 AddArrow, //add arrow 00058 AddHtml, 00059 AddMap, // add new map 00060 AddLegend, // add vector legend 00061 AddLabel, // add label 00062 AddScalebar, // add scalebar 00063 AddPicture, // add raster/vector picture 00064 AddRectangle, 00065 AddEllipse, 00066 AddTriangle, 00067 AddTable, //add attribute table 00068 MoveItemContent //move content of item (e.g. content of map) 00069 }; 00070 00071 QgsComposerView( QWidget* parent = 0, const char* name = 0, Qt::WFlags f = 0 ); 00072 00074 void groupItems(); 00075 00077 void ungroupItems(); 00078 00079 QgsComposerView::Tool currentTool() const {return mCurrentTool;} 00080 void setCurrentTool( QgsComposerView::Tool t ) {mCurrentTool = t;} 00081 00083 void setComposition( QgsComposition* c ); 00085 QgsComposition* composition(); 00086 00088 QMainWindow* composerWindow(); 00089 00090 void setPaintingEnabled( bool enabled ) { mPaintingEnabled = enabled; } 00091 bool paintingEnabled() const { return mPaintingEnabled; } 00092 00094 void updateRulers(); 00095 00096 void setHorizontalRuler( QgsComposerRuler* r ) { mHorizontalRuler = r; } 00097 void setVerticalRuler( QgsComposerRuler* r ) { mVerticalRuler = r; } 00098 00099 protected: 00100 void mousePressEvent( QMouseEvent* ); 00101 void mouseReleaseEvent( QMouseEvent* ); 00102 void mouseMoveEvent( QMouseEvent* ); 00103 void mouseDoubleClickEvent( QMouseEvent* e ); 00104 00105 void keyPressEvent( QKeyEvent * e ); 00106 00107 void wheelEvent( QWheelEvent* event ); 00108 00109 void paintEvent( QPaintEvent* event ); 00110 00111 void hideEvent( QHideEvent* e ); 00112 void showEvent( QShowEvent* e ); 00113 00114 void resizeEvent( QResizeEvent* event ); 00115 void scrollContentsBy( int dx, int dy ); 00116 00117 private: 00119 QgsComposerView::Tool mCurrentTool; 00121 QGraphicsRectItem* mRubberBandItem; 00123 QGraphicsLineItem* mRubberBandLineItem; 00125 QgsComposerItem* mMoveContentItem; 00127 QPointF mMoveContentStartPos; 00129 QPointF mRubberBandStartPos; 00130 00131 bool mPaintingEnabled; 00132 00133 QgsComposerRuler* mHorizontalRuler; 00134 QgsComposerRuler* mVerticalRuler; 00135 00137 void addShape( Tool currentTool ); 00138 00139 //void connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c ); 00140 00141 signals: 00143 void selectedItemChanged( QgsComposerItem* selected ); 00145 void itemRemoved( QgsComposerItem* ); 00148 void actionFinished(); 00149 00151 void composerViewShow( QgsComposerView* ); 00153 void composerViewHide( QgsComposerView* ); 00154 }; 00155 00156 #endif