Commit dbfb587d authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Fix parameter type change in Qt5

parent c9d7bf34
......@@ -76,19 +76,19 @@
</layer>
<layer name="standardplaces" backend="geodata">
<geodata name="cityplacemarks">
<sourcefile>cityplacemarks.kml</sourcefile>
<sourcefile>cityplacemarks.cache</sourcefile>
</geodata>
<geodata name="baseplacemarks">
<sourcefile>baseplacemarks.kml</sourcefile>
<sourcefile>baseplacemarks.cache</sourcefile>
</geodata>
<geodata name="elevplacemarks">
<sourcefile>elevplacemarks.kml</sourcefile>
<sourcefile>elevplacemarks.cache</sourcefile>
</geodata>
<geodata name="otherplacemarks">
<sourcefile>otherplacemarks.kml</sourcefile>
<sourcefile>otherplacemarks.cache</sourcefile>
</geodata>
<geodata name="boundaryplacemarks">
<sourcefile>boundaryplacemarks.kml</sourcefile>
<sourcefile>boundaryplacemarks.cache</sourcefile>
</geodata>
</layer>
</map>
......
......@@ -44,19 +44,19 @@
<layer name="standardplaces" backend="geodata">
<geodata name="cityplacemarks">
<sourcefile>cityplacemarks.kml</sourcefile>
<sourcefile>cityplacemarks.cache</sourcefile>
</geodata>
<geodata name="baseplacemarks">
<sourcefile>baseplacemarks.kml</sourcefile>
<sourcefile>baseplacemarks.cache</sourcefile>
</geodata>
<geodata name="elevplacemarks">
<sourcefile>elevplacemarks.kml</sourcefile>
<sourcefile>elevplacemarks.cache</sourcefile>
</geodata>
<geodata name="otherplacemarks">
<sourcefile>otherplacemarks.kml</sourcefile>
<sourcefile>otherplacemarks.cache</sourcefile>
</geodata>
<geodata name="boundaryplacemarks">
<sourcefile>boundaryplacemarks.kml</sourcefile>
<sourcefile>boundaryplacemarks.cache</sourcefile>
</geodata>
</layer>
</map>
......
......@@ -43,19 +43,19 @@
</layer>
<layer name="standardplaces" backend="geodata">
<geodata name="cityplacemarks">
<sourcefile>cityplacemarks.kml</sourcefile>
<sourcefile>cityplacemarks.cache</sourcefile>
</geodata>
<geodata name="baseplacemarks">
<sourcefile>baseplacemarks.kml</sourcefile>
<sourcefile>baseplacemarks.cache</sourcefile>
</geodata>
<geodata name="elevplacemarks">
<sourcefile>elevplacemarks.kml</sourcefile>
<sourcefile>elevplacemarks.cache</sourcefile>
</geodata>
<geodata name="otherplacemarks">
<sourcefile>otherplacemarks.kml</sourcefile>
<sourcefile>otherplacemarks.cache</sourcefile>
</geodata>
<geodata name="boundaryplacemarks">
<sourcefile>boundaryplacemarks.kml</sourcefile>
<sourcefile>boundaryplacemarks.cache</sourcefile>
</geodata>
</layer>
</map>
......
......@@ -62,19 +62,19 @@
<layer name="standardplaces" backend="geodata">
<geodata name="cityplacemarks">
<sourcefile>cityplacemarks.kml</sourcefile>
<sourcefile>cityplacemarks.cache</sourcefile>
</geodata>
<geodata name="baseplacemarks">
<sourcefile>baseplacemarks.kml</sourcefile>
<sourcefile>baseplacemarks.cache</sourcefile>
</geodata>
<geodata name="elevplacemarks">
<sourcefile>elevplacemarks.kml</sourcefile>
<sourcefile>elevplacemarks.cache</sourcefile>
</geodata>
<geodata name="otherplacemarks">
<sourcefile>otherplacemarks.kml</sourcefile>
<sourcefile>otherplacemarks.cache</sourcefile>
</geodata>
<geodata name="boundaryplacemarks">
<sourcefile>boundaryplacemarks.kml</sourcefile>
<sourcefile>boundaryplacemarks.cache</sourcefile>
</geodata>
</layer>
</map>
......
......@@ -74,19 +74,19 @@
<layer name="standardplaces" backend="geodata">
<geodata name="cityplacemarks">
<sourcefile>cityplacemarks.kml</sourcefile>
<sourcefile>cityplacemarks.cache</sourcefile>
</geodata>
<geodata name="baseplacemarks">
<sourcefile>baseplacemarks.kml</sourcefile>
<sourcefile>baseplacemarks.cache</sourcefile>
</geodata>
<geodata name="elevplacemarks">
<sourcefile>elevplacemarks.kml</sourcefile>
<sourcefile>elevplacemarks.cache</sourcefile>
</geodata>
<geodata name="otherplacemarks">
<sourcefile>otherplacemarks.kml</sourcefile>
<sourcefile>otherplacemarks.cache</sourcefile>
</geodata>
<geodata name="boundaryplacemarks">
<sourcefile>boundaryplacemarks.kml</sourcefile>
<sourcefile>boundaryplacemarks.cache</sourcefile>
</geodata>
</layer>
</map>
......
......@@ -74,19 +74,19 @@
<layer name="standardplaces" backend="geodata">
<geodata name="cityplacemarks">
<sourcefile>cityplacemarks.kml</sourcefile>
<sourcefile>cityplacemarks.cache</sourcefile>
</geodata>
<geodata name="baseplacemarks">
<sourcefile>baseplacemarks.kml</sourcefile>
<sourcefile>baseplacemarks.cache</sourcefile>
</geodata>
<geodata name="elevplacemarks">
<sourcefile>elevplacemarks.kml</sourcefile>
<sourcefile>elevplacemarks.cache</sourcefile>
</geodata>
<geodata name="otherplacemarks">
<sourcefile>otherplacemarks.kml</sourcefile>
<sourcefile>otherplacemarks.cache</sourcefile>
</geodata>
<geodata name="boundaryplacemarks">
<sourcefile>boundaryplacemarks.kml</sourcefile>
<sourcefile>boundaryplacemarks.cache</sourcefile>
</geodata>
</layer>
</map>
......
......@@ -60,19 +60,19 @@
<layer name="standardplaces" backend="geodata">
<geodata name="cityplacemarks">
<sourcefile>cityplacemarks.kml</sourcefile>
<sourcefile>cityplacemarks.cache</sourcefile>
</geodata>
<geodata name="baseplacemarks">
<sourcefile>baseplacemarks.kml</sourcefile>
<sourcefile>baseplacemarks.cache</sourcefile>
</geodata>
<geodata name="elevplacemarks">
<sourcefile>elevplacemarks.kml</sourcefile>
<sourcefile>elevplacemarks.cache</sourcefile>
</geodata>
<geodata name="otherplacemarks">
<sourcefile>otherplacemarks.kml</sourcefile>
<sourcefile>otherplacemarks.cache</sourcefile>
</geodata>
<geodata name="boundaryplacemarks">
<sourcefile>boundaryplacemarks.kml</sourcefile>
<sourcefile>boundaryplacemarks.cache</sourcefile>
</geodata>
</layer>
</map>
......
......@@ -90,19 +90,19 @@
<layer name="standardplaces" backend="geodata">
<geodata name="cityplacemarks">
<sourcefile>cityplacemarks.kml</sourcefile>
<sourcefile>cityplacemarks.cache</sourcefile>
</geodata>
<geodata name="baseplacemarks">
<sourcefile>baseplacemarks.kml</sourcefile>
<sourcefile>baseplacemarks.cache</sourcefile>
</geodata>
<geodata name="elevplacemarks">
<sourcefile>elevplacemarks.kml</sourcefile>
<sourcefile>elevplacemarks.cache</sourcefile>
</geodata>
<geodata name="otherplacemarks">
<sourcefile>otherplacemarks.kml</sourcefile>
<sourcefile>otherplacemarks.cache</sourcefile>
</geodata>
<geodata name="boundaryplacemarks">
<sourcefile>boundaryplacemarks.kml</sourcefile>
<sourcefile>boundaryplacemarks.cache</sourcefile>
</geodata>
</layer>
</map>
......
......@@ -74,19 +74,19 @@
<layer name="standardplaces" backend="geodata">
<geodata name="cityplacemarks">
<sourcefile>cityplacemarks.kml</sourcefile>
<sourcefile>cityplacemarks.cache</sourcefile>
</geodata>
<geodata name="baseplacemarks">
<sourcefile>baseplacemarks.kml</sourcefile>
<sourcefile>baseplacemarks.cache</sourcefile>
</geodata>
<geodata name="elevplacemarks">
<sourcefile>elevplacemarks.kml</sourcefile>
<sourcefile>elevplacemarks.cache</sourcefile>
</geodata>
<geodata name="otherplacemarks">
<sourcefile>otherplacemarks.kml</sourcefile>
<sourcefile>otherplacemarks.cache</sourcefile>
</geodata>
<geodata name="boundaryplacemarks">
<sourcefile>boundaryplacemarks.kml</sourcefile>
<sourcefile>boundaryplacemarks.cache</sourcefile>
</geodata>
</layer>
</map>
......
......@@ -75,19 +75,19 @@
<layer name="standardplaces" backend="geodata">
<geodata name="cityplacemarks">
<sourcefile>cityplacemarks.kml</sourcefile>
<sourcefile>cityplacemarks.cache</sourcefile>
</geodata>
<geodata name="baseplacemarks">
<sourcefile>baseplacemarks.kml</sourcefile>
<sourcefile>baseplacemarks.cache</sourcefile>
</geodata>
<geodata name="elevplacemarks">
<sourcefile>elevplacemarks.kml</sourcefile>
<sourcefile>elevplacemarks.cache</sourcefile>
</geodata>
<geodata name="otherplacemarks">
<sourcefile>otherplacemarks.kml</sourcefile>
<sourcefile>otherplacemarks.cache</sourcefile>
</geodata>
<geodata name="boundaryplacemarks">
<sourcefile>boundaryplacemarks.kml</sourcefile>
<sourcefile>boundaryplacemarks.cache</sourcefile>
</geodata>
</layer>
</map>
......
......@@ -42,10 +42,10 @@
<layer name="lunarplaces" backend="geodata">
<geodata name="moonlandingsites">
<sourcefile>moonlandingsites.kml</sourcefile>
<sourcefile>moonlandingsites.cache</sourcefile>
</geodata>
<geodata name="moonterrain">
<sourcefile>moonterrain.kml</sourcefile>
<sourcefile>moonterrain.cache</sourcefile>
</geodata>
</layer>
</map>
......
......@@ -75,9 +75,6 @@ public:
{
}
void saveFile(const QString& filename );
void savePlacemarks(QDataStream &out, const GeoDataContainer *container);
void createFilterProperties( GeoDataContainer *container );
int cityPopIdx( qint64 population ) const;
int spacePopIdx( qint64 population ) const;
......@@ -90,7 +87,6 @@ public:
bool m_recenter;
QString m_filepath;
QString m_contents;
QString m_nonExistentLocalCacheFile;
QString m_property;
GeoDataStyle* m_style;
DocumentRole m_documentRole;
......@@ -147,7 +143,6 @@ void FileLoader::run()
if ( path == "." ) path.clear();
QString name = fileinfo.completeBaseName();
QString suffix = fileinfo.suffix();
QString cacheFile;
// determine source, cache names
if ( fileinfo.isAbsolute() ) {
......@@ -157,40 +152,19 @@ void FileLoader::run()
else if ( d->m_filepath.contains( '/' ) ) {
// _relative_ path: "maps/mars/viking/patrick.kml"
defaultSourceName = MarbleDirs::path( path + '/' + name + '.' + suffix );
if ( !QFile::exists( defaultSourceName ) ) {
defaultSourceName = MarbleDirs::path( path + '/' + name + ".cache" );
}
}
else {
// _standard_ shared placemarks: "placemarks/patrick.kml"
defaultSourceName = MarbleDirs::path( "placemarks/" + path + name + '.' + suffix );
cacheFile = MarbleDirs::path( "placemarks/" + path + name + ".cache" );
if ( cacheFile.isEmpty()) {
cacheFile = MarbleDirs::localPath() + "/placemarks/" + path + name + ".cache";
if ( !QFileInfo( cacheFile ).exists() ) {
d->m_nonExistentLocalCacheFile = cacheFile;
}
if ( !QFile::exists( defaultSourceName ) ) {
defaultSourceName = MarbleDirs::path( "placemarks/" + path + name + ".cache" );
}
}
// if cache file more recent that source file, load cache file
if ( QFile::exists( cacheFile ) ) {
mDebug() << "Loading Cache File:" + cacheFile;
QDateTime sourceLastModified;
if ( QFile::exists( defaultSourceName ) ) {
sourceLastModified = QFileInfo( defaultSourceName ).lastModified();
}
const QDateTime cacheLastModified = QFileInfo( cacheFile ).lastModified();
if ( sourceLastModified <= cacheLastModified ) {
connect( &d->m_runner, SIGNAL(parsingFinished(GeoDataDocument*,QString)),
this, SLOT(documentParsed(GeoDataDocument*,QString)) );
d->m_runner.parseFile( cacheFile, d->m_documentRole );
}
}
// we load source file, multiple cases
else if ( QFile::exists( defaultSourceName ) ) {
if ( QFile::exists( defaultSourceName ) ) {
mDebug() << "No recent Default Placemark Cache File available!";
// use runners: pnt, gpx, osm
......@@ -238,67 +212,6 @@ bool FileLoader::recenter() const
return d->m_recenter;
}
const quint32 MarbleMagicNumber = 0x31415926;
void FileLoaderPrivate::saveFile( const QString& filename )
{
if ( !QDir( MarbleDirs::localPath() + "/placemarks/" ).exists() )
( QDir::root() ).mkpath( MarbleDirs::localPath() + "/placemarks/" );
mDebug() << "Creating cache at " << filename ;
QFile file( filename );
if ( !file.open( QIODevice::WriteOnly ) ) {
mDebug() << Q_FUNC_INFO << "Can't open" << filename << "for writing";
return;
}
QDataStream out( &file );
// Write a header with a "magic number" and a version
// out << (quint32)0xA0B0C0D0;
out << (quint32)MarbleMagicNumber;
out << (qint32)015;
out.setVersion( QDataStream::Qt_4_2 );
savePlacemarks(out, m_document);
}
void FileLoaderPrivate::savePlacemarks(QDataStream &out, const GeoDataContainer *container)
{
qreal lon;
qreal lat;
qreal alt;
const QVector<GeoDataPlacemark*> placemarks = container->placemarkList();
QVector<GeoDataPlacemark*>::const_iterator it = placemarks.constBegin();
QVector<GeoDataPlacemark*>::const_iterator const end = placemarks.constEnd();
for (; it != end; ++it ) {
out << (*it)->name();
(*it)->coordinate( m_clock->dateTime() ).geoCoordinates( lon, lat, alt );
// Use double to provide a single cache file format across architectures
out << (double)(lon) << (double)(lat) << (double)(alt);
out << QString( (*it)->role() );
out << QString( (*it)->description() );
out << QString( (*it)->countryCode() );
out << QString( (*it)->state() );
out << (double) (*it)->area();
out << (qint64) (*it)->population();
out << ( qint16 ) ( (*it)->extendedData().value("gmt").value().toInt() );
out << ( qint8 ) ( (*it)->extendedData().value("dst").value().toInt() );
}
const QVector<GeoDataFolder*> folders = container->folderList();
QVector<GeoDataFolder*>::const_iterator cont = folders.constBegin();
QVector<GeoDataFolder*>::const_iterator endcont = folders.constEnd();
for (; cont != endcont; ++cont ) {
savePlacemarks(out, *cont);
}
}
void FileLoaderPrivate::documentParsed( GeoDataDocument* doc, const QString& error )
{
m_error = error;
......@@ -312,9 +225,6 @@ void FileLoaderPrivate::documentParsed( GeoDataDocument* doc, const QString& err
createFilterProperties( doc );
emit q->newGeoDataDocumentAdded( m_document );
if ( !m_nonExistentLocalCacheFile.isEmpty() ) {
saveFile( m_nonExistentLocalCacheFile );
}
}
emit q->loaderFinished( q );
}
......
......@@ -23,6 +23,7 @@
#include <QRegion>
#include <QSizePolicy>
#include <QNetworkProxy>
#include <QMetaMethod>
#ifdef MARBLE_DBUS
#include <QDBusConnection>
......@@ -739,6 +740,7 @@ void MarbleWidget::resizeEvent( QResizeEvent *event )
QWidget::resizeEvent( event );
}
#if QT_VERSION < 0x050000
void MarbleWidget::connectNotify( const char * signal )
{
if ( QByteArray( signal ) ==
......@@ -754,6 +756,21 @@ void MarbleWidget::disconnectNotify( const char * signal )
if ( d->m_inputhandler )
d->m_inputhandler->setPositionSignalConnected( false );
}
#else
void MarbleWidget::connectNotify( const QMetaMethod &signal )
{
if ( d->m_inputhandler && signal == QMetaMethod::fromSignal( &MarbleWidget::mouseMoveGeoPosition ) ) {
d->m_inputhandler->setPositionSignalConnected( true );
}
}
void MarbleWidget::disconnectNotify( const QMetaMethod &signal )
{
if ( d->m_inputhandler && signal == QMetaMethod::fromSignal( &MarbleWidget::mouseMoveGeoPosition ) ) {
d->m_inputhandler->setPositionSignalConnected( false );
}
}
#endif
bool MarbleWidget::screenCoordinates( qreal lon, qreal lat,
qreal& x, qreal& y ) const
......
......@@ -1048,8 +1048,13 @@ class MARBLE_EXPORT MarbleWidget : public QWidget
*/
virtual void resizeEvent( QResizeEvent *event );
#if QT_VERSION < 0x050000
void connectNotify( const char * signal );
void disconnectNotify( const char * signal );
#else
virtual void connectNotify(const QMetaMethod &signal);
virtual void disconnectNotify(const QMetaMethod &signal);
#endif
/**
* @brief Reimplementation of the changeEvent() function in QWidget to
......
......@@ -6,6 +6,7 @@ add_subdirectory( asc2kml )
add_subdirectory( constellations2kml )
add_subdirectory( dso2kml )
add_subdirectory( iau2kml )
add_subdirectory( kml2cache )
add_subdirectory( kml2kml )
add_subdirectory( poly2kml )
add_subdirectory( pnt2svg )
......
SET (TARGET kml2cache)
PROJECT (${TARGET})
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${QT_INCLUDE_DIR}
)
if( QT4_FOUND )
include( ${QT_USE_FILE} )
endif()
set( ${TARGET}_SRC kml2cache.cpp )
add_definitions( -DMAKE_MARBLE_LIB )
add_executable( ${TARGET} ${${TARGET}_SRC} )
if (QT4_FOUND)
target_link_libraries( ${TARGET} ${QT_QTCORE_LIBRARY} ${QT_QTMAIN_LIBRARY} marblewidget )
else()
target_link_libraries( ${TARGET} ${Qt5Core_LIBRARIES} marblewidget )
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 2008 Patrick Spendrin <ps_ml@gmx.de>
// Copyright 2013 Dennis Nienhüser <earthwings@gentoo.org>
//
// A simple tool to read a .kml file and write it back to a .cache file
#include <MarbleWidget.h>
#include <MarbleClock.h>
#include <GeoDataParser.h>
#include <GeoDataDocument.h>
#include <GeoDataPlacemark.h>
#include <GeoDataExtendedData.h>
#include <GeoWriter.h>
#include <QDebug>
#include <QFile>
#include <iostream>
using namespace std;
using namespace Marble;
const quint32 MarbleMagicNumber = 0x31415926;
void savePlacemarks( QDataStream &out, const GeoDataContainer *container, MarbleClock* clock )
{
qreal lon;
qreal lat;
qreal alt;
const QVector<GeoDataPlacemark*> placemarks = container->placemarkList();
QVector<GeoDataPlacemark*>::const_iterator it = placemarks.constBegin();
QVector<GeoDataPlacemark*>::const_iterator const end = placemarks.constEnd();
for (; it != end; ++it ) {
out << (*it)->name();
(*it)->coordinate( clock->dateTime() ).geoCoordinates( lon, lat, alt );
// Use double to provide a single cache file format across architectures
out << (double)(lon) << (double)(lat) << (double)(alt);
out << QString( (*it)->role() );
out << QString( (*it)->description() );
out << QString( (*it)->countryCode() );
out << QString( (*it)->state() );
out << (double) (*it)->area();
out << (qint64) (*it)->population();
out << ( qint16 ) ( (*it)->extendedData().value("gmt").value().toInt() );
out << ( qint8 ) ( (*it)->extendedData().value("dst").value().toInt() );
}
const QVector<GeoDataFolder*> folders = container->folderList();
QVector<GeoDataFolder*>::const_iterator cont = folders.constBegin();
QVector<GeoDataFolder*>::const_iterator endcont = folders.constEnd();
for (; cont != endcont; ++cont ) {
savePlacemarks( out, *cont, clock );
}
}
void saveFile( const QString& filename, GeoDataDocument* document )
{
QFile file( filename );
if ( !file.open( QIODevice::WriteOnly ) ) {
qDebug() << Q_FUNC_INFO << "Can't open" << filename << "for writing";
return;
}
QDataStream out( &file );
// Write a header with a "magic number" and a version
// out << (quint32)0xA0B0C0D0;
out << (quint32)MarbleMagicNumber;
out << (qint32)015;
out.setVersion( QDataStream::Qt_4_2 );
savePlacemarks( out, document, new MarbleClock );
}
int main(int argc, char** argv)
{
if (argc != 3) {
cout << "Usage: " << argv[0] << " input.kml output.cache" << endl;
return 0;
}
QFile file(argv[1]);
file.open(QIODevice::ReadOnly);
GeoDataParser parser(GeoData_KML);
if ( !parser.read( &file ) ) {
cerr << "Error parsing '" << file.fileName().toStdString();
cerr << "': '" << parser.errorString().toStdString() << "'" << endl;
return 1;
}
GeoDataDocument