21 #include <QGridLayout>
22 #include <QFileDialog>
33 void QgsWebViewWidgetWrapper::loadUrl(
const QString &url )
36 mWebView->load( url );
45 if ( mLineEdit->text() == QSettings().value(
"qgis/nullValue",
"NULL" ).toString() )
46 v = QVariant( QVariant::String );
48 v = mLineEdit->text();
56 QWidget* container =
new QWidget( parent );
57 QGridLayout* layout =
new QGridLayout( container );
59 QWebView* webView =
new QWebView( parent );
60 webView->setObjectName(
"EditorWebView" );
61 QPushButton* pb =
new QPushButton(
tr(
"..." ), container );
62 pb->setObjectName(
"FileChooserButton" );
64 layout->addWidget( webView, 0, 0, 1, 2 );
65 layout->addWidget( le, 1, 0 );
66 layout->addWidget( pb, 1, 1 );
68 container->setLayout( layout );
77 mLineEdit = qobject_cast<QLineEdit*>( editor );
88 container = qobject_cast<QWidget*>( mLineEdit->parent() );
93 mLineEdit = container->findChild<QLineEdit*>();
96 mButton = container->findChild<QPushButton*>(
"FileChooserButton" );
98 mButton = container->findChild<QPushButton*>();
100 mWebView = container->findChild<QWebView*>(
"EditorWebView" );
102 mWebView = container->findChild<QWebView*>();
107 mWebView->settings()->setAttribute( QWebSettings::LocalContentCanAccessRemoteUrls,
true );
108 mWebView->settings()->setAttribute( QWebSettings::JavascriptCanOpenWindows,
true );
110 mWebView->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled,
true );
115 connect( mButton, SIGNAL( clicked() ),
this, SLOT( selectFileName() ) );
119 connect( mLineEdit, SIGNAL( textChanged( QString ) ),
this, SLOT( loadUrl( QString ) ) );
120 connect( mLineEdit, SIGNAL( textChanged( QString ) ),
this, SLOT(
valueChanged( QString ) ) );
128 if ( value.isNull() )
129 mLineEdit->setText( QSettings().
value(
"qgis/nullValue",
"NULL" ).toString() );
131 mLineEdit->setText( value.toString() );
134 loadUrl( value.toString() );
140 mLineEdit->setEnabled( enabled );
143 mButton->setEnabled( enabled );
146 void QgsWebViewWidgetWrapper::selectFileName()
151 text = mLineEdit->text();
153 QString fileName = QFileDialog::getOpenFileName( mLineEdit,
tr(
"Select a file" ), QFileInfo( text ).absolutePath() );
155 if ( fileName.isNull() )
159 mLineEdit->setText( QDir::toNativeSeparators( fileName ) );