File indexing completed on 2024-05-19 15:05:34
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2011 Guillaume Martres <smarter@ubuntu.com> 0004 // 0005 0006 #ifndef MARBLE_TRACKERPLUGINMODEL_H 0007 #define MARBLE_TRACKERPLUGINMODEL_H 0008 0009 #include <QObject> 0010 0011 class QUrl; 0012 0013 namespace Marble 0014 { 0015 0016 class GeoDataTreeModel; 0017 class TrackerPluginItem; 0018 class TrackerPluginModelPrivate; 0019 0020 /** 0021 * A model used to download, store and update items 0022 */ 0023 class TrackerPluginModel : public QObject 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 /** 0029 * Constructs a model with the given @p treeModel and @p pluginManager. 0030 * 0031 * These parameters can be obtained by calling treeModel() and 0032 * pluginManager() on an instance of MarbleModel. 0033 */ 0034 explicit TrackerPluginModel( GeoDataTreeModel *treeModel ); 0035 0036 ~TrackerPluginModel() override; 0037 0038 void enable( bool enabled ); 0039 0040 /** 0041 * Add the item @p mark to the model. 0042 * 0043 * @see beginUpdateItems, endUpdateItems 0044 */ 0045 void addItem( TrackerPluginItem *mark ); 0046 0047 /** 0048 * Return all available items. 0049 */ 0050 QVector<TrackerPluginItem*> items() const; 0051 0052 /** 0053 * Remove all items from the model. 0054 */ 0055 void clear(); 0056 0057 /** 0058 * Begin a series of add or remove items operations on the model. 0059 * 0060 * Always call this method before adding or removing items to the model 0061 * and call endUpdateItems() once you're done updating the model. 0062 * @see endUpdateItems(), addItem() 0063 */ 0064 void beginUpdateItems(); 0065 0066 /** 0067 * End a series of add or remove items operations on the model. 0068 * 0069 * Always call this method once you're finished adding and removing items 0070 * to the model. 0071 * @see beginUpdateItems(), addItem(), removeItem() 0072 */ 0073 void endUpdateItems(); 0074 0075 /** 0076 * Adds @p url to the download queue. 0077 * Once the file is downloaded, parseFile() will be called with its first 0078 * parameter equals to @p id. 0079 */ 0080 void downloadFile( const QUrl &url, const QString &id ); 0081 0082 /** 0083 * This method is called whenever a file queued up for download by 0084 * downloadFile() has finished downloading, reimplement it to use it. 0085 * 0086 * @param id The @p id parameter passed to downloadFile() 0087 * @param file The content of the file 0088 */ 0089 virtual void parseFile( const QString &id, const QByteArray &file ); 0090 0091 Q_SIGNALS: 0092 void itemUpdateStarted(); 0093 void itemUpdateEnded(); 0094 void fileParsed( const QString &id ); 0095 0096 private: 0097 TrackerPluginModelPrivate *d; 0098 Q_PRIVATE_SLOT( d, void downloaded( const QString &, const QString & ) ); 0099 Q_PRIVATE_SLOT( d, void update() ); 0100 }; 0101 0102 } // namespace Marble 0103 0104 #endif // MARBLE_TRACKERPLUGINMODEL_H