Subversion Repositories public

Rev

Rev 276 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
274 andreas 1
//
2
// C++ Implementation:
3
//
4
// Description:
5
//
6
//
7
// Author: Andreas Theofilu <andreas@theosys.at>, (C) 2009
8
//
9
// Copyright: See COPYING file that comes with this distribution
10
//
11
//
12
 
13
#include "config.h"
14
#include "shapewidget.h"
15
#include <KConfig>
16
#include <KUrlRequester>
17
#include <KLineEdit>
18
#include <QDir>
19
 
20
shapeWidget::shapeWidget (QWidget* parent, Qt::WFlags fl)
21
		: QDialog (parent, fl), Ui::shapeWidgetBase()
22
{
23
QString basePath;
24
QDir dir = QDir::home();
25
QString path = dir.absolutePath();
26
 
27
	setupUi (this);
28
	// Make sure we are useing only existing files on the local system.
29
	edShapeFileSet->setMode(KFile::ExistingOnly | KFile::LocalOnly);
30
	edPluginPath->setMode(KFile::ExistingOnly | KFile::LocalOnly);
31
	edFontPath->setMode(KFile::ExistingOnly | KFile::LocalOnly);
32
	edXmlFile->setMode(KFile::ExistingOnly | KFile::LocalOnly);
33
 
34
	// Get some already saved information from the config file
35
	KConfig cfg (QString("sportwatcher.rc"), KConfig::SimpleConfig);
36
	KConfigGroup ic (&cfg, "SportWatcher");
37
	KConfigGroup sh (&cfg, "ShapeFile");
38
	basePath = ic.readEntry("Data", path + "/.sportwatcher");
39
	edShapeFileSet->setUrl(ic.readEntry("MAP", basePath + "/shapefiles"));
40
	// Read the shape specific informations
41
#ifdef MAPNIK_PLUGINS
42
	edPluginPath->setUrl(QString(MAPNIK_PLUGINS));
43
	edPluginPath->setEnabled(false);
44
#else
45
	// Test some default path
46
	if (dir.exists(QString("/usr/lib/mapnik/input")))
47
	   edPluginPath->setUrl(sh.readEntry("PluginPath", QString("/usr/lib/mapnik/input")));
48
	else if (dir.exists(QString("/usr/local/lib/mapnik/input")))
49
	   edPluginPath->setUrl(sh.readEntry("PluginPath", QString("/usr/local/lib/mapnik/input")));
50
	else if (dir.exists(QString("/usr/lib/mapnik/0.6/input")))
51
	   edPluginPath->setUrl(sh.readEntry("PluginPath", QString("/usr/lib/mapnik/0.6/input")));
52
	else
53
	   edPluginPath->setUrl(sh.readEntry("PluginPath", QString("")));
54
#endif
55
#ifdef MAPNIK_FONTS
56
	edFontPath->setUrl(QString(MAPNIK_FONTS));
57
	edFontPath->setEnabled(false);
58
#else
59
	// Test some default path
60
	if (dir.exists(QString("/usr/lib/mapnik/fonts")))
61
	   edFontPath->setUrl(sh.readEntry("FontPath", QString("/usr/lib/mapnik/fonts")));
62
	else if (dir.exists(QString("/usr/local/lib/mapnik/fonts")))
63
	   edFontPath->setUrl(sh.readEntry("FontPath", QString("/usr/local/lib/mapnik/fonts")));
64
	else if (dir.exists(QString("/usr/share/mapnik/fonts")))
65
	   edFontPath->setUrl(sh.readEntry("FontPath", QString("/usr/share/mapnik/fonts")));
66
	else if (dir.exists(QString("/usr/share/fonts/truetype/ttf-dejavu")))
67
	   edFontPath->setUrl(sh.readEntry("FontPath", QString("/usr/share/fonts/truetype/ttf-dejavu")));
68
	else
69
	   edFontPath->setUrl(sh.readEntry("FontPath", QString("")));
70
#endif
71
	edXmlFile->setUrl(sh.readEntry("XmlFile", basePath + "/shapefiles/osm.xml"));
72
}
73
 
74
shapeWidget::~shapeWidget()
75
{
76
}
77
 
78
/*$SPECIALIZATION$*/
79
void shapeWidget::accept()
80
{
81
	KConfig cfg (QString("sportwatcher.rc"), KConfig::SimpleConfig);
82
	KConfigGroup ic (&cfg, "SportWatcher");
83
	KConfigGroup sh (&cfg, "ShapeFile");
84
	ic.writeEntry("MAP", edShapeFileSet->lineEdit()->text());
85
	sh.writeEntry("PluginPath", edPluginPath->lineEdit()->text());
86
	sh.writeEntry("FontPath", edFontPath->lineEdit()->text());
87
	sh.writeEntry("XmlFile", edXmlFile->lineEdit()->text());
88
	cfg.sync();
89
	done(QDialog::Accepted);
90
}
91
 
92
#include "shapewidget.moc"
93