File indexing completed on 2024-04-28 03:50:20

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2011 Daniel Marth <danielmarth@gmx.at>
0004 //
0005 
0006 #ifndef OPENCACHINGMODEL_H
0007 #define OPENCACHINGMODEL_H
0008 
0009 #include "AbstractDataPluginModel.h"
0010 #include <QDateTime>
0011 
0012 namespace Marble
0013 {
0014 
0015 class MarbleModel;
0016 
0017 class OpenCachingModelPrivate;
0018 
0019 namespace {
0020 // The maximum number of items we want to show on the screen.
0021 const quint32 numberOfItemsOnScreen = 20;
0022 }
0023 
0024 /**
0025  * Model that manages cache information.
0026  */
0027 class OpenCachingModel : public AbstractDataPluginModel
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032     explicit OpenCachingModel( const PluginManager *pluginManager, QObject *parent = 0 );
0033     ~OpenCachingModel();
0034 
0035     void setNumResults( int numResults );
0036     void setMaxDistance( int maxDistance );
0037     void setMinDifficulty( double minDifficulty );
0038     void setMaxDifficulty( double maxDifficulty );
0039     void setStartDate( const QDateTime& startDate );
0040     void setEndDate( const QDateTime& endDate );
0041 
0042 protected:
0043     /**
0044      * Generates the download url for the description file from the web service depending on
0045      * the @p box surrounding the view and the @p number of files to show.
0046      **/
0047     virtual void getAdditionalItems( const GeoDataLatLonAltBox& box,
0048                                      const MarbleModel *model,
0049                                      qint32 number = 10 );
0050 
0051     /**
0052      * Parses the @p file which getAdditionalItems downloads and
0053      * prepares the data for usage.
0054      **/
0055     void parseFile( const QByteArray& file );
0056 
0057 private:
0058     int m_numResults;
0059     int m_maxDistance;
0060     qreal m_minDifficulty;
0061     qreal m_maxDifficulty;
0062     QDateTime m_startDate;
0063     QDateTime m_endDate;
0064     OpenCachingModelPrivate *const d;
0065 };
0066 
0067 }
0068 
0069 #endif // OPENCACHINGMODEL_H