2009-02-27 13:57:26 +00:00
|
|
|
/** \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
|
|
|
|
|
2010-04-24 12:03:08 +00:00
|
|
|
%ConvertToSubClassCode
|
|
|
|
if (sipCpp->inherits("QgsComposerView"))
|
|
|
|
sipClass = sipClass_QgsComposerView;
|
|
|
|
else
|
|
|
|
sipClass = NULL;
|
|
|
|
%End
|
|
|
|
|
|
|
|
|
2009-02-27 13:57:26 +00:00
|
|
|
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
|
2010-02-09 16:18:36 +00:00
|
|
|
AddShape, //add shape item (ellipse, rectangle, triangle)
|
2009-02-27 13:57:26 +00:00
|
|
|
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();
|
|
|
|
|
|
|
|
/**Returns the composer main window*/
|
|
|
|
QMainWindow* composerWindow();
|
|
|
|
|
2010-12-02 09:55:42 +00:00
|
|
|
void setPaintingEnabled( bool enabled );
|
|
|
|
bool paintingEnabled() const;
|
|
|
|
|
|
|
|
/**Convenience function to create a QgsAddRemoveItemCommand, connect its signals and push it to the undo stack*/
|
|
|
|
void pushAddRemoveCommand( QgsComposerItem* item, const QString& text, QgsAddRemoveItemCommand::State state = QgsAddRemoveItemCommand::Added );
|
|
|
|
|
2009-02-27 13:57:26 +00:00
|
|
|
protected:
|
|
|
|
void mousePressEvent( QMouseEvent* );
|
|
|
|
void mouseReleaseEvent( QMouseEvent* );
|
|
|
|
void mouseMoveEvent( QMouseEvent* );
|
|
|
|
|
|
|
|
void keyPressEvent( QKeyEvent * e );
|
|
|
|
void keyReleaseEvent( QKeyEvent * e );
|
|
|
|
|
|
|
|
void wheelEvent( QWheelEvent* event );
|
|
|
|
|
|
|
|
|
|
|
|
public slots:
|
2010-11-29 15:30:19 +00:00
|
|
|
/**Casts object to the proper subclass type and calls corresponding itemAdded signal*/
|
|
|
|
void sendItemAddedSignal( QgsComposerItem* item );
|
2009-02-27 13:57:26 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
/**Is emitted when selected item changed. If 0, no item is selected*/
|
2010-11-22 22:32:03 +00:00
|
|
|
void selectedItemChanged( QgsComposerItem* selected );
|
2009-02-27 13:57:26 +00:00
|
|
|
/**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();
|
2011-06-30 16:30:50 +02:00
|
|
|
|
|
|
|
/**Emitted before composerview is shown*/
|
|
|
|
void composerViewShow( QgsComposerView* );
|
|
|
|
/**Emitted before composerview is hidden*/
|
|
|
|
void composerViewHide( QgsComposerView* );
|
2009-02-27 13:57:26 +00:00
|
|
|
};
|