1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-02-21 10:10:49 +01:00

Enable loading of multiple map files at once

This commit is contained in:
Martin Tůma 2018-01-29 22:43:55 +01:00
parent fbc0fd86cf
commit c90a03e22c
2 changed files with 25 additions and 17 deletions

View File

@ -661,8 +661,6 @@ void GUI::openFile()
bool GUI::openFile(const QString &fileName) bool GUI::openFile(const QString &fileName)
{ {
bool ret = true;
if (fileName.isEmpty() || _files.contains(fileName)) if (fileName.isEmpty() || _files.contains(fileName))
return false; return false;
@ -677,13 +675,14 @@ bool GUI::openFile(const QString &fileName)
updateWindowTitle(); updateWindowTitle();
updateGraphTabs(); updateGraphTabs();
updateMapView(); updateMapView();
return true;
} else { } else {
if (_files.isEmpty()) if (_files.isEmpty())
_fileActionGroup->setEnabled(false); _fileActionGroup->setEnabled(false);
ret = false;
}
return ret; return false;
}
} }
bool GUI::loadFile(const QString &fileName) bool GUI::loadFile(const QString &fileName)
@ -1117,30 +1116,38 @@ void GUI::showGraphSliderInfo(bool show)
void GUI::loadMap() void GUI::loadMap()
{ {
QString fileName = QFileDialog::getOpenFileName(this, tr("Open map file"), QStringList files = QFileDialog::getOpenFileNames(this, tr("Open map file"),
QString(), MapList::formats()); QString(), MapList::formats());
QStringList list = files;
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
loadMap(*it);
}
bool GUI::loadMap(const QString &fileName)
{
if (fileName.isEmpty()) if (fileName.isEmpty())
return; return false;
int count = _ml->maps().count();
if (_ml->loadFile(fileName)) { if (_ml->loadFile(fileName)) {
for (int i = count; i < _ml->maps().count(); i++) { QAction *a = new QAction(_ml->maps().last()->name(), this);
QAction *a = new QAction(_ml->maps().at(i)->name(), this); a->setCheckable(true);
a->setCheckable(true); a->setActionGroup(_mapsActionGroup);
a->setActionGroup(_mapsActionGroup); _mapsSignalMapper->setMapping(a, _ml->maps().size() - 1);
_mapsSignalMapper->setMapping(a, i); connect(a, SIGNAL(triggered()), _mapsSignalMapper, SLOT(map()));
connect(a, SIGNAL(triggered()), _mapsSignalMapper, SLOT(map())); _mapActions.append(a);
_mapActions.append(a); _mapMenu->insertAction(_mapsEnd, a);
_mapMenu->insertAction(_mapsEnd, a);
}
_showMapAction->setEnabled(true); _showMapAction->setEnabled(true);
_clearMapCacheAction->setEnabled(true); _clearMapCacheAction->setEnabled(true);
_mapActions.last()->activate(QAction::Trigger); _mapActions.last()->activate(QAction::Trigger);
return true;
} else { } else {
QString error = tr("Error loading map:") + "\n\n" QString error = tr("Error loading map:") + "\n\n"
+ fileName + "\n\n" + _ml->errorString(); + fileName + "\n\n" + _ml->errorString();
QMessageBox::critical(this, APP_NAME, error); QMessageBox::critical(this, APP_NAME, error);
return false;
} }
} }

View File

@ -99,6 +99,7 @@ private:
bool openPOIFile(const QString &fileName); bool openPOIFile(const QString &fileName);
bool loadFile(const QString &fileName); bool loadFile(const QString &fileName);
bool loadMap(const QString &fileName);
void exportFile(const QString &fileName); void exportFile(const QString &fileName);
void updateStatusBarInfo(); void updateStatusBarInfo();
void updateWindowTitle(); void updateWindowTitle();