Commit 45a6bffa authored by Dennis Nienhüser's avatar Dennis Nienhüser

Remove opencaching.com plugin (service is dead)

BUG: 381357
parent ce6cbb18
......@@ -34,7 +34,6 @@ add_subdirectory(foursquare)
# and terms of service of opencaching are cleared up.
#add_subdirectory( opencaching )
if(NOT MARBLE_NO_WEBKITWIDGETS)
add_subdirectory( opencachingcom )
add_subdirectory( opendesktop )
add_subdirectory( photo )
endif()
......
PROJECT( OpenCachingComPlugin )
INCLUDE_DIRECTORIES(
${CMAKE_BINARY_DIR}/src/plugins/render/opencachingcom
)
SET( my_SRCS
OpenCachingComPlugin.cpp
OpenCachingComModel.cpp
OpenCachingComItem.cpp
)
# SET( opencaching_UI OpenCachingConfigWidget.ui )
SET( cachedetailsdialog_UI CacheDetailsDialog.ui )
# QT_WRAP_UI(my_SRCS ${opencaching_UI})
QT_WRAP_UI(my_SRCS ${cachedetailsdialog_UI})
qt_add_resources(my_SRCS opencachingcom.qrc)
MARBLE_ADD_PLUGIN( OpenCachingComPlugin ${my_SRCS} )
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CacheDetailsDialog</class>
<widget class="QWidget" name="CacheDetailsDialog">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLabel" name="labelHeader">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="buttonWww">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabGeneral">
<property name="enabled">
<bool>true</bool>
</property>
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="labelGeneral">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>173</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelTagIcons">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabDescription">
<attribute name="title">
<string>Description</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="MarbleWebView" name="textDescription"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabHint">
<property name="enabled">
<bool>true</bool>
</property>
<attribute name="title">
<string>Hint</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QTextBrowser" name="textHint"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabLogs">
<attribute name="title">
<string>Logs</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QTextBrowser" name="textLogs"/>
</item>
</layout>
</widget>
</widget>
</item>
<item row="2" column="0" colspan="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>294</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2" colspan="2">
<widget class="QPushButton" name="buttonClose">
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header>QtWebKit/QWebView</header>
</customwidget>
<customwidget>
<class>Marble::MarbleWebView</class>
<extends>QWebView</extends>
<header>MarbleWebView.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
//
// 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 2012 Anders Lund <anders@alweb.dk>
//
#ifndef OPENCACHINGCOMITEM_H
#define OPENCACHINGCOMITEM_H
#include "AbstractDataPluginItem.h"
// #include "OpenCachingComCache.h"
#include <QVariantMap>
class QAction;
namespace Ui {
class CacheDetailsDialog;
}
namespace Marble
{
class OpenCachingComModel;
class OpenCachingComItem : public AbstractDataPluginItem
{
Q_OBJECT
public:
OpenCachingComItem( const QVariantMap& cache, OpenCachingComModel *parent );
~OpenCachingComItem() override;
bool initialized() const override;
void paint( QPainter *painter ) override;
QAction *action() override;
bool operator<( const AbstractDataPluginItem *other ) const override;
void addDownloadedFile( const QString &url, const QString &type ) override;
public Q_SLOTS:
void showInfoDialog();
private Q_SLOTS:
void dialogCloseClicked();
void openWww();
private:
void updateTooltip();
QString iconName() const;
static QString dateString(const QVariant& ms); ///< create a date string from millisecondssinceepoch in a qvariant
static const QString ratingNumberString(const QVariant& number); ///< "1" -> "1.0"
QString formatDistance(qreal spheredistance) const; ///< nice string from a Marble::distanceSphere()
void fillDialogTabs(); ///< loads description, hint and logs into the dialog tabs
Ui::CacheDetailsDialog *m_ui; ///< 0 unless dialog exists
OpenCachingComModel *const m_model;
QVariantMap m_cache;
QAction *const m_action;
QStringList m_images;
};
}
#endif // OPENCACHINGCOMITEM_H
//
// 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 2012 Anders Lund <anders@alweb.dk>
//
#include "OpenCachingComModel.h"
#include "OpenCachingComItem.h"
#include "MarbleGlobal.h"
#include "MarbleModel.h"
#include "GeoDataCoordinates.h"
#include "MarbleDebug.h"
#include <QDebug>
#include <QString>
#include <QUrl>
#include <QJsonDocument>
namespace Marble {
OpenCachingComModel::OpenCachingComModel( const MarbleModel *marbleModel, QObject *parent )
: AbstractDataPluginModel( "opencachingcom", marbleModel, parent )
{
// translate known values for tags and cache types
// What would be a nice place for this??? Put here, since this object is only
// constructed once.
// note to translators: "cache" in this context means "geocache",
// please refer to opencaching.com and wikipedia if in doubt.
tr("Boat required");
tr("Chirp");
tr("Diving");
tr("Exclusive");
tr("Historic site");
tr("Letterbox");
tr("Night");
tr("Tree climbing");
tr("UV light");
tr("Traditional Cache");
tr("Multi-cache");
tr("Virtual Cache");
tr("Puzzle Cache");
tr("Unknown Cache");
}
OpenCachingComModel::~OpenCachingComModel()
{
}
void OpenCachingComModel::getAdditionalItems( const GeoDataLatLonAltBox& box, qint32 number )
{
if (marbleModel()->planetId() != QLatin1String("earth")) {
return;
}
if ( m_previousbox.contains( box ) )
{
return;
}
QString url("http://www.opencaching.com/api/geocache/?Authorization=");
url += AUTHKEY + QStringLiteral("&bbox=%1,%2,%3,%4")
.arg( box.south( GeoDataCoordinates::Degree ) )
.arg( box.west(GeoDataCoordinates::Degree ) )
.arg( box.north(GeoDataCoordinates::Degree ) )
.arg( box.east(GeoDataCoordinates::Degree ) );
if(!m_previousbox.isNull())
{
url += QStringLiteral("&exclude_bbox=%1,%2,%3,%4")
.arg( m_previousbox.south( GeoDataCoordinates::Degree ) )
.arg( m_previousbox.west(GeoDataCoordinates::Degree ) )
.arg( m_previousbox.north(GeoDataCoordinates::Degree ) )
.arg( m_previousbox.east(GeoDataCoordinates::Degree ) );
}
url += QLatin1String("&limit=") + QString::number(number);
// TODO Limit to user set tags/types/difficulty - when there is a config dialog...
m_previousbox = box;
// qDebug()<<"Fetching more caches: "<<url;
downloadDescriptionFile( QUrl( url ) );
}
void OpenCachingComModel::parseFile( const QByteArray& file )
{
QJsonDocument jsonDoc = QJsonDocument::fromJson(file);
QVariantList caches = jsonDoc.toVariant().toList();
// qDebug()<<"parsing "<<caches.size()<<" items";
QList<AbstractDataPluginItem*> items;
while (!caches.isEmpty())
{
QVariantMap map = caches.takeFirst().toMap();
if ( !findItem( map["oxcode"].toString() ) )
{
items << new OpenCachingComItem( map, this );
}
}
addItemsToList(items);
}
void OpenCachingComModel::fetchData(const QUrl& url, const QString &type, OpenCachingComItem *item)
{
downloadItem(url, type, item);
}
const GeoDataCoordinates OpenCachingComModel::home() const
{
qreal lon, lat;
int zoom;
marbleModel()->home( lon, lat, zoom );
return GeoDataCoordinates(lon, lat, 0, GeoDataCoordinates::Degree);
}
} // namespace Marble
#include "moc_OpenCachingComModel.cpp"
//
// 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 2012 Anders Lund <anders@alweb.dk>
//
#ifndef OPENCACHINGCOMMODEL_H
#define OPENCACHINGCOMMODEL_H
#include "AbstractDataPluginModel.h"
#include "GeoDataLatLonAltBox.h"
// Please note and respect that this key is for use ONLY within this plugin.
#define AUTHKEY "mJg2Q5fD3qczP7M8"
namespace Marble
{
class MarbleModel;
class OpenCachingComItem;
namespace {
// The maximum number of items we want to show on the screen.
const quint32 numberOfItemsOnScreen = 100;
}
class OpenCachingComModel : public AbstractDataPluginModel
{
Q_OBJECT
public:
explicit OpenCachingComModel( const MarbleModel *marbleModel, QObject *parent = 0 );
~OpenCachingComModel() override;
/// Fetch a file for a cache
void fetchData(const QUrl &url, const QString &type, OpenCachingComItem *item);
/// home location
const GeoDataCoordinates home() const;
protected:
/**
* Generates the download url for the description file from the web service depending on
* the @p box surrounding the view and the @p number of files to show.
**/
void getAdditionalItems( const GeoDataLatLonAltBox& box,
qint32 number = numberOfItemsOnScreen ) override;
/**
* Parses the @p file which getAdditionalItems downloads and
* prepares the data for usage.
**/
void parseFile( const QByteArray& file ) override;
private:
GeoDataLatLonAltBox m_previousbox;
};
}
#endif // OPENCACHINGCOMMODEL_H
//
// 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 2012 Anders Lund <anders@alweb.dk>
//
#include "OpenCachingComPlugin.h"
#include "OpenCachingComModel.h"
#include <QIcon>
namespace Marble {
OpenCachingComPlugin::OpenCachingComPlugin()
: AbstractDataPlugin( 0 )
, m_isInitialized( false )
{
}
OpenCachingComPlugin::OpenCachingComPlugin(const MarbleModel *marbleModel)
: AbstractDataPlugin( marbleModel )
, m_isInitialized( false )
{
setEnabled( true ); // Plugin is enabled by default
setVisible( false ); // Plugin is invisible by default
}
void OpenCachingComPlugin::initialize()
{
OpenCachingComModel *model = new OpenCachingComModel( marbleModel(), this );
setModel( model );
setNumberOfItems( numberOfItemsOnScreen );
m_isInitialized = true;
}
bool OpenCachingComPlugin::isInitialized() const
{
return m_isInitialized;
}
QStringList OpenCachingComPlugin::backendTypes() const
{
return QStringList(QStringLiteral("opencaching.com"));
}
QString OpenCachingComPlugin::name() const
{
return tr( "OpenCaching.Com" );
}
QString OpenCachingComPlugin::guiString() const
{
return tr( "&OpenCaching.Com" );
}
QString OpenCachingComPlugin::nameId() const
{
return QStringLiteral("opencaching.com");
}
QString OpenCachingComPlugin::version() const
{
return QStringLiteral("1.0");
}
QString OpenCachingComPlugin::description() const
{
return tr( "Shows caches from OpenCaching.com on the map." );
}
QString OpenCachingComPlugin::copyrightYears() const
{
return QStringLiteral("2012");
}
QVector<PluginAuthor> OpenCachingComPlugin::pluginAuthors() const
{
return QVector<PluginAuthor>()
<< PluginAuthor(QStringLiteral("Anders Lund"), QStringLiteral("anders@alweb.dk"));
}
QIcon OpenCachingComPlugin::icon() const
{
return QIcon(QStringLiteral(":/occlogo.png"));
}
}
#include "moc_OpenCachingComPlugin.cpp"
//
// 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 2012 Anders Lund <anders@alweb.dk>
//
#ifndef OPENCACHINGCOMPLUGIN_H
#define OPENCACHINGCOMPLUGIN_H
#include "AbstractDataPlugin.h"
namespace Ui
{
// class OpenCachingConfigWidget;
}
namespace Marble
{
/**
* Plugin to display geocaches from opencaching.com on the map.
*/
class OpenCachingComPlugin : public AbstractDataPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.kde.marble.OpenCachingComPlugin")
Q_INTERFACES( Marble::RenderPluginInterface )
MARBLE_PLUGIN( OpenCachingComPlugin )
public:
OpenCachingComPlugin();
explicit OpenCachingComPlugin(const MarbleModel *marbleModel);
void initialize() override;
bool isInitialized() const override;
QStringList backendTypes() const override;
QString name() const override;
QString guiString() const override;