Skip to content

Commit adf7940

Browse files
committed
Adjustments after rebasing onto master due to GH-2371
1 parent d541897 commit adf7940

File tree

2 files changed

+22
-33
lines changed

2 files changed

+22
-33
lines changed

src/gui/map/map_find_feature.cpp

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,18 @@ ObjectQuery MapFindFeature::makeQuery() const
206206
}
207207

208208

209-
// slot
210209
void MapFindFeature::findNext()
211210
{
212211
if (auto query = makeQuery())
213-
findNextMatchingObject(controller, query);
212+
{
213+
// remember current selected object as start point in case next object found is deleted by 'Delete & Find Next'
214+
previous_object = controller.getMap()->getFirstSelectedObject();
215+
findNextMatchingObject(controller, query, center_view->isChecked());
216+
}
214217
}
215218

216219
// static
217-
void MapFindFeature::findNextMatchingObject(MapEditorController& controller, const ObjectQuery& query)
220+
void MapFindFeature::findNextMatchingObject(MapEditorController& controller, const ObjectQuery& query, bool center_selection_visibility)
218221
{
219222
auto* map = controller.getMap();
220223

@@ -248,22 +251,18 @@ void MapFindFeature::findNextMatchingObject(MapEditorController& controller, con
248251
map->addObjectToSelection(next_match, false);
249252

250253
map->emitSelectionChanged();
251-
if (center_view->isChecked())
252-
map->ensureVisibilityOfSelectedObjects(Map::CenterFullVisibility);
253-
else
254-
map->ensureVisibilityOfSelectedObjects(Map::FullVisibility);
254+
map->ensureVisibilityOfSelectedObjects(center_selection_visibility ? Map::CenterFullVisibility : Map::FullVisibility);
255255

256256
if (!map->selectedObjects().empty())
257257
controller.setEditTool();
258258
}
259259

260260

261-
// slot
262261
void MapFindFeature::deleteAndFindNext()
263262
{
264263
auto map = controller.getMap();
265264
map->deleteSelectedObjects();
266-
// restore start point for search in findNext() but only if the object still exists.
265+
// restore start point for search in findNextMatchingObject() but only if the object still exists.
267266
if (previous_object && map->getCurrentPart()->contains(previous_object))
268267
{
269268
map->addObjectToSelection(previous_object, false);
@@ -272,15 +271,14 @@ void MapFindFeature::deleteAndFindNext()
272271
}
273272

274273

275-
// slot
276274
void MapFindFeature::findAll()
277275
{
278276
if (auto query = makeQuery())
279-
findAllMatchingObjects(controller, query);
277+
findAllMatchingObjects(controller, query, center_view->isChecked());
280278
}
281279

282280
// static
283-
void MapFindFeature::findAllMatchingObjects(MapEditorController& controller, const ObjectQuery& query)
281+
void MapFindFeature::findAllMatchingObjects(MapEditorController& controller, const ObjectQuery& query, bool center_selection_visibility)
284282
{
285283
auto map = controller.getMap();
286284
map->clearObjectSelection(false);
@@ -291,18 +289,14 @@ void MapFindFeature::findAllMatchingObjects(MapEditorController& controller, con
291289
}, std::cref(query));
292290

293291
map->emitSelectionChanged();
294-
if (center_view->isChecked())
295-
map->ensureVisibilityOfSelectedObjects(Map::CenterFullVisibility);
296-
else
297-
map->ensureVisibilityOfSelectedObjects(Map::FullVisibility);
292+
map->ensureVisibilityOfSelectedObjects(center_selection_visibility ? Map::CenterFullVisibility : Map::FullVisibility);
298293
controller.getWindow()->showStatusBarMessage(OpenOrienteering::TagSelectWidget::tr("%n object(s) selected", nullptr, map->getNumSelectedObjects()), 2000);
299294

300295
if (!map->selectedObjects().empty())
301296
controller.setEditTool();
302297
}
303298

304299

305-
// slot
306300
void MapFindFeature::objectSelectionChanged()
307301
{
308302
auto map = controller.getMap();
@@ -311,7 +305,6 @@ void MapFindFeature::objectSelectionChanged()
311305
}
312306

313307

314-
// slot
315308
void MapFindFeature::centerView()
316309
{
317310
if (center_view->isChecked())
@@ -323,14 +316,12 @@ void MapFindFeature::centerView()
323316
}
324317

325318

326-
// slot
327319
void MapFindFeature::showHelp() const
328320
{
329321
Util::showHelp(controller.getWindow(), "find_objects.html");
330322
}
331323

332324

333-
// slot
334325
void MapFindFeature::tagSelectorToggled(bool active)
335326
{
336327
editor_stack->setCurrentIndex(active ? 1 : 0);

src/gui/map/map_find_feature.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,19 @@ class MapFindFeature : public QObject
7676

7777
void setEnabled(bool enabled);
7878

79-
QAction* showDialogAction() const { return show_action; }
79+
QAction* showDialogAction() { return show_action; }
8080

81-
QAction* findNextAction() const { return find_next_action; }
81+
QAction* findNextAction() { return find_next_action; }
82+
83+
static void findNextMatchingObject(MapEditorController& controller, const ObjectQuery& query, bool center_selection_visibility = false);
84+
85+
static void findAllMatchingObjects(MapEditorController& controller, const ObjectQuery& query, bool center_selection_visibility = false);
86+
87+
private:
88+
void showDialog();
89+
90+
ObjectQuery makeQuery() const;
8291

83-
private slots:
8492
void findNext();
8593

8694
void deleteAndFindNext();
@@ -95,16 +103,6 @@ private slots:
95103

96104
void tagSelectorToggled(bool active);
97105

98-
static void findNextMatchingObject(MapEditorController& controller, const ObjectQuery& query);
99-
100-
static void findAllMatchingObjects(MapEditorController& controller, const ObjectQuery& query);
101-
102-
private:
103-
void showDialog();
104-
105-
ObjectQuery makeQuery() const;
106-
107-
108106

109107
MapEditorController& controller;
110108
QPointer<QDialog> find_dialog; // child of controller's window

0 commit comments

Comments
 (0)