@@ -370,7 +370,10 @@ void NextcloudDeckDialog::on_cardItemTreeWidget_customContextMenuRequested(const
370370 QIcon (" :icons/breeze-qownnotes/16x16/text-html.svg" )));
371371 QAction *cardLinkAction = menu.addAction (tr (" &Add card link to note" ));
372372 openUrlAction->setIcon (QIcon::fromTheme (
373- QStringLiteral (" document-new" ), QIcon (" :icons/breeze-qownnotes/16x16/document-new.svg" )));
373+ QStringLiteral (" insert-link" ), QIcon (" :icons/breeze-qownnotes/16x16/insert-link.svg" )));
374+ QAction *searchInNotesAction = menu.addAction (tr (" &Search for card link in notes" ));
375+ searchInNotesAction->setIcon (QIcon::fromTheme (
376+ QStringLiteral (" edit-find" ), QIcon (" :icons/breeze-qownnotes/16x16/edit-find.svg" )));
374377
375378 QAction *selectedItem = menu.exec (globalPos);
376379
@@ -384,23 +387,39 @@ void NextcloudDeckDialog::on_cardItemTreeWidget_customContextMenuRequested(const
384387 openUrlInBrowserForItem (item);
385388 } else if (selectedItem == cardLinkAction) {
386389 addCardLinkToCurrentNote (item);
390+ } else if (selectedItem == searchInNotesAction) {
391+ searchLinkInNotes (item);
387392 }
388393}
389394
395+ void NextcloudDeckDialog::searchLinkInNotes (QTreeWidgetItem *item) {
396+ const int cardId = item->data (0 , Qt::UserRole).toInt ();
397+
398+ if (cardId < 1 ) {
399+ return ;
400+ }
401+
402+ const auto link = NextcloudDeckService (this ).getCardLinkForId (cardId);
403+ Q_EMIT searchInNotes (link);
404+ close ();
405+ }
406+
390407void NextcloudDeckDialog::addCardLinkToCurrentNote (const QTreeWidgetItem *item) {
391408 const int cardId = item->data (0 , Qt::UserRole).toInt ();
409+ if (cardId < 1 ) {
410+ return ;
411+ }
392412
393- if (cardId > 0 ) {
394- const auto title = item->text (0 );
395- const auto linkText = QStringLiteral (" [%1](%2)" )
396- .arg (title, NextcloudDeckService (this ).getCardLinkForId (cardId));
413+ const auto title = item->text (0 );
414+ const auto linkText =
415+ QStringLiteral (" [%1](%2)" ).arg (title, NextcloudDeckService (this ).getCardLinkForId (cardId));
397416
398417#ifndef INTEGRATION_TESTS
399- // Only insert the link if we're creating a new card, not updating an existing one
400- MainWindow *mainWindow = MainWindow::instance ();
401- if (mainWindow != nullptr ) {
402- mainWindow->activeNoteTextEdit ()->insertPlainText (linkText);
403- }
404- #endif
418+ MainWindow *mainWindow = MainWindow::instance ();
419+ if (mainWindow != nullptr ) {
420+ mainWindow->activeNoteTextEdit ()->insertPlainText (linkText);
405421 }
422+ #endif
423+
424+ close ();
406425}
0 commit comments