18#include "KReportItemMaps.h"
19#include "KReportUtils.h"
20#include "KReportRenderObjects.h"
22#include <KPropertyListData>
23#include <KPropertySet>
27#include <sys/socket.h>
29#define myDebug() if (0) kDebug(44021)
32KReportItemMaps::KReportItemMaps()
37KReportItemMaps::KReportItemMaps(
const QDomNode &element)
40 nameProperty()->setValue(KReportUtils::readNameAttribute(element.
toElement()));
47 themeId = themeId.isEmpty() ? m_themeManager.mapThemeIds()[0] : themeId;
48 m_themeProperty->setValue(themeId);
53KReportItemMaps::~KReportItemMaps()
57void KReportItemMaps::createProperties()
59 createDataSourceProperty();
61 m_latitudeProperty =
new KProperty(
"latitude", 0.0,
tr(
"Latitude"), QString(), KProperty::Double);
62 m_latitudeProperty->setOption(
"min", -90);
63 m_latitudeProperty->setOption(
"max", 90);
65 m_latitudeProperty->setOption(
"precision", 7);
67 m_longitudeProperty =
new KProperty(
"longitude", 0.0,
tr(
"Longitude"), QString(), KProperty::Double);
68 m_longitudeProperty->setOption(
"min", -180);
69 m_longitudeProperty->setOption(
"max", 180);
71 m_longitudeProperty->setOption(
"precision", 7);
73 m_zoomProperty =
new KProperty(
"zoom", 1000,
tr(
"Zoom") );
74 m_zoomProperty->setOption(
"min", 0);
75 m_zoomProperty->setOption(
"max", 4000);
76 m_zoomProperty->setOption(
"step", 100);
77 m_zoomProperty->setOption(
"slider",
true);
79 QStringList mapThemIds(m_themeManager.mapThemeIds());
81 m_themeProperty =
new KProperty(
"theme",
new KPropertyListData(mapThemIds, mapThemIds),
82 QVariant(mapThemIds[1]),
tr(
"Theme"));
84 if (mapThemIds.contains(QLatin1String(
"earth/srtm/srtm.dgml"))) {
85 m_themeProperty->setValue(QLatin1String(
"earth/srtm/srtm.dgml"),
86 KProperty::ValueOption::IgnoreOld);
89 propertySet()->addProperty(m_latitudeProperty);
90 propertySet()->addProperty(m_longitudeProperty);
91 propertySet()->addProperty(m_zoomProperty);
92 propertySet()->addProperty(m_themeProperty);
95QString KReportItemMaps::typeName()
const
97 return QLatin1String(
"maps");
101 const QVariant &data, KReportScriptHandler *script)
105 deserializeData(data);
107 m_sectionId = section;
111 m_oroPicture =
new OROPicture();
116 m_pageId->insertPrimitive(m_oroPicture);
120 OROPicture *i2 =
dynamic_cast<OROPicture*
>(m_oroPicture->clone());
126 m_mapRenderer.renderJob(
this);
131void KReportItemMaps::deserializeData(
const QVariant& serialized)
134 QStringList dataList = serialized.
toString().
split(QLatin1Char(
';'));
135 if (dataList.
size() == 3) {
136 m_latitude = dataList[0].toDouble();
137 m_longtitude = dataList[1].toDouble();
138 m_zoom = dataList[2].toInt();
140 m_latitude = m_latitudeProperty->value().toReal();
141 m_longtitude = m_longitudeProperty->value().toReal();
142 m_zoom = m_zoomProperty->value().toInt();
146void KReportItemMaps::renderFinished()
148 emit finishedRendering();
156qreal KReportItemMaps::longtitude()
const
161qreal KReportItemMaps::latitude()
const
166int KReportItemMaps::zoom()
const
171QString KReportItemMaps::themeId()
const
173 return m_themeProperty->value().toString();
181 QStringList dataList = itemData.
toString().
split(QLatin1Char(
';'));
183 if (dataList.
size() == 3) {
184 lat = dataList[0].toDouble();
185 lon = dataList[1].toDouble();
186 zoom = dataList[2].toInt();
187 }
else if (dataList.
size() == 2) {
188 lat = dataList[0].toDouble();
189 lon = dataList[1].toDouble();
190 zoom = m_zoomProperty->
value().toInt();
192 lat = m_latitudeProperty->value().toReal();
193 lon = m_longitudeProperty->value().toReal();
194 zoom = m_zoomProperty->value().toInt();
197 if (m_longDataSetFromScript) {
200 if (m_latDataSetFromScript) {
203 if (m_zoomDataSetFromScript) {
206 return QString(QLatin1String(
"%1;%2;%3")).arg(lat).arg(lon).arg(zoom);
static QPointF scenePosition(const QPointF &ptPos)
Helper function mapping to screen units (pixels), ptPos is in points.
QPointF position() const
Return the position in points.
static QSizeF sceneSize(const QSizeF &ptSize)
Helper function mapping to screen units (pixels), ptSize is in points.
QSizeF size() const
Return the size in points.
Represents a single page in a document and may contain zero or more OROPrimitive objects all of which...
Defines a picture. A picture is different to an image, in that it is drawn using commands.
Represents a single a single row in a document and may contain zero or more OROPrimitives.
QString attribute(const QString &name, const QString &defValue) const const
QDomElement toElement() const const
qsizetype size() const const
T value(qsizetype i) const const
QString tr(const char *sourceText, const char *disambiguation, int n)
QString fromUtf8(QByteArrayView str)
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QString toString() const const