diff --git a/src/plugins/render/notes/NotesItem.cpp b/src/plugins/render/notes/NotesItem.cpp index bf97d7f1f..b9f479c8b 100644 --- a/src/plugins/render/notes/NotesItem.cpp +++ b/src/plugins/render/notes/NotesItem.cpp @@ -1,44 +1,41 @@ // 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 2016 Spencer Brown +// Copyright 2017 Spencer Brown // #include "NotesItem.h" #include "MarbleDirs.h" #include #include using namespace Marble; -const QFont NotesItem::s_font = QFont( QStringLiteral( "Sans Serif" ), 10, QFont::Bold ); -const int NotesItem::s_labelOutlineWidth = 5; - -NotesItem::NotesItem( QObject *parent ) - : AbstractDataPluginItem( parent ), +NotesItem::NotesItem(QObject *parent) + : AbstractDataPluginItem(parent), m_pixmap(MarbleDirs::path("bitmaps/waypoint.png")) { - setSize( QSize( 3, 3 ) ); - setCacheMode( ItemCoordinateCache ); + setSize(m_pixmap.size()); + setCacheMode(ItemCoordinateCache); } NotesItem::~NotesItem() { } bool NotesItem::initialized() const { return !id().isEmpty(); } -bool NotesItem::operator<( const AbstractDataPluginItem *other ) const +bool NotesItem::operator<(const AbstractDataPluginItem *other) const { return this->id() < other->id(); } -void NotesItem::paint( QPainter *painter ) +void NotesItem::paint(QPainter *painter) { painter->drawPixmap(0, 0, m_pixmap); } diff --git a/src/plugins/render/notes/NotesItem.h b/src/plugins/render/notes/NotesItem.h index bbee01ae4..a18dc97a2 100644 --- a/src/plugins/render/notes/NotesItem.h +++ b/src/plugins/render/notes/NotesItem.h @@ -1,42 +1,40 @@ // // 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 2016 Spencer Brown +// Copyright 2017 Spencer Brown // #ifndef NOTESITEM_H #define NOTESITEM_H #include "AbstractDataPluginItem.h" #include namespace Marble { class NotesItem : public AbstractDataPluginItem { Q_OBJECT - public: - explicit NotesItem( QObject *parent ); +public: + explicit NotesItem(QObject *parent); ~NotesItem() override; bool initialized() const override; - void paint( QPainter *painter ) override; + void paint(QPainter *painter) override; - bool operator<( const AbstractDataPluginItem *other ) const override; + bool operator<(const AbstractDataPluginItem *other) const override; private: - static const QFont s_font; - static const int s_labelOutlineWidth; QPixmap m_pixmap; }; } #endif // NOTESITEM_H diff --git a/src/plugins/render/notes/NotesModel.cpp b/src/plugins/render/notes/NotesModel.cpp index 1b2c64815..287b41624 100644 --- a/src/plugins/render/notes/NotesModel.cpp +++ b/src/plugins/render/notes/NotesModel.cpp @@ -1,87 +1,85 @@ // // 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 2016 Spencer Brown +// Copyright 2017 Spencer Brown // #include "NotesModel.h" #include "NotesItem.h" #include "MarbleGlobal.h" #include "MarbleModel.h" #include "GeoDataCoordinates.h" #include "GeoDataLatLonAltBox.h" #include "MarbleDebug.h" #include "Planet.h" #include #include #include #include #include #include using namespace Marble; -NotesModel::NotesModel( const MarbleModel *marbleModel, QObject *parent ) - : AbstractDataPluginModel( "Notes", marbleModel, parent ) +NotesModel::NotesModel(const MarbleModel *marbleModel, QObject *parent) + : AbstractDataPluginModel("Notes", marbleModel, parent) { } -void NotesModel::getAdditionalItems( const GeoDataLatLonAltBox& box, qint32 number ) +void NotesModel::getAdditionalItems(const GeoDataLatLonAltBox& box, qint32 number) { - double left = box.west( GeoDataCoordinates::Degree ); - double bottom = box.south( GeoDataCoordinates::Degree ); - double right = box.east( GeoDataCoordinates::Degree ); - double top = box.north( GeoDataCoordinates::Degree ); + double left = box.west(GeoDataCoordinates::Degree); + double bottom = box.south(GeoDataCoordinates::Degree); + double right = box.east(GeoDataCoordinates::Degree); + double top = box.north(GeoDataCoordinates::Degree); QString bboxValue; - bboxValue.append(QString::number( left )).append(",").append(QString::number( bottom )).append(",").append(QString::number( right )).append(",").append(QString::number( top )); + bboxValue.append(QString::number(left)).append(",").append(QString::number(bottom)).append(",").append(QString::number(right)).append(",").append(QString::number(top)); - QUrl osmNotesApiUrl("http://api.openstreetmap.org/api/0.6/notes.json"); + QUrl osmNotesApiUrl("https://api.openstreetmap.org/api/0.6/notes.json"); QUrlQuery urlQuery; - urlQuery.addQueryItem( "bbox", bboxValue ); - urlQuery.addQueryItem ("limit", QString::number( number )); + urlQuery.addQueryItem("bbox", bboxValue); + urlQuery.addQueryItem("limit", QString::number(number)); osmNotesApiUrl.setQuery(urlQuery); - downloadDescriptionFile( osmNotesApiUrl ); + downloadDescriptionFile(osmNotesApiUrl); } -void NotesModel::parseFile( const QByteArray& file ) +void NotesModel::parseFile(const QByteArray& file) { QJsonDocument jsonDoc = QJsonDocument::fromJson(file); QJsonValue features = jsonDoc.object().value(QStringLiteral("features")); if (features.isArray()) { QList items; QJsonArray jsonArray = features.toArray(); for (auto jsonRef : jsonArray) { - QJsonObject jsonObj = jsonRef.toObject(); QJsonObject geometry = jsonObj.value(QStringLiteral("geometry")).toObject(); QJsonArray coordinates = geometry.value(QStringLiteral("coordinates")).toArray(); double longitude = coordinates.at(0).toDouble(); double latitude = coordinates.at(1).toDouble(); - GeoDataCoordinates coordinateset( longitude, latitude, 0.0, GeoDataCoordinates::Degree ); + GeoDataCoordinates coordinateset(longitude, latitude, 0.0, GeoDataCoordinates::Degree); QString id = QString::number(jsonObj.value(QStringLiteral("properties")).toObject().value(QStringLiteral("id")).toInt()); - qDebug() << id; - NotesItem *item = new NotesItem (this); - item->setId( id ); - item->setCoordinate( coordinateset ); + NotesItem *item = new NotesItem(this); + item->setId(id); + item->setCoordinate(coordinateset); items << item; } - addItemsToList( items ); + addItemsToList(items); } } #include "moc_NotesModel.cpp" diff --git a/src/plugins/render/notes/NotesModel.h b/src/plugins/render/notes/NotesModel.h index f1f667aaa..460b7a81e 100644 --- a/src/plugins/render/notes/NotesModel.h +++ b/src/plugins/render/notes/NotesModel.h @@ -1,31 +1,32 @@ // // 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 2016 Spencer Brown +// Copyright 2017 Spencer Brown // #ifndef NOTESMODEL_H #define NOTESMODEL_H #include "AbstractDataPluginModel.h" -namespace Marble { +namespace Marble +{ - class NotesModel : public AbstractDataPluginModel - { - Q_OBJECT +class NotesModel : public AbstractDataPluginModel +{ + Q_OBJECT - public: - explicit NotesModel( const MarbleModel *marbleModel, QObject *parent = 0 ); +public: + explicit NotesModel(const MarbleModel *marbleModel, QObject *parent = 0); - protected: - void getAdditionalItems( const GeoDataLatLonAltBox& box, qint32 number = 100 ) override; - void parseFile( const QByteArray& file ) override; - }; +protected: + void getAdditionalItems(const GeoDataLatLonAltBox& box, qint32 number = 10) override; + void parseFile(const QByteArray& file) override; +}; } #endif diff --git a/src/plugins/render/notes/NotesPlugin.cpp b/src/plugins/render/notes/NotesPlugin.cpp index 7e3198992..f52f93a6f 100644 --- a/src/plugins/render/notes/NotesPlugin.cpp +++ b/src/plugins/render/notes/NotesPlugin.cpp @@ -1,77 +1,77 @@ // // 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 2016 Spencer Brown +// Copyright 2017 Spencer Brown // #include "NotesPlugin.h" #include "NotesModel.h" #include using namespace Marble; NotesPlugin::NotesPlugin() - : AbstractDataPlugin( 0 ) + : AbstractDataPlugin(0) { } -NotesPlugin::NotesPlugin( const MarbleModel *marbleModel ) - : AbstractDataPlugin( marbleModel ) +NotesPlugin::NotesPlugin(const MarbleModel *marbleModel) + : AbstractDataPlugin(marbleModel) { - setEnabled( true ); - setVisible( false ); + setEnabled(true); + setVisible(false); } void NotesPlugin::initialize() { - setModel( new NotesModel( marbleModel(), this ) ); - setNumberOfItems( 20 ); + setModel(new NotesModel(marbleModel(), this)); + setNumberOfItems(20); } QString NotesPlugin::name() const { - return tr( "Notes Plugin" ); + return tr("Notes Plugin"); } QString NotesPlugin::guiString() const { - return tr( "Notes" ); + return tr("Notes"); } QString NotesPlugin::nameId() const { return QStringLiteral("notes"); } QString NotesPlugin::version() const { return QStringLiteral("1.0"); } QString NotesPlugin::copyrightYears() const { - return QStringLiteral("2016"); + return QStringLiteral("2017"); } QVector NotesPlugin::pluginAuthors() const { return QVector() - << PluginAuthor(QStringLiteral("Spencer Brown"), QStringLiteral("spencerbrown991@gmail.com")); + << PluginAuthor(QStringLiteral("Spencer Brown"), QStringLiteral("spencerbrown991@gmail.com")); } QString NotesPlugin::description() const { - return tr( "Show placemarks for Open Street Map notes." ); + return tr("Show OpenStreetMap Notes."); } QIcon NotesPlugin::icon() const { return QIcon(); } #include "moc_NotesPlugin.cpp" diff --git a/src/plugins/render/notes/NotesPlugin.h b/src/plugins/render/notes/NotesPlugin.h index c699c9a23..08b2f01fd 100644 --- a/src/plugins/render/notes/NotesPlugin.h +++ b/src/plugins/render/notes/NotesPlugin.h @@ -1,51 +1,52 @@ // // 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 2016 Spencer Brown +// Copyright 2017 Spencer Brown // #ifndef NOTESPLUGIN_H #define NOTESPLUGIN_H #include "AbstractDataPlugin.h" -namespace Marble { - -class NotesPlugin : public AbstractDataPlugin { +namespace Marble +{ +class NotesPlugin : public AbstractDataPlugin +{ Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.marble.NotesPlugin") - Q_INTERFACES( Marble::RenderPluginInterface ) - MARBLE_PLUGIN( NotesPlugin ) + Q_INTERFACES(Marble::RenderPluginInterface) + MARBLE_PLUGIN(NotesPlugin) - public: +public: NotesPlugin(); - explicit NotesPlugin( const MarbleModel *marbleModel ); + explicit NotesPlugin(const MarbleModel *marbleModel); void initialize() override; QString name() const override; QString guiString() const override; QString nameId() const override; QString version() const override; QString description() const override; QString copyrightYears() const override; QVector pluginAuthors() const override; QIcon icon() const override; }; } #endif // NOTESPLUGIN_H