QGIS API Documentation  2.99.0-Master (6a61179)
qgsmaptip.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaptip.h - Query a layer and show a maptip on the canvas
3  ---------------------
4  begin : October 2007
5  copyright : (C) 2007 by Gary Sherman
6  email : sherman @ mrcc dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSMAPTIP_H
16 #define QGSMAPTIP_H
17 
18 class QgsMapLayer;
19 class QgsMapCanvas;
20 class QPoint;
21 class QString;
22 class QgsPoint;
23 class QgsVectorLayer;
24 class QgsWebView;
25 
26 #include <QWidget>
27 #include <QUrl>
28 #include "qgsfeature.h"
29 
49 class GUI_EXPORT QgsMapTip : public QWidget
50 {
51  Q_OBJECT
52  public:
53 
56  QgsMapTip();
57 
60  virtual ~QgsMapTip();
61 
71  void showMapTip( QgsMapLayer * thepLayer,
72  QgsPoint & theMapPosition,
73  QPoint & thePixelPosition,
74  QgsMapCanvas *mpMapCanvas );
75 
79  void clear( QgsMapCanvas *mpMapCanvas = nullptr );
80  private:
81  // Fetch the feature to use for the maptip text.
82  // Only the first feature in the search radius is used
83  QString fetchFeature( QgsMapLayer * thepLayer,
84  QgsPoint & theMapPosition,
85  QgsMapCanvas *mapCanvas );
86 
87  QString replaceText(
88  QString displayText, QgsVectorLayer *layer, QgsFeature &feat );
89 
90  // Flag to indicate if a maptip is currently being displayed
91  bool mMapTipVisible;
92 
93  QWidget* mWidget;
94  QgsWebView* mWebView;
95 
96  private slots:
97  void onLinkClicked( const QUrl& url );
98 };
99 #endif // QGSMAPTIP_H
Base class for all map layer types.
Definition: qgsmaplayer.h:49
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:135
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:106
The QgsWebView class is a collection of stubs to mimic the API of QWebView on systems where the real ...
Definition: qgswebview.h:57
A maptip is a class to display a tip on a map canvas when a mouse is hovered over a feature...
Definition: qgsmaptip.h:49
A class to represent a point.
Definition: qgspoint.h:111
Represents a vector layer which manages a vector based data sets.