Skip to content

Commit a1b22c1

Browse files
committed
#3374 mainwindow: allow deleting of single folder with Del key in notetree-mode
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent 323ddd8 commit a1b22c1

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

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

55
- You can now **add a link to a card** to the current note in the
66
**Nextcloud Deck dialog** (for [#3357](https://github.com/pbek/QOwnNotes/issues/3357))
7+
- In _note tree mode_, if only one folder is selected, you can delete it with the `Del` key
8+
(for [#3374](https://github.com/pbek/QOwnNotes/issues/3374))
79

810
## 25.10.1
911

src/mainwindow.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4704,11 +4704,17 @@ void MainWindow::removeSelectedNotes() {
47044704
// store updated notes to disk
47054705
storeUpdatedNotesToDisk();
47064706

4707-
const int selectedItemsCount = getSelectedNotesCount();
4707+
const auto selItems = ui->noteTreeWidget->selectedItems();
4708+
const int selectedItemsCount = selItems.count();
47084709

47094710
if (selectedItemsCount == 0) {
47104711
return;
47114712
}
4713+
if (selectedItemsCount == 1 && selItems[0]->data(0, Qt::UserRole + 1) == FolderType) {
4714+
// If just one folder is selected, remove the folder
4715+
NoteSubFolderTree::removeSelectedNoteSubFolders(ui->noteTreeWidget);
4716+
return;
4717+
}
47124718

47134719
if (Utils::Gui::question(
47144720
this, tr("Remove selected notes"),
@@ -4741,7 +4747,6 @@ void MainWindow::removeSelectedNotes() {
47414747
const QSignalBlocker blocker1(ui->noteTreeWidget);
47424748
Q_UNUSED(blocker1)
47434749

4744-
const auto selItems = ui->noteTreeWidget->selectedItems();
47454750
for (QTreeWidgetItem *item : selItems) {
47464751
if (item->data(0, Qt::UserRole + 1) != NoteType) {
47474752
continue;

src/widgets/notesubfoldertree.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class NoteSubFolderTree : public QTreeWidget {
2020
void reload();
2121

2222
static QMenu *contextMenu(QTreeWidget *parent);
23+
static void removeSelectedNoteSubFolders(QTreeWidget *treeWidget);
2324

2425
public Q_SLOTS:
2526
void onItemExpanded(QTreeWidgetItem *item);
@@ -30,8 +31,6 @@ class NoteSubFolderTree : public QTreeWidget {
3031
void onItemChanged(QTreeWidgetItem *item, int column);
3132
void onItemSelectionChanged();
3233

33-
static void removeSelectedNoteSubFolders(QTreeWidget *treeWidget);
34-
3534
Q_SIGNALS:
3635
void currentSubFolderChanged();
3736
void multipleSubfoldersSelected();

0 commit comments

Comments
 (0)