QGIS API Documentation  2.3.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...
 

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 composition (derived from QGraphicsScene) 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...
 

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 updateRubberBand (QPointF &pos)
 Redraws the 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
 

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

Member Enumeration Documentation

Enumerator
ClipboardModeCut 
ClipboardModeCopy 

Definition at line 73 of file qgscomposerview.h.

Enumerator
PasteModeCursor 
PasteModeCenter 
PasteModeInPlace 

Definition at line 79 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 54 of file qgscomposerview.h.

Enumerator
Inactive 
Active 
ActiveUntilMouseRelease 

Definition at line 86 of file qgscomposerview.h.

Constructor & Destructor Documentation

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

Definition at line 49 of file qgscomposerview.cpp.

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 1615 of file qgscomposerview.cpp.

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

Definition at line 119 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 1091 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 1568 of file qgscomposerview.cpp.

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

void QgsComposerView::hideEvent ( QHideEvent *  e)
protected

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

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

Definition at line 127 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.

void QgsComposerView::mouseReleaseEvent ( QMouseEvent *  e)
protected
void QgsComposerView::paintEvent ( QPaintEvent *  event)
protected

Definition at line 1504 of file qgscomposerview.cpp.

References mPaintingEnabled.

bool QgsComposerView::paintingEnabled ( ) const
inline

Definition at line 131 of file qgscomposerview.h.

void QgsComposerView::pasteItems ( PasteMode  mode)

Pastes items from clipboard.

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

References mRubberBandItem.

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

void QgsComposerView::resizeEvent ( QResizeEvent *  event)
protected

Definition at line 1529 of file qgscomposerview.cpp.

References updateRulers(), and zoomLevelChanged().

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

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

References composition().

void QgsComposerView::setComposition ( QgsComposition c)

Sets composition (derived from QGraphicsScene)

Definition at line 1542 of file qgscomposerview.cpp.

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

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

Definition at line 136 of file qgscomposerview.h.

void QgsComposerView::setPaintingEnabled ( bool  enabled)
inline

Definition at line 130 of file qgscomposerview.h.

void QgsComposerView::setVerticalRuler ( QgsComposerRuler r)
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 1488 of file qgscomposerview.cpp.

References updateRulers(), and zoomLevelChanged().

void QgsComposerView::showEvent ( QShowEvent *  e)
protected

Definition at line 1523 of file qgscomposerview.cpp.

References composerViewShow().

void QgsComposerView::startMarqueeSelect ( QPointF &  scenePoint)
private

Starts a marquee selection.

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

References mMarqueeZoom, mRubberBandItem, and mRubberBandStartPos.

Referenced by mousePressEvent().

void QgsComposerView::ungroupItems ( )

Ungroups the selected items.

Definition at line 1593 of file qgscomposerview.cpp.

References composition(), itemRemoved(), QgsComposerItemGroup::removeItems(), and QgsComposition::selectedComposerItems().

void QgsComposerView::updateRubberBand ( QPointF &  pos)
private

Redraws the rubber band.

Definition at line 954 of file qgscomposerview.cpp.

References mRubberBandItem, and mRubberBandStartPos.

Referenced by mouseMoveEvent().

void QgsComposerView::updateRulers ( )

Update rulers with current scene rect.

Definition at line 518 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 163 of file qgscomposerview.h.

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

QgsComposerRuler* QgsComposerView::mHorizontalRuler
private

Definition at line 187 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 198 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 179 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 181 of file qgscomposerview.h.

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

QPoint QgsComposerView::mMouseCurrentXY
private

Definition at line 204 of file qgscomposerview.h.

Referenced by keyPressEvent(), and mouseMoveEvent().

QPoint QgsComposerView::mMouseLastXY
private

Definition at line 203 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 196 of file qgscomposerview.h.

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

QPoint QgsComposerView::mMousePressStartPos
private

Definition at line 205 of file qgscomposerview.h.

Referenced by mousePressEvent(), and mouseReleaseEvent().

QgsComposerItem* QgsComposerView::mMoveContentItem
private

Item to move content.

Definition at line 172 of file qgscomposerview.h.

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

QPointF QgsComposerView::mMoveContentStartPos
private

Start position of content move.

Definition at line 174 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 201 of file qgscomposerview.h.

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

bool QgsComposerView::mPaintingEnabled
private

Definition at line 185 of file qgscomposerview.h.

Referenced by paintEvent().

QgsComposerView::Tool QgsComposerView::mPreviousTool
private

Previous composer tool.

Definition at line 165 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 170 of file qgscomposerview.h.

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

QPointF QgsComposerView::mRubberBandStartPos
private

Start of rubber band creation.

Definition at line 176 of file qgscomposerview.h.

Referenced by mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), startMarqueeSelect(), startMarqueeZoom(), and updateRubberBand().

QgsComposerView::ToolStatus QgsComposerView::mTemporaryZoomStatus
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().

bool QgsComposerView::mToolPanning
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().

QgsComposerRuler* QgsComposerView::mVerticalRuler
private

Definition at line 188 of file qgscomposerview.h.

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


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