Skip to content

Commit

Permalink
#1717 add: note backlink widget integration
Browse files Browse the repository at this point in the history
Signed-off-by: Patrizio Bekerle <[email protected]>
  • Loading branch information
pbek committed Aug 30, 2024
1 parent 5eef35d commit 346f0d5
Show file tree
Hide file tree
Showing 11 changed files with 744 additions and 481 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# QOwnNotes Changelog

## Next
## 24.9.0
- There now is a **backlink widget** in the navigation panel to show backlinks
to the current note (for [#1717](https://github.com/pbek/QOwnNotes/issues/1717))
- The aarch64 CMake build process was fixed (for [#3076](https://github.com/pbek/QOwnNotes/issues/3076))

## 24.8.6
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ set(SOURCE_FILES
widgets/qownnotesmarkdowntextedit.h
widgets/navigationwidget.cpp
widgets/navigationwidget.h
widgets/backlinkwidget.cpp
widgets/backlinkwidget.h
widgets/notepreviewwidget.cpp
widgets/notepreviewwidget.h
widgets/combobox.cpp
Expand Down
2 changes: 2 additions & 0 deletions src/QOwnNotes.pro
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ SOURCES += main.cpp\
dialogs/issueassistantdialog.cpp \
dialogs/tagadddialog.cpp \
widgets/navigationwidget.cpp \
widgets/backlinkwidget.cpp \
widgets/notepreviewwidget.cpp \
api/noteapi.cpp \
api/notesubfolderapi.cpp \
Expand Down Expand Up @@ -286,6 +287,7 @@ HEADERS += mainwindow.h \
dialogs/issueassistantdialog.h \
dialogs/tagadddialog.h \
widgets/navigationwidget.h \
widgets/backlinkwidget.h \
widgets/notepreviewwidget.h \
api/noteapi.h \
api/notesubfolderapi.h \
Expand Down
23 changes: 23 additions & 0 deletions src/entities/note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3382,6 +3382,29 @@ bool Note::handleNoteMoving(const Note &oldNote) {
return noteIdList.contains(_id);
}

QList<Note> Note::findBacklinks() const {
const QVector<int> noteIdList = this->findLinkedNoteIds();
const int noteCount = noteIdList.count();

if (noteCount == 0) {
return {};
}

QList<Note> notes;

for (const int noteId : noteIdList) {
const Note linkedNote = Note::fetch(noteId);

if (!linkedNote.isFetched()) {
continue;
}

notes << linkedNote;
}

return notes;
}

/**
* Creates a note headline from a name
*
Expand Down
2 changes: 2 additions & 0 deletions src/entities/note.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ class Note {

static bool applyIgnoredNotesSetting(QStringList &fileNames);

QList<Note> findBacklinks() const;

protected:
int _id;
int _noteSubFolderId;
Expand Down
Loading

0 comments on commit 346f0d5

Please sign in to comment.