QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Signals | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
QgsComposerView Class Reference

Widget to display the composer items. More...

#include <qgscomposerview.h>

Inheritance diagram for QgsComposerView:
Inheritance graph
[legend]
Collaboration diagram for QgsComposerView:
Collaboration graph
[legend]

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. More...
 
void itemRemoved (QgsComposerItem *)
 Is emitted when a composer item has been removed from the scene. More...
 
void actionFinished ()
 Current action (e.g. More...
 
void cursorPosChanged (QPointF)
 Is emitted when mouse cursor coordinates change. More...
 
void zoomLevelChanged ()
 Is emitted when the view zoom changes. More...
 
void composerViewShow (QgsComposerView *)
 Emitted before composerview is shown. More...
 
void composerViewHide (QgsComposerView *)
 Emitted before composerview is hidden. More...
 
void compositionSet (QgsComposition *)
 Emitted when the composition is set for the view. More...
 

Public Member Functions

 QgsComposerView (QWidget *parent=0, const char *name=0, Qt::WindowFlags f=0)
 
void groupItems ()
 Add an item group containing the selected items. More...
 
void ungroupItems ()
 Ungroups the selected items. More...
 
void copyItems (ClipboardMode mode)
 Cuts or copies the selected items. More...
 
void pasteItems (PasteMode mode)
 Pastes items from clipboard. More...
 
void deleteSelectedItems ()
 Deletes selected items. More...
 
void selectAll ()
 Selects all items. More...
 
void selectNone ()
 Deselects all items. More...
 
void selectInvert ()
 Inverts current selection. More...
 
QgsComposerView::Tool currentTool () const
 
void setCurrentTool (QgsComposerView::Tool t)
 
void setComposition (QgsComposition *c)
 Sets the composition for the view. More...
 
QgsCompositioncomposition ()
 Returns the composition or 0 in case of error. More...
 
QMainWindow * composerWindow ()
 Returns the composer main window. More...
 
void setPaintingEnabled (bool enabled)
 
bool paintingEnabled () const
 
void updateRulers ()
 Update rulers with current scene rect. More...
 
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%. More...
 
void setPreviewModeEnabled (bool enabled)
 Sets whether a preview effect should be used to alter the view's appearance. More...
 
void setPreviewMode (QgsPreviewEffect::PreviewMode mode)
 Sets the preview mode which should be used to modify the view's appearance. More...
 

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. More...
 
QCursor defaultCursorForTool (Tool currentTool)
 Returns the default mouse cursor for a tool. More...
 
void wheelZoom (QWheelEvent *event)
 Zoom composition from a mouse wheel event. More...
 
void updateRubberBandRect (QPointF &pos, const bool constrainSquare=false, const bool fromCenter=false)
 Redraws the rectangular rubber band. More...
 
void updateRubberBandLine (const QPointF &pos, const bool constrainAngles=false)
 Redraws the linear rubber band. More...
 
void removeRubberBand ()
 Removes the rubber band and cleans up. More...
 
void startMarqueeSelect (QPointF &scenePoint)
 Starts a marquee selection. More...
 
void endMarqueeSelect (QMouseEvent *e)
 Finalises a marquee selection. More...
 
void startMarqueeZoom (QPointF &scenePoint)
 Starts a zoom in marquee. More...
 
void endMarqueeZoom (QMouseEvent *e)
 Finalises a marquee zoom. More...
 

Private Attributes

QgsComposerView::Tool mCurrentTool
 Current composer tool. More...
 
QgsComposerView::Tool mPreviousTool
 Previous composer tool. More...
 
QGraphicsRectItem * mRubberBandItem
 Rubber band item. More...
 
QGraphicsLineItem * mRubberBandLineItem
 Rubber band item for arrows. More...
 
QgsComposerItemmMoveContentItem
 Item to move content. More...
 
QPointF mMoveContentStartPos
 Start position of content move. More...
 
QPointF mRubberBandStartPos
 Start of rubber band creation. More...
 
bool mMarqueeSelect
 True if user is currently selecting by marquee. More...
 
bool mMarqueeZoom
 True if user is currently zooming by marquee. More...
 
QgsComposerView::ToolStatus mTemporaryZoomStatus
 True if user is currently temporarily activating the zoom tool by holding control+space. More...
 
bool mPaintingEnabled
 
QgsComposerRulermHorizontalRuler
 
QgsComposerRulermVerticalRuler
 
bool mToolPanning
 True if user is currently panning by clicking and dragging with the pan tool. More...
 
bool mMousePanning
 True if user is currently panning by holding the middle mouse button. More...
 
bool mKeyPanning
 True if user is currently panning by holding the space key. More...
 
bool mMovingItemContent
 True if user is currently dragging with the move item content tool. More...
 
QPoint mMouseLastXY
 
QPoint mMouseCurrentXY
 
QPoint mMousePressStartPos
 
QgsPreviewEffectmPreviewEffect
 

Detailed Description

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 48 of file qgscomposerview.h.

Member Enumeration Documentation

Enumerator
ClipboardModeCut 
ClipboardModeCopy 

Definition at line 74 of file qgscomposerview.h.

Enumerator
PasteModeCursor 
PasteModeCenter 
PasteModeInPlace 

Definition at line 80 of file qgscomposerview.h.

Current tool.

Enumerator
Select 
AddArrow 
AddHtml 
AddMap 
AddLegend 
AddLabel 
AddScalebar 
AddPicture 
AddRectangle 
AddEllipse 
AddTriangle 
AddTable 
MoveItemContent 
Pan 
Zoom 

Definition at line 55 of file qgscomposerview.h.

Enumerator
Inactive 
Active 
ActiveUntilMouseRelease 

Definition at line 87 of file qgscomposerview.h.

Constructor & Destructor Documentation

QgsComposerView::QgsComposerView ( QWidget *  parent = 0,
const char *  name = 0,
Qt::WindowFlags  f = 0 
)

Definition at line 50 of file qgscomposerview.cpp.

References mPreviewEffect.

Member Function Documentation

void QgsComposerView::actionFinished ( )
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().

void QgsComposerView::addShape ( Tool  currentTool)
private
void QgsComposerView::composerViewHide ( QgsComposerView )
signal

Emitted before composerview is hidden.

Referenced by hideEvent().

void QgsComposerView::composerViewShow ( QgsComposerView )
signal

Emitted before composerview is shown.

Referenced by showEvent().

QMainWindow * QgsComposerView::composerWindow ( )

Returns the composer main window.

Definition at line 1766 of file qgscomposerview.cpp.

QgsComposition * QgsComposerView::composition ( )
void QgsComposerView::compositionSet ( QgsComposition )
signal

Emitted when the composition is set for the view.

Referenced by setComposition().

void QgsComposerView::copyItems ( ClipboardMode  mode)
QgsComposerView::Tool QgsComposerView::currentTool ( ) const
inline

Definition at line 120 of file qgscomposerview.h.

Referenced by wheelEvent().

void QgsComposerView::cursorPosChanged ( QPointF  )
signal

Is emitted when mouse cursor coordinates change.

Referenced by mouseMoveEvent().

QCursor QgsComposerView::defaultCursorForTool ( Tool  currentTool)
private
void QgsComposerView::deleteSelectedItems ( )

Deletes selected items.

Definition at line 1209 of file qgscomposerview.cpp.

References composition(), QgsComposition::removeComposerItem(), and QgsComposition::selectedComposerItems().

void QgsComposerView::endMarqueeSelect ( QMouseEvent *  e)
private
void QgsComposerView::endMarqueeZoom ( QMouseEvent *  e)
private
void QgsComposerView::groupItems ( )

Add an item group containing the selected items.

Definition at line 1718 of file qgscomposerview.cpp.

References QgsComposerItemGroup::addItem(), composition(), QgsComposition::selectedComposerItems(), selectedItemChanged(), and QgsComposerItem::setSelected().

void QgsComposerView::hideEvent ( QHideEvent *  e)
protected

Definition at line 1664 of file qgscomposerview.cpp.

References composerViewHide().

void QgsComposerView::itemRemoved ( QgsComposerItem )
signal

Is emitted when a composer item has been removed from the scene.

Referenced by ungroupItems().

void QgsComposerView::keyPressEvent ( QKeyEvent *  e)
protected
void QgsComposerView::keyReleaseEvent ( QKeyEvent *  e)
protected
void QgsComposerView::mouseDoubleClickEvent ( QMouseEvent *  e)
protected

Definition at line 1113 of file qgscomposerview.cpp.

void QgsComposerView::mouseMoveEvent ( QMouseEvent *  e)
protected
void QgsComposerView::mousePressEvent ( QMouseEvent *  e)
protected
void QgsComposerView::mouseReleaseEvent ( QMouseEvent *  e)
protected

Definition at line 624 of file qgscomposerview.cpp.

References actionFinished(), AddArrow, QgsComposition::addComposerArrow(), QgsComposition::addComposerLabel(), QgsComposition::addComposerLegend(), QgsComposition::addComposerMap(), QgsComposition::addComposerPicture(), QgsComposition::addComposerTable(), QgsAddRemoveMultiFrameCommand::Added, AddEllipse, QgsComposerHtml::addFrame(), AddHtml, AddLabel, AddLegend, AddMap, AddPicture, AddRectangle, addShape(), AddTable, AddTriangle, QgsComposerLabel::adjustSizeToText(), QgsComposition::beginCommand(), QgsComposition::beginMultiFrameCommand(), QgsComposition::composerMapItems(), 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, mToolPanning, Pan, QgsComposition::pushAddRemoveCommand(), removeRubberBand(), QgsRectangle::scale(), Select, selectedItemChanged(), QgsComposition::selectionHandles(), QgsComposition::setAllUnselected(), QgsComposerAttributeTable::setComposerMap(), QgsComposerMap::setOffset(), QgsComposition::setPreventCursorChange(), QgsComposerPicture::setSceneRect(), QgsComposerItem::setSceneRect(), QgsComposerAttributeTable::setSceneRect(), QgsComposerItem::setSelected(), QgsComposerLabel::setText(), QgsRectangle::toRectF(), tr, QgsComposition::undoStack(), QgsComposerLegend::updateLegend(), and Zoom.

void QgsComposerView::paintEvent ( QPaintEvent *  event)
protected

Definition at line 1651 of file qgscomposerview.cpp.

References mPaintingEnabled.

bool QgsComposerView::paintingEnabled ( ) const
inline

Definition at line 135 of file qgscomposerview.h.

void QgsComposerView::pasteItems ( PasteMode  mode)

Pastes items from clipboard.

Definition at line 1172 of file qgscomposerview.cpp.

References QgsComposition::addItemsFromXML(), composition(), PasteModeCursor, PasteModeInPlace, Select, and setCurrentTool().

void QgsComposerView::removeRubberBand ( )
private

Removes the rubber band and cleans up.

Definition at line 471 of file qgscomposerview.cpp.

References mRubberBandItem.

Referenced by addShape(), endMarqueeSelect(), endMarqueeZoom(), and mouseReleaseEvent().

void QgsComposerView::resizeEvent ( QResizeEvent *  event)
protected

Definition at line 1676 of file qgscomposerview.cpp.

References updateRulers(), and zoomLevelChanged().

void QgsComposerView::scrollContentsBy ( int  dx,
int  dy 
)
protected

Definition at line 1683 of file qgscomposerview.cpp.

References updateRulers().

void QgsComposerView::selectAll ( )
void QgsComposerView::selectedItemChanged ( QgsComposerItem selected)
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 ( )
void QgsComposerView::selectNone ( )

Deselects all items.

Definition at line 1259 of file qgscomposerview.cpp.

References composition(), and QgsComposition::setAllUnselected().

void QgsComposerView::setComposition ( QgsComposition c)

Sets the composition for the view.

If the composition is being set manually and not by a QgsComposer, then this must be set BEFORE adding any items to the composition.

Definition at line 1689 of file qgscomposerview.cpp.

References compositionSet(), mHorizontalRuler, mVerticalRuler, and QgsComposerRuler::setComposition().

void QgsComposerView::setCurrentTool ( QgsComposerView::Tool  t)
void QgsComposerView::setHorizontalRuler ( QgsComposerRuler r)
inline

Definition at line 140 of file qgscomposerview.h.

void QgsComposerView::setPaintingEnabled ( bool  enabled)
inline

Definition at line 134 of file qgscomposerview.h.

void QgsComposerView::setPreviewMode ( QgsPreviewEffect::PreviewMode  mode)

Sets the preview mode which should be used to modify the view's appearance.

Preview modes are only used if setPreviewMode is set to true.

Parameters
modePreviewMode to be used to draw the view
Note
added in 2.3
See also
setPreviewModeEnabled

Definition at line 1641 of file qgscomposerview.cpp.

References mPreviewEffect, and QgsPreviewEffect::setMode().

void QgsComposerView::setPreviewModeEnabled ( bool  enabled)

Sets whether a preview effect should be used to alter the view's appearance.

Parameters
enabledSet to true to enable the preview effect on the view
Note
added in 2.3
See also
setPreviewMode

Definition at line 1631 of file qgscomposerview.cpp.

References mPreviewEffect.

void QgsComposerView::setVerticalRuler ( QgsComposerRuler r)
inline

Definition at line 141 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 1615 of file qgscomposerview.cpp.

References updateRulers(), and zoomLevelChanged().

void QgsComposerView::showEvent ( QShowEvent *  e)
protected

Definition at line 1670 of file qgscomposerview.cpp.

References composerViewShow().

void QgsComposerView::startMarqueeSelect ( QPointF &  scenePoint)
private

Starts a marquee selection.

Definition at line 481 of file qgscomposerview.cpp.

References mMarqueeSelect, mRubberBandItem, and mRubberBandStartPos.

Referenced by mousePressEvent().

void QgsComposerView::startMarqueeZoom ( QPointF &  scenePoint)
private

Starts a zoom in marquee.

Definition at line 567 of file qgscomposerview.cpp.

References mMarqueeZoom, mRubberBandItem, and mRubberBandStartPos.

Referenced by mousePressEvent().

void QgsComposerView::ungroupItems ( )
void QgsComposerView::updateRubberBandLine ( const QPointF &  pos,
const bool  constrainAngles = false 
)
private
void QgsComposerView::updateRubberBandRect ( QPointF &  pos,
const bool  constrainSquare = false,
const bool  fromCenter = false 
)
private

Redraws the rectangular rubber band.

Definition at line 1020 of file qgscomposerview.cpp.

References mRubberBandItem, and mRubberBandStartPos.

Referenced by mouseMoveEvent().

void QgsComposerView::updateRulers ( )

Update rulers with current scene rect.

Definition at line 459 of file qgscomposerview.cpp.

References mHorizontalRuler, mVerticalRuler, and QgsComposerRuler::setSceneTransform().

Referenced by mouseMoveEvent(), resizeEvent(), scrollContentsBy(), setZoomLevel(), and wheelZoom().

void QgsComposerView::wheelEvent ( QWheelEvent *  event)
protected
void QgsComposerView::wheelZoom ( QWheelEvent *  event)
private
void QgsComposerView::zoomLevelChanged ( )
signal

Is emitted when the view zoom changes.

Referenced by resizeEvent(), setZoomLevel(), and wheelZoom().

Member Data Documentation

QgsComposerView::Tool QgsComposerView::mCurrentTool
private

Current composer tool.

Definition at line 181 of file qgscomposerview.h.

Referenced by keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and setCurrentTool().

QgsComposerRuler* QgsComposerView::mHorizontalRuler
private

Definition at line 205 of file qgscomposerview.h.

Referenced by mouseMoveEvent(), setComposition(), and updateRulers().

bool QgsComposerView::mKeyPanning
private

True if user is currently panning by holding the space key.

Definition at line 216 of file qgscomposerview.h.

Referenced by keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), and mousePressEvent().

bool QgsComposerView::mMarqueeSelect
private

True if user is currently selecting by marquee.

Definition at line 197 of file qgscomposerview.h.

Referenced by endMarqueeSelect(), mouseMoveEvent(), mouseReleaseEvent(), and startMarqueeSelect().

bool QgsComposerView::mMarqueeZoom
private

True if user is currently zooming by marquee.

Definition at line 199 of file qgscomposerview.h.

Referenced by endMarqueeZoom(), keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), mouseReleaseEvent(), and startMarqueeZoom().

QPoint QgsComposerView::mMouseCurrentXY
private

Definition at line 222 of file qgscomposerview.h.

Referenced by keyPressEvent(), and mouseMoveEvent().

QPoint QgsComposerView::mMouseLastXY
private

Definition at line 221 of file qgscomposerview.h.

Referenced by keyPressEvent(), mouseMoveEvent(), and mousePressEvent().

bool QgsComposerView::mMousePanning
private

True if user is currently panning by holding the middle mouse button.

Definition at line 214 of file qgscomposerview.h.

Referenced by keyPressEvent(), mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

QPoint QgsComposerView::mMousePressStartPos
private

Definition at line 223 of file qgscomposerview.h.

Referenced by mousePressEvent(), and mouseReleaseEvent().

QgsComposerItem* QgsComposerView::mMoveContentItem
private

Item to move content.

Definition at line 190 of file qgscomposerview.h.

Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

QPointF QgsComposerView::mMoveContentStartPos
private

Start position of content move.

Definition at line 192 of file qgscomposerview.h.

Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

bool QgsComposerView::mMovingItemContent
private

True if user is currently dragging with the move item content tool.

Definition at line 219 of file qgscomposerview.h.

Referenced by keyPressEvent(), mousePressEvent(), and mouseReleaseEvent().

bool QgsComposerView::mPaintingEnabled
private

Definition at line 203 of file qgscomposerview.h.

Referenced by paintEvent().

QgsPreviewEffect* QgsComposerView::mPreviewEffect
private

Definition at line 225 of file qgscomposerview.h.

Referenced by QgsComposerView(), setPreviewMode(), and setPreviewModeEnabled().

QgsComposerView::Tool QgsComposerView::mPreviousTool
private

Previous composer tool.

Definition at line 183 of file qgscomposerview.h.

Referenced by endMarqueeZoom(), keyPressEvent(), and keyReleaseEvent().

QGraphicsRectItem* QgsComposerView::mRubberBandItem
private
QGraphicsLineItem* QgsComposerView::mRubberBandLineItem
private

Rubber band item for arrows.

Definition at line 188 of file qgscomposerview.h.

Referenced by keyPressEvent(), mousePressEvent(), mouseReleaseEvent(), updateRubberBandLine(), and wheelEvent().

QPointF QgsComposerView::mRubberBandStartPos
private

Start of rubber band creation.

Definition at line 194 of file qgscomposerview.h.

Referenced by mousePressEvent(), startMarqueeSelect(), startMarqueeZoom(), updateRubberBandLine(), and updateRubberBandRect().

QgsComposerView::ToolStatus QgsComposerView::mTemporaryZoomStatus
private

True if user is currently temporarily activating the zoom tool by holding control+space.

Definition at line 201 of file qgscomposerview.h.

Referenced by endMarqueeZoom(), keyPressEvent(), and keyReleaseEvent().

bool QgsComposerView::mToolPanning
private

True if user is currently panning by clicking and dragging with the pan tool.

Definition at line 212 of file qgscomposerview.h.

Referenced by keyPressEvent(), mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

QgsComposerRuler* QgsComposerView::mVerticalRuler
private

Definition at line 206 of file qgscomposerview.h.

Referenced by mouseMoveEvent(), setComposition(), and updateRulers().


The documentation for this class was generated from the following files: