mirror of
git://projects.qi-hardware.com/nanomap.git
synced 2024-11-22 05:50:36 +02:00
move handling of application parameters to main.cpp
This commit is contained in:
parent
bf6b56644e
commit
4e98efe5a5
9
main.cpp
9
main.cpp
@ -24,7 +24,16 @@
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
MainWidget w;
|
MainWidget w;
|
||||||
|
|
||||||
|
if (QApplication::arguments().count() > 1) {
|
||||||
|
w.loadGpx(QApplication::arguments().at(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
QObject::connect(&w, SIGNAL(close()), &a, SLOT(quit()));
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,11 +42,6 @@ MainWidget::MainWidget(QWidget *parent)
|
|||||||
m_dlWidget(new DownloadWidget(this)),
|
m_dlWidget(new DownloadWidget(this)),
|
||||||
m_routingWidget(new RoutingWidget(this))
|
m_routingWidget(new RoutingWidget(this))
|
||||||
{
|
{
|
||||||
QString fileName;
|
|
||||||
if (QApplication::arguments().count() > 1) {
|
|
||||||
fileName = QApplication::arguments().at(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
layout->addWidget(m_stack);
|
layout->addWidget(m_stack);
|
||||||
@ -59,12 +54,6 @@ MainWidget::MainWidget(QWidget *parent)
|
|||||||
l->setVisible(false);
|
l->setVisible(false);
|
||||||
m_map->addLayer(l, 4);
|
m_map->addLayer(l, 4);
|
||||||
|
|
||||||
if (fileName.endsWith(".gpx")) {
|
|
||||||
l = new GpxLayer(m_map);
|
|
||||||
l->load(fileName);
|
|
||||||
m_map->addLayer(l, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
l = new MarkerLayer(m_map);
|
l = new MarkerLayer(m_map);
|
||||||
connect(l, SIGNAL(markerAdded(QString)), m_markerList, SLOT(addMarker(QString)));
|
connect(l, SIGNAL(markerAdded(QString)), m_markerList, SLOT(addMarker(QString)));
|
||||||
connect(m_markerList, SIGNAL(centerOnMarker(int)), l, SLOT(centerOnMarker(int)));
|
connect(m_markerList, SIGNAL(centerOnMarker(int)), l, SLOT(centerOnMarker(int)));
|
||||||
@ -76,6 +65,7 @@ MainWidget::MainWidget(QWidget *parent)
|
|||||||
l = new GpsLayer(m_map);
|
l = new GpsLayer(m_map);
|
||||||
m_map->addLayer(l, 1);
|
m_map->addLayer(l, 1);
|
||||||
|
|
||||||
|
connect(m_map, SIGNAL(close()), this, SIGNAL(close()));
|
||||||
connect(m_map, SIGNAL(showMarkerList()), this, SLOT(showList()));
|
connect(m_map, SIGNAL(showMarkerList()), this, SLOT(showList()));
|
||||||
connect(m_map, SIGNAL(downloadArea(int, QRectF)), this, SLOT(downloadArea(int, QRectF)));
|
connect(m_map, SIGNAL(downloadArea(int, QRectF)), this, SLOT(downloadArea(int, QRectF)));
|
||||||
connect(m_map, SIGNAL(route(QPointF, QPointF)), this, SLOT(findRoute(QPointF, QPointF)));
|
connect(m_map, SIGNAL(route(QPointF, QPointF)), this, SLOT(findRoute(QPointF, QPointF)));
|
||||||
@ -98,6 +88,15 @@ MainWidget::~MainWidget()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWidget::loadGpx(const QString &fileName)
|
||||||
|
{
|
||||||
|
if (fileName.endsWith(".gpx")) {
|
||||||
|
AbstractLayer *l = new GpxLayer(m_map);
|
||||||
|
l->load(fileName);
|
||||||
|
m_map->addLayer(l, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWidget::showList()
|
void MainWidget::showList()
|
||||||
{
|
{
|
||||||
m_stack->setCurrentIndex(1);
|
m_stack->setCurrentIndex(1);
|
||||||
|
@ -36,6 +36,11 @@ public:
|
|||||||
MainWidget(QWidget *parent = 0);
|
MainWidget(QWidget *parent = 0);
|
||||||
~MainWidget();
|
~MainWidget();
|
||||||
|
|
||||||
|
void loadGpx(const QString &fileName);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void close();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showList();
|
void showList();
|
||||||
void markerAdded(const QString &name);
|
void markerAdded(const QString &name);
|
||||||
|
Loading…
Reference in New Issue
Block a user