Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: save collapse-state for note tree #2928

Merged
merged 3 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bugfix: save collapse-state for note tree
  • Loading branch information
Miika Tuominen committed Dec 20, 2023
commit 7164bf16e31e041dbc56dfda8e400d9ed48aaf1c
2 changes: 2 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2123,6 +2123,8 @@ void MainWindow::loadNoteDirectoryList() {

ui->noteSubFolderTreeWidget->buildTreeForParentItem(noteFolderItem);
noteFolderItem->setExpanded(true);
connect(ui->noteTreeWidget, &QTreeWidget::itemExpanded, ui->noteSubFolderTreeWidget, &NoteSubFolderTree::onItemExpanded);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since loadNoteDirectoryList() is called quite often, aren't those connect statements executed multiple times too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah they should probably be moved someplace better. But I'm wondering why in the firstplace is the note list used for the tree, and not the directory view. Then no extra connect calls would be needed.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't even make sense to me that the NoteSubFolderTree is involved at all, the notes are also added to the NoteSubFolderTree now. I suspect that might be a big regression from a pull request from two years ago that moved lots of stuff around.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the notes are also added to the NoteSubFolderTree now

Ok, the note sub-folder tree is disabled when I restart the application. Still strange.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I'm wondering why in the firstplace is the note list used for the tree, and not the directory view.

Because the directory view lacks far more interaction for making notes work there than the notetree widget.

Copy link
Contributor Author

@discapes discapes Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the directory view lacks far more interaction for making notes work there than the notetree widget.

Got it. I guess NoteSubFolderTree is involved because the buildTreeForParentItem method was found useful. It confused me at first since it's getting called on an item that's not a part of the NoteSubFolderTree, and I'm surprised it works. But that's fine. Anyway, I moved the connect() calls to a better place in the last commit.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a lot got mixed up in the "cleanup contribution" two years ago...

connect(ui->noteTreeWidget, &QTreeWidget::itemCollapsed, ui->noteSubFolderTreeWidget, &NoteSubFolderTree::onItemExpanded);

itemCount = Note::countAll();
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/widgets/notesubfoldertree.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ class NoteSubFolderTree : public QTreeWidget {

static QMenu *contextMenu(QTreeWidget *parent);

private Q_SLOTS:
pbek marked this conversation as resolved.
Show resolved Hide resolved
void onItemExpanded(QTreeWidgetItem *item);

private Q_SLOTS:
void onContextMenuRequested(QPoint pos);
void onCurrentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
void onItemChanged(QTreeWidgetItem *item, int column);
Expand Down
Loading