diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -4,9 +4,8 @@ #todo ecm_optional_add_subdirectory(chart) endif() -#TODO: enable when Marble is stable and useful for KF5/Qt5 -#find_package(Marble) -if(MARBLE_FOUND) +find_package(Marble) +if(Marble_FOUND) ecm_optional_add_subdirectory(maps) endif() diff --git a/src/plugins/maps/CMakeLists.txt b/src/plugins/maps/CMakeLists.txt --- a/src/plugins/maps/CMakeLists.txt +++ b/src/plugins/maps/CMakeLists.txt @@ -6,7 +6,7 @@ KReportDesignerItemMaps.cpp KReportItemMaps.cpp KReportMapsPlugin.cpp - MapRenderer.cpp + KReportMapRenderer.cpp ${kreport_mapsplugin_QM_LOADER} ) @@ -22,7 +22,7 @@ PUBLIC KReport PRIVATE - ${MARBLE_LIBRARIES} + Marble ) ########### install files ############### diff --git a/src/plugins/maps/KReportDesignerItemMaps.h b/src/plugins/maps/KReportDesignerItemMaps.h --- a/src/plugins/maps/KReportDesignerItemMaps.h +++ b/src/plugins/maps/KReportDesignerItemMaps.h @@ -24,14 +24,14 @@ #include #include -#include "KoReportItemMaps.h" +#include "KReportItemMaps.h" class KReportDesignerItemMaps : public KReportItemMaps, public KReportDesignerItemRectBase { Q_OBJECT public: - KReportDesignerItemMaps(KoReportDesigner *, QGraphicsScene* scene, const QPointF &pos); - KReportDesignerItemMaps(QDomNode *element, KoReportDesigner *, QGraphicsScene* scene); + KReportDesignerItemMaps(KReportDesigner *, QGraphicsScene* scene, const QPointF &pos); + KReportDesignerItemMaps(const QDomNode &element, KReportDesigner *, QGraphicsScene* scene); virtual ~KReportDesignerItemMaps(); virtual void buildXML(QDomDocument *doc, QDomElement *parent); @@ -42,7 +42,7 @@ virtual void mousePressEvent(QGraphicsSceneMouseEvent * event); private: - void init(QGraphicsScene*, KoReportDesigner*); + void init(QGraphicsScene*, KReportDesigner*); private Q_SLOTS: void slotPropertyChanged(KPropertySet &, KProperty &); diff --git a/src/plugins/maps/KReportDesignerItemMaps.cpp b/src/plugins/maps/KReportDesignerItemMaps.cpp --- a/src/plugins/maps/KReportDesignerItemMaps.cpp +++ b/src/plugins/maps/KReportDesignerItemMaps.cpp @@ -1,6 +1,5 @@ /* - * Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com) - * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk) + * Copyright (C) 2007-2016 by Adam Pigg (adam@piggz.co.uk) * Copyright (C) 2011-2015 by Radoslaw Wicik (radoslaw@wicik.pl) * * This library is free software; you can redistribute it and/or @@ -17,9 +16,9 @@ * License along with this library. If not, see . */ -#include "KoReportDesignerItemMaps.h" -#include "KoReportDesignerItemBase.h" -#include "KoReportDesigner.h" +#include "KReportDesignerItemMaps.h" +#include "KReportDesignerItemBase.h" +#include "KReportDesigner.h" #include #include @@ -30,31 +29,31 @@ #include #include "kreportplugin_debug.h" -void KReportDesignerItemMaps::init(QGraphicsScene *scene, KoReportDesigner *d) +void KReportDesignerItemMaps::init(QGraphicsScene *scene, KReportDesigner *d) { if (scene) scene->addItem(this); - KoReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); + KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); connect(m_set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); setZValue(Z); } -KReportDesignerItemMaps::KReportDesignerItemMaps(KoReportDesigner * rw, QGraphicsScene* scene, const QPointF &pos) - : KoReportDesignerItemRectBase(rw) +KReportDesignerItemMaps::KReportDesignerItemMaps(KReportDesigner * rw, QGraphicsScene* scene, const QPointF &pos) + : KReportDesignerItemRectBase(rw) { Q_UNUSED(pos); init(scene, rw); setSceneRect(properRect(*rw, KREPORT_ITEM_RECT_DEFAULT_WIDTH, KREPORT_ITEM_RECT_DEFAULT_WIDTH)); m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); } -KReportDesignerItemMaps::KReportDesignerItemMaps(QDomNode *element, KoReportDesigner * rw, QGraphicsScene* scene) - : KoReportItemMaps(element), KoReportDesignerItemRectBase(rw) +KReportDesignerItemMaps::KReportDesignerItemMaps(const QDomNode &element, KReportDesigner * rw, QGraphicsScene* scene) + : KReportItemMaps(element), KReportDesignerItemRectBase(rw) { init(scene, rw); setSceneRect(m_pos.toScene(), m_size.toScene()); @@ -125,12 +124,12 @@ } } - KoReportDesignerItemRectBase::propertyChanged(s, p); + KReportDesignerItemRectBase::propertyChanged(s, p); if (m_reportDesigner) m_reportDesigner->setModified(true); } void KReportDesignerItemMaps::mousePressEvent(QGraphicsSceneMouseEvent * event) { m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); - KoReportDesignerItemRectBase::mousePressEvent(event); + KReportDesignerItemRectBase::mousePressEvent(event); } diff --git a/src/plugins/maps/KReportItemMaps.h b/src/plugins/maps/KReportItemMaps.h --- a/src/plugins/maps/KReportItemMaps.h +++ b/src/plugins/maps/KReportItemMaps.h @@ -26,10 +26,11 @@ #include - #include "KReportPosition.h" #include "KReportSize.h" -#include "MapRenderer.h" +#include "KReportMapRenderer.h" + +#include class OROImage; class OROPicture; @@ -48,7 +49,7 @@ KReportItemMaps() { createProperties(); } - explicit KReportItemMaps(QDomNode *element); + explicit KReportItemMaps(const QDomNode &element); virtual ~KReportItemMaps(); virtual QString typeName() const; diff --git a/src/plugins/maps/KReportItemMaps.cpp b/src/plugins/maps/KReportItemMaps.cpp --- a/src/plugins/maps/KReportItemMaps.cpp +++ b/src/plugins/maps/KReportItemMaps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk) + * Copyright (C) 2007-2016 by Adam Pigg (adam@piggz.co.uk) * Copyright (C) 2011-2015 by Radoslaw Wicik (radoslaw@wicik.pl) * * This library is free software; you can redistribute it and/or @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ -#include "KoReportItemMaps.h" +#include "KReportItemMaps.h" #include @@ -27,7 +27,7 @@ #define myDebug() if (0) kDebug(44021) -KReportItemMaps::KReportItemMaps(QDomNode *element) +KReportItemMaps::KReportItemMaps(const QDomNode &element) : m_longtitude(0) , m_latitude(0) , m_zoom(1200) @@ -40,17 +40,17 @@ { createProperties(); - m_name->setValue(element->toElement().attribute(QLatin1String("report:name"))); - m_controlSource->setValue(element->toElement().attribute(QLatin1String("report:item-data-source"))); - Z = element->toElement().attribute(QLatin1String("report:z-index")).toDouble(); - m_latitudeProperty->setValue(element->toElement().attribute(QLatin1String("report:latitude")).toDouble()); - m_longitudeProperty->setValue(element->toElement().attribute(QLatin1String("report:longitude")).toDouble()); - m_zoomProperty->setValue(element->toElement().attribute(QLatin1String("report:zoom")).toInt()); - QString themeId(element->toElement().attribute(QLatin1String("report:theme"))); + m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); + m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); + Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); + m_latitudeProperty->setValue(element.toElement().attribute(QLatin1String("report:latitude")).toDouble()); + m_longitudeProperty->setValue(element.toElement().attribute(QLatin1String("report:longitude")).toDouble()); + m_zoomProperty->setValue(element.toElement().attribute(QLatin1String("report:zoom")).toInt()); + QString themeId(element.toElement().attribute(QLatin1String("report:theme"))); themeId = themeId.isEmpty() ? m_themeManager.mapThemeIds()[0] : themeId; m_themeProperty->setValue(themeId); - parseReportRect(element->toElement(), &m_pos, &m_size); + parseReportRect(element.toElement(), &m_pos, &m_size); } KReportItemMaps::~KReportItemMaps() @@ -147,6 +147,7 @@ void KReportItemMaps::deserializeData(const QVariant& serialized) { + kreportpluginDebug() << "Map data for this record is" << serialized; QStringList dataList = serialized.toString().split(QLatin1Char(';')); if (dataList.size() == 3) { m_latitude = dataList[0].toDouble(); diff --git a/src/plugins/maps/KReportMapRenderer.h b/src/plugins/maps/KReportMapRenderer.h --- a/src/plugins/maps/KReportMapRenderer.h +++ b/src/plugins/maps/KReportMapRenderer.h @@ -20,65 +20,31 @@ #define MAPRENDERER_H #include -#include +#include #include #include "kreportplugin_debug.h" class KReportItemMaps; -namespace Marble{ - /** - * Workaround Marble error in signal specification. - * - * renderStatusChange and renderStateChange signals are using params that are in - * Marble namespace and are not prefixed with Marble:: in their declaration in - * MarbleWidget.h this class is workaround of the bug. - */ - class RenderStatusSignalProxy: public QObject{ - Q_OBJECT - public: - explicit RenderStatusSignalProxy(QObject* parent):QObject(parent){}; - void setConnection(MarbleWidget* marble){ - connect(marble,SIGNAL(renderStatusChanged(RenderStatus)),this,SLOT(onRenderStatusChange(RenderStatus))); - connect(marble,SIGNAL(renderStateChanged(RenderState)),this,SLOT(onRenderStateChange(RenderState))); - }; - void disconnect(MarbleWidget* marble){ - disconnect(marble,SIGNAL(renderStatusChanged(RenderStatus)),this,SLOT(onRenderStatusChange(RenderStatus))); - disconnect(marble,SIGNAL(renderStateChanged(RenderState)),this,SLOT(onRenderStateChange(RenderState))); - } - public Q_SLOTS: - void onRenderStatusChange(RenderStatus renderStatus){ - kreportpluginDebug() << "!!!!!!!!!!!!!!!! STATUS change"; - emit renderStatusChanged(static_cast(renderStatus)); - }; - void onRenderStateChange(const RenderState &state){ - kreportpluginDebug() << "################ STATE change"; - emit renderStatusChanged(static_cast(state.status())); - }; - Q_SIGNALS: - void renderStatusChanged(int renderStatus); - }; -} class KReportMapRenderer : public QObject { Q_OBJECT - Q_DISABLE_COPY(MapRenderer) + Q_DISABLE_COPY(KReportMapRenderer) public: KReportMapRenderer(QObject* parent = 0); virtual ~KReportMapRenderer(); void renderJob(KReportItemMaps* reportItemMaps); Q_SIGNALS: void jobFinished(); private Q_SLOTS: - void onRenderStatusChange(int renderStatus); + void onRenderStatusChange(Marble::RenderStatus renderStatus); void downloadProgres(int active, int queued); void downloadFinished(); private: - Marble::MarbleWidget m_marble; + Marble::MarbleMap m_marble; KReportItemMaps* m_currentJob; - Marble::RenderStatusSignalProxy m_renderStatusProxy; }; #endif // MAPRENDERER_H diff --git a/src/plugins/maps/KReportMapRenderer.cpp b/src/plugins/maps/KReportMapRenderer.cpp --- a/src/plugins/maps/KReportMapRenderer.cpp +++ b/src/plugins/maps/KReportMapRenderer.cpp @@ -16,22 +16,22 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "MapRenderer.h" -#include "KoReportItemMaps.h" +#include "KReportMapRenderer.h" +#include "KReportItemMaps.h" #include #include #include #include -#include "marble/HttpDownloadManager.h" +#include #include +#include #include "kreportplugin_debug.h" KReportMapRenderer::KReportMapRenderer(QObject* parent) : QObject(parent) , m_currentJob(0) - , m_renderStatusProxy(this) { m_marble.setMapThemeId(QLatin1String("earth/openstreetmap/openstreetmap.dgml")); m_marble.setShowOverviewMap(false); @@ -44,10 +44,8 @@ } } - connect(m_marble.model()->downloadManager(),SIGNAL(progressChanged(int,int)),this,SLOT(downloadProgres(int,int))); - - m_renderStatusProxy.setConnection(m_marble); - connect(&m_renderStatusProxy,SIGNAL(renderStatusChanged(int)),this,SLOT(onRenderStatusChange(int))); + connect(m_marble.model()->downloadManager(), &Marble::HttpDownloadManager::progressChanged, this, &KReportMapRenderer::downloadProgres); + connect(&m_marble, &Marble::MarbleMap::renderStatusChanged, this, &KReportMapRenderer::onRenderStatusChange); } KReportMapRenderer::~KReportMapRenderer() @@ -59,30 +57,38 @@ { m_currentJob = reportItemMaps; int zoom = m_currentJob->zoom(); + kreportpluginDebug() << "Map Renderer rendering" << m_currentJob->longtitude() << m_currentJob->latitude(); + m_marble.setMapThemeId(m_currentJob->themeId()); //some themes enable overview map, and this must be disabled after theme switch. m_marble.setShowOverviewMap(false); - m_marble.setFixedSize(m_currentJob->size()); - m_marble.centerOn(m_currentJob->longtitude(), m_currentJob->latitude(), false); - m_marble.setZoom(zoom); - m_marble.render(m_currentJob->oroImage()->picture()); - m_currentJob->renderFinished(); + m_marble.setSize(m_currentJob->size()); + m_marble.centerOn(m_currentJob->longtitude(), m_currentJob->latitude()); + m_marble.setRadius(pow(M_E, (zoom / 200.0))); + + // Create a painter that will do the painting. + Marble::GeoPainter geoPainter( m_currentJob->oroImage()->picture(), m_marble.viewport(), m_marble.mapQuality() ); + m_marble.paint( geoPainter, QRect() ); + + if (m_marble.renderStatus() == Marble::Complete) { + m_currentJob->renderFinished(); + } } -void KReportMapRenderer::onRenderStatusChange(int renderStatus) +void KReportMapRenderer::onRenderStatusChange(Marble::RenderStatus renderStatus) { + kreportpluginDebug() << m_marble.renderStatus() << "|" << renderStatus; + if(m_currentJob){ - kreportpluginDebug() << m_marble.renderStatus() << "|" << renderStatus; - Marble::RenderStatus status = static_cast(renderStatus); kreportpluginDebug() << this << m_currentJob << m_currentJob->longtitude() << m_currentJob->latitude() << m_currentJob->zoom() - << " | status: " << status; + << " | status: " << renderStatus; - if(status == Marble::Complete){ + if(renderStatus == Marble::Complete){ m_currentJob->renderFinished(); } } diff --git a/src/plugins/maps/KReportMapsPlugin.h b/src/plugins/maps/KReportMapsPlugin.h --- a/src/plugins/maps/KReportMapsPlugin.h +++ b/src/plugins/maps/KReportMapsPlugin.h @@ -30,8 +30,8 @@ virtual ~KReportMapsPlugin(); virtual QObject* createRendererInstance(const QDomNode& element); - virtual QObject* createDesignerInstance(const QDomNode& element, KoReportDesigner* , QGraphicsScene* scene); - virtual QObject* createDesignerInstance(KoReportDesigner* , QGraphicsScene* scene, const QPointF& pos); + virtual QObject* createDesignerInstance(const QDomNode& element, KReportDesigner* , QGraphicsScene* scene); + virtual QObject* createDesignerInstance(KReportDesigner* , QGraphicsScene* scene, const QPointF& pos); #ifdef KREPORT_SCRIPTING virtual QObject* createScriptInstance(KReportItemBase* item); #endif diff --git a/src/plugins/maps/KReportMapsPlugin.cpp b/src/plugins/maps/KReportMapsPlugin.cpp --- a/src/plugins/maps/KReportMapsPlugin.cpp +++ b/src/plugins/maps/KReportMapsPlugin.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2010 by Adam Pigg (adam@piggz.co.uk) + Copyright (C) 2010-2016 by Adam Pigg (adam@piggz.co.uk) Copyright (C) 2011 by Radoslaw Wicik (radoslaw@wicik.pl) This library is free software; you can redistribute it and/or @@ -18,16 +18,17 @@ Boston, MA 02110-1301, USA. */ -#include "KoReportMapsPlugin.h" -#include "KoReportItemMaps.h" -#include "KoReportDesignerItemMaps.h" +#include "KReportMapsPlugin.h" +#include "KReportItemMaps.h" +#include "KReportDesignerItemMaps.h" #include #ifdef KREPORT_SCRIPTING -#include "krscriptmaps.h" +#include "KReportScriptMaps.h" #endif +#include "kreport_debug.h" -KREPORT_PLUGIN_FACTORY(KoReportMapsPlugin, "kreport_mapsplugin.json") +KREPORT_PLUGIN_FACTORY(KReportMapsPlugin, "kreport_mapsplugin.json") KReportMapsPlugin::KReportMapsPlugin(QObject *parent, const QVariantList &args) : KReportPluginInterface(parent) { @@ -43,18 +44,19 @@ return new KReportItemMaps(element); } -QObject* KReportMapsPlugin::createDesignerInstance(const QDomNode& element, KoReportDesigner* designer, QGraphicsScene* scene) +QObject* KReportMapsPlugin::createDesignerInstance(const QDomNode& element, KReportDesigner* designer, QGraphicsScene* scene) { return new KReportDesignerItemMaps(element, designer, scene); } -QObject* KReportMapsPlugin::createDesignerInstance(KoReportDesigner* designer, QGraphicsScene* scene, const QPointF& pos) +QObject* KReportMapsPlugin::createDesignerInstance(KReportDesigner* designer, QGraphicsScene* scene, const QPointF& pos) { + kreportpluginDebug() << "KReport maps init"; return new KReportDesignerItemMaps(designer, scene, pos); } #ifdef KREPORT_SCRIPTING -QObject* KoReportMapsPlugin::createScriptInstance(KReportItemBase* /*item*/) +QObject* KReportMapsPlugin::createScriptInstance(KReportItemBase* /*item*/) { /*KoReportItemMaps *image = dynamic_cast(item); if (image) { @@ -64,4 +66,4 @@ } #endif -#include "KoReportMapsPlugin.moc" +#include "KReportMapsPlugin.moc" diff --git a/src/plugins/maps/KReportScriptMaps.cpp b/src/plugins/maps/KReportScriptMaps.cpp --- a/src/plugins/maps/KReportScriptMaps.cpp +++ b/src/plugins/maps/KReportScriptMaps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk) + * Copyright (C) 2007-2016 by Adam Pigg (adam@piggz.co.uk) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -15,10 +15,8 @@ * License along with this library. If not, see . */ -#include "krscriptmaps.h" - -#include "KoReportItemMaps.h" - +#include "KReportScriptMaps.h" +#include "KReportItemMaps.h" namespace Scripting { diff --git a/src/plugins/maps/kreport_mapsplugin.json b/src/plugins/maps/kreport_mapsplugin.json --- a/src/plugins/maps/kreport_mapsplugin.json +++ b/src/plugins/maps/kreport_mapsplugin.json @@ -40,7 +40,7 @@ "Description[uk]": "Елемент карти для звітів", "Description[x-test]": "xxMaps element for Reportsxx", "EnabledByDefault": true, - "Icon": "report_maps_element", + "Icon": "kreport_maps_element", "Id": "org.kde.kreport.maps", "License": "LGPL", "Name": "Maps", @@ -68,4 +68,4 @@ }, "X-KDE-PluginInfo-LegacyName": "maps", "X-KReport-Priority": "50" -} \ No newline at end of file +} diff --git a/src/plugins/maps/marble/HttpDownloadManager.h b/src/plugins/maps/marble/HttpDownloadManager.h deleted file mode 100644 --- a/src/plugins/maps/marble/HttpDownloadManager.h +++ /dev/null @@ -1,118 +0,0 @@ -// -// This file is part of the Marble Virtual Globe. -// -// This program is free software licensed under the GNU LGPL. You can -// find a copy of this license in LICENSE.txt in the top directory of -// the source code. -// -// Copyright 2007 Torsten Rahn -// Copyright 2007 Inge Wallin -// Copyright 2009 Jens-Michael Hoffmann -// - -// -// The HttpDownloadManager manages http downloads. -// - -#ifndef MARBLE_HTTPDOWNLOADMANAGER_H -#define MARBLE_HTTPDOWNLOADMANAGER_H - -#include - -#include - -class QUrl; - -namespace Marble -{ - -class DownloadPolicy; -class DownloadQueueSet; -class StoragePolicy; - -/** - * @short This class manages scheduled downloads. - - * The downloadmanager offers a maximum number of active jobs and a - * limit for pending jobs. it also takes care that the job queue - * won't be polluted by jobs that timed out already. - */ -class MARBLE_EXPORT HttpDownloadManager : public QObject -{ - Q_OBJECT - - public: - /** - * Creates a new http download manager. - * - * @note HttpDownloadManager doesn't take ownership of @p policy. - * - * @param policy The storage policy for this manager. - */ - explicit HttpDownloadManager( StoragePolicy *policy ); - - /** - * Destroys the http download manager. - */ - virtual ~HttpDownloadManager(); - - /** - * Switches loading on/off, useful for offline mode. - */ - void setDownloadEnabled( const bool enable ); - void addDownloadPolicy( const DownloadPolicy& ); - - public Q_SLOTS: - - /** - * Adds a new job with a sourceUrl, destination file name and given id. - */ - void addJob( const QUrl& sourceUrl, const QString& destFilename, const QString &id, - const DownloadUsage usage ); - - - Q_SIGNALS: - void downloadComplete( QString, QString ); - - /** - * This signal is emitted if a file is downloaded and the data argument - * contains the files content. The HttpDownloadManager takes care to save - * it using the given storage policy. - */ - void downloadComplete( QByteArray data, QString initiatorId ); - - /** - * Signal is emitted when a new job is added to the queue. - */ - void jobAdded(); - - /** - * Signal is emitted when a job is removed from the queue. - * The job might be completed or blacklisted. - */ - void jobRemoved(); - - /** - * A job was queued, activated or removed (finished, failed) - */ - void progressChanged( int active, int queued ); - - private Q_SLOTS: - void finishJob( const QByteArray& data, const QString& destinationFileName, - const QString& id ); - void requeue(); - void startRetryTimer(); - - private: - Q_DISABLE_COPY( HttpDownloadManager ) - - void connectDefaultQueueSets(); - void connectQueueSet( DownloadQueueSet * ); - bool hasDownloadPolicy( const DownloadPolicy& policy ) const; - class Private; - Private * const d; -}; - -} - -#endif // MARBLE_HTTPDOWNLOADMANAGER_H