2
// C++ Implementation: WMSServersList
7
// Author: cbro <cbro@semperpax.com>, (C) 2009
9
// Copyright: See COPYING file that comes with this distribution
13
#include <QApplication>
15
#include "WmsServersList.h"
16
#include "Preferences/MerkaartorPreferences.h"
18
WmsServer::WmsServer()
20
WmsServer(QApplication::translate("MerkaartorPreferences","New Server"), "", "", "", "", "", "");
23
WmsServer::WmsServer(const WmsServer& other)
24
: WmsName(other.WmsName), WmsAdress(other.WmsAdress), WmsPath(other.WmsPath), WmsLayers(other.WmsLayers),
25
WmsProjections(other.WmsProjections), WmsStyles(other.WmsStyles), WmsImgFormat(other.WmsImgFormat), deleted(other.deleted)
29
WmsServer::WmsServer(QString Name, QString Adress, QString Path, QString Layers, QString Projections, QString Styles, QString ImgFormat, bool Deleted)
30
: WmsName(Name), WmsAdress(Adress), WmsPath(Path), WmsLayers(Layers), WmsProjections(Projections), WmsStyles(Styles), WmsImgFormat(ImgFormat), deleted(Deleted)
33
WmsName = QApplication::translate("MerkaartorPreferences","New Server");
37
void WmsServer::toXml(QDomElement parent)
39
QDomElement p = parent.ownerDocument().createElement("WmsServer");
40
parent.appendChild(p);
41
p.setAttribute("name", WmsName);
42
p.setAttribute("address", WmsAdress);
43
p.setAttribute("path", WmsPath);
44
p.setAttribute("layers", WmsLayers);
45
p.setAttribute("projections", WmsProjections);
46
p.setAttribute("styles", WmsStyles);
47
p.setAttribute("format", WmsImgFormat);
49
p.setAttribute("deleted", "true");
52
WmsServer WmsServer::fromXml(QDomElement parent)
56
if (parent.tagName() == "WmsServer") {
57
theServer.WmsName = parent.attribute("name");
58
theServer.WmsAdress = parent.attribute("address");
59
theServer.WmsPath = parent.attribute("path");
60
theServer.WmsLayers = parent.attribute("layers");
61
theServer.WmsProjections = parent.attribute("projections");
62
theServer.WmsStyles = parent.attribute("styles");
63
theServer.WmsImgFormat = parent.attribute("format");
64
theServer.deleted = (parent.attribute("deleted") == "true" ? true : false);
72
void WmsServersList::add(WmsServersList aWmsServersList)
74
QMapIterator <QString, WmsServer> it(*(aWmsServersList.getServers()));
75
while (it.hasNext()) {
78
WmsServer anItem = it.value();
79
theServers.insert(anItem.WmsName, anItem);
83
WmsServerList* WmsServersList::getServers()
88
void WmsServersList::addServer(WmsServer aServer)
90
theServers.insert(aServer.WmsName, aServer);
93
bool WmsServersList::contains(QString name) const
95
if (theServers.contains(name))
98
WmsServerListIterator it(theServers);
99
while (it.hasNext()) {
102
if (it.key().contains(name, Qt::CaseInsensitive))
109
WmsServer WmsServersList::getServer(QString name) const
111
if (theServers.contains(name))
112
return theServers.value(name);
114
WmsServerListIterator it(theServers);
115
while (it.hasNext()) {
118
if (it.key().contains(name, Qt::CaseInsensitive))
125
void WmsServersList::toXml(QDomElement parent)
127
QDomElement rt = parent.ownerDocument().createElement("WmsServers");
128
parent.appendChild(rt);
129
rt.setAttribute("creator", QString("Merkaartor v%1%2").arg(STRINGIFY(VERSION)).arg(STRINGIFY(REVISION)));
131
WmsServerListIterator it(theServers);
132
while (it.hasNext()) {
135
WmsServer i = it.value();
140
WmsServersList WmsServersList::fromXml(QDomElement parent)
142
WmsServersList theServersList;
144
if (parent.nodeName() == "WmsServers") {
145
QDomElement c = parent.firstChildElement();
147
if (c.tagName() == "WmsServer") {
148
theServersList.addServer(WmsServer::fromXml(c));
151
c = c.nextSiblingElement();
155
return theServersList;