diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp index 11cc6230..42f14646 100644 --- a/src/GUI/gui.cpp +++ b/src/GUI/gui.cpp @@ -270,10 +270,21 @@ void GUI::createActions(TreeNode &mapActions, addAction(_statisticsAction); // POI actions + poiActions = createPOIActions(); _openPOIAction = new QAction(QIcon(OPEN_FILE_ICON), tr("Load POI file..."), this); _openPOIAction->setMenuRole(QAction::NoRole); 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->setMenuRole(QAction::NoRole); _overlapPOIAction->setCheckable(true); @@ -291,7 +302,6 @@ void GUI::createActions(TreeNode &mapActions, connect(_showPOIAction, SIGNAL(triggered(bool)), _mapView, SLOT(showPOI(bool))); addAction(_showPOIAction); - poiActions = createPOIActions(); // Map actions mapActions = createMapActions(); @@ -584,6 +594,8 @@ void GUI::createMenus(const TreeNode &mapActions, createPOINodeMenu(poiActions, _poiMenu); _poisEnd = _poiMenu->addSeparator(); _poiMenu->addAction(_openPOIAction); + _poiMenu->addAction(_selectAllPOIAction); + _poiMenu->addAction(_unselectAllPOIAction); _poiMenu->addSeparator(); _poiMenu->addAction(_showPOILabelsAction); _poiMenu->addAction(_overlapPOIAction); @@ -937,6 +949,9 @@ bool GUI::openPOIFile(const QString &fileName) action->setChecked(true); _poiMenu->insertAction(_poisEnd, action); + _selectAllPOIAction->setEnabled(true); + _unselectAllPOIAction->setEnabled(true); + return true; } else { QString error = tr("Error loading POI file:") + "\n\n" @@ -1749,6 +1764,26 @@ void GUI::poiFileChecked(QAction *action) _poi->enableFile(action->data().value(), action->isChecked()); } +void GUI::selectAllPOIs() +{ + QList actions(_poisActionGroup->actions()); + for (int i = 0; i < actions.size(); i++) { + POIAction *a = static_cast(actions.at(i)); + if (_poi->enableFile(a->data().toString(), true)) + a->setChecked(true); + } +} + +void GUI::unselectAllPOIs() +{ + QList actions(_poisActionGroup->actions()); + for (int i = 0; i < actions.size(); i++) { + POIAction *a = static_cast(actions.at(i)); + if (_poi->enableFile(a->data().toString(), false)) + a->setChecked(false); + } +} + void GUI::graphChanged(int index) { if (index < 0) diff --git a/src/GUI/gui.h b/src/GUI/gui.h index 59585565..a01bb7aa 100644 --- a/src/GUI/gui.h +++ b/src/GUI/gui.h @@ -75,6 +75,8 @@ private slots: void mapChanged(QAction *action); void graphChanged(int); void poiFileChecked(QAction *action); + void selectAllPOIs(); + void unselectAllPOIs(); void next(); void prev(); @@ -179,6 +181,8 @@ private: QAction *_reloadFileAction; QAction *_statisticsAction; QAction *_openPOIAction; + QAction *_selectAllPOIAction; + QAction *_unselectAllPOIAction; QAction *_showPOIAction; QAction *_overlapPOIAction; QAction *_showPOILabelsAction;