File indexing completed on 2024-04-21 03:49:33

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <tackat@kde.org>
0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
0005 //
0006 
0007 #ifndef MARBLE_FILEMANAGER_H
0008 #define MARBLE_FILEMANAGER_H
0009 
0010 #include "GeoDataDocument.h"
0011 
0012 #include <QObject>
0013 
0014 class QString;
0015 
0016 namespace Marble
0017 {
0018 
0019 class FileManagerPrivate;
0020 class FileLoader;
0021 class GeoDataLatLonBox;
0022 class GeoDataTreeModel;
0023 class PluginManager;
0024 
0025 /**
0026  * This class is responsible for loading the
0027  * different files into Geodata model.
0028  *
0029  * The loaded data are accessible via
0030  * various models in MarbleModel.
0031  */
0032 class MARBLE_EXPORT FileManager : public QObject
0033 {
0034     Q_OBJECT
0035 
0036  public:
0037     /**
0038      * Creates a new file manager.
0039      *
0040      * @param treeModel The GeoDataTreeModel model.
0041      * @param pluginManager The plugin manager.
0042      * @param parent The parent object.
0043      */
0044     explicit FileManager( GeoDataTreeModel *treeModel, const PluginManager *pluginManager, QObject *parent = nullptr );
0045 
0046     /**
0047      * Destroys the file manager.
0048      */
0049     ~FileManager() override;
0050 
0051     /**
0052      * Loads a new file into the manager.
0053      */
0054     void addFile(const QString &fileName, const QString &property, const GeoDataStyle::Ptr &style, DocumentRole role, int renderOrder = 0, bool recenter = false );
0055 
0056 
0057     /**
0058     * removes an existing file from the manager
0059     */
0060     void removeFile( const QString &fileName );
0061 
0062     /**
0063     * add Data containing KML code as string
0064     */
0065     void addData( const QString &name, const QString &data, DocumentRole role );
0066 
0067     void closeFile( const GeoDataDocument *document );
0068 
0069     int size() const;
0070     GeoDataDocument *at( const QString &key );
0071 
0072     /** Returns the number of files being opened at the moment */
0073     int pendingFiles() const;
0074 
0075  Q_SIGNALS:
0076     void fileAdded( const QString &key );
0077     void fileRemoved( const QString &key );
0078     void centeredDocument( const GeoDataLatLonBox& );
0079     void fileError(const QString &key, const QString& error);
0080 
0081  private:
0082 
0083     Q_PRIVATE_SLOT( d, void cleanupLoader( FileLoader *loader ) )
0084 
0085     Q_DISABLE_COPY( FileManager )
0086 
0087     friend class FileManagerPrivate;
0088     FileManagerPrivate *const d;
0089 };
0090 
0091 }
0092 
0093 #endif