diff --git a/src/ui/MapWidget.cc b/src/ui/MapWidget.cc index ed12e1a..277f571 100644 --- a/src/ui/MapWidget.cc +++ b/src/ui/MapWidget.cc @@ -34,6 +34,7 @@ MapWidget::MapWidget(QWidget *parent) : mav(NULL), lastUpdate(0), initialized(false), + mc(NULL), m_ui(new Ui::MapWidget) { m_ui->setupUi(this); @@ -952,7 +953,7 @@ void MapWidget::updatePosition(float time, double lat, double lon) //gpsposition->setText(QString::number(time) + " / " + QString::number(lat) + " / " + QString::number(lon)); if (followgps->isChecked() && isVisible()) { - mc->setView(QPointF(lat, lon)); + if (mc) mc->setView(QPointF(lat, lon)); } } @@ -975,6 +976,8 @@ void MapWidget::wheelEvent(QWheelEvent *event) void MapWidget::keyPressEvent(QKeyEvent *event) { + if (mc) + { switch (event->key()) { case Qt::Key_Plus: mc->zoomIn(); @@ -997,17 +1000,23 @@ void MapWidget::keyPressEvent(QKeyEvent *event) default: QWidget::keyPressEvent(event); } + } } void MapWidget::resizeEvent(QResizeEvent* event ) { Q_UNUSED(event); - mc->resize(this->size()); + if (mc) mc->resize(this->size()); } void MapWidget::showEvent(QShowEvent* event) { Q_UNUSED(event); + if (!initialized) + { + initialized = true; + init(); + } } void MapWidget::hideEvent(QHideEvent* event) diff --git a/src/ui/map3D/QGCGoogleEarthView.cc b/src/ui/map3D/QGCGoogleEarthView.cc index a421074..f2a50bc 100644 --- a/src/ui/map3D/QGCGoogleEarthView.cc +++ b/src/ui/map3D/QGCGoogleEarthView.cc @@ -44,17 +44,13 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) : #endif #ifdef _MSC_VER webViewWin(new QGCWebAxWidget(this)), + documentWin(NULL), #endif -#if (defined _MSC_VER) ui(new Ui::QGCGoogleEarthView) -#else - ui(new Ui::QGCGoogleEarthView) -#endif { #ifdef _MSC_VER // Create layout and attach webViewWin - QFile file("doc.html"); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) qDebug() << __FILE__ << __LINE__ << "Could not open log file"; @@ -406,6 +402,16 @@ QVariant QGCGoogleEarthView::documentElement(QString name) } else { + if (documentWin) + { + // Get HTMLElement object + QVariantList params; + params.append(name); + //QAxObject* elementWin = documentWin->dynamicCall("getElementById(QString)", params); + QVariant result =documentWin->dynamicCall("toString()"); + qDebug() << "GOT RESULT" << result; + return QVariant(0);//QVariant(result); + } //QVariantList params; //params.append(javaScript); //params.append("JScript"); @@ -425,6 +431,7 @@ void QGCGoogleEarthView::initializeGoogleEarth() QAxObject* doc = webViewWin->querySubObject("Document()"); //IDispatch* Disp; IDispatch* winDoc = NULL; + IHTMLDocument2* document = NULL; //332C4425-26CB-11D0-B483-00C04FD90119 IHTMLDocument2 //25336920-03F9-11CF-8FD0-00AA00686F13 HTMLDocument @@ -435,11 +442,11 @@ void QGCGoogleEarthView::initializeGoogleEarth() // CoInternetSetFeatureEnabled // (FEATURE_LOCALMACHINE_LOCKDOWN, SET_FEATURE_ON_PROCESS, TRUE); // - IHTMLDocument2* document = NULL; + document = NULL; winDoc->QueryInterface( IID_IHTMLDocument2, (void**)&document ); IHTMLWindow2 *window = NULL; document->get_parentWindow( &window ); - + documentWin = new QAxObject(document, webViewWin); jScriptWin = new QAxObject(window, webViewWin); connect(jScriptWin, SIGNAL(exception(int,QString,QString,QString)), this, SLOT(printWinException(int,QString,QString,QString))); jScriptInitialized = true; diff --git a/src/ui/map3D/QGCGoogleEarthView.h b/src/ui/map3D/QGCGoogleEarthView.h index 5d256ce..183d858 100644 --- a/src/ui/map3D/QGCGoogleEarthView.h +++ b/src/ui/map3D/QGCGoogleEarthView.h @@ -143,6 +143,7 @@ protected: #ifdef _MSC_VER QGCWebAxWidget* webViewWin; QAxObject* jScriptWin; + QAxObject* documentWin; #endif #if (defined Q_OS_MAC) QWebView* webViewMac;