mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
mapwidgetcontextmenu: create a ListModel for the context menu
Menu item indexes are enumerated in the object menuItemIndex, while menuItemData, holds an array of objects which will define the number of items, with indexes (idx) and text (itemText). When the ListModel is created, it's dynamically populated from from menuItemData. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
7dfb168f7f
commit
eeb53e965e
1 changed files with 21 additions and 0 deletions
|
@ -24,4 +24,25 @@ Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly property var menuItemIndex: {
|
||||
"OPEN_LOCATION_IN_GOOGLE_MAPS": 0,
|
||||
"COPY_LOCATION_DECIMAL": 1,
|
||||
"COPY_LOCATION_SEXAGESIMAL": 2
|
||||
}
|
||||
|
||||
readonly property var menuItemData: [
|
||||
{ idx: menuItemIndex.OPEN_LOCATION_IN_GOOGLE_MAPS, itemText: qsTr("Open location in Google Maps") },
|
||||
{ idx: menuItemIndex.COPY_LOCATION_DECIMAL, itemText: qsTr("Copy location to clipboard (decimal)") },
|
||||
{ idx: menuItemIndex.COPY_LOCATION_SEXAGESIMAL, itemText: qsTr("Copy location to clipboard (sexagesimal)") }
|
||||
]
|
||||
|
||||
ListModel {
|
||||
id: listModel
|
||||
property int selectedIdx: -1
|
||||
Component.onCompleted: {
|
||||
for (var i = 0; i < menuItemData.length; i++)
|
||||
append(menuItemData[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue