[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [libkgeomap/frameworks] src: Fixing event listener
From:       Mohamed Anwer <mohammed.ahmed.anwer () gmail ! com>
Date:       2015-02-28 20:30:17
Message-ID: E1YRo1h-0007go-FP () scm ! kde ! org
[Download RAW message or body]

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::Expanding);
 
     // create a timer for monitoring for javascript events, but do not start it yet:
-    d->javascriptScanTimer = new QTimer(this);
-    d->javascriptScanTimer->setSingleShot(false);
-    d->javascriptScanTimer->setInterval(300);
-
-//    connect(d->javascriptScanTimer, SIGNAL(timeout()),
-//            this, SLOT(slotScanForJSMessages()));
+//    d->javascriptScanTimer = 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 = 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 =  jsStatusBarText();
-
-//    if (status!=QLatin1String("(event)"))
-//        return;
+void HTMLWidget::slotScanForJSMessages(QString message)
+{
+    if (message!=QLatin1String("(event)"))
+        return;
 
-//    qCDebug(LIBKGEOMAP_LOG) << status;
+    qCDebug(LIBKGEOMAP_LOG) << message;
 
-//    const QString eventBufferString = \
runScript(QLatin1String("kgeomapReadEventStrings();")).toString(); +    const QString \
eventBufferString = runScript(QLatin1String("kgeomapReadEventStrings();")).toString();
  
-//    if (eventBufferString.isEmpty())
-//        return;
+    if (eventBufferString.isEmpty())
+        return;
 
-//    const QStringList events = eventBufferString.split(QLatin1Char( '|' ));
+    const QStringList events = 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:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic