QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
qgswebview.h
Go to the documentation of this file.
1
/***************************************************************************
2
3
----------------------------------------------------
4
date : 19.5.2015
5
copyright : (C) 2015 by Matthias Kuhn
6
email : matthias (at) opengis.ch
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
16
#ifndef QGSWEBVIEW_H
17
#define QGSWEBVIEW_H
18
19
20
#include "
qgswebpage.h
"
21
22
#include <QTextBrowser>
23
#include <QWidget>
24
25
#define SIP_NO_FILE
26
27
class
QPrinter;
28
38
class
CORE_EXPORT
QgsWebView
:
public
QTextBrowser
39
{
41
Q_OBJECT
42
public
:
43
explicit
QgsWebView
( QWidget *parent =
nullptr
)
44
: QTextBrowser( parent )
45
, mSettings( std::make_unique<QWebSettings>() )
46
, mPage( std::make_unique<QWebPage>(
this
) )
47
{
48
connect(
this
, &QTextBrowser::anchorClicked,
this
, &QgsWebView::linkClicked );
49
connect(
this
, &QgsWebView::pageLoadFinished, mPage.get(), &QWebPage::loadFinished );
50
}
51
52
~QgsWebView
()
override
{}
53
54
void
setUrl(
const
QUrl &url ) { setSource( url ); }
55
56
void
load(
const
QUrl &url ) { setSource( url ); }
57
58
QUrl url()
const
{
return
source(); }
59
60
QWebPage
*page()
const
{
return
mPage.get(); }
61
62
QWebSettings
*settings()
const
{
return
mSettings.get(); }
63
64
virtual
QgsWebView
*createWindow( QWebPage::WebWindowType ) {
return
new
QgsWebView
(); }
65
66
void
setContent(
const
QByteArray &data,
const
QString &contentType,
const
QUrl & )
67
{
68
QString text = QString::fromUtf8( data );
69
if
( contentType ==
"text/html"
)
70
setHtml( text );
71
else
72
setPlainText( text );
73
74
emit pageLoadFinished(
true
);
75
}
76
77
void
print( QPrinter * ) {}
78
79
signals:
80
void
linkClicked(
const
QUrl &link );
81
82
void
pageLoadFinished(
bool
ok );
83
84
public
slots:
85
86
void
setHtml(
const
QString &text )
87
{
88
QTextBrowser::setHtml( text );
89
emit pageLoadFinished(
true
);
90
}
91
92
void
setText(
const
QString &text )
93
{
94
QTextBrowser::setText( text );
95
emit pageLoadFinished(
true
);
96
}
97
98
private
:
99
std::unique_ptr<QWebSettings> mSettings;
100
std::unique_ptr<QWebPage> mPage;
101
103
};
104
105
#endif
// QGSWEBVIEW_H
QWebPage
A collection of stubs to mimic the API of a QWebPage on systems where QtWebkit is not available.
Definition
qgswebpage.h:93
QWebSettings
A collection of stubs to mimic the API of a QWebSettings on systems where QtWebkit is not available.
Definition
qgswebpage.h:38
QgsWebView
A collection of stubs to mimic the API of QWebView on systems where the real library is not available...
Definition
qgswebview.h:39
qgswebpage.h
Generated on
for QGIS API Documentation by
1.17.0