Commit a940024c authored by Stefan Brüns's avatar Stefan Brüns Committed by Torsten Rahn
Browse files

Remove obsolete KmlDocument and KmzHandler classes

parent 39811ab3
......@@ -6,7 +6,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/lib/marble/geodata/handlers/kml
)
set( kml_SRCS KmlDocument.cpp KmlParser.cpp KmlPlugin.cpp KmlRunner.cpp KmzHandler.cpp )
set( kml_SRCS KmlParser.cpp KmlPlugin.cpp KmlRunner.cpp)
marble_add_plugin( KmlPlugin ${kml_SRCS} )
......
//
// 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 2013 Dennis Nienhüser <nienhueser@kde.org>
#include "KmlDocument.h"
#include "MarbleDebug.h"
#include <QFile>
#include <QDir>
namespace Marble
{
KmlDocument::~KmlDocument()
{
for( const QString &file: m_files ) {
if ( !QFile::remove( file ) ) {
mDebug() << "Failed to remove temporary file" << file;
}
}
if ( !m_path.isEmpty() ) {
removeDirectoryRecursively( m_path );
}
}
void KmlDocument::setFiles( const QString &path, const QStringList &files )
{
m_path = path;
m_files = files;
}
void KmlDocument::removeDirectoryRecursively( const QString &path )
{
QStringList const subdirs = QDir( path ).entryList( QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot );
for( const QString &subdir: subdirs ) {
removeDirectoryRecursively(path + QLatin1Char('/') + subdir);
}
QDir::root().rmdir( path );
}
}
//
// 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 2013 Dennis Nienhüser <nienhueser@kde.org>
#ifndef MARBLE_KMLDOCUMENT_H
#define MARBLE_KMLDOCUMENT_H
#include "GeoDataDocument.h"
#include <QStringList>
namespace Marble {
class KmlDocument : public GeoDataDocument
{
public:
~KmlDocument() override;
/**
* @brief Temporary files to delete at destruction
* @param path Empty subdirectories below this directory will be deleted at destruction
* @param files List of files to delete at destruction
*/
void setFiles( const QString &path, const QStringList &files );
private:
void cleanupTemporaryFiles( const QString &path );
void removeDirectoryRecursively( const QString &path );
QString m_path;
QStringList m_files;
};
}
#endif
//
// 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 Dennis Nienhüser <nienhueser@kde.org>
#include "KmzHandler.h"
#include "MarbleDebug.h"
#include <MarbleZipReader.h>
#include <QDir>
#include <QUuid>
namespace Marble {
bool KmzHandler::open(const QString &kmz, QString &error)
{
MarbleZipReader zip( kmz );
if ( zip.status() != MarbleZipReader::NoError ) {
error = QStringLiteral("Failed to extract %1: error code %2").arg(kmz).arg(zip.status());
mDebug() << error;
return false;
}
QString const uuid = QUuid::createUuid().toString().mid(1, 8);
QString const filename = QDir::tempPath() + QLatin1String("/marble-kmz-") + uuid;
if (!QDir::root().mkpath(filename)) {
error = QStringLiteral("Failed to create temporary storage %1 for extracting %2").arg(filename).arg(kmz);
mDebug() << error;
return false;
}
m_kmzPath = filename + QLatin1Char('/');
if (!zip.extractAll( m_kmzPath ))
{
error = QStringLiteral("Failed to extract kmz file contents to %1").arg(m_kmzPath);
mDebug() << error;
return false;
}
for(const MarbleZipReader::FileInfo &fileInfo: zip.fileInfoList()) {
//if (!fileInfo.isFile) {
// continue;
//}
QString file = filename + QLatin1Char('/') + fileInfo.filePath;
m_kmzFiles << fileInfo.filePath;
if (file.endsWith(QLatin1String(".kml"), Qt::CaseInsensitive)) {
if ( !m_kmlFile.isEmpty() ) {
mDebug() << "File" << kmz << "contains more than one .kml files";
}
m_kmlFile = file;
}
}
return true;
}
QString KmzHandler::kmlFile() const
{
return m_kmlFile;
}
QString KmzHandler::kmzPath() const
{
return m_kmzPath;
}
QStringList KmzHandler::kmzFiles() const
{
return m_kmzFiles;
}
}
//
// 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 Dennis Nienhüser <nienhueser@kde.org>
#ifndef MARBLE_KMZHANDLER_H
#define MARBLE_KMZHANDLER_H
#include <QStringList>
namespace Marble {
class KmzHandler
{
public:
bool open(const QString &file, QString &error);
QString kmlFile() const;
QString kmzPath() const;
QStringList kmzFiles() const;
private:
QString m_kmlFile;
QString m_kmzPath;
QStringList m_kmzFiles;
};
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment