📄 qgslegend.h
字号:
/** called to read legend settings from project */ void readProject(const QDomDocument &); /** called to write legend settings to project */ void writeProject(QDomDocument &); /**Removes the current LegendLayer and all its LegendLayerFiles*/ void legendLayerRemove(); /**Toggle show in overview for current layer*/ void legendLayerShowInOverview(); /**Zooms to extent of the current legend layer (considers there may be several legend layer files*/ void legendLayerZoom(); /***Zooms so that the pixels of the raster layer occupies exactly one screen pixel. Only works on raster layers*/ void legendLayerZoomNative(); /**Show attribute table*/ void legendLayerAttributeTable(); /**Shows the property dialog of the first legend layer file in a legend layer*/ void legendLayerShowProperties(); 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. * @return void */ void mouseMoveEvent(QMouseEvent * e); /*! * 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. * @return void */ void mousePressEvent(QMouseEvent * e); /*! * 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. * <h1>Behaviour rules for dropped legend items</h1> * <ul> * <li> Symbology groups, properies groups and layers groups can only be dropped * onto QgsLegendLayer nodes. </li> * <li>Only QgsLegendGroup and QgsLegendLayer can be top level items in the view</li> * <li>Groups can be nested by dropping them into each other,</li> * <li>Each group can have one or more layers</li> * <li>Layers can be ordered by dragging them above or below another layer.</li> * <li>The order for QgsLegendSymbologyGroup, QgsLegendPropertyGroup and QgsLegendLayerGroup * is predefined to sort in that order.</li> * </ul> * @note Overrides method of the same name in the QListView class. * @return void */ void mouseReleaseEvent(QMouseEvent * e); void mouseDoubleClickEvent(QMouseEvent* e); /**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()*/ void storeInitialPosition(QTreeWidgetItem* li); /**Moves an item back to the position where storeInitialPosition has been called*/ void resetToInitialPosition(QTreeWidgetItem* li); /**Returns the legend layer to which a map layer gelongs*/ QgsLegendLayer* findLegendLayer(const QString& layerKey); /**Checks mPixmapWidthValues and mPixmapHeightValues and sets a new icon size if necessary*/ void adjustIconSize(); /**Initialize pixmaps - called when QgsLegend is constructed */ void initPixmaps(); /**This function compares the layer order before a drag with the current layer ordering and triggers a canvas repaint if it has changed*/ bool checkLayerOrderUpdate(); private slots: /**Calls 'handleRightClickEvent' on the item*/ void handleRightClickEvent(QTreeWidgetItem* item, const QPoint& position); /**Removes the current legend group*/ void legendGroupRemove(); /**Sets all listview items to open*/ void expandAll(); /**Sets all listview items to closed*/ void collapseAll(); /**Just for a test*/ void handleItemChange(QTreeWidgetItem* item, int row); /** delegates current layer to map canvas */ void handleCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous); /**Calls openPersistentEditor for the current item*/ void openEditor(); /**Removes the current item and inserts it as a toplevel item at the end of the legend*/ void makeToTopLevelItem(); /**Show/ Hide the legend layer file groups*/ void showLegendLayerFileGroups(); 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. */ QgsLegend( QgsLegend const & ); /*! * 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. */ QgsLegend & operator=( QgsLegend const & ); /*! * Position of mouse when it is pressed at the start of a drag event. */ QPoint mLastPressPos; /**True if the mouse is pressed*/ bool mMousePressedFlag; /// keep track of the Item being dragged QTreeWidgetItem* mItemBeingMoved; /*! * Position in the list of the item being moved as it was at the start of a drag event. * An item at the top of the list will be 0 and each successive item below it * will be 1,2 3 etc... regardless of nesting level. */ int mItemBeingMovedOrigPos; /**Information needed by 'storeInitialPosition' and 'resetToInitialPosition'*/ enum HIERARCHY_POSITION_TYPE { FIRST_ITEM, FIRST_CHILD, YOUNGER_SIBLING }; HIERARCHY_POSITION_TYPE mRestoreInformation; QTreeWidgetItem* mRestoreItem; bool mShowLegendLayerFiles; /**Stores the layer ordering before a mouse Move. After the move, this is used to decide if the mapcanvas really has to be refreshed*/ std::deque<QString> mLayersPriorToMove; /**Action for the legendlayer right click menu*/ QAction* mToggleEditingAction; /*! * A fuction sed to determin how far down in the list an item is (starting with one for the first Item. *If the item is not in the legend, -1 is returned * @see mItemBeingMovedOrigPos */ int getItemPos(QTreeWidgetItem* item); /**Pointer to the main canvas. Used for requiring repaints in case of legend changes*/ QgsMapCanvas* mMapCanvas; /**Map that keeps track of which checkboxes are in which check state. This is necessary because QTreeView does not emit a signal for check state changes*/ std::map<QTreeWidgetItem*, Qt::CheckState> mStateOfCheckBoxes; /**Stores the width values of the LegendSymbologyItem pixmaps. The purpose of this is that the legend may automatically change the global IconWidth when items are added or removed*/ std::multiset<int> mPixmapWidthValues; /**Stores the width values of the LegendSymbologyItem pixmaps. The purpose of this is that the legend may automatically change the global IconWidth when items are added or removed*/ std::multiset<int> mPixmapHeightValues; /**QgsLegend does not set the icon with/height to values lower than the minimum icon size*/ QSize mMinimumIconSize; /** structure which holds pixmap which are used in legend */ class QgsLegendPixmaps { public: //! Pixmap which is shown by default QPixmap mOriginalPixmap; //! Pixmap to show a bogus vertex was encoutnered in this layer (applies to vector layers only) QPixmap mProjectionErrorPixmap; //! Pixmap to show if this layer is represented in overview or now QPixmap mInOverviewPixmap; //! Pixmap to show it this layer has currently editing turned on QPixmap mEditablePixmap; } mPixmaps;signals: void zOrderChanged(QgsLegend * lv); //! Emited whenever current (selected) layer changes // the pointer to layer can be null if no layer is selected void currentLayerChanged ( QgsMapLayer * layer );};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -