mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 19:55:53 +01:00
Check for duplicit map loads
This commit is contained in:
parent
4bad086152
commit
e76e7b71ed
@ -777,7 +777,7 @@ void GUI::openFile()
|
|||||||
bool GUI::openFile(const QString &fileName, bool silent)
|
bool GUI::openFile(const QString &fileName, bool silent)
|
||||||
{
|
{
|
||||||
if (_files.contains(fileName))
|
if (_files.contains(fileName))
|
||||||
return false;
|
return true;
|
||||||
|
|
||||||
if (!loadFile(fileName, silent))
|
if (!loadFile(fileName, silent))
|
||||||
return false;
|
return false;
|
||||||
@ -891,7 +891,7 @@ void GUI::openPOIFile()
|
|||||||
bool GUI::openPOIFile(const QString &fileName)
|
bool GUI::openPOIFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
if (_poi->files().contains(fileName))
|
if (_poi->files().contains(fileName))
|
||||||
return false;
|
return true;
|
||||||
|
|
||||||
if (_poi->loadFile(fileName)) {
|
if (_poi->loadFile(fileName)) {
|
||||||
_mapView->showPOI(true);
|
_mapView->showPOI(true);
|
||||||
@ -1449,6 +1449,18 @@ void GUI::loadMap()
|
|||||||
lastReady->trigger();
|
lastReady->trigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MapAction *findMapAction(const QList<QAction*> &mapActions,
|
||||||
|
const Map *map)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < mapActions.count(); i++) {
|
||||||
|
const Map *m = mapActions.at(i)->data().value<Map*>();
|
||||||
|
if (map->path() == m->path())
|
||||||
|
return static_cast<MapAction*>(mapActions.at(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool GUI::loadMap(const QString &fileName, MapAction *&action, bool silent)
|
bool GUI::loadMap(const QString &fileName, MapAction *&action, bool silent)
|
||||||
{
|
{
|
||||||
QString error;
|
QString error;
|
||||||
@ -1461,9 +1473,14 @@ bool GUI::loadMap(const QString &fileName, MapAction *&action, bool silent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MapAction *lastReady = 0;
|
MapAction *lastReady = 0;
|
||||||
|
QList<QAction*> mapActions(_mapsActionGroup->actions());
|
||||||
|
|
||||||
for (int i = 0; i < maps.size(); i++) {
|
for (int i = 0; i < maps.size(); i++) {
|
||||||
Map *map = maps.at(i);
|
Map *map = maps.at(i);
|
||||||
MapAction *a = createMapAction(map);
|
MapAction *a;
|
||||||
|
|
||||||
|
if (!(a = findMapAction(mapActions, map))) {
|
||||||
|
a = createMapAction(map);
|
||||||
_mapMenu->insertAction(_mapsEnd, a);
|
_mapMenu->insertAction(_mapsEnd, a);
|
||||||
if (map->isReady()) {
|
if (map->isReady()) {
|
||||||
lastReady = a;
|
lastReady = a;
|
||||||
@ -1471,6 +1488,11 @@ bool GUI::loadMap(const QString &fileName, MapAction *&action, bool silent)
|
|||||||
_clearMapCacheAction->setEnabled(true);
|
_clearMapCacheAction->setEnabled(true);
|
||||||
} else
|
} else
|
||||||
connect(a, SIGNAL(loaded()), this, SLOT(mapLoaded()));
|
connect(a, SIGNAL(loaded()), this, SLOT(mapLoaded()));
|
||||||
|
} else {
|
||||||
|
map = a->data().value<Map*>();
|
||||||
|
if (map->isReady())
|
||||||
|
lastReady = a;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
action = lastReady;
|
action = lastReady;
|
||||||
@ -1510,14 +1532,15 @@ void GUI::loadMapDir()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QList<MapItem*> items(_mapView->loadMaps(maps));
|
QList<MapItem*> items(_mapView->loadMaps(maps));
|
||||||
|
QList<QAction*> mapActions(_mapsActionGroup->actions());
|
||||||
|
|
||||||
QFileInfo fi(dir);
|
QFileInfo fi(dir);
|
||||||
QMenu *menu = new QMenu(fi.fileName());
|
QMenu *menu = new QMenu(fi.fileName());
|
||||||
menu->setStyleSheet("QMenu { menu-scrollable: 1; }");
|
|
||||||
_mapMenu->insertMenu(_mapsEnd, menu);
|
|
||||||
|
|
||||||
for (int i = 0; i < maps.size(); i++) {
|
for (int i = 0; i < maps.size(); i++) {
|
||||||
Map *map = maps.at(i);
|
Map *map = maps.at(i);
|
||||||
|
|
||||||
|
if (!findMapAction(mapActions, map)) {
|
||||||
MapAction *a = createMapAction(map);
|
MapAction *a = createMapAction(map);
|
||||||
menu->addAction(a);
|
menu->addAction(a);
|
||||||
if (map->isReady()) {
|
if (map->isReady()) {
|
||||||
@ -1528,6 +1551,14 @@ void GUI::loadMapDir()
|
|||||||
|
|
||||||
connect(items.at(i), SIGNAL(triggered()), a, SLOT(trigger()));
|
connect(items.at(i), SIGNAL(triggered()), a, SLOT(trigger()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menu->isEmpty())
|
||||||
|
delete menu;
|
||||||
|
else {
|
||||||
|
menu->setStyleSheet("QMenu { menu-scrollable: 1; }");
|
||||||
|
_mapMenu->insertMenu(_mapsEnd, menu);
|
||||||
|
}
|
||||||
|
|
||||||
_mapDir = fi.absolutePath();
|
_mapDir = fi.absolutePath();
|
||||||
_areaCount += maps.size();
|
_areaCount += maps.size();
|
||||||
@ -2470,7 +2501,7 @@ void GUI::readSettings()
|
|||||||
|
|
||||||
QAction *GUI::mapAction(const QString &name)
|
QAction *GUI::mapAction(const QString &name)
|
||||||
{
|
{
|
||||||
QList<QAction *> maps = _mapsActionGroup->actions();
|
QList<QAction *> maps(_mapsActionGroup->actions());
|
||||||
|
|
||||||
// Last map
|
// Last map
|
||||||
for (int i = 0; i < maps.count(); i++) {
|
for (int i = 0; i < maps.count(); i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user