Skip to content

Update filtering for recording layer dropdown#4611

Open
xkello wants to merge 1 commit into
masterfrom
feature/sort-layers-for-dropdown
Open

Update filtering for recording layer dropdown#4611
xkello wants to merge 1 commit into
masterfrom
feature/sort-layers-for-dropdown

Conversation

@xkello

@xkello xkello commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Description

The Layers view already lets a project choose how layers are ordered - alphabetically, or matching the order set up in QGIS (the Mergin/SortLayersMethod/Method project setting). The Choose Active Layer dropdown shown when adding a feature didn't comply to this setting and was always alphabetical, which mismatched the workflow for projects that rely on a deliberate QGIS layer order.

Fixes: #4419

What changed

  • Extracted the existing sort-method lookup out of LayerTreeSortFilterModel::onSourceModelInitialized() into a new static helper, LayerTreeSortFilterModel::sortMethod(QgsProject*), so the setting is read from one place instead of being duplicated.
  • Overrode RecordingLayersProxyModel::lessThan() to consult that same helper:
    • Alphabetical -> falls back to the existing alphabetical compare (QgsMapLayerProxyModel::lessThan).
    • PreserveQgisOrder -> ranks layers by their position in QgsProject::layerTreeRoot()->findLayerIds(), meaning the real QGIS layer-tree order, since the dropdown's source model (LayersModel) doesn't natively preserve that order the way the Layers tab's source model does.

Behaviour

  • No change for projects using alphabetical sorting.
  • Projects configured for QGIS order sorting now see the active-layer dropdown (used when adding a feature) match the same layer order shown in the Layers tab, instead of always being alphabetical.
Qgis layer order Alphabetical
image image

@xkello xkello added this to the 2026.4.0 milestone Jul 20, 2026
@xkello
xkello requested a review from Withalion July 20, 2026 12:39
@github-actions

Copy link
Copy Markdown

📦 Build Artifacts Ready

OS Status Build Info Workflow run
macOS Build Build failed or not found. #7039
linux Build 📬 Mergin Maps 70651 x86_64 Expires: 18/10/2026 #7065
win64 Build 📬 Mergin Maps 62411 win64 Expires: 18/10/2026 #6241
Android Build 📬 Mergin Maps 834911 APK [armeabi-v7a] Expires: 18/10/2026 #8349
📬 Mergin Maps 834911 APK [armeabi-v7a] Google Play Store #8349
Android Build 📬 Mergin Maps 834951 APK [arm64-v8a] Expires: 18/10/2026 #8349
📬 Mergin Maps 834951 APK [arm64-v8a] Google Play Store #8349
iOS Build 📬 Build number: 26.07.929111 #9291

@github-actions

Copy link
Copy Markdown

📦 Build Artifacts Ready

OS Status Build Info Workflow run
macOS Build 📬 Mergin Maps 70392 dmg Expires: 19/10/2026 #7039
linux Build 📬 Mergin Maps 70651 x86_64 Expires: 18/10/2026 #7065
win64 Build 📬 Mergin Maps 62411 win64 Expires: 18/10/2026 #6241
Android Build 📬 Mergin Maps 834911 APK [armeabi-v7a] Expires: 18/10/2026 #8349
📬 Mergin Maps 834911 APK [armeabi-v7a] Google Play Store #8349
Android Build 📬 Mergin Maps 834951 APK [arm64-v8a] Expires: 18/10/2026 #8349
📬 Mergin Maps 834951 APK [arm64-v8a] Google Play Store #8349
iOS Build 📬 Build number: 26.07.929111 #9291

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to reorder layers on the 'Add' drop down

1 participant