1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00

Added options to select/unselect all POI files

This commit is contained in:
Martin Tůma 2021-03-21 22:40:39 +01:00
parent 7a7d67eeaa
commit 8079e827a0
2 changed files with 40 additions and 1 deletions

View File

@ -270,10 +270,21 @@ void GUI::createActions(TreeNode<MapAction*> &mapActions,
addAction(_statisticsAction); addAction(_statisticsAction);
// POI actions // POI actions
poiActions = createPOIActions();
_openPOIAction = new QAction(QIcon(OPEN_FILE_ICON), tr("Load POI file..."), _openPOIAction = new QAction(QIcon(OPEN_FILE_ICON), tr("Load POI file..."),
this); this);
_openPOIAction->setMenuRole(QAction::NoRole); _openPOIAction->setMenuRole(QAction::NoRole);
connect(_openPOIAction, SIGNAL(triggered()), this, SLOT(openPOIFile())); connect(_openPOIAction, SIGNAL(triggered()), this, SLOT(openPOIFile()));
_selectAllPOIAction = new QAction(tr("Select all files"), this);
_selectAllPOIAction->setMenuRole(QAction::NoRole);
_selectAllPOIAction->setEnabled(!_poisActionGroup->actions().isEmpty());
connect(_selectAllPOIAction, SIGNAL(triggered()), this,
SLOT(selectAllPOIs()));
_unselectAllPOIAction = new QAction(tr("Unselect all files"), this);
_unselectAllPOIAction->setMenuRole(QAction::NoRole);
_unselectAllPOIAction->setEnabled(_selectAllPOIAction->isEnabled());
connect(_unselectAllPOIAction, SIGNAL(triggered()), this,
SLOT(unselectAllPOIs()));
_overlapPOIAction = new QAction(tr("Overlap POIs"), this); _overlapPOIAction = new QAction(tr("Overlap POIs"), this);
_overlapPOIAction->setMenuRole(QAction::NoRole); _overlapPOIAction->setMenuRole(QAction::NoRole);
_overlapPOIAction->setCheckable(true); _overlapPOIAction->setCheckable(true);
@ -291,7 +302,6 @@ void GUI::createActions(TreeNode<MapAction*> &mapActions,
connect(_showPOIAction, SIGNAL(triggered(bool)), _mapView, connect(_showPOIAction, SIGNAL(triggered(bool)), _mapView,
SLOT(showPOI(bool))); SLOT(showPOI(bool)));
addAction(_showPOIAction); addAction(_showPOIAction);
poiActions = createPOIActions();
// Map actions // Map actions
mapActions = createMapActions(); mapActions = createMapActions();
@ -584,6 +594,8 @@ void GUI::createMenus(const TreeNode<MapAction*> &mapActions,
createPOINodeMenu(poiActions, _poiMenu); createPOINodeMenu(poiActions, _poiMenu);
_poisEnd = _poiMenu->addSeparator(); _poisEnd = _poiMenu->addSeparator();
_poiMenu->addAction(_openPOIAction); _poiMenu->addAction(_openPOIAction);
_poiMenu->addAction(_selectAllPOIAction);
_poiMenu->addAction(_unselectAllPOIAction);
_poiMenu->addSeparator(); _poiMenu->addSeparator();
_poiMenu->addAction(_showPOILabelsAction); _poiMenu->addAction(_showPOILabelsAction);
_poiMenu->addAction(_overlapPOIAction); _poiMenu->addAction(_overlapPOIAction);
@ -937,6 +949,9 @@ bool GUI::openPOIFile(const QString &fileName)
action->setChecked(true); action->setChecked(true);
_poiMenu->insertAction(_poisEnd, action); _poiMenu->insertAction(_poisEnd, action);
_selectAllPOIAction->setEnabled(true);
_unselectAllPOIAction->setEnabled(true);
return true; return true;
} else { } else {
QString error = tr("Error loading POI file:") + "\n\n" QString error = tr("Error loading POI file:") + "\n\n"
@ -1749,6 +1764,26 @@ void GUI::poiFileChecked(QAction *action)
_poi->enableFile(action->data().value<QString>(), action->isChecked()); _poi->enableFile(action->data().value<QString>(), action->isChecked());
} }
void GUI::selectAllPOIs()
{
QList<QAction*> actions(_poisActionGroup->actions());
for (int i = 0; i < actions.size(); i++) {
POIAction *a = static_cast<POIAction*>(actions.at(i));
if (_poi->enableFile(a->data().toString(), true))
a->setChecked(true);
}
}
void GUI::unselectAllPOIs()
{
QList<QAction*> actions(_poisActionGroup->actions());
for (int i = 0; i < actions.size(); i++) {
POIAction *a = static_cast<POIAction*>(actions.at(i));
if (_poi->enableFile(a->data().toString(), false))
a->setChecked(false);
}
}
void GUI::graphChanged(int index) void GUI::graphChanged(int index)
{ {
if (index < 0) if (index < 0)

View File

@ -75,6 +75,8 @@ private slots:
void mapChanged(QAction *action); void mapChanged(QAction *action);
void graphChanged(int); void graphChanged(int);
void poiFileChecked(QAction *action); void poiFileChecked(QAction *action);
void selectAllPOIs();
void unselectAllPOIs();
void next(); void next();
void prev(); void prev();
@ -179,6 +181,8 @@ private:
QAction *_reloadFileAction; QAction *_reloadFileAction;
QAction *_statisticsAction; QAction *_statisticsAction;
QAction *_openPOIAction; QAction *_openPOIAction;
QAction *_selectAllPOIAction;
QAction *_unselectAllPOIAction;
QAction *_showPOIAction; QAction *_showPOIAction;
QAction *_overlapPOIAction; QAction *_overlapPOIAction;
QAction *_showPOILabelsAction; QAction *_showPOILabelsAction;