summaryrefslogtreecommitdiffstats
path: root/kipi-plugins/gpssync/kmlexport.h
blob: 1f0ba5d7a1371d6aa3d3debcf14dc9a286932f0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/* ============================================================
 *
 * This file is a part of kipi-plugins project
 * http://www.kipi-plugins.org
 *
 * Date        : 2006-05-16
 * Description : a tool to export GPS data to KML file.
 *
 * Copyright (C) 2006-2007 by Stephane Pontier <shadow dot walker at free dot fr>
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * ============================================================ */

#ifndef KIPIKMLEXPORTKMLEXPORT_H
#define KIPIKMLEXPORTKMLEXPORT_H

// TQt includes.

#include <tqcolor.h>
#include <tqdir.h>
#include <tqdom.h>

// Local includes.

#include "kmlgpsdataparser.h"

class TQImage;

namespace KIPI 
{
    class BatchProgressDialog;
    class Interface;
}

namespace KIPIGPSSyncPlugin 
{

/**
Exporter to KML

	@author KIPI dev. team
*/
class kmlExport
{

public:

    kmlExport(KIPI::Interface* interface);
    ~kmlExport();

    bool createDir(TQDir dir);

    /*! generate the kml element for pictures with tumbnails
     *  @param interface the kipi interface
     *  @param KURL the URL of the picture
     *  @param kmlAlbum the album used
     */
    void generateImagesthumb(KIPI::Interface* interface, const KURL&, TQDomElement &kmlAlbum);

    /*! Produce a web-friendly file name
     *  otherwise, while google earth works fine, maps.google.com may not find pictures and thumbnail
     *  thank htmlexport
     *  @param the filename
     *  @return the webifyed filename
     */
    TQString webifyFileName(const TQString &fileName);

    /*! Generate a square thumbnail from @fullImage of @size x @size pixels
     *  @param fullImage the original image
     *  @param size the size of the thumbnail
     *  @return the thumbnail
     */
    TQImage generateSquareThumbnail(const TQImage& fullImage, int size);

    /*! Generate a square thumbnail from @fullImage of @size x @size pixels
     *  with a white border
     *  @param fullImage the original image
     *  @param size the size of the thumbnail
     *  @return the thumbnail
     */
    TQImage generateBorderedThumbnail(const TQImage& fullImage, int size);
    void   addTrack(TQDomElement &kmlAlbum);
    void   generate();
    int    getConfig();

public:

    bool             m_localTarget;
    bool             m_optimize_googlemap;
    bool             m_GPXtracks;

    int              m_iconSize;
    int              m_googlemapSize;
    int              m_size;
    int              m_altitudeMode;
    int              m_TimeZone;
    int              m_LineWidth;
    int              m_GPXOpacity;
    int              m_GPXAltitudeMode;

    /** directory used in kmldocument structure */
    TQString          m_imageDir;
    TQString          m_GPXFile;
    TQString          m_UrlDestDir;

    /** temporary directory where everything will be created */
    TQString          m_tempDestDir;

    /** directory selected by user*/
    TQString          m_baseDestDir;

    TQString          m_imgdir;
    TQString          m_KMLFileName;

    TQColor           m_GPXColor;

    KIPI::Interface *m_interface;

private:

    /*! the root document, used to create all TQDomElements */
    TQDomDocument              *kmlDocument;

    /*! the GPS parsed data */
    KMLGPSDataParser           m_gpxParser;

    KIPI::BatchProgressDialog *m_progressDialog;

private:

    void logInfo(const TQString& msg);
    void logError(const TQString& msg);
    void logWarning(const TQString& msg);

    /*!
     *  \fn KIPIKMLExport::kmlExport::addKmlElement(TQDomElement target, TQString tag)
     *  Add a new element
     *  @param target the parent element to which add the element
     *  @param tag the new element name
     *  @return the New element
     */
    TQDomElement addKmlElement(TQDomElement &target, TQString tag)
    {
        TQDomElement kmlElement = kmlDocument->createElement( tag );
        target.appendChild( kmlElement );
        return kmlElement;
    }

    /*!
     *  \fn KIPIKMLExport::kmlExport::addKmlTextElement(TQDomElement target, TQString tag, TQString text)
     *  Add a new element with a text
     *  @param target the parent element to which add the element
     *  @param tag the new element name
     *  @param text the text content of the new element
     *  @return the New element
     */
    TQDomElement addKmlTextElement(TQDomElement &target, TQString tag, TQString text)
    {
        TQDomElement kmlElement  = kmlDocument->createElement( tag );
        target.appendChild( kmlElement );
        TQDomText kmlTextElement = kmlDocument->createTextNode( text );
        kmlElement.appendChild( kmlTextElement );
        return kmlElement;
    }

    /*!
     *  \fn KIPIKMLExport::kmlExport::addKmlHtmlElement(TQDomElement target, TQString tag, TQString text)
     *  Add a new element with html content (html entities are escaped and text is wrapped in a CDATA section)
     *  @param target the parent element to which add the element
     *  @param tag the new element name
     *  @param text the HTML content of the new element
     *  @return the New element
     */
    TQDomElement addKmlHtmlElement(TQDomElement &target, TQString tag, TQString text)
    {
        TQDomElement kmlElement  = kmlDocument->createElement( tag );
        target.appendChild( kmlElement );
        TQDomText kmlTextElement = kmlDocument->createCDATASection( text );
        kmlElement.appendChild( kmlTextElement );
        return kmlElement;
    }
};

} // namespace KIPIGPSSyncPlugin

#endif // KIPIKMLEXPORTKMLEXPORT_H