diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index f3f23ce4..4c9fea36 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -1,15 +1,14 @@ ecm_optional_add_subdirectory(barcode) if(NOT WIN32) #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() if(QT_QTWEBKIT_FOUND) #todo ecm_optional_add_subdirectory(web) endif() diff --git a/src/plugins/maps/CMakeLists.txt b/src/plugins/maps/CMakeLists.txt index e67bc9dd..d70c584e 100644 --- a/src/plugins/maps/CMakeLists.txt +++ b/src/plugins/maps/CMakeLists.txt @@ -1,32 +1,32 @@ ecm_create_qm_loader(kreport_mapsplugin_QM_LOADER kreport_mapsplugin_qt) #build a shared library set(kreport_mapsplugin_LIB_SRCS ${PROJECT_SOURCE_DIR}/src/common/kreportplugin_debug.cpp KReportDesignerItemMaps.cpp KReportItemMaps.cpp KReportMapsPlugin.cpp - MapRenderer.cpp + KReportMapRenderer.cpp ${kreport_mapsplugin_QM_LOADER} ) if(KREPORT_SCRIPTING) list(APPEND kreport_mapsplugin_LIB_SRCS KReportScriptMaps.cpp ) endif() add_library(kreport_mapsplugin MODULE ${kreport_mapsplugin_LIB_SRCS}) target_link_libraries(kreport_mapsplugin PUBLIC KReport PRIVATE - ${MARBLE_LIBRARIES} + Marble ) ########### install files ############### install(TARGETS kreport_mapsplugin DESTINATION ${KREPORT_PLUGIN_INSTALL_DIR}) add_subdirectory(pics) diff --git a/src/plugins/maps/KReportDesignerItemMaps.cpp b/src/plugins/maps/KReportDesignerItemMaps.cpp index 8e2222db..c9c53005 100644 --- a/src/plugins/maps/KReportDesignerItemMaps.cpp +++ b/src/plugins/maps/KReportDesignerItemMaps.cpp @@ -1,136 +1,135 @@ /* - * 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 * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * 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 #include #include #include #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()); } KReportDesignerItemMaps* KReportDesignerItemMaps::clone() { QDomDocument d; QDomElement e = d.createElement(QLatin1String("clone")); QDomNode n; buildXML(&d, &e); n = e.firstChild(); return new KReportDesignerItemMaps(n, designer(), 0); } KReportDesignerItemMaps::~KReportDesignerItemMaps() { // do we need to clean anything up? } void KReportDesignerItemMaps::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { Q_UNUSED(option); Q_UNUSED(widget); // store any values we plan on changing so we can restore them QPen p = painter->pen(); painter->fillRect(rect(), QColor(0xc2, 0xfc, 0xc7));//C2FCC7 //Draw a border so user knows the object edge painter->setPen(QPen(QColor(224, 224, 224))); painter->drawRect(rect()); painter->setPen(Qt::black); painter->drawText(rect(), 0, dataSourceAndObjectTypeName(itemDataSource(), QLatin1String("map"))); drawHandles(painter); // restore an values before we started just in case painter->setPen(p); } void KReportDesignerItemMaps::buildXML(QDomDocument *doc, QDomElement *parent) { QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); // properties addPropertyAsAttribute(&entity, m_name); addPropertyAsAttribute(&entity, m_controlSource); addPropertyAsAttribute(&entity, m_latitudeProperty); addPropertyAsAttribute(&entity, m_longitudeProperty); addPropertyAsAttribute(&entity, m_zoomProperty); addPropertyAsAttribute(&entity, m_themeProperty); //addPropertyAsAttribute(&entity, m_resizeMode); entity.setAttribute(QLatin1String("report:z-index"), zValue()); buildXMLRect(doc, &entity, &m_pos, &m_size); parent->appendChild(entity); } void KReportDesignerItemMaps::slotPropertyChanged(KPropertySet &s, KProperty &p) { kreportpluginDebug() << p.name() << ":" << p.value(); if (p.name().toLower() == "name") { //For some reason p.oldValue returns an empty string if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { p.setValue(m_oldName); } else { m_oldName = p.value().toString(); } } - 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/KReportDesignerItemMaps.h b/src/plugins/maps/KReportDesignerItemMaps.h index 07cca40b..36e52259 100644 --- a/src/plugins/maps/KReportDesignerItemMaps.h +++ b/src/plugins/maps/KReportDesignerItemMaps.h @@ -1,52 +1,52 @@ /* * Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com) * Copyright (C) 2007-2008 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 * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef __REPORTENTITYIMAGE_H__ #define __REPORTENTITYIMAGE_H__ #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); virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); virtual KReportDesignerItemMaps* clone(); protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent * event); private: - void init(QGraphicsScene*, KoReportDesigner*); + void init(QGraphicsScene*, KReportDesigner*); private Q_SLOTS: void slotPropertyChanged(KPropertySet &, KProperty &); }; #endif diff --git a/src/plugins/maps/KReportItemMaps.cpp b/src/plugins/maps/KReportItemMaps.cpp index 3085cc16..3fc6836d 100644 --- a/src/plugins/maps/KReportItemMaps.cpp +++ b/src/plugins/maps/KReportItemMaps.cpp @@ -1,228 +1,229 @@ /* - * 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 * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * 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 #include #include #include #define myDebug() if (0) kDebug(44021) -KReportItemMaps::KReportItemMaps(QDomNode *element) +KReportItemMaps::KReportItemMaps(const QDomNode &element) : m_longtitude(0) , m_latitude(0) , m_zoom(1200) , m_pageId(0) , m_sectionId(0) , m_oroPicture(0) , m_longDataSetFromScript(false) , m_latDataSetFromScript(false) , m_zoomDataSetFromScript(false) { 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() { delete m_set; } void KReportItemMaps::createProperties() { m_set = new KPropertySet; m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), QString(), tr("Data Source")); m_latitudeProperty = new KProperty("latitude", 0.0, tr("Latitude"), tr("Latitude"), KProperty::Double); m_latitudeProperty->setOption("min", -90); m_latitudeProperty->setOption("max", 90); m_latitudeProperty->setOption("unit", QString::fromUtf8("°")); m_latitudeProperty->setOption("precision", 7); m_longitudeProperty = new KProperty("longitude", 0.0, tr("Longitude"), tr("Longitude"), KProperty::Double); m_longitudeProperty->setOption("min", -180); m_longitudeProperty->setOption("max", 180); m_longitudeProperty->setOption("unit", QString::fromUtf8("°")); m_longitudeProperty->setOption("precision", 7); m_zoomProperty = new KProperty("zoom", 1000, tr("Zoom"), tr("Zoom") ); m_zoomProperty->setOption("min", 0); m_zoomProperty->setOption("max", 4000); m_zoomProperty->setOption("step", 100); m_zoomProperty->setOption("slider", true); QStringList mapThemIds(m_themeManager.mapThemeIds()); m_themeProperty = new KProperty("theme", mapThemIds, mapThemIds, mapThemIds[1]); if (mapThemIds.contains(QLatin1String("earth/srtm/srtm.dgml"))) { m_themeProperty->setValue(QLatin1String("earth/srtm/srtm.dgml"), false); } addDefaultProperties(); m_set->addProperty(m_controlSource); m_set->addProperty(m_latitudeProperty); m_set->addProperty(m_longitudeProperty); m_set->addProperty(m_zoomProperty); m_set->addProperty(m_themeProperty); } void KReportItemMaps::setColumn(const QString &c) { m_controlSource->setValue(c); } QString KReportItemMaps::itemDataSource() const { return m_controlSource->value().toString(); } QString KReportItemMaps::typeName() const { return QLatin1String("maps"); } int KReportItemMaps::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, const QVariant &data, KReportScriptHandler *script) { Q_UNUSED(script) deserializeData(data); m_pageId = page; m_sectionId = section; m_offset = offset; m_oroPicture = new OROPicture(); m_oroPicture->setPosition(m_pos.toScene() + m_offset); m_oroPicture->setSize(m_size.toScene()); if (m_pageId) { m_pageId->addPrimitive(m_oroPicture); } if (m_sectionId) { OROPicture *i2 = dynamic_cast(m_oroPicture->clone()); i2->setPosition(m_pos.toPoint()); } m_mapRenderer.renderJob(this); return 0; //Item doesn't stretch the section height } 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(); m_longtitude = dataList[1].toDouble(); m_zoom = dataList[2].toInt(); } else { m_latitude = m_latitudeProperty->value().toReal(); m_longtitude = m_longitudeProperty->value().toReal(); m_zoom = m_zoomProperty->value().toInt(); } } void KReportItemMaps::renderFinished() { emit finishedRendering(); } OROPicture* KReportItemMaps::oroImage() { return m_oroPicture; } qreal KReportItemMaps::longtitude() const { return m_longtitude; } qreal KReportItemMaps::latitude() const { return m_latitude; } int KReportItemMaps::zoom() const { return m_zoom; } QSize KReportItemMaps::size() const { return m_size.toScene().toSize(); } QString KReportItemMaps::themeId() const { return m_themeProperty->value().toString(); } QVariant KReportItemMaps::realItemData(const QVariant& itemData) const { double lat, lon; int zoom; QStringList dataList = itemData.toString().split(QLatin1Char(';')); if (dataList.size() == 3) { lat = dataList[0].toDouble(); lon = dataList[1].toDouble(); zoom = dataList[2].toInt(); } else if (dataList.size() == 2) { lat = dataList[0].toDouble(); lon = dataList[1].toDouble(); zoom = m_zoomProperty->value().toInt(); } else { lat = m_latitudeProperty->value().toReal(); lon = m_longitudeProperty->value().toReal(); zoom = m_zoomProperty->value().toInt(); } if (m_longDataSetFromScript) { lon = m_longtitude; } if (m_latDataSetFromScript) { lat = m_latitude; } if (m_zoomDataSetFromScript) { zoom = m_zoom; } return QString(QLatin1String("%1;%2;%3")).arg(lat).arg(lon).arg(zoom); } diff --git a/src/plugins/maps/KReportItemMaps.h b/src/plugins/maps/KReportItemMaps.h index 61b55003..4c5648a8 100644 --- a/src/plugins/maps/KReportItemMaps.h +++ b/src/plugins/maps/KReportItemMaps.h @@ -1,100 +1,101 @@ /* * Copyright (C) 2007-2008 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 * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef KREPORTITEMMAPS_H #define KREPORTITEMMAPS_H #include "KReportAsyncItemBase.h" #include #include #include - #include "KReportPosition.h" #include "KReportSize.h" -#include "MapRenderer.h" +#include "KReportMapRenderer.h" + +#include class OROImage; class OROPicture; class OROPage; class OROSection; namespace Scripting { class Maps; } class KReportItemMaps : public KReportAsyncItemBase { Q_OBJECT public: KReportItemMaps() { createProperties(); } - explicit KReportItemMaps(QDomNode *element); + explicit KReportItemMaps(const QDomNode &element); virtual ~KReportItemMaps(); virtual QString typeName() const; virtual int renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, const QVariant &data, KReportScriptHandler *script); virtual QString itemDataSource() const; virtual QVariant realItemData(const QVariant &itemData) const; void renderFinished(); qreal longtitude() const; qreal latitude() const; int zoom() const; QString themeId() const; QSize size() const; OROPicture* oroImage(); protected: KProperty* m_controlSource; KProperty* m_latitudeProperty; KProperty* m_longitudeProperty; KProperty* m_zoomProperty; KProperty* m_themeProperty; void setColumn(const QString&); qreal m_longtitude; qreal m_latitude; int m_zoom; OROPage *m_pageId; OROSection *m_sectionId; QPointF m_offset; OROPicture * m_oroPicture; KReportMapRenderer m_mapRenderer; Marble::MapThemeManager m_themeManager; private: virtual void createProperties(); void deserializeData(const QVariant& serialized); bool m_longDataSetFromScript; bool m_latDataSetFromScript; bool m_zoomDataSetFromScript; friend class Scripting::Maps; }; #endif diff --git a/src/plugins/maps/KReportMapRenderer.cpp b/src/plugins/maps/KReportMapRenderer.cpp index d6e2b428..e1537d57 100644 --- a/src/plugins/maps/KReportMapRenderer.cpp +++ b/src/plugins/maps/KReportMapRenderer.cpp @@ -1,105 +1,111 @@ /* * Copyright (C) 2015 Radosław Wicik * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * 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); m_marble.setMapQualityForViewContext(Marble::PrintQuality, Marble::Still); m_marble.setShowCrosshairs(true); foreach(Marble::AbstractFloatItem* floatItem, m_marble.floatItems()){ if(floatItem->nameId() == QString(QLatin1String("navigation"))){ floatItem->setVisible(false); } } - 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() { } void KReportMapRenderer::renderJob(KReportItemMaps* reportItemMaps) { 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(); } } } void KReportMapRenderer::downloadFinished() { kreportpluginDebug() << "job:" << m_currentJob << "(" << m_currentJob->latitude() << "," << m_currentJob->longtitude() << ")"; } void KReportMapRenderer::downloadProgres(int active, int queued) { if(m_currentJob){ kreportpluginDebug() << "job:" << m_currentJob << "(" << m_currentJob->latitude() << "," << m_currentJob->longtitude() << ")" << "active/queued:" << active << "/" << queued; } } diff --git a/src/plugins/maps/KReportMapRenderer.h b/src/plugins/maps/KReportMapRenderer.h index 5e6e2e43..fe2432a1 100644 --- a/src/plugins/maps/KReportMapRenderer.h +++ b/src/plugins/maps/KReportMapRenderer.h @@ -1,84 +1,50 @@ /* * Copyright (C) 2015 Radosław Wicik * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MAPRENDERER_H #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/KReportMapsPlugin.cpp b/src/plugins/maps/KReportMapsPlugin.cpp index c0ace393..5117c057 100644 --- a/src/plugins/maps/KReportMapsPlugin.cpp +++ b/src/plugins/maps/KReportMapsPlugin.cpp @@ -1,67 +1,69 @@ /* - 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 modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 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) { Q_UNUSED(args) } KReportMapsPlugin::~KReportMapsPlugin() { } QObject* KReportMapsPlugin::createRendererInstance(const QDomNode& element) { 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) { return new Scripting::Maps(image); }*/ return 0; } #endif -#include "KoReportMapsPlugin.moc" +#include "KReportMapsPlugin.moc" diff --git a/src/plugins/maps/KReportMapsPlugin.h b/src/plugins/maps/KReportMapsPlugin.h index 6b6ad9fd..804b064e 100644 --- a/src/plugins/maps/KReportMapsPlugin.h +++ b/src/plugins/maps/KReportMapsPlugin.h @@ -1,40 +1,40 @@ /* Copyright (C) 2010 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 modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KREPORTMAPSPLUGIN_H #define KREPORTMAPSPLUGIN_H #include "KReportPluginInterface.h" class KReportMapsPlugin : public KReportPluginInterface { public: explicit KReportMapsPlugin(QObject *parent, const QVariantList &args = QVariantList()); 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 }; #endif // KOREPORTMAPSPLUGIN_H diff --git a/src/plugins/maps/KReportScriptMaps.cpp b/src/plugins/maps/KReportScriptMaps.cpp index 97eae4c8..b5873b70 100644 --- a/src/plugins/maps/KReportScriptMaps.cpp +++ b/src/plugins/maps/KReportScriptMaps.cpp @@ -1,76 +1,74 @@ /* - * 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 * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ -#include "krscriptmaps.h" - -#include "KoReportItemMaps.h" - +#include "KReportScriptMaps.h" +#include "KReportItemMaps.h" namespace Scripting { Maps::Maps(KReportItemMaps *i) { m_map = i; m_map->m_latDataSetFromScript = false; m_map->m_longDataSetFromScript = false; m_map->m_zoomDataSetFromScript = false; } Maps::~Maps() { } QPointF Maps::position() const { return m_map->m_pos.toPoint(); } void Maps::setPosition(const QPointF& p) { m_map->m_pos.setPointPos(p); } QSizeF Maps::size() const { return m_map->m_size.toPoint(); } void Maps::setSize(const QSizeF& s) { m_map->m_size.setPointSize(s); } void Maps::setLatitude(qreal latitude) { m_map->m_latitude = latitude; m_map->m_latDataSetFromScript = true; } void Maps::setLongitude(qreal longitude) { m_map->m_longtitude = longitude; m_map->m_longDataSetFromScript = true; } void Maps::setZoom(int zoom) { m_map->m_zoom = zoom; m_map->m_zoomDataSetFromScript = true; } } diff --git a/src/plugins/maps/kreport_mapsplugin.json b/src/plugins/maps/kreport_mapsplugin.json index 339e8da0..3cabef13 100644 --- a/src/plugins/maps/kreport_mapsplugin.json +++ b/src/plugins/maps/kreport_mapsplugin.json @@ -1,71 +1,71 @@ { "KPlugin": { "Authors": [ { "Email": "kexi@kde.org", "Name": "Kexi Team", "Name[ast]": "L'equipu de Kexi", "Name[ca@valencia]": "L'equip del Kexi", "Name[ca]": "L'equip del Kexi", "Name[cs]": "Tým Kexi", "Name[de]": "Kexi-Team", "Name[es]": "El equipo de Kexi", "Name[fi]": "Kexi-työryhmä", "Name[gl]": "Equipo de Kexi", "Name[nl]": "Het team van Kexi", "Name[pl]": "Zespół Kexi", "Name[pt]": "Equipa do Kexi", "Name[pt_BR]": "Equipe do Kexi", "Name[sk]": "Tím Kexi", "Name[sv]": "Kexi-gruppen", "Name[uk]": "Команда Kexi", "Name[x-test]": "xxKexi Teamxx" } ], "Category": "", "Dependencies": [], "Description": "Maps element for Reports", "Description[ca@valencia]": "Element de mapes per informes", "Description[ca]": "Element de mapes per informes", "Description[de]": "Kartenelement für Berichte", "Description[es]": "Elemento de mapas para Reports", "Description[fi]": "Karttaelementti raportteihin", "Description[gl]": "Elemento de mapas para informes.", "Description[nl]": "Kaartelement voor rapporten", "Description[pl]": "Element mapy dla raportów", "Description[pt]": "Elemento de mapas para os Relatórios", "Description[pt_BR]": "Elemento Mapas para Relatórios", "Description[sk]": "Prvok máp pre Reports", "Description[sv]": "Kartelement för rapporter", "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", "Name[ast]": "Mapes", "Name[ca@valencia]": "Mapes", "Name[ca]": "Mapes", "Name[cs]": "Mapy", "Name[de]": "Karten", "Name[es]": "Mapas", "Name[fi]": "Kartta", "Name[gl]": "Mapas", "Name[nl]": "Kaarten", "Name[pl]": "Mapy", "Name[pt]": "Mapas", "Name[pt_BR]": "Mapas", "Name[sk]": "Mapy", "Name[sv]": "Kartor", "Name[uk]": "Карти", "Name[x-test]": "xxMapsxx", "ServiceTypes": [ "KReport/Element" ], "Version": "1.0", "Website": "http://kexi-project.org" }, "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 index c7ae5bbd..00000000 --- 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