MCPcopy Create free account
hub / github.com/comaps/comaps / FillTree

Method FillTree

qt/bookmark_dialog.cpp:256–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254}
255
256void BookmarkDialog::FillTree()
257{
258 m_tree->setSortingEnabled(false);
259 m_tree->clear();
260 m_categories.clear();
261 m_bookmarks.clear();
262 m_tracks.clear();
263
264 auto categoriesItem = CreateTreeItem("Categories", nullptr);
265
266 auto const & bm = m_framework.GetBookmarkManager();
267
268 if (!bm.IsAsyncLoadingInProgress())
269 {
270 for (auto catId : bm.GetUnsortedBmGroupsIdList())
271 {
272 auto categoryItem = CreateTreeItem(bm.GetCategoryName(catId), categoriesItem);
273 m_categories[categoryItem] = catId;
274
275 for (auto bookmarkId : bm.GetUserMarkIds(catId))
276 {
277 auto const bookmark = bm.GetBookmark(bookmarkId);
278 auto name = GetPreferredBookmarkStr(bookmark->GetName());
279 if (name.empty())
280 {
281 name = measurement_utils::FormatLatLon(mercator::YToLat(bookmark->GetPivot().y),
282 mercator::XToLon(bookmark->GetPivot().x), true /* withComma */);
283 }
284 auto bookmarkItem = CreateTreeItem(name + " (Bookmark)", categoryItem);
285 m_bookmarks[bookmarkItem] = bookmarkId;
286 }
287
288 for (auto trackId : bm.GetTrackIds(catId))
289 {
290 auto const track = bm.GetTrack(trackId);
291 auto name = track->GetName();
292 if (name.empty())
293 name = "No name";
294 auto trackItem = CreateTreeItem(name + " (Track)", categoryItem);
295 trackItem->setForeground(0, Qt::darkGreen);
296 m_tracks[trackItem] = trackId;
297 }
298 }
299 }
300 else
301 {
302 CreateTreeItem("Loading in progress...", categoriesItem);
303 }
304
305 m_tree->addTopLevelItem(categoriesItem);
306 m_tree->expandAll();
307 m_tree->setCurrentItem(categoriesItem);
308
309 m_tree->header()->setSectionResizeMode(0, QHeaderView::Stretch);
310 m_tree->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
311}
312
313void BookmarkDialog::ShowModal()

Callers

nothing calls this directly

Calls 12

GetPreferredBookmarkStrFunction · 0.85
FormatLatLonFunction · 0.85
YToLatFunction · 0.85
XToLonFunction · 0.85
GetCategoryNameMethod · 0.80
GetBookmarkMethod · 0.80
GetTrackMethod · 0.80
clearMethod · 0.45
GetNameMethod · 0.45
emptyMethod · 0.45
GetPivotMethod · 0.45

Tested by

no test coverage detected