| 379 | } |
| 380 | |
| 381 | void KrBookmarkHandler::buildMenu(KrBookmark *parent, QMenu *menu, int depth) |
| 382 | { |
| 383 | // add search bar widget to the top of the menu |
| 384 | if (depth == 0) { |
| 385 | menu->addAction(_quickSearchAction); |
| 386 | } |
| 387 | |
| 388 | // run the loop twice, in order to put the folders on top. stupid but easy :-) |
| 389 | // note: this code drops the separators put there by the user |
| 390 | QListIterator<KrBookmark *> it(parent->children()); |
| 391 | while (it.hasNext()) { |
| 392 | KrBookmark *bm = it.next(); |
| 393 | |
| 394 | if (!bm->isFolder()) |
| 395 | continue; |
| 396 | auto *newMenu = new QMenu(menu); |
| 397 | newMenu->setIcon(Icon(bm->iconName())); |
| 398 | newMenu->setTitle(bm->text()); |
| 399 | QAction *menuAction = menu->addMenu(newMenu); |
| 400 | QVariant v; |
| 401 | v.setValue(bm); |
| 402 | menuAction->setData(v); |
| 403 | |
| 404 | buildMenu(bm, newMenu, depth + 1); |
| 405 | } |
| 406 | |
| 407 | it.toFront(); |
| 408 | while (it.hasNext()) { |
| 409 | KrBookmark *bm = it.next(); |
| 410 | if (bm->isFolder()) |
| 411 | continue; |
| 412 | if (bm->isSeparator()) { |
| 413 | menu->addSeparator(); |
| 414 | continue; |
| 415 | } |
| 416 | |
| 417 | QUrl urlToSet = bm->url(); |
| 418 | if (!urlToSet.isEmpty() && urlToSet.isRelative()) { |
| 419 | // Make it possible that the url can be used later by Krusader. |
| 420 | // This avoids users seeing the effects described in the "Editing a local path in Bookmark |
| 421 | // Manager breaks a bookmark" bug report (https://bugs.kde.org/show_bug.cgi?id=393320), |
| 422 | // though it would be better to solve that upstream frameworks-kbookmarks bug |
| 423 | bm->setURL(QUrl::fromUserInput(urlToSet.toString(), QString(), QUrl::AssumeLocalFile)); |
| 424 | } |
| 425 | |
| 426 | menu->addAction(bm); |
| 427 | CONNECT_BM(bm); |
| 428 | } |
| 429 | |
| 430 | if (depth == 0) { |
| 431 | KConfigGroup group(krConfig, "Private"); |
| 432 | bool hasPopularURLs = group.readEntry("BM Popular URLs", true); |
| 433 | bool hasTrash = group.readEntry("BM Trash", true); |
| 434 | bool hasLan = group.readEntry("BM Lan", true); |
| 435 | bool hasVirtualFS = group.readEntry("BM Virtual FS", true); |
| 436 | bool hasJumpback = group.readEntry("BM Jumpback", true); |
| 437 | |
| 438 | if (hasPopularURLs) { |
nothing calls this directly
no test coverage detected