QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
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
QgsPointXY
;
23
class
QgsVectorLayer
;
24
class
QgsWebView
;
25
26
#include "qgis_gui.h"
27
#include "
qgsfeature.h
"
28
29
#include <QTimer>
30
#include <QUrl>
31
#include <QWidget>
32
52
class
GUI_EXPORT
QgsMapTip
:
public
QWidget
53
{
54
Q_OBJECT
55
public
:
59
QgsMapTip
();
60
71
void
showMapTip
(
QgsMapLayer
*thepLayer,
QgsPointXY
&mapPosition,
const
QPoint &pixelPosition,
QgsMapCanvas
*mpMapCanvas );
72
78
void
clear
(
QgsMapCanvas
*mpMapCanvas =
nullptr
,
int
msDelay = 0 );
79
85
static
QString
vectorMapTipPreviewText
(
QgsMapLayer
*layer,
QgsMapCanvas
*mapCanvas,
const
QString &mapTemplate,
const
QString &displayExpression );
86
92
static
QString
rasterMapTipPreviewText
(
QgsMapLayer
*layer,
QgsMapCanvas
*mapCanvas,
const
QString &mapTemplate );
93
94
private
slots:
95
void
onLinkClicked(
const
QUrl &url );
96
void
resizeAndMoveToolTip();
97
98
private
:
99
// Fetch the feature to use for the maptip text.
100
// Only the first feature in the search radius is used
101
QString fetchFeature(
QgsMapLayer
*thepLayer,
QgsPointXY
&mapPosition,
QgsMapCanvas
*mapCanvas );
102
103
// Sample the raster and get the maptip text
104
QString fetchRaster(
QgsMapLayer
*layer,
QgsPointXY
&mapPosition,
QgsMapCanvas
*mapCanvas );
105
106
// Insert the raw map tip text into an HTML template and return the result
107
static
QString htmlText(
const
QString &text,
int
maxWidth = -1 );
108
109
// Flag to indicate if a maptip is currently being displayed
110
bool
mMapTipVisible;
111
112
QgsWebView
*mWebView =
nullptr
;
113
114
static
const
int
MARGIN_VALUE = 5;
115
116
QTimer mDelayedClearTimer;
117
118
// Template for the actual HTML content that will be displayed in QgsWebView
119
static
const
QString sMapTipTemplate;
120
121
QPoint mPosition;
122
const
QgsMapCanvas
*mMapCanvas =
nullptr
;
123
};
124
#endif
// QGSMAPTIP_H
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition
qgsmapcanvas.h:96
QgsMapLayer
Base class for all map layer types.
Definition
qgsmaplayer.h:83
QgsMapTip::showMapTip
void showMapTip(QgsMapLayer *thepLayer, QgsPointXY &mapPosition, const QPoint &pixelPosition, QgsMapCanvas *mpMapCanvas)
Show a maptip at a given point on the map canvas.
Definition
qgsmaptip.cpp:88
QgsMapTip::rasterMapTipPreviewText
static QString rasterMapTipPreviewText(QgsMapLayer *layer, QgsMapCanvas *mapCanvas, const QString &mapTemplate)
Returns the html that would be displayed in a maptip for a given layer.
Definition
qgsmaptip.cpp:468
QgsMapTip::vectorMapTipPreviewText
static QString vectorMapTipPreviewText(QgsMapLayer *layer, QgsMapCanvas *mapCanvas, const QString &mapTemplate, const QString &displayExpression)
Returns the html that would be displayed in a maptip for a given layer.
Definition
qgsmaptip.cpp:423
QgsMapTip::QgsMapTip
QgsMapTip()
Default constructor.
Definition
qgsmaptip.cpp:79
QgsMapTip::clear
void clear(QgsMapCanvas *mpMapCanvas=nullptr, int msDelay=0)
Clear the current maptip if it exists.
Definition
qgsmaptip.cpp:239
QgsPointXY
Represents a 2D point.
Definition
qgspointxy.h:62
QgsVectorLayer
Represents a vector layer which manages a vector based dataset.
Definition
qgsvectorlayer.h:414
QgsWebView
A collection of stubs to mimic the API of QWebView on systems where the real library is not available...
Definition
qgswebview.h:39
qgsfeature.h
Generated on
for QGIS API Documentation by
1.17.0