1
0
mirror of git://projects.qi-hardware.com/nanomap.git synced 2024-11-25 16:12:48 +02:00

replace combobox with listwidget to select the poi type

This commit is contained in:
Niels 2011-03-22 16:33:27 +01:00
parent 6bdf7c5f47
commit 3110a49a0d
2 changed files with 19 additions and 16 deletions

View File

@ -48,7 +48,7 @@ DownloadWidget::DownloadWidget(QWidget *parent)
m_levelSpinBox(new QSpinBox(this)), m_levelSpinBox(new QSpinBox(this)),
m_prefixInput(new QLineEdit(this)), m_prefixInput(new QLineEdit(this)),
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_poiTypes(new QListWidget(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_packageList(new QListWidget(this)),
@ -109,10 +109,7 @@ 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); layout->setRowStretch(0, 1);
label = new QLabel("Type:", this);
layout->addWidget(label, 0, 0);
QSettings set(QDir::homePath()+"/Maps/nanomap.conf", QSettings::NativeFormat); QSettings set(QDir::homePath()+"/Maps/nanomap.conf", QSettings::NativeFormat);
set.beginGroup("poi"); set.beginGroup("poi");
@ -123,17 +120,19 @@ DownloadWidget::DownloadWidget(QWidget *parent)
foreach (const QString &icon, icons) { foreach (const QString &icon, icons) {
QString name = icon; QString name = icon;
name.remove(".png"); name.remove(".png");
m_poiType->addItem(QIcon(iconPath+"/"+icon), name); QListWidgetItem *item = new QListWidgetItem(QIcon(iconPath+"/"+icon), name);
m_poiTypes->addItem(item);
} }
layout->addWidget(m_poiType, 0, 1, 1, 3); //m_poiTypes->setSelectionMode(QAbstractItemView::MultiSelection);
layout->addWidget(m_poiTypes, 0, 0, 1, 4);
m_makePOILayer->setChecked(true); m_makePOILayer->setChecked(true);
layout->addWidget(m_makePOILayer , 2, 0, 1, 4); layout->addWidget(m_makePOILayer , 1, 0, 1, 4);
label = new QLabel("Save to:", this); label = new QLabel("Save to:", this);
layout->addWidget(label , 3, 0); layout->addWidget(label , 2, 0);
layout->addWidget(m_destFilename, 3, 1, 1, 3); layout->addWidget(m_destFilename, 2, 1, 1, 3);
m_tabWidget->addTab(widget, "&Points of Interest"); m_tabWidget->addTab(widget, "&Points of Interest");
@ -327,12 +326,17 @@ void DownloadWidget::replyFinishedTiles(QNetworkReply *reply)
void DownloadWidget::startDownloadPOIs() void DownloadWidget::startDownloadPOIs()
{ {
QString baseUrl("http://azure.openstreetmap.org/xapi/api/0.6/node"); QListWidgetItem *item = m_poiTypes->currentItem();
QString key = m_poiType->currentText().section("-", 0, 0); if (!item) {
QString value = m_poiType->currentText().section("-", 1); return;
}
QString key = item->text().section("-", 0, 0);
QString value = item->text().section("-", 1);
QString keyValue = QString("[%1=%2]").arg(key, value); QString keyValue = QString("[%1=%2]").arg(key, value);
QString bbox = QString("[bbox=%1,%2,%3,%4]").arg(m_dlRect.left()).arg(m_dlRect.top()) QString bbox = QString("[bbox=%1,%2,%3,%4]").arg(m_dlRect.left()).arg(m_dlRect.top())
.arg(m_dlRect.right()).arg(m_dlRect.bottom()); .arg(m_dlRect.right()).arg(m_dlRect.bottom());
QString baseUrl("http://azure.openstreetmap.org/xapi/api/0.6/node");
QUrl url(baseUrl+keyValue+bbox); QUrl url(baseUrl+keyValue+bbox);
QNetworkReply *reply = m_manager->get(QNetworkRequest(url)); QNetworkReply *reply = m_manager->get(QNetworkRequest(url));
connect(reply, SIGNAL(downloadProgress(qint64, qint64)), connect(reply, SIGNAL(downloadProgress(qint64, qint64)),
@ -368,7 +372,7 @@ void DownloadWidget::replyFinishedPOIs(QNetworkReply *reply)
file.close(); file.close();
if (m_makePOILayer->isChecked()) { if (m_makePOILayer->isChecked()) {
emit loadFile(m_destFilename->text(), m_poiType->currentText().section("-", 1)); emit loadFile(m_destFilename->text(), m_poiTypes->currentItem()->text().section("-", 1));
} }
} }

View File

@ -21,7 +21,6 @@
#define DOWNLOADWIDGET_H #define DOWNLOADWIDGET_H
#include <QtGui/QCheckBox> #include <QtGui/QCheckBox>
#include <QtGui/QComboBox>
#include <QtGui/QLabel> #include <QtGui/QLabel>
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
#include <QtGui/QListWidget> #include <QtGui/QListWidget>
@ -87,7 +86,7 @@ private:
QSpinBox *m_levelSpinBox; QSpinBox *m_levelSpinBox;
QLineEdit *m_prefixInput; QLineEdit *m_prefixInput;
QCheckBox *m_skipExisting; QCheckBox *m_skipExisting;
QComboBox *m_poiType; QListWidget *m_poiTypes;
QCheckBox *m_makePOILayer; QCheckBox *m_makePOILayer;
QLineEdit *m_destFilename; QLineEdit *m_destFilename;
QListWidget *m_packageList; QListWidget *m_packageList;