Skip to content

Commit 43dad42

Browse files
committed
#3357 nextclouddeckdialog: search for card link in notes
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent 8f86af4 commit 43dad42

File tree

5 files changed

+258
-225
lines changed

5 files changed

+258
-225
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## 25.10.3
44

5+
- You can now **search for a card link** in all notes from the **Nextcloud Deck dialog**
6+
(for [#3357](https://github.com/pbek/QOwnNotes/issues/3357))
57
- [qc](https://github.com/qownnotes/qc) v0.6.2 was released
68
- Refactor the code to fix deprecations and issues and to make it cleaner and easier to maintain
79
- Update dependencies

src/dialogs/nextclouddeckdialog.cpp

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
390407
void 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
}

src/dialogs/nextclouddeckdialog.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class NextcloudDeckDialog;
1616

1717
class NextcloudDeckDialog : public MasterDialog {
1818
Q_OBJECT
19+
Q_SIGNALS:
20+
void searchInNotes(QString text);
1921

2022
public:
2123
explicit NextcloudDeckDialog(QWidget *parent = nullptr, bool listMode = false);
@@ -59,6 +61,8 @@ class NextcloudDeckDialog : public MasterDialog {
5961

6062
void on_cardItemTreeWidget_customContextMenuRequested(const QPoint &pos);
6163

64+
void searchLinkInNotes(QTreeWidgetItem *item);
65+
6266
private:
6367
Ui::NextcloudDeckDialog *ui;
6468
void setupMainSplitter();

0 commit comments

Comments
 (0)