QgsLegend Class Reference

#include <qgslegend.h>

Collaboration diagram for QgsLegend:

Collaboration graph
[legend]
List of all members.

Detailed Description

A Legend treeview for QGIS Map legend is a specialised QListView designed to show grooups of map layers, map layers, and the map layer members, properties and symbols for each layer.

The legend supports simple operations such as displaying an ordered list of layers in the current canvas, and complex operations such as drag/dropping layer symbologies and properties between layers.

There are a variety of different items that can appear in a QgsLegend. All items added to a QgsLegend should be inherited from QgsLegendItem as this will ensure that they can perform legend specific tasks such as seeing if dropping of other items onto them is allowed, returning their type etc.

The following types are defined:

Note:
Additional group types may be defined in the future to accommodate WMS, PostGIS etc layers.
Author:
Gary E.Sherman, Tim Sutton, Marco Hugentobler and Jens Oberender

Definition at line 83 of file qgslegend.h.

Public Slots

void addLayer (QgsMapLayer *layer)
void setMapCanvas (QgsMapCanvas *canvas)
void refreshLayerSymbology (QString key, bool expandItem=true)
 Updates symbology items for a layer.
void removeAll ()
void selectAll (bool select)
void addGroup ()
void removeLayer (QString)
void readProject (const QDomDocument &)
 called to read legend settings from project
void writeProject (QDomDocument &)
 called to write legend settings to project
void legendLayerRemove ()
 Removes the current LegendLayer and all its LegendLayerFiles.
void legendLayerShowInOverview ()
 Toggle show in overview for current layer.
void legendLayerZoom ()
 Zooms to extent of the current legend layer (considers there may be several legend layer files.
void legendLayerZoomNative ()
void legendLayerAttributeTable ()
 Show attribute table.
void legendLayerShowProperties ()
 Shows the property dialog of the first legend layer file in a legend layer.

Signals

void zOrderChanged (QgsLegend *lv)
void currentLayerChanged (QgsMapLayer *layer)
 Emited whenever current (selected) layer changes.

Public Member Functions

 QgsLegend (QWidget *parent=0, const char *name=0)
 
Note:

 ~QgsLegend ()
 Destructor.
QgsLegendLayerFilecurrentLayerFile ()
 Returns QgsLegendLayerFile associated with current layer.
QgsMapLayercurrentLayer ()
bool writeXML (QDomNode &layer_node, QDomDocument &document)
 Writes the content of the legend to a project file.
bool readXML (QDomNode &legendnode)
 Restores the legend from a project file.
bool yCoordAboveCenter (QgsLegendItem *it, int ycoord)
 Returns true, if the y-coordinate is >= the center of the item.
QTreeWidgetItem * firstItem ()
 Returns the first item in the hierarchy.
QTreeWidgetItem * nextItem (QTreeWidgetItem *item)
 Returns the next item (next sibling or next item on level above).
QTreeWidgetItem * nextSibling (QTreeWidgetItem *item)
 Returns the next sibling of an item or 0 if there is none.
QTreeWidgetItem * previousSibling (QTreeWidgetItem *item)
 Returns the previous sibling of an item or 0 if there is none.
void insertItem (QTreeWidgetItem *move, QTreeWidgetItem *into)
 Inserts an item into another one.
void moveItem (QTreeWidgetItem *move, QTreeWidgetItem *after)
 Moves an item after another one.
void removeItem (QTreeWidgetItem *item)
 Removes an item from the legend.
std::deque< QString > layerIDs ()
 Returns the ids of the layers contained in this legend.
void updateMapCanvasLayerSet ()
 Updates layer set of map canvas.
void updateOverview ()
 Updates overview.
void enableOverviewModeAllLayers (bool isInOverview)
 Show/remove all layer in/from overview.
void addPixmapWidthValue (int width)
 Adds an entry to mPixmapWidthValues.
void addPixmapHeightValue (int height)
 Adds an entry to mPixmapHeightValues.
void removePixmapWidthValue (int width)
 Removes an entry from mPixmapWidthValues.
void removePixmapHeightValue (int height)
 Removes an entry from mPixmapHeightValues.
void setName (QgsLegendLayerFile *w, QString layerName)
 Sets the name of the QgsLegendLayer that is the parent of the given QgsLegendLayerFile.
void setToggleEditingAction (QAction *editingAction)
 Sets the toggle editing action.
QgsLegendPixmapspixmaps ()
 Returns structure with legend pixmaps.
void updateCheckStates (QTreeWidgetItem *item, Qt::CheckState state)

Static Public Member Functions

static QDomNode nextDomNode (const QDomNode &theNode)
 Finds the next dom node.

Protected Member Functions

void mouseMoveEvent (QMouseEvent *e)
void mousePressEvent (QMouseEvent *e)
void mouseReleaseEvent (QMouseEvent *e)
void mouseDoubleClickEvent (QMouseEvent *e)
void storeInitialPosition (QTreeWidgetItem *li)
 Stores the necessary information about the position of an item in the hierarchy.
void resetToInitialPosition (QTreeWidgetItem *li)
 Moves an item back to the position where storeInitialPosition has been called.
QgsLegendLayerfindLegendLayer (const QString &layerKey)
 Returns the legend layer to which a map layer gelongs.
void adjustIconSize ()
 Checks mPixmapWidthValues and mPixmapHeightValues and sets a new icon size if necessary.
void initPixmaps ()
 Initialize pixmaps - called when QgsLegend is constructed.
bool checkLayerOrderUpdate ()
 This function compares the layer order before a drag with the current layer ordering and triggers a canvas repaint if it has changed.

Private Types

enum  HIERARCHY_POSITION_TYPE { FIRST_ITEM, FIRST_CHILD, YOUNGER_SIBLING }
 Information needed by 'storeInitialPosition' and 'resetToInitialPosition'. More...

Private Slots

void handleRightClickEvent (QTreeWidgetItem *item, const QPoint &position)
 Calls 'handleRightClickEvent' on the item.
void legendGroupRemove ()
 Removes the current legend group.
void expandAll ()
 Sets all listview items to open.
void collapseAll ()
 Sets all listview items to closed.
void handleItemChange (QTreeWidgetItem *item, int row)
 Just for a test.
void handleCurrentItemChanged (QTreeWidgetItem *current, QTreeWidgetItem *previous)
 delegates current layer to map canvas
void openEditor ()
 Calls openPersistentEditor for the current item.
void makeToTopLevelItem ()
 Removes the current item and inserts it as a toplevel item at the end of the legend.
void showLegendLayerFileGroups ()
 Show/ Hide the legend layer file groups.

Private Member Functions

 QgsLegend (QgsLegend const &)
QgsLegendoperator= (QgsLegend const &)
int getItemPos (QTreeWidgetItem *item)

Private Attributes

QPoint mLastPressPos
bool mMousePressedFlag
 True if the mouse is pressed.
QTreeWidgetItem * mItemBeingMoved
 keep track of the Item being dragged
int mItemBeingMovedOrigPos
HIERARCHY_POSITION_TYPE mRestoreInformation
QTreeWidgetItem * mRestoreItem
bool mShowLegendLayerFiles
std::deque< QString > mLayersPriorToMove
 Stores the layer ordering before a mouse Move.
QAction * mToggleEditingAction
 Action for the legendlayer right click menu.
QgsMapCanvasmMapCanvas
 Pointer to the main canvas.
std::map< QTreeWidgetItem *,
Qt::CheckState > 
mStateOfCheckBoxes
 Map that keeps track of which checkboxes are in which check state.
std::multiset< int > mPixmapWidthValues
 Stores the width values of the LegendSymbologyItem pixmaps.
std::multiset< int > mPixmapHeightValues
 Stores the width values of the LegendSymbologyItem pixmaps.
QSize mMinimumIconSize
 QgsLegend does not set the icon with/height to values lower than the minimum icon size.
QgsLegend::QgsLegendPixmaps mPixmaps
 structure which holds pixmap which are used in legend

Classes

class  QgsLegendPixmaps
 structure which holds pixmap which are used in legend More...


Member Enumeration Documentation

enum QgsLegend::HIERARCHY_POSITION_TYPE [private]

Information needed by 'storeInitialPosition' and 'resetToInitialPosition'.

Enumerator:
FIRST_ITEM 
FIRST_CHILD 
YOUNGER_SIBLING 

Definition at line 358 of file qgslegend.h.


Constructor & Destructor Documentation

QgsLegend::QgsLegend ( QWidget *  parent = 0,
const char *  name = 0 
)

Note:

Constructor.

Parameters:
qgis_app link to qgisapp
theParent An optional parent widget
theName An optional name for the widget

Definition at line 63 of file qgslegend.cpp.

References handleCurrentItemChanged(), handleItemChange(), initPixmaps(), QgsProject::instance(), readProject(), and writeProject().

QgsLegend::~QgsLegend (  ) 

Destructor.

Definition at line 97 of file qgslegend.cpp.

QgsLegend::QgsLegend ( QgsLegend const &   )  [private]

Prevent the copying of QgsLegends

Todo:
See if this is really required - we may want multiple map, canvas and legend support at some stage in the future.


Member Function Documentation

QgsLegendLayerFile * QgsLegend::currentLayerFile (  ) 

Returns QgsLegendLayerFile associated with current layer.

Definition at line 536 of file qgslegend.cpp.

References QgsLegendLayer::firstLayerFile(), and QgsLegendItem::parent().

Referenced by currentLayer(), QgisApp::removeLayer(), QgisApp::saveAsShapefile(), QgisApp::saveSelectionAsShapefile(), and QgisApp::toggleEditing().

QgsMapLayer * QgsLegend::currentLayer (  ) 

Returns the current layer if the current item is a QgsLegendLayerFile. If the current item is a QgsLegendLayer, its first maplayer is returned. Else, 0 is returned.

Definition at line 564 of file qgslegend.cpp.

References currentLayerFile(), and QgsLegendLayerFile::layer().

Referenced by QgisApp::activeLayer(), QgisApp::attributeTable(), QgisApp::deleteSelected(), handleCurrentItemChanged(), legendLayerZoom(), mouseReleaseEvent(), and QgisApp::toggleEditing().

bool QgsLegend::writeXML ( QDomNode &  layer_node,
QDomDocument &  document 
)

Writes the content of the legend to a project file.

Definition at line 779 of file qgslegend.cpp.

References firstItem(), QgsMapLayer::getLayerID(), QgsLegendLayerFile::isInOverview(), QgsLegendLayerFile::isVisible(), QgsLegendLayerFile::layer(), QgsLegendItem::LEGEND_GROUP, QgsLegendItem::LEGEND_LAYER, QgsLegendItem::LEGEND_LAYER_FILE, QgsLegendItem::LEGEND_LAYER_FILE_GROUP, QgsLegendItem::LEGEND_PROPERTY_GROUP, QgsLegendItem::LEGEND_SYMBOL_GROUP, nextItem(), QgsLegendItem::parent(), and QgsLegendItem::type().

Referenced by writeProject().

bool QgsLegend::readXML ( QDomNode &  legendnode  ) 

Restores the legend from a project file.

Definition at line 942 of file qgslegend.cpp.

References SpatialIndex::StorageManager::clear(), QgsMapLayerRegistry::instance(), QgsLegendLayerFile::isVisible(), QgsMapLayerRegistry::mapLayer(), mStateOfCheckBoxes, name(), QgsLegendLayerFile::nameFromLayer(), nextDomNode(), QgsLegendItem::parent(), refreshLayerSymbology(), QgsLegendLayerFile::setInOverview(), QgsLegendLayerFile::setVisible(), and QgsLegendLayerFile::updateLegendItem().

Referenced by readProject().

bool QgsLegend::yCoordAboveCenter ( QgsLegendItem it,
int  ycoord 
)

Returns true, if the y-coordinate is >= the center of the item.

Definition at line 1223 of file qgslegend.cpp.

Referenced by mouseMoveEvent().

QTreeWidgetItem * QgsLegend::firstItem (  ) 

Returns the first item in the hierarchy.

Definition at line 1240 of file qgslegend.cpp.

Referenced by collapseAll(), enableOverviewModeAllLayers(), expandAll(), findLegendLayer(), getItemPos(), layerIDs(), removeLayer(), selectAll(), showLegendLayerFileGroups(), storeInitialPosition(), updateMapCanvasLayerSet(), and writeXML().

QTreeWidgetItem * QgsLegend::nextItem ( QTreeWidgetItem *  item  ) 

Returns the next item (next sibling or next item on level above).

Definition at line 1246 of file qgslegend.cpp.

References QgsLegendItem::child(), nextSibling(), QgsLegendItem::nextSibling(), and QgsLegendItem::parent().

Referenced by collapseAll(), enableOverviewModeAllLayers(), expandAll(), findLegendLayer(), getItemPos(), layerIDs(), removeLayer(), selectAll(), showLegendLayerFileGroups(), updateMapCanvasLayerSet(), and writeXML().

QTreeWidgetItem * QgsLegend::nextSibling ( QTreeWidgetItem *  item  ) 

Returns the next sibling of an item or 0 if there is none.

Definition at line 1285 of file qgslegend.cpp.

Referenced by mouseReleaseEvent(), and nextItem().

QTreeWidgetItem * QgsLegend::previousSibling ( QTreeWidgetItem *  item  ) 

Returns the previous sibling of an item or 0 if there is none.

Definition at line 1299 of file qgslegend.cpp.

QDomNode QgsLegend::nextDomNode ( const QDomNode &  theNode  )  [static]

Finds the next dom node.

This function is used by QgsLegend, but probably its not a good place here

Definition at line 1313 of file qgslegend.cpp.

Referenced by readXML().

void QgsLegend::insertItem ( QTreeWidgetItem *  move,
QTreeWidgetItem *  into 
)

Inserts an item into another one.

Stores the item specific settings of the moved item (and its subitems) and applies it afterwards again

Definition at line 1335 of file qgslegend.cpp.

References QgsLegendItem::parent(), QgsLegendItem::release(), removeItem(), QgsLegendItem::restoreAppearanceSettings(), and QgsLegendItem::storeAppearanceSettings().

Referenced by mouseMoveEvent().

void QgsLegend::moveItem ( QTreeWidgetItem *  move,
QTreeWidgetItem *  after 
)

Moves an item after another one.

Stores the item specific settings of the moved item (and its subitems) and applies it afterwards again

Definition at line 1355 of file qgslegend.cpp.

Referenced by mouseMoveEvent(), and resetToInitialPosition().

void QgsLegend::removeItem ( QTreeWidgetItem *  item  ) 

Removes an item from the legend.

This is e.g. necessary before shifting it to another place

Definition at line 1377 of file qgslegend.cpp.

Referenced by insertItem(), legendLayerRemove(), makeToTopLevelItem(), removeLayer(), and resetToInitialPosition().

std::deque< QString > QgsLegend::layerIDs (  ) 

Returns the ids of the layers contained in this legend.

The order is bottom->top

Definition at line 1434 of file qgslegend.cpp.

References firstItem(), QgsMapLayer::getLayerID(), nextItem(), and QgsDebugMsg.

Referenced by checkLayerOrderUpdate(), and storeInitialPosition().

void QgsLegend::updateMapCanvasLayerSet (  ) 

Updates layer set of map canvas.

Definition at line 1389 of file qgslegend.cpp.

References firstItem(), mMapCanvas, nextItem(), and QgsMapCanvas::setLayerSet().

Referenced by addLayer(), checkLayerOrderUpdate(), enableOverviewModeAllLayers(), handleItemChange(), readProject(), removeAll(), removeLayer(), QgsLegendLayerFile::showInOverview(), and QgsLegendLayer::showInOverview().

void QgsLegend::updateOverview (  ) 

Updates overview.

Definition at line 1413 of file qgslegend.cpp.

References mMapCanvas, and QgsMapCanvas::updateOverview().

Referenced by enableOverviewModeAllLayers(), QgsLegendLayerFile::showInOverview(), and QgsLegendLayer::showInOverview().

void QgsLegend::enableOverviewModeAllLayers ( bool  isInOverview  ) 

Show/remove all layer in/from overview.

Definition at line 1418 of file qgslegend.cpp.

References firstItem(), nextItem(), QgsLegendLayerFile::setInOverview(), updateMapCanvasLayerSet(), and updateOverview().

Referenced by QgisApp::addAllToOverview(), and QgisApp::removeAllFromOverview().

void QgsLegend::addPixmapWidthValue ( int  width  ) 

Adds an entry to mPixmapWidthValues.

Definition at line 1491 of file qgslegend.cpp.

References mPixmapWidthValues.

Referenced by QgsLegendSymbologyItem::setLegend().

void QgsLegend::addPixmapHeightValue ( int  height  ) 

Adds an entry to mPixmapHeightValues.

Definition at line 1496 of file qgslegend.cpp.

References mPixmapHeightValues.

Referenced by QgsLegendSymbologyItem::setLegend().

void QgsLegend::removePixmapWidthValue ( int  width  ) 

Removes an entry from mPixmapWidthValues.

Definition at line 1501 of file qgslegend.cpp.

References mPixmapWidthValues.

Referenced by QgsLegendSymbologyItem::~QgsLegendSymbologyItem().

void QgsLegend::removePixmapHeightValue ( int  height  ) 

Removes an entry from mPixmapHeightValues.

Definition at line 1511 of file qgslegend.cpp.

References mPixmapHeightValues.

Referenced by QgsLegendSymbologyItem::~QgsLegendSymbologyItem().

void QgsLegend::setName ( QgsLegendLayerFile w,
QString  layerName 
)

Sets the name of the QgsLegendLayer that is the parent of the given QgsLegendLayerFile.

Definition at line 1521 of file qgslegend.cpp.

References QgsLegendItem::parent().

Referenced by QgsLegendLayerFile::layerNameChanged().

void QgsLegend::setToggleEditingAction ( QAction *  editingAction  )  [inline]

Sets the toggle editing action.

Usually called from QgisApp

Definition at line 176 of file qgslegend.h.

References mToggleEditingAction.

Referenced by QgisApp::createLegend().

QgsLegendPixmaps& QgsLegend::pixmaps (  )  [inline]

Returns structure with legend pixmaps.

Definition at line 179 of file qgslegend.h.

References mPixmaps.

Referenced by QgsLegendLayerFile::updateLegendItem().

void QgsLegend::updateCheckStates ( QTreeWidgetItem *  item,
Qt::CheckState  state 
) [inline]

Definition at line 182 of file qgslegend.h.

References mStateOfCheckBoxes.

Referenced by QgsLegendLayer::updateCheckState().

void QgsLegend::addLayer ( QgsMapLayer layer  )  [slot]

Adds a new layer group with the maplayer to the canvas

Definition at line 483 of file qgslegend.cpp.

References QgsMapCanvas::isDrawing(), QgsLegendLayerFile::isVisible(), QgsMapCanvas::layerCount(), mMapCanvas, mShowLegendLayerFiles, mStateOfCheckBoxes, QgsMapLayer::name(), QgsLegendLayerFile::nameFromLayer(), refreshLayerSymbology(), QgsLegendLayer::setLayerTypeIcon(), QgsLegendLayerFile::updateLegendItem(), updateMapCanvasLayerSet(), and QgsMapCanvas::zoomToFullExtent().

void QgsLegend::setMapCanvas ( QgsMapCanvas canvas  )  [inline, slot]

Definition at line 189 of file qgslegend.h.

References mMapCanvas.

Referenced by QgisApp::createLegend().

void QgsLegend::refreshLayerSymbology ( QString  key,
bool  expandItem = true 
) [slot]

Updates symbology items for a layer.

Definition at line 1462 of file qgslegend.cpp.

References adjustIconSize(), findLegendLayer(), QgsMapCanvas::map(), mMapCanvas, QgsMapCanvasMap::paintDevice(), and QgsLegendLayer::refreshSymbology().

Referenced by addLayer(), legendLayerShowProperties(), readXML(), and QgisAppInterface::refreshLegend().

void QgsLegend::removeAll (  )  [slot]

Slot called to clear the tree of all items

Note:
Usually connected to a QgsMapCanvas that will ask its legend to clear itself.
Returns:
void

Definition at line 119 of file qgslegend.cpp.

References SpatialIndex::StorageManager::clear(), mMinimumIconSize, mPixmapHeightValues, mPixmapWidthValues, mStateOfCheckBoxes, and updateMapCanvasLayerSet().

void QgsLegend::selectAll ( bool  select  )  [slot]

Called when the user wishes to toggle on or off all of the layers in the legend, and in the map.

Returns:
void

Definition at line 129 of file qgslegend.cpp.

References firstItem(), handleItemChange(), QgsMapCanvas::isDrawing(), QgsLegendItem::LEGEND_LAYER_FILE, mMapCanvas, nextItem(), and QgsLegendItem::type().

Referenced by QgisApp::hideAllLayers(), and QgisApp::showAllLayers().

void QgsLegend::addGroup (  )  [slot]

Slot called when user wishes to add a new empty layer group to the legend. The user will be prompted for the name of the newly added group.

Returns:
void

Definition at line 112 of file qgslegend.cpp.

References mStateOfCheckBoxes.

Referenced by handleRightClickEvent().

void QgsLegend::removeLayer ( QString   )  [slot]

Definition at line 150 of file qgslegend.cpp.

References adjustIconSize(), firstItem(), QgsMapLayer::getLayerID(), QgsMapCanvas::isDrawing(), QgsLegendLayerFile::layer(), mMapCanvas, mStateOfCheckBoxes, nextItem(), QgsDebugMsg, removeItem(), and updateMapCanvasLayerSet().

void QgsLegend::readProject ( const QDomDocument &   )  [slot]

called to read legend settings from project

Definition at line 1858 of file qgslegend.cpp.

References QgsDebugMsg, readXML(), and updateMapCanvasLayerSet().

Referenced by QgsLegend().

void QgsLegend::writeProject ( QDomDocument &   )  [slot]

called to write legend settings to project

Definition at line 1875 of file qgslegend.cpp.

References QgsDebugMsg, and writeXML().

Referenced by QgsLegend().

void QgsLegend::legendLayerRemove (  )  [slot]

Removes the current LegendLayer and all its LegendLayerFiles.

Definition at line 600 of file qgslegend.cpp.

References adjustIconSize(), QgsMapLayer::getLayerID(), QgsMapLayerRegistry::instance(), QgsMapCanvas::isDrawing(), QgsLegendLayerFile::layer(), QgsLegendLayer::legendLayerFiles(), QgsLegendLayer::mapLayers(), mMapCanvas, mStateOfCheckBoxes, removeItem(), and QgsMapLayerRegistry::removeMapLayer().

Referenced by legendGroupRemove(), and QgisApp::removeLayer().

void QgsLegend::legendLayerShowInOverview (  )  [slot]

Toggle show in overview for current layer.

Definition at line 734 of file qgslegend.cpp.

References QgsMapCanvas::isDrawing(), QgsLegendItem::LEGEND_LAYER, QgsLegendItem::LEGEND_LAYER_FILE, mMapCanvas, and QgsLegendItem::type().

Referenced by QgisApp::isInOverview().

void QgsLegend::legendLayerZoom (  )  [slot]

Zooms to extent of the current legend layer (considers there may be several legend layer files.

Definition at line 1732 of file qgslegend.cpp.

References QgsRect::combineExtentWith(), currentLayer(), QgsProject::dirty(), QgsMapLayer::extent(), QgsProject::instance(), QgsRect::isFinite(), QgsMapRenderer::layerExtentToOutputExtent(), QgsMapCanvas::mapRenderer(), mMapCanvas, QgsMapCanvas::refresh(), QgsRect::scale(), and QgsMapCanvas::setExtent().

Referenced by QgisApp::zoomToLayerExtent().

void QgsLegend::legendLayerZoomNative (  )  [slot]

Definition at line 1791 of file qgslegend.cpp.

References QgsProject::dirty(), QgsLegendLayer::firstMapLayer(), QgsProject::instance(), QgsMapCanvas::mapUnitsPerPixel(), mMapCanvas, QgsDebugMsg, QgsRasterLayer::rasterUnitsPerPixel(), QgsMapCanvas::refresh(), and QgsMapCanvas::zoom().

Referenced by QgisApp::zoomActualSize().

void QgsLegend::legendLayerAttributeTable (  )  [slot]

Show attribute table.

Definition at line 1819 of file qgslegend.cpp.

References QgsAttributeTableDisplay::attributeTable(), QgsLegendLayer::firstMapLayer(), QgsMapCanvas::isDrawing(), QgsLegendLayerFile::layer(), and mMapCanvas.

void QgsLegend::legendLayerShowProperties (  )  [slot]

Shows the property dialog of the first legend layer file in a legend layer.

Definition at line 654 of file qgslegend.cpp.

References QgsMapCanvas::isDrawing(), QgsLegendItem::LEGEND_LAYER, QgsLegendItem::LEGEND_LAYER_FILE, mMapCanvas, QgsMapLayer::RasterLayer, refreshLayerSymbology(), QgsMapLayer::type(), and QgsLegendItem::type().

Referenced by QgisApp::layerProperties(), and mouseDoubleClickEvent().

void QgsLegend::mouseMoveEvent ( QMouseEvent *  e  )  [protected]

Event handler for mouse movements. Mainly intended so handle cases where user is dragging and dropping items into or out of groups, or is reordering layers.

Note:
Overrides method of the same name in the QListView class.
Returns:
void

Definition at line 201 of file qgslegend.cpp.

References getItemPos(), QgsLegendItem::INSERT, insertItem(), QgsLegendItem::LEGEND_LAYER_FILE, mItemBeingMoved, mItemBeingMovedOrigPos, mLastPressPos, mMousePressedFlag, moveItem(), QgsLegendItem::nextSibling(), QgsLegendItem::parent(), QgsDebugMsg, QgsLegendItem::REORDER, resetToInitialPosition(), storeInitialPosition(), QgsLegendItem::type(), and yCoordAboveCenter().

void QgsLegend::mousePressEvent ( QMouseEvent *  e  )  [protected]

Event handler for buton mouse presses. Mainly intended so handle cases where user is dragging and dropping items into or out of groups, or is reordering layers.

Note:
Overrides method of the same name in the QListView class.
Returns:
void

Definition at line 185 of file qgslegend.cpp.

References handleRightClickEvent(), mLastPressPos, and mMousePressedFlag.

void QgsLegend::mouseReleaseEvent ( QMouseEvent *  e  )  [protected]

Event handler for mouse button releases. Mainly intended so handle cases where user is dragging and dropping items into or out of groups, or is reordering layers. Each sublass of QgsLegendItem has an accept method that defines behaviour rules for whether another QgsLegendItem child instance can be dropped onto it.

Behaviour rules for dropped legend items

Note:
Overrides method of the same name in the QListView class.
Returns:
void

Definition at line 306 of file qgslegend.cpp.

References checkLayerOrderUpdate(), QgsMapLayer::copySymbologySettings(), currentLayer(), QgsLegendItem::LEGEND_LAYER_FILE, QgsLegendItem::LEGEND_LAYER_FILE_GROUP, mItemBeingMoved, mMousePressedFlag, nextSibling(), and QgsDebugMsg.

void QgsLegend::mouseDoubleClickEvent ( QMouseEvent *  e  )  [protected]

Definition at line 398 of file qgslegend.cpp.

References QgsMapCanvas::isDrawing(), legendLayerShowProperties(), and mMapCanvas.

void QgsLegend::storeInitialPosition ( QTreeWidgetItem *  li  )  [protected]

Stores the necessary information about the position of an item in the hierarchy.

Afterwards, this item may be moved back to the original position with resetToInitialPosition()

Definition at line 1106 of file qgslegend.cpp.

References FIRST_CHILD, FIRST_ITEM, firstItem(), layerIDs(), mLayersPriorToMove, mRestoreInformation, mRestoreItem, and YOUNGER_SIBLING.

Referenced by mouseMoveEvent().

void QgsLegend::resetToInitialPosition ( QTreeWidgetItem *  li  )  [protected]

Moves an item back to the position where storeInitialPosition has been called.

Definition at line 1131 of file qgslegend.cpp.

References FIRST_CHILD, FIRST_ITEM, moveItem(), mRestoreInformation, mRestoreItem, QgsDebugMsg, QgsLegendItem::release(), removeItem(), and YOUNGER_SIBLING.

Referenced by mouseMoveEvent().

QgsLegendLayer * QgsLegend::findLegendLayer ( const QString &  layerKey  )  [protected]

Returns the legend layer to which a map layer gelongs.

Definition at line 1169 of file qgslegend.cpp.

References firstItem(), QgsLegendLayer::mapLayers(), and nextItem().

Referenced by refreshLayerSymbology().

void QgsLegend::adjustIconSize (  )  [protected]

Checks mPixmapWidthValues and mPixmapHeightValues and sets a new icon size if necessary.

Definition at line 1193 of file qgslegend.cpp.

References mMinimumIconSize, mPixmapHeightValues, and mPixmapWidthValues.

Referenced by legendGroupRemove(), legendLayerRemove(), refreshLayerSymbology(), and removeLayer().

void QgsLegend::initPixmaps (  )  [protected]

Initialize pixmaps - called when QgsLegend is constructed.

Definition at line 459 of file qgslegend.cpp.

References QgisApp::getThemePixmap(), QgsLegend::QgsLegendPixmaps::mEditablePixmap, QgsLegend::QgsLegendPixmaps::mInOverviewPixmap, QgsLegend::QgsLegendPixmaps::mOriginalPixmap, mPixmaps, and QgsLegend::QgsLegendPixmaps::mProjectionErrorPixmap.

Referenced by QgsLegend().

bool QgsLegend::checkLayerOrderUpdate (  )  [protected]

This function compares the layer order before a drag with the current layer ordering and triggers a canvas repaint if it has changed.

Definition at line 1891 of file qgslegend.cpp.

References layerIDs(), mLayersPriorToMove, and updateMapCanvasLayerSet().

Referenced by mouseReleaseEvent().

void QgsLegend::handleRightClickEvent ( QTreeWidgetItem *  item,
const QPoint &  position 
) [private, slot]

Calls 'handleRightClickEvent' on the item.

Definition at line 407 of file qgslegend.cpp.

References addGroup(), collapseAll(), expandAll(), QgisApp::getThemeIcon(), QgsMapCanvas::isDrawing(), QgsLegendItem::LEGEND_GROUP, QgsLegendItem::LEGEND_LAYER, QgsLegendItem::LEGEND_LAYER_FILE, legendGroupRemove(), makeToTopLevelItem(), mMapCanvas, mShowLegendLayerFiles, mToggleEditingAction, openEditor(), showLegendLayerFileGroups(), and QgsLegendItem::type().

Referenced by mousePressEvent().

void QgsLegend::legendGroupRemove (  )  [private, slot]

Removes the current legend group.

Definition at line 577 of file qgslegend.cpp.

References adjustIconSize(), QgsLegendItem::child(), QgsMapCanvas::isDrawing(), legendLayerRemove(), and mMapCanvas.

Referenced by handleRightClickEvent().

void QgsLegend::expandAll (  )  [private, slot]

Sets all listview items to open.

Definition at line 759 of file qgslegend.cpp.

References firstItem(), and nextItem().

Referenced by handleRightClickEvent().

void QgsLegend::collapseAll (  )  [private, slot]

Sets all listview items to closed.

Definition at line 769 of file qgslegend.cpp.

References firstItem(), and nextItem().

Referenced by handleRightClickEvent().

void QgsLegend::handleItemChange ( QTreeWidgetItem *  item,
int  row 
) [private, slot]

Just for a test.

Definition at line 1537 of file qgslegend.cpp.

References QgsLegendItem::child(), QgsMapCanvas::freeze(), QgsLegendLayerFile::layer(), QgsLegendLayer::legendLayerFiles(), QgsLegendGroup::legendLayerFiles(), QgsLegendLayer::mapLayers(), mMapCanvas, mStateOfCheckBoxes, QgsLegendItem::parent(), QgsDebugMsg, QgsMapCanvas::renderFlag(), QgsMapCanvas::setRenderFlag(), QgsLegendLayerFile::setVisible(), QgsLegendLayer::updateCheckState(), and updateMapCanvasLayerSet().

Referenced by QgsLegend(), and selectAll().

<
void QgsLegend::handleCurrentItemChanged (