QGIS API Documentation
2.2.0-Valmiera
|
Widget to display the composer items. More...
#include <qgscomposerview.h>
Public Types | |
enum | Tool { Select = 0, AddArrow, AddHtml, AddMap, AddLegend, AddLabel, AddScalebar, AddPicture, AddRectangle, AddEllipse, AddTriangle, AddTable, MoveItemContent, Pan, Zoom } |
Current tool. More... | |
enum | ClipboardMode { ClipboardModeCut, ClipboardModeCopy } |
enum | PasteMode { PasteModeCursor, PasteModeCenter, PasteModeInPlace } |
enum | ToolStatus { Inactive, Active, ActiveUntilMouseRelease } |
Signals | |
void | selectedItemChanged (QgsComposerItem *selected) |
Is emitted when selected item changed. | |
void | itemRemoved (QgsComposerItem *) |
Is emitted when a composer item has been removed from the scene. | |
void | actionFinished () |
Current action (e.g. | |
void | cursorPosChanged (QPointF) |
Is emitted when mouse cursor coordinates change. | |
void | zoomLevelChanged () |
Is emitted when the view zoom changes. | |
void | composerViewShow (QgsComposerView *) |
Emitted before composerview is shown. | |
void | composerViewHide (QgsComposerView *) |
Emitted before composerview is hidden. |
Public Member Functions | |
QgsComposerView (QWidget *parent=0, const char *name=0, Qt::WFlags f=0) | |
void | groupItems () |
Add an item group containing the selected items. | |
void | ungroupItems () |
Ungroups the selected items. | |
void | copyItems (ClipboardMode mode) |
Cuts or copies the selected items. | |
void | pasteItems (PasteMode mode) |
Pastes items from clipboard. | |
void | deleteSelectedItems () |
Deletes selected items. | |
void | selectAll () |
Selects all items. | |
void | selectNone () |
Deselects all items. | |
void | selectInvert () |
Inverts current selection. | |
QgsComposerView::Tool | currentTool () const |
void | setCurrentTool (QgsComposerView::Tool t) |
void | setComposition (QgsComposition *c) |
Sets composition (derived from QGraphicsScene) | |
QgsComposition * | composition () |
Returns the composition or 0 in case of error. | |
QMainWindow * | composerWindow () |
Returns the composer main window. | |
void | setPaintingEnabled (bool enabled) |
bool | paintingEnabled () const |
void | updateRulers () |
Update rulers with current scene rect. | |
void | setHorizontalRuler (QgsComposerRuler *r) |
void | setVerticalRuler (QgsComposerRuler *r) |
void | setZoomLevel (double zoomLevel) |
Set zoom level, where a zoom level of 1.0 corresponds to 100%. |
Protected Member Functions | |
void | mousePressEvent (QMouseEvent *) |
void | mouseReleaseEvent (QMouseEvent *) |
void | mouseMoveEvent (QMouseEvent *) |
void | mouseDoubleClickEvent (QMouseEvent *e) |
void | keyPressEvent (QKeyEvent *e) |
void | keyReleaseEvent (QKeyEvent *e) |
void | wheelEvent (QWheelEvent *event) |
void | paintEvent (QPaintEvent *event) |
void | hideEvent (QHideEvent *e) |
void | showEvent (QShowEvent *e) |
void | resizeEvent (QResizeEvent *event) |
void | scrollContentsBy (int dx, int dy) |
Private Member Functions | |
void | addShape (Tool currentTool) |
Draw a shape on the canvas. | |
QCursor | defaultCursorForTool (Tool currentTool) |
Returns the default mouse cursor for a tool. | |
void | wheelZoom (QWheelEvent *event) |
Zoom composition from a mouse wheel event. | |
void | updateRubberBand (QPointF &pos) |
Redraws the rubber band. | |
void | removeRubberBand () |
Removes the rubber band and cleans up. | |
void | startMarqueeSelect (QPointF &scenePoint) |
Starts a marquee selection. | |
void | endMarqueeSelect (QMouseEvent *e) |
Finalises a marquee selection. | |
void | startMarqueeZoom (QPointF &scenePoint) |
Starts a zoom in marquee. | |
void | endMarqueeZoom (QMouseEvent *e) |
Finalises a marquee zoom. |
Private Attributes | |
QgsComposerView::Tool | mCurrentTool |
Current composer tool. | |
QgsComposerView::Tool | mPreviousTool |
Previous composer tool. | |
QGraphicsRectItem * | mRubberBandItem |
Rubber band item. | |
QGraphicsLineItem * | mRubberBandLineItem |
Rubber band item for arrows. | |
QgsComposerItem * | mMoveContentItem |
Item to move content. | |
QPointF | mMoveContentStartPos |
Start position of content move. | |
QPointF | mRubberBandStartPos |
Start of rubber band creation. | |
bool | mMarqueeSelect |
True if user is currently selecting by marquee. | |
bool | mMarqueeZoom |
True if user is currently zooming by marquee. | |
QgsComposerView::ToolStatus | mTemporaryZoomStatus |
True if user is currently temporarily activating the zoom tool by holding control+space. | |
bool | mPaintingEnabled |
QgsComposerRuler * | mHorizontalRuler |
QgsComposerRuler * | mVerticalRuler |
bool | mToolPanning |
True if user is currently panning by clicking and dragging with the pan tool. | |
bool | mMousePanning |
True if user is currently panning by holding the middle mouse button. | |
bool | mKeyPanning |
True if user is currently panning by holding the space key. | |
bool | mMovingItemContent |
True if user is currently dragging with the move item content tool. | |
QPoint | mMouseLastXY |
QPoint | mMouseCurrentXY |
QPoint | mMousePressStartPos |
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.
Definition at line 47 of file qgscomposerview.h.
Definition at line 73 of file qgscomposerview.h.
Definition at line 79 of file qgscomposerview.h.
Current tool.
Select | |
AddArrow | |
AddHtml | |
AddMap | |
AddLegend | |
AddLabel | |
AddScalebar | |
AddPicture | |
AddRectangle | |
AddEllipse | |
AddTriangle | |
AddTable | |
MoveItemContent | |
Pan | |
Zoom |
Definition at line 54 of file qgscomposerview.h.
Definition at line 86 of file qgscomposerview.h.
QgsComposerView::QgsComposerView | ( | QWidget * | parent = 0 , |
const char * | name = 0 , |
||
Qt::WFlags | f = 0 |
||
) |
Definition at line 47 of file qgscomposerview.cpp.
|
signal |
Current action (e.g.
adding composer map) has been finished. The purpose of this signal is that QgsComposer may set the selection tool again
Referenced by addShape(), mousePressEvent(), and mouseReleaseEvent().
|
private |
Draw a shape on the canvas.
Definition at line 484 of file qgscomposerview.cpp.
References actionFinished(), QgsComposition::addComposerShape(), AddRectangle, AddTriangle, composition(), QgsComposerShape::Ellipse, mRubberBandItem, QgsComposition::pushAddRemoveCommand(), QgsComposerShape::Rectangle, removeRubberBand(), selectedItemChanged(), QgsComposerItem::setSelected(), QgsComposerShape::setShapeType(), QgsComposerShape::setUseSymbolV2(), tr, and QgsComposerShape::Triangle.
Referenced by mouseReleaseEvent().
|
signal |
Emitted before composerview is hidden.
Referenced by hideEvent().
|
signal |
Emitted before composerview is shown.
Referenced by showEvent().
QMainWindow * QgsComposerView::composerWindow | ( | ) |
Returns the composer main window.
Definition at line 1613 of file qgscomposerview.cpp.
QgsComposition * QgsComposerView::composition | ( | ) |
Returns the composition or 0 in case of error.
Definition at line 1553 of file qgscomposerview.cpp.
Referenced by addShape(), copyItems(), deleteSelectedItems(), endMarqueeSelect(), groupItems(), keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), pasteItems(), selectAll(), selectInvert(), selectNone(), setCurrentTool(), ungroupItems(), wheelEvent(), and wheelZoom().
void QgsComposerView::copyItems | ( | ClipboardMode | mode | ) |
Cuts or copies the selected items.
Definition at line 998 of file qgscomposerview.cpp.
References ClipboardModeCopy, ClipboardModeCut, composition(), QgsComposerItemGroup::items(), QgsComposition::removeComposerItem(), and QgsComposition::selectedComposerItems().
|
inline |
Definition at line 119 of file qgscomposerview.h.
Referenced by wheelEvent().
|
signal |
Is emitted when mouse cursor coordinates change.
Referenced by mouseMoveEvent().
|
private |
Returns the default mouse cursor for a tool.
Definition at line 446 of file qgscomposerview.cpp.
References AddArrow, AddEllipse, AddHtml, AddLabel, AddLegend, AddMap, AddPicture, AddRectangle, AddScalebar, AddTable, AddTriangle, cross_hair_cursor, MoveItemContent, Pan, Select, Zoom, and zoom_in.
Referenced by keyReleaseEvent(), mouseReleaseEvent(), and setCurrentTool().
void QgsComposerView::deleteSelectedItems | ( | ) |
Deletes selected items.
Definition at line 1089 of file qgscomposerview.cpp.
References composition(), QgsComposition::removeComposerItem(), and QgsComposition::selectedComposerItems().
|
private |
Finalises a marquee selection.
Definition at line 554 of file qgscomposerview.cpp.
References composition(), mMarqueeSelect, mRubberBandItem, QgsComposerItem::positionLock(), removeRubberBand(), QgsComposition::selectedComposerItems(), selectedItemChanged(), and QgsComposerItem::setSelected().
Referenced by mouseReleaseEvent().
|
private |
Finalises a marquee zoom.
Definition at line 640 of file qgscomposerview.cpp.
References ActiveUntilMouseRelease, Inactive, mMarqueeZoom, mPreviousTool, mRubberBandItem, mTemporaryZoomStatus, removeRubberBand(), QgsRectangle::scale(), setCurrentTool(), and QgsRectangle::toRectF().
Referenced by mouseReleaseEvent().
void QgsComposerView::groupItems | ( | ) |
Add an item group containing the selected items.
Definition at line 1566 of file qgscomposerview.cpp.
References QgsComposerItemGroup::addItem(), composition(), QgsComposition::selectedComposerItems(), selectedItemChanged(), and QgsComposerItem::setSelected().
|
protected |
Definition at line 1515 of file qgscomposerview.cpp.
References composerViewHide().
|
signal |
Is emitted when a composer item has been removed from the scene.
Referenced by ungroupItems().
|
protected |
Definition at line 1180 of file qgscomposerview.cpp.
References Active, ActiveUntilMouseRelease, composition(), Inactive, QgsComposerMergeCommand::ItemMove, mCurrentTool, mKeyPanning, mMarqueeZoom, mMouseCurrentXY, mMouseLastXY, mMousePanning, mMovingItemContent, mPreviousTool, mRubberBandItem, mRubberBandLineItem, mTemporaryZoomStatus, mToolPanning, QgsComposition::selectedComposerItems(), setCurrentTool(), QgsComposition::setPreventCursorChange(), tr, Zoom, zoom_in, and zoom_out.
|
protected |
Definition at line 1321 of file qgscomposerview.cpp.
References ActiveUntilMouseRelease, composition(), defaultCursorForTool(), Inactive, mCurrentTool, mKeyPanning, mMarqueeZoom, mPreviousTool, mTemporaryZoomStatus, Pan, setCurrentTool(), QgsComposition::setPreventCursorChange(), Zoom, zoom_in, and zoom_out.
|
protected |
Definition at line 993 of file qgscomposerview.cpp.
|
protected |
Definition at line 863 of file qgscomposerview.cpp.
References AddArrow, AddEllipse, AddHtml, AddMap, AddRectangle, AddTriangle, composition(), cursorPosChanged(), mCurrentTool, mHorizontalRuler, mKeyPanning, mMarqueeSelect, mMarqueeZoom, mMouseCurrentXY, mMouseLastXY, mMousePanning, mMoveContentItem, mMoveContentStartPos, MoveItemContent, mRubberBandLineItem, mRubberBandStartPos, mToolPanning, mVerticalRuler, Select, QgsComposerMap::setOffset(), QgsComposerRuler::updateMarker(), updateRubberBand(), and updateRulers().
|
protected |
Definition at line 125 of file qgscomposerview.cpp.
References actionFinished(), AddArrow, QgsComposition::addComposerLabel(), QgsComposition::addComposerLegend(), QgsComposition::addComposerPicture(), QgsComposition::addComposerScaleBar(), QgsComposition::addComposerTable(), AddEllipse, AddHtml, AddLabel, AddLegend, AddMap, AddPicture, AddRectangle, AddScalebar, AddTable, AddTriangle, QgsComposerLabel::adjustSizeToText(), QgsComposerScaleBar::applyDefaultSize(), QgsComposition::composerItemAt(), QgsComposition::composerMapItems(), composition(), mCurrentTool, mKeyPanning, mMouseLastXY, mMousePanning, mMousePressStartPos, mMoveContentItem, mMoveContentStartPos, mMovingItemContent, QgsComposerMouseHandles::mouseActionForScenePos(), QgsComposerMouseHandles::MoveItem, MoveItemContent, mRubberBandItem, mRubberBandLineItem, mRubberBandStartPos, mToolPanning, QgsComposerMouseHandles::NoAction, Pan, QgsComposerItem::positionLock(), QgsComposition::pushAddRemoveCommand(), QgsRectangle::scale(), Select, QgsComposerItem::selected(), QgsComposition::selectedComposerItems(), selectedItemChanged(), QgsComposition::selectionHandles(), QgsComposerMouseHandles::SelectItem, QgsComposerScaleBar::setComposerMap(), QgsComposerItem::setPositionLock(), QgsComposition::setPreventCursorChange(), QgsComposerPicture::setSceneRect(), QgsComposerAttributeTable::setSceneRect(), QgsComposerItem::setSceneRect(), QgsComposerItem::setSelected(), QgsComposerLabel::setText(), QgsComposition::snapPointToGrid(), startMarqueeSelect(), startMarqueeZoom(), QgsRectangle::toRectF(), tr, QgsComposerLegend::updateLegend(), and Zoom.
|
protected |
Definition at line 681 of file qgscomposerview.cpp.
References actionFinished(), AddArrow, QgsComposition::addComposerArrow(), QgsComposition::addComposerMap(), QgsAddRemoveMultiFrameCommand::Added, AddEllipse, QgsComposerHtml::addFrame(), AddHtml, AddMap, AddRectangle, addShape(), AddTriangle, QgsComposition::beginCommand(), QgsComposition::beginMultiFrameCommand(), composition(), defaultCursorForTool(), QgsComposition::endCommand(), endMarqueeSelect(), endMarqueeZoom(), QgsComposition::endMultiFrameCommand(), QgsComposerMouseHandles::isDragging(), QgsComposerMouseHandles::isResizing(), mCurrentTool, mMarqueeSelect, mMarqueeZoom, mMousePanning, mMousePressStartPos, mMoveContentItem, mMoveContentStartPos, mMovingItemContent, QgsComposerItem::moveContent(), MoveItemContent, mRubberBandItem, mRubberBandLineItem, mRubberBandStartPos, mToolPanning, Pan, QgsComposition::pushAddRemoveCommand(), removeRubberBand(), QgsRectangle::scale(), Select, selectedItemChanged(), QgsComposition::selectionHandles(), QgsComposerMap::setOffset(), QgsComposition::setPreventCursorChange(), QgsComposerItem::setSelected(), QgsComposition::snapPointToGrid(), QgsRectangle::toRectF(), tr, QgsComposition::undoStack(), and Zoom.
|
protected |
Definition at line 1502 of file qgscomposerview.cpp.
References mPaintingEnabled.
|
inline |
Definition at line 131 of file qgscomposerview.h.
void QgsComposerView::pasteItems | ( | PasteMode | mode | ) |
Pastes items from clipboard.
Definition at line 1052 of file qgscomposerview.cpp.
References QgsComposition::addItemsFromXML(), composition(), PasteModeCursor, PasteModeInPlace, Select, and setCurrentTool().
|
private |
Removes the rubber band and cleans up.
Definition at line 528 of file qgscomposerview.cpp.
References mRubberBandItem.
Referenced by addShape(), endMarqueeSelect(), endMarqueeZoom(), and mouseReleaseEvent().
|
protected |
Definition at line 1527 of file qgscomposerview.cpp.
References updateRulers(), and zoomLevelChanged().
|
protected |
Definition at line 1534 of file qgscomposerview.cpp.
References updateRulers().
void QgsComposerView::selectAll | ( | ) |
Selects all items.
Definition at line 1109 of file qgscomposerview.cpp.
References composition(), QgsComposerItem::positionLock(), selectedItemChanged(), and QgsComposerItem::setSelected().
|
signal |
Is emitted when selected item changed.
If 0, no item is selected
Referenced by addShape(), endMarqueeSelect(), groupItems(), mousePressEvent(), mouseReleaseEvent(), selectAll(), and selectInvert().
void QgsComposerView::selectInvert | ( | ) |
Inverts current selection.
Definition at line 1149 of file qgscomposerview.cpp.
References composition(), QgsComposerItem::positionLock(), QgsComposerItem::selected(), selectedItemChanged(), and QgsComposerItem::setSelected().
void QgsComposerView::selectNone | ( | ) |
void QgsComposerView::setComposition | ( | QgsComposition * | c | ) |
Sets composition (derived from QGraphicsScene)
Definition at line 1540 of file qgscomposerview.cpp.
References mHorizontalRuler, mVerticalRuler, and QgsComposerRuler::setComposition().
void QgsComposerView::setCurrentTool | ( | QgsComposerView::Tool | t | ) |
Definition at line 72 of file qgscomposerview.cpp.
References AddArrow, AddEllipse, AddHtml, AddLabel, AddLegend, AddMap, AddPicture, AddRectangle, AddScalebar, AddTable, AddTriangle, composition(), defaultCursorForTool(), mCurrentTool, Pan, QgsComposition::setPreventCursorChange(), and Zoom.
Referenced by endMarqueeZoom(), keyPressEvent(), keyReleaseEvent(), and pasteItems().
|
inline |
Definition at line 136 of file qgscomposerview.h.
|
inline |
Definition at line 130 of file qgscomposerview.h.
|
inline |
Definition at line 137 of file qgscomposerview.h.
void QgsComposerView::setZoomLevel | ( | double | zoomLevel | ) |
Set zoom level, where a zoom level of 1.0 corresponds to 100%.
Definition at line 1486 of file qgscomposerview.cpp.
References updateRulers(), and zoomLevelChanged().
|
protected |
Definition at line 1521 of file qgscomposerview.cpp.
References composerViewShow().
|
private |
Starts a marquee selection.
Definition at line 538 of file qgscomposerview.cpp.
References mMarqueeSelect, mRubberBandItem, and mRubberBandStartPos.
Referenced by mousePressEvent().
|
private |
Starts a zoom in marquee.
Definition at line 624 of file qgscomposerview.cpp.
References mMarqueeZoom, mRubberBandItem, and mRubberBandStartPos.
Referenced by mousePressEvent().
void QgsComposerView::ungroupItems | ( | ) |
Ungroups the selected items.
Definition at line 1591 of file qgscomposerview.cpp.
References composition(), itemRemoved(), QgsComposerItemGroup::removeItems(), and QgsComposition::selectedComposerItems().
|
private |
Redraws the rubber band.
Definition at line 952 of file qgscomposerview.cpp.
References mRubberBandItem, and mRubberBandStartPos.
Referenced by mouseMoveEvent().
void QgsComposerView::updateRulers | ( | ) |
Update rulers with current scene rect.
Definition at line 516 of file qgscomposerview.cpp.
References mHorizontalRuler, mVerticalRuler, and QgsComposerRuler::setSceneTransform().
Referenced by mouseMoveEvent(), resizeEvent(), scrollContentsBy(), setZoomLevel(), and wheelZoom().
|
protected |
Definition at line 1369 of file qgscomposerview.cpp.
References QgsComposerItem::beginCommand(), QgsComposition::composerItemAt(), composition(), currentTool(), MoveItemContent, mRubberBandItem, mRubberBandLineItem, tr, and wheelZoom().
|
private |
Zoom composition from a mouse wheel event.
Definition at line 1408 of file qgscomposerview.cpp.
References QgsRectangle::center(), composition(), QgsComposerMap::previewMode(), QgsComposerMap::Render, QgsComposerMap::updateCachedImage(), updateRulers(), QgsMapCanvas::WheelNothing, QgsMapCanvas::WheelZoomAndRecenter, QgsMapCanvas::WheelZoomToMouseCursor, and zoomLevelChanged().
Referenced by wheelEvent().
|
signal |
Is emitted when the view zoom changes.
Referenced by resizeEvent(), setZoomLevel(), and wheelZoom().
|
private |
Current composer tool.
Definition at line 163 of file qgscomposerview.h.
Referenced by keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and setCurrentTool().
|
private |
Definition at line 187 of file qgscomposerview.h.
Referenced by mouseMoveEvent(), setComposition(), and updateRulers().
|
private |
True if user is currently panning by holding the space key.
Definition at line 198 of file qgscomposerview.h.
Referenced by keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), and mousePressEvent().
|
private |
True if user is currently selecting by marquee.
Definition at line 179 of file qgscomposerview.h.
Referenced by endMarqueeSelect(), mouseMoveEvent(), mouseReleaseEvent(), and startMarqueeSelect().
|
private |
True if user is currently zooming by marquee.
Definition at line 181 of file qgscomposerview.h.
Referenced by endMarqueeZoom(), keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), mouseReleaseEvent(), and startMarqueeZoom().
|
private |
Definition at line 204 of file qgscomposerview.h.
Referenced by keyPressEvent(), and mouseMoveEvent().
|
private |
Definition at line 203 of file qgscomposerview.h.
Referenced by keyPressEvent(), mouseMoveEvent(), and mousePressEvent().
|
private |
True if user is currently panning by holding the middle mouse button.
Definition at line 196 of file qgscomposerview.h.
Referenced by keyPressEvent(), mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().
|
private |
Definition at line 205 of file qgscomposerview.h.
Referenced by mousePressEvent(), and mouseReleaseEvent().
|
private |
Item to move content.
Definition at line 172 of file qgscomposerview.h.
Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().
|
private |
Start position of content move.
Definition at line 174 of file qgscomposerview.h.
Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().
|
private |
True if user is currently dragging with the move item content tool.
Definition at line 201 of file qgscomposerview.h.
Referenced by keyPressEvent(), mousePressEvent(), and mouseReleaseEvent().
|
private |
Definition at line 185 of file qgscomposerview.h.
Referenced by paintEvent().
|
private |
Previous composer tool.
Definition at line 165 of file qgscomposerview.h.
Referenced by endMarqueeZoom(), keyPressEvent(), and keyReleaseEvent().
|
private |
Rubber band item.
Definition at line 168 of file qgscomposerview.h.
Referenced by addShape(), endMarqueeSelect(), endMarqueeZoom(), keyPressEvent(), mousePressEvent(), mouseReleaseEvent(), removeRubberBand(), startMarqueeSelect(), startMarqueeZoom(), updateRubberBand(), and wheelEvent().
|
private |
Rubber band item for arrows.
Definition at line 170 of file qgscomposerview.h.
Referenced by keyPressEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and wheelEvent().
|
private |
Start of rubber band creation.
Definition at line 176 of file qgscomposerview.h.
Referenced by mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), startMarqueeSelect(), startMarqueeZoom(), and updateRubberBand().
|
private |
True if user is currently temporarily activating the zoom tool by holding control+space.
Definition at line 183 of file qgscomposerview.h.
Referenced by endMarqueeZoom(), keyPressEvent(), and keyReleaseEvent().
|
private |
True if user is currently panning by clicking and dragging with the pan tool.
Definition at line 194 of file qgscomposerview.h.
Referenced by keyPressEvent(), mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().
|
private |
Definition at line 188 of file qgscomposerview.h.
Referenced by mouseMoveEvent(), setComposition(), and updateRulers().