Skip to content

Commit

Permalink
#2354 add: allow viewing of image and attachment files of current not…
Browse files Browse the repository at this point in the history
…e only

Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
  • Loading branch information
pbek committed Oct 9, 2024
1 parent ec3e257 commit 07db4e2
Show file tree
Hide file tree
Showing 10 changed files with 357 additions and 239 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# QOwnNotes Changelog

## 24.10.1
- In the *Stored image files* and the *Stored attachments* dialogs it's now possible
to only show files of the current note (for [2354](https://github.com/pbek/QOwnNotes/issues/2354))

## 24.10.0
- [qc](https://github.com/qownnotes/qc) v0.6.1 was released
- Add support for storing commands in [Atuin](https://atuin.sh/) on execution
Expand Down
52 changes: 43 additions & 9 deletions src/dialogs/storedattachmentsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,26 @@ void StoredAttachmentsDialog::refreshAttachmentFiles() {
return;
}

QStringList attachmentFiles =
attachmentsDir.entryList(QStringList(QStringLiteral("*")), QDir::Files, QDir::Time);
attachmentFiles.removeDuplicates();
QStringList attachmentFiles;
QVector<Note> noteList;

if (_currentNoteOnly) {
MainWindow *mainWindow = MainWindow::instance();
if (mainWindow == nullptr) {
return;
}

const auto note = mainWindow->getCurrentNote();
if (note.isFetched()) {
attachmentFiles = note.getAttachmentsFileList();
noteList = { note };
}
} else {
attachmentFiles = attachmentsDir.entryList(QStringList(QStringLiteral("*")), QDir::Files, QDir::Time);
noteList = Note::fetchAll();
}

QVector<Note> noteList = Note::fetchAll();
attachmentFiles.removeDuplicates();
int noteListCount = noteList.count();
_fileNoteList.clear();

Expand Down Expand Up @@ -374,11 +389,6 @@ void StoredAttachmentsDialog::on_noteTreeWidget_itemDoubleClicked(QTreeWidgetIte
openCurrentNote();
}

void StoredAttachmentsDialog::on_checkBox_toggled(bool checked) {
_orphanedAttachmentsOnly = checked;
refreshAttachmentFiles();
}

void StoredAttachmentsDialog::on_refreshButton_clicked() { refreshAttachmentFiles(); }

void StoredAttachmentsDialog::on_fileTreeWidget_itemChanged(QTreeWidgetItem *item, int column) {
Expand Down Expand Up @@ -490,3 +500,27 @@ void StoredAttachmentsDialog::on_noteTreeWidget_customContextMenuRequested(const
openCurrentNote();
}
}

void StoredAttachmentsDialog::on_orphanedCheckBox_toggled(bool checked)
{
if (checked) {
const QSignalBlocker blocker(ui->fileTreeWidget);
Q_UNUSED(blocker)
ui->currentNoteCheckBox->setChecked(false);
}

_orphanedAttachmentsOnly = checked;
refreshAttachmentFiles();
}

void StoredAttachmentsDialog::on_currentNoteCheckBox_toggled(bool checked)
{
if (checked) {
const QSignalBlocker blocker(ui->fileTreeWidget);
Q_UNUSED(blocker)
ui->orphanedCheckBox->setChecked(false);
}

_currentNoteOnly = checked;
refreshAttachmentFiles();
}
7 changes: 5 additions & 2 deletions src/dialogs/storedattachmentsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class StoredAttachmentsDialog : public MasterDialog {

void on_noteTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);

void on_checkBox_toggled(bool checked);

void on_refreshButton_clicked();

void on_fileTreeWidget_itemChanged(QTreeWidgetItem *item, int column);
Expand All @@ -47,9 +45,14 @@ class StoredAttachmentsDialog : public MasterDialog {

void on_noteTreeWidget_customContextMenuRequested(const QPoint &pos);

void on_orphanedCheckBox_toggled(bool checked);

void on_currentNoteCheckBox_toggled(bool checked);

private:
Ui::StoredAttachmentsDialog *ui;
bool _orphanedAttachmentsOnly = false;
bool _currentNoteOnly = false;
QHash<QString, QVector<Note>> _fileNoteList;

static QString getFilePath(QTreeWidgetItem *item);
Expand Down
Loading

0 comments on commit 07db4e2

Please sign in to comment.