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

List:       kde-commits
Subject:    KDE/kdeedu/marble/src/plugins/render/panoramio
From:       Shashank Singh <shashank.personal () gmail ! com>
Date:       2009-03-26 16:23:44
Message-ID: 1238084624.976658.8358.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 944989 by ssingh:

[1]installed a event filter for Panoramio PLugin 


 M  +37 -34    PanoramioPlugin.cpp  
 M  +9 -5      PanoramioPlugin.h  


--- trunk/KDE/kdeedu/marble/src/plugins/render/panoramio/PanoramioPlugin.cpp \
#944988:944989 @@ -20,52 +20,44 @@
 #include "GeoDataLatLonAltBox.h"
 #include "ViewportParams.h"
 
-namespace Marble
-{
 
-QStringList PanoramioPlugin::backendTypes() const
-{
+
+namespace Marble {
+
+QStringList PanoramioPlugin::backendTypes() const {
     return QStringList("panoramio");
 }
 
-QString PanoramioPlugin::renderPolicy() const
-{
+QString PanoramioPlugin::renderPolicy() const {
     return QString("ALWAYS");
 }
 
-QStringList PanoramioPlugin::renderPosition() const
-{
+QStringList PanoramioPlugin::renderPosition() const {
     return QStringList("ALWAYS_ON_TOP");
 }
 
-QString PanoramioPlugin::name() const
-{
+QString PanoramioPlugin::name() const {
     return tr("Panoramio Photos");
 }
 
-QString PanoramioPlugin::guiString() const
-{
+QString PanoramioPlugin::guiString() const {
     return tr("&Panoramio");
 }
 
-QString PanoramioPlugin::nameId() const
-{
+QString PanoramioPlugin::nameId() const {
     return QString("panoramio");
 }
 
-QString PanoramioPlugin::description() const
-{
+QString PanoramioPlugin::description() const {
     return tr("Automatically downloads images from around the world in preference to \
their popularity");  }
 
-QIcon PanoramioPlugin::icon() const
-{
+QIcon PanoramioPlugin::icon() const {
     return QIcon();
 }
 
 
-void PanoramioPlugin::initialize()
-{
+void PanoramioPlugin::initialize() {
     flag = 0;
     numberOfImagesToShow = 20;
     m_storagePolicy = new CacheStoragePolicy(MarbleDirs::localPath() + "/cache/");
@@ -74,15 +66,13 @@
 
 }
 
-bool PanoramioPlugin::isInitialized() const
-{
+bool PanoramioPlugin::isInitialized() const {
     return true;
 }
 /**
 *This function render whatever images it has in list
 */
-bool PanoramioPlugin::render(GeoPainter *painter, ViewportParams *viewport, const \
                QString& renderPos, GeoSceneLayer * layer)
-{
+bool PanoramioPlugin::render(GeoPainter *painter, ViewportParams *viewport, const \
                QString& renderPos, GeoSceneLayer * layer) {
     static qreal deltaWest = 0 , deltaEast = 0 , deltaSouth = 0 , deltaNorth = 0;
     painter->autoMapQuality();
     GeoDataLatLonAltBox mylatLonAltBox = viewport->viewLatLonAltBox();
@@ -98,15 +88,14 @@
 
         }
     }
-  return true;
+    return true;
 }
 /**
-*this slot is called after the json has been downlaod 
-*[1]this flost calls the json parser 
+*this slot is called after the json has been downlaod
+*[1]this flost calls the json parser
 *[2]add jobs in  http Download manager for each parsed entry in parsed json
 */
-void PanoramioPlugin::slotDownloadImage(QString relativeUrlString, QString id)
-{
+void PanoramioPlugin::slotDownloadImage(QString relativeUrlString, QString id) {
     disconnect(m_downloadManager, SIGNAL(downloadComplete(QString, QString)), this, \
                SLOT(slotDownloadImage(QString , QString)));
     connect(m_downloadManager, SIGNAL(downloadComplete(QString, QString)), this, \
SLOT(slotAppendImageToList(QString , QString)));  
@@ -116,7 +105,7 @@
 //	qDebug()<<temp.photo_file_url;
         if (!m_storagePolicy->fileExists(temp.photo_title)) {
             m_downloadManager->addJob(QUrl(temp.photo_file_url), temp.photo_title, \
                QString::number(x));
-           qDebug() << "adding " << temp.photo_title;
+            qDebug() << "adding " << temp.photo_title;
         }
     }
 
@@ -125,8 +114,7 @@
 *this slot is called once a image has been downloaded by HTTPdownloader
 [1]It appends the image to a imageWidget
 */
-void PanoramioPlugin::slotAppendImageToList(const QString relativeUrlString, const \
                QString id)
-{
+void PanoramioPlugin::slotAppendImageToList(const QString relativeUrlString, const \
                QString id) {
     tempImage.load(MarbleDirs::localPath() + "/cache/" + relativeUrlString);
 //     imagesWeHave.append(tempImage.scaled(QSize(50, 50),  Qt::IgnoreAspectRatio , \
Qt::FastTransformation));  images.append(new imageWidget);
@@ -137,8 +125,7 @@
 /**
 *This function add jobs to downlaod manager to fetch json file from panoramio \
                sevrers
 */
-void PanoramioPlugin::downloadPanoramio(int rangeFrom , int rangeTo , qreal east , \
                qreal west , qreal north , qreal south)
-{
+void PanoramioPlugin::downloadPanoramio(int rangeFrom , int rangeTo , qreal east , \
                qreal west , qreal north , qreal south) {
     m_downloadManager->addJob(QUrl("http://www.panoramio.com/map/get_panoramas.php?from="
  + QString::number(rangeFrom)
                                    + "&to=" + QString::number(rangeTo)
@@ -149,8 +136,24 @@
     connect(m_downloadManager, SIGNAL(downloadComplete(QString, QString)), this, \
SLOT(slotDownloadImage(QString , QString)));  }
 
+
+/**
+*trying to install a event filter on marble widget to fliter events for our little \
image widgets +*/
+bool PanoramioPlugin::eventFilter(QObject *object, QEvent *e) {
+    MarbleWidget *widget = dynamic_cast<MarbleWidget*> (object);
+    if ( !widget ) {
+        return RenderPlugin::eventFilter(object, e);
+    }
+    QMouseEvent *event = static_cast<QMouseEvent*> (e);
+    if ( e->type() == QEvent::MouseButtonPress ) {
+        qDebug()<<__func__;
+    }
 }
 
+
+
+}
 Q_EXPORT_PLUGIN2(PanoramioPlugin, Marble::PanoramioPlugin)
 
 #include "PanoramioPlugin.moc"
--- trunk/KDE/kdeedu/marble/src/plugins/render/panoramio/PanoramioPlugin.h \
#944988:944989 @@ -23,19 +23,21 @@
 #include "jsonparser.h"
 #include "imagewidget.h"
 #include "RenderPlugin.h"
+#include "MarbleWidget.h"
 #include <QWidget>
 #include <QLabel>
 #include <QPushButton>
-namespace Marble
-{
+#include <QMouseEvent>
+#include <QRectF>
+namespace Marble {
 
 /**
  * @short The class that specifies the a simple panormaio plugin
  *
  */
+class MarbleWidget;
 
-class PanoramioPlugin : public RenderPlugin
-{
+class PanoramioPlugin : public RenderPlugin {
     Q_OBJECT
     Q_INTERFACES(Marble::RenderPluginInterface)
     MARBLE_PLUGIN(PanoramioPlugin)
@@ -63,6 +65,8 @@
     bool isInitialized() const;
 
     bool render(GeoPainter *painter, ViewportParams *viewport, const QString& \
renderPos, GeoSceneLayer * layer = 0); +protected:
+    bool eventFilter( QObject *object, QEvent *e );
 
 public slots:
     void slotDownloadImage(QString , QString);   //completed download of json reply \
fom panoramio @@ -80,7 +84,7 @@
     QPixmap tempImage;
     int flag;//this flag is one when globe has an Image  (downloaded or already \
                there in cache)
     int numberOfImagesToShow;//this factor stires how many are to be downloaded and \
                shown on the globe
-    QList<imageWidget*>images;//these widgets are supposed to show draw images and \
take click events  +    QList<imageWidget*>images;//these widgets are supposed to \
show draw images and take click events  };
 
 }


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

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