Commit 0268fb5e authored by pixhawk's avatar pixhawk

Adding full google maps support to windows

parent d88602e1
......@@ -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)
......
......@@ -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;
......
......@@ -143,6 +143,7 @@ protected:
#ifdef _MSC_VER
QGCWebAxWidget* webViewWin;
QAxObject* jScriptWin;
QAxObject* documentWin;
#endif
#if (defined Q_OS_MAC)
QWebView* webViewMac;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment