mirror of
git://projects.qi-hardware.com/nanomap.git
synced 2024-11-21 23:19:42 +02:00
add not (yet) working downloader for routing data
This commit is contained in:
parent
8d77601115
commit
f86e246ddb
@ -26,7 +26,6 @@
|
|||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtGui/QLayout>
|
#include <QtGui/QLayout>
|
||||||
#include <QtNetwork/QNetworkReply>
|
|
||||||
#include <QtNetwork/QNetworkRequest>
|
#include <QtNetwork/QNetworkRequest>
|
||||||
|
|
||||||
DownloadWidget::DownloadWidget(QWidget *parent)
|
DownloadWidget::DownloadWidget(QWidget *parent)
|
||||||
@ -40,6 +39,7 @@ DownloadWidget::DownloadWidget(QWidget *parent)
|
|||||||
m_startLevel(0),
|
m_startLevel(0),
|
||||||
m_dlRect(),
|
m_dlRect(),
|
||||||
m_dlList(),
|
m_dlList(),
|
||||||
|
m_currentDownload(0),
|
||||||
m_prefix("OSM"),
|
m_prefix("OSM"),
|
||||||
m_up(new QLabel("N 0", this)),
|
m_up(new QLabel("N 0", this)),
|
||||||
m_left(new QLabel("E 0", this)),
|
m_left(new QLabel("E 0", this)),
|
||||||
@ -50,7 +50,9 @@ DownloadWidget::DownloadWidget(QWidget *parent)
|
|||||||
m_skipExisting(new QCheckBox("S&kip already downloaded tiles", this)),
|
m_skipExisting(new QCheckBox("S&kip already downloaded tiles", this)),
|
||||||
m_poiType(new QComboBox(this)),
|
m_poiType(new QComboBox(this)),
|
||||||
m_makePOILayer(new QCheckBox("&Load file after download", this)),
|
m_makePOILayer(new QCheckBox("&Load file after download", this)),
|
||||||
m_destFilename(new QLineEdit(QDir::homePath()+"/pois.osm", this))
|
m_destFilename(new QLineEdit(QDir::homePath()+"/pois.osm", this)),
|
||||||
|
m_packageList(new QListWidget(this)),
|
||||||
|
m_destDir(new QLineEdit(QDir::homePath(), this))
|
||||||
{
|
{
|
||||||
QGridLayout *layout = new QGridLayout(this);
|
QGridLayout *layout = new QGridLayout(this);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
@ -87,13 +89,13 @@ DownloadWidget::DownloadWidget(QWidget *parent)
|
|||||||
label->setFrameShape(QLabel::Box);
|
label->setFrameShape(QLabel::Box);
|
||||||
layout->addWidget(label, 1, 1, 1, 2);
|
layout->addWidget(label, 1, 1, 1, 2);
|
||||||
|
|
||||||
label = new QLabel("Download up to level", this);
|
label = new QLabel("Download up to level:", this);
|
||||||
layout->addWidget(label, 3, 0, 1, 2);
|
layout->addWidget(label, 3, 0, 1, 2);
|
||||||
|
|
||||||
m_levelSpinBox->setRange(0, 18);
|
m_levelSpinBox->setRange(0, 18);
|
||||||
layout->addWidget(m_levelSpinBox, 3, 2, 1, 2);
|
layout->addWidget(m_levelSpinBox, 3, 2, 1, 2);
|
||||||
|
|
||||||
label = new QLabel("Download into directory", this);
|
label = new QLabel("Download into directory:", this);
|
||||||
layout->addWidget(label, 4, 0, 1, 2);
|
layout->addWidget(label, 4, 0, 1, 2);
|
||||||
|
|
||||||
m_prefixInput->setText(m_prefix);
|
m_prefixInput->setText(m_prefix);
|
||||||
@ -138,10 +140,22 @@ DownloadWidget::DownloadWidget(QWidget *parent)
|
|||||||
widget = new QWidget(this);
|
widget = new QWidget(this);
|
||||||
layout = new QGridLayout(widget);
|
layout = new QGridLayout(widget);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
layout->setRowStretch(1, 1);
|
||||||
|
|
||||||
label = new QLabel("TODO", this);
|
label = new QLabel("This Page does not work yet!!!", this);
|
||||||
label->setAlignment(Qt::AlignCenter);
|
label->setAlignment(Qt::AlignCenter);
|
||||||
layout->addWidget(label, 0, 0);
|
layout->addWidget(label, 0, 0, 1, 2);
|
||||||
|
|
||||||
|
QPushButton *updateList = new QPushButton("Update list", this);
|
||||||
|
connect(updateList, SIGNAL(clicked()), this, SLOT(updateSourceList()));
|
||||||
|
layout->addWidget(updateList, 0, 2);
|
||||||
|
|
||||||
|
layout->addWidget(m_packageList, 1, 0, 1, 3);
|
||||||
|
|
||||||
|
label = new QLabel("Download into directory:", this);
|
||||||
|
layout->addWidget(label, 2, 0);
|
||||||
|
|
||||||
|
layout->addWidget(m_destDir, 2, 1, 1, 2);
|
||||||
|
|
||||||
m_tabWidget->addTab(widget, "&Routing data");
|
m_tabWidget->addTab(widget, "&Routing data");
|
||||||
|
|
||||||
@ -204,6 +218,16 @@ void DownloadWidget::replyFinished(QNetworkReply *reply)
|
|||||||
case POIs:
|
case POIs:
|
||||||
replyFinishedPOIs(reply);
|
replyFinishedPOIs(reply);
|
||||||
break;
|
break;
|
||||||
|
case SourceList:
|
||||||
|
if (reply->error() == QNetworkReply::NoError) {
|
||||||
|
QStringList list = QString::fromUtf8(reply->readAll().constData()).split("\n");
|
||||||
|
foreach (const QString &pkg, list) {
|
||||||
|
QListWidgetItem *item = new QListWidgetItem(pkg.section('@', 0, 0));
|
||||||
|
item->setData(Qt::UserRole, QVariant(pkg.section('@', 1)));
|
||||||
|
m_packageList->addItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
@ -214,6 +238,26 @@ void DownloadWidget::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
|||||||
m_dlProgress->setValue(bytesReceived);
|
m_dlProgress->setValue(bytesReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DownloadWidget::saveDownload()
|
||||||
|
{
|
||||||
|
if (m_currentDownload->error() != QNetworkReply::NoError) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QString path = m_currentDownload->url().path().section("/", -2);
|
||||||
|
QByteArray a = m_currentDownload->readAll();
|
||||||
|
|
||||||
|
QFile file(m_destDir->text()+"/"+path);
|
||||||
|
if (file.open(QFile::WriteOnly)) {
|
||||||
|
file.write(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DownloadWidget::updateSourceList()
|
||||||
|
{
|
||||||
|
m_downloadMode = SourceList;
|
||||||
|
m_manager->get(QNetworkRequest(QUrl("http://host.domain.tld/path/source.list")));
|
||||||
|
}
|
||||||
|
|
||||||
void DownloadWidget::startDownloadTiles()
|
void DownloadWidget::startDownloadTiles()
|
||||||
{
|
{
|
||||||
m_prefix = m_prefixInput->text();
|
m_prefix = m_prefixInput->text();
|
||||||
@ -330,10 +374,33 @@ void DownloadWidget::replyFinishedPOIs(QNetworkReply *reply)
|
|||||||
|
|
||||||
void DownloadWidget::startDownloadPackages()
|
void DownloadWidget::startDownloadPackages()
|
||||||
{
|
{
|
||||||
QUrl url("http://download../...");
|
QListWidgetItem *item = m_packageList->currentItem();
|
||||||
QNetworkReply *reply = m_manager->get(QNetworkRequest(url));
|
if (!item) {
|
||||||
connect(reply, SIGNAL(downloadProgress(qint64, qint64)),
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString baseUrl = item->data(Qt::UserRole).toString();
|
||||||
|
m_dlList << baseUrl+"Contraction Hierarchies_config";
|
||||||
|
m_dlList << baseUrl+"Contraction Hierarchies_edges";
|
||||||
|
m_dlList << baseUrl+"Contraction Hierarchies_names";
|
||||||
|
m_dlList << baseUrl+"Contraction Hierarchies_paths";
|
||||||
|
m_dlList << baseUrl+"Contraction Hierarchies_types";
|
||||||
|
m_dlList << baseUrl+"GPSGrid_config";
|
||||||
|
m_dlList << baseUrl+"GPSGrid_grid";
|
||||||
|
m_dlList << baseUrl+"GPSGrid_index_1";
|
||||||
|
m_dlList << baseUrl+"GPSGrid_index_2";
|
||||||
|
m_dlList << baseUrl+"GPSGrid_index_3";
|
||||||
|
m_dlList << baseUrl+"OSM Renderer_settings";
|
||||||
|
m_dlList << baseUrl+"plugins.ini";
|
||||||
|
m_dlList << baseUrl+"Unicode Tournament Trie_main";
|
||||||
|
m_dlList << baseUrl+"Unicode Tournament Trie_sub";
|
||||||
|
m_dlList << baseUrl+"Unicode Tournament Trie_ways";
|
||||||
|
|
||||||
|
m_currentDownload = m_manager->get(QNetworkRequest(QUrl(m_dlList.takeFirst())));
|
||||||
|
connect(m_currentDownload, SIGNAL(downloadProgress(qint64, qint64)),
|
||||||
this, SLOT(downloadProgress(qint64, qint64)));
|
this, SLOT(downloadProgress(qint64, qint64)));
|
||||||
|
connect(m_currentDownload, SIGNAL(readReady()),
|
||||||
|
this, SLOT(saveDownload()));
|
||||||
|
|
||||||
m_dlProgress->show();
|
m_dlProgress->show();
|
||||||
m_dlProgress->setValue(0);
|
m_dlProgress->setValue(0);
|
||||||
@ -347,10 +414,19 @@ void DownloadWidget::replyFinishedPackages(QNetworkReply *reply)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(reply)
|
Q_UNUSED(reply)
|
||||||
|
|
||||||
m_dlProgress->hide();
|
if (m_dlList.isEmpty()) {
|
||||||
m_tabWidget->setEnabled(true);
|
m_dlProgress->hide();
|
||||||
m_startButton->setEnabled(true);
|
m_tabWidget->setEnabled(true);
|
||||||
m_backButton->setEnabled(true);
|
m_startButton->setEnabled(true);
|
||||||
|
m_backButton->setEnabled(true);
|
||||||
|
} else {
|
||||||
|
QUrl url(m_dlList.takeFirst());
|
||||||
|
m_currentDownload = m_manager->get(QNetworkRequest(url));
|
||||||
|
connect(m_currentDownload, SIGNAL(downloadProgress(qint64, qint64)),
|
||||||
|
this, SLOT(downloadProgress(qint64, qint64)));
|
||||||
|
connect(m_currentDownload, SIGNAL(readReady()),
|
||||||
|
this, SLOT(saveDownload()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DownloadWidget::lon2string(qreal lon)
|
QString DownloadWidget::lon2string(qreal lon)
|
||||||
|
@ -24,12 +24,14 @@
|
|||||||
#include <QtGui/QComboBox>
|
#include <QtGui/QComboBox>
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
#include <QtGui/QLineEdit>
|
#include <QtGui/QLineEdit>
|
||||||
|
#include <QtGui/QListWidget>
|
||||||
#include <QtGui/QProgressBar>
|
#include <QtGui/QProgressBar>
|
||||||
#include <QtGui/QPushButton>
|
#include <QtGui/QPushButton>
|
||||||
#include <QtGui/QSpinBox>
|
#include <QtGui/QSpinBox>
|
||||||
#include <QtGui/QTabWidget>
|
#include <QtGui/QTabWidget>
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
#include <QtNetwork/QNetworkAccessManager>
|
#include <QtNetwork/QNetworkAccessManager>
|
||||||
|
#include <QtNetwork/QNetworkReply>
|
||||||
|
|
||||||
class DownloadWidget : public QWidget
|
class DownloadWidget : public QWidget
|
||||||
{
|
{
|
||||||
@ -49,12 +51,15 @@ private slots:
|
|||||||
void startDownload();
|
void startDownload();
|
||||||
void replyFinished(QNetworkReply *reply);
|
void replyFinished(QNetworkReply *reply);
|
||||||
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
||||||
|
void saveDownload();
|
||||||
|
void updateSourceList();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum DownloadMode {
|
enum DownloadMode {
|
||||||
Tiles,
|
Tiles,
|
||||||
POIs,
|
POIs,
|
||||||
Packages
|
Packages,
|
||||||
|
SourceList
|
||||||
};
|
};
|
||||||
|
|
||||||
void startDownloadTiles();
|
void startDownloadTiles();
|
||||||
@ -76,6 +81,7 @@ private:
|
|||||||
int m_startLevel;
|
int m_startLevel;
|
||||||
QRectF m_dlRect;
|
QRectF m_dlRect;
|
||||||
QStringList m_dlList;
|
QStringList m_dlList;
|
||||||
|
QNetworkReply *m_currentDownload;
|
||||||
QString m_prefix;
|
QString m_prefix;
|
||||||
QLabel *m_up, *m_left, *m_right, *m_bottom;
|
QLabel *m_up, *m_left, *m_right, *m_bottom;
|
||||||
QSpinBox *m_levelSpinBox;
|
QSpinBox *m_levelSpinBox;
|
||||||
@ -84,6 +90,8 @@ private:
|
|||||||
QComboBox *m_poiType;
|
QComboBox *m_poiType;
|
||||||
QCheckBox *m_makePOILayer;
|
QCheckBox *m_makePOILayer;
|
||||||
QLineEdit *m_destFilename;
|
QLineEdit *m_destFilename;
|
||||||
|
QListWidget *m_packageList;
|
||||||
|
QLineEdit *m_destDir;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user