From kde-commits Sat Feb 28 20:30:17 2015 From: Mohamed Anwer Date: Sat, 28 Feb 2015 20:30:17 +0000 To: kde-commits Subject: [libkgeomap/frameworks] src: Fixing event listener Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=142515542623595 Git commit 21c7f63a8ada4dbd0b7504833678b0149ee1c167 by Mohamed Anwer. Committed on 28/02/2015 at 20:28. Pushed by mohamedanwer into branch 'frameworks'. Fixing event listener M +22 -22 src/html_widget.cpp M +1 -1 src/html_widget.h http://commits.kde.org/libkgeomap/21c7f63a8ada4dbd0b7504833678b0149ee1c167 diff --git a/src/html_widget.cpp b/src/html_widget.cpp index a9d8e6d..f5d0d34 100644 --- a/src/html_widget.cpp +++ b/src/html_widget.cpp @@ -49,7 +49,7 @@ public: Private() : parent(0), isReady(false), - javascriptScanTimer(0), + //javascriptScanTimer(0), selectionStatus(false), firstSelectionPoint(), intermediateSelectionPoint(), @@ -60,7 +60,7 @@ public: = QWidget* parent; bool isReady; - QTimer* javascriptScanTimer; + //QTimer* javascriptScanTimer; = bool selectionStatus; GeoCoordinates firstSelectionPoint; @@ -80,12 +80,9 @@ HTMLWidget::HTMLWidget(QWidget* const parent) d->parent->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expandin= g); = // create a timer for monitoring for javascript events, but do not sta= rt it yet: - d->javascriptScanTimer =3D new QTimer(this); - d->javascriptScanTimer->setSingleShot(false); - d->javascriptScanTimer->setInterval(300); - -// connect(d->javascriptScanTimer, SIGNAL(timeout()), -// this, SLOT(slotScanForJSMessages())); +// d->javascriptScanTimer =3D new QTimer(this); +// d->javascriptScanTimer->setSingleShot(false); +// d->javascriptScanTimer->setInterval(300); = connect(this, SIGNAL(loadProgress(int)), this, SLOT(progress(int))); @@ -93,6 +90,9 @@ HTMLWidget::HTMLWidget(QWidget* const parent) connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotHTMLCompleted(bool))); = + connect(this, SIGNAL(statusBarMessage(QString)), + this, SLOT(slotScanForJSMessages(QString))); + if (d->parent) { d->parent->installEventFilter(this); @@ -104,6 +104,8 @@ HTMLWidget::~HTMLWidget() delete d; } = +// This method wasn't called ever, before porting to QWebView +// What does it do? //void HTMLWidget::loadInitialHTML(const QString& initialHTML) //{ //// qCDebug(LIBKGEOMAP_LOG) << initialHTML; @@ -123,7 +125,7 @@ void HTMLWidget::slotHTMLCompleted(bool ok) d->isReady =3D ok; = // start monitoring for javascript events using a timer: - d->javascriptScanTimer->start(); + // d->javascriptScanTimer->start(); = emit(signalJavaScriptReady()); } @@ -252,24 +254,22 @@ void HTMLWidget::mouseMoveEvent(QMouseEvent *e) QWebView::mouseMoveEvent(e); } = -//void HTMLWidget::slotScanForJSMessages() -//{ -// const QString status =3D jsStatusBarText(); - -// if (status!=3DQLatin1String("(event)")) -// return; +void HTMLWidget::slotScanForJSMessages(QString message) +{ + if (message!=3DQLatin1String("(event)")) + return; = -// qCDebug(LIBKGEOMAP_LOG) << status; + qCDebug(LIBKGEOMAP_LOG) << message; = -// const QString eventBufferString =3D runScript(QLatin1String("kgeomap= ReadEventStrings();")).toString(); + const QString eventBufferString =3D runScript(QLatin1String("kgeomapRe= adEventStrings();")).toString(); = -// if (eventBufferString.isEmpty()) -// return; + if (eventBufferString.isEmpty()) + return; = -// const QStringList events =3D eventBufferString.split(QLatin1Char( '|= ' )); + const QStringList events =3D eventBufferString.split(QLatin1Char( '|' = )); = -// emit(signalHTMLEvents(events)); -//} + emit(signalHTMLEvents(events)); +} = /** * @brief Wrapper around executeScript to catch more errors diff --git a/src/html_widget.h b/src/html_widget.h index b1abc03..dfd9842 100644 --- a/src/html_widget.h +++ b/src/html_widget.h @@ -69,7 +69,7 @@ protected: protected Q_SLOTS: = void slotHTMLCompleted(bool ok); -// void slotScanForJSMessages(); + void slotScanForJSMessages(QString message); void progress(int progress); = Q_SIGNALS: