diff options
author | Christopher Dumas <christopherdumas@gmail.com> | 2019-05-23 14:15:57 -0700 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-24 00:24:28 +0200 |
commit | 00075b1c8a8b0d51b0cc565f22cfba39414bd8c3 (patch) | |
tree | 51068cab9c8e3f363d0a3152be5fe0a46e998518 /Applications/FileManager/DirectoryView.cpp | |
parent | fba57d6ba3f0b5fc56d01874df2f37a0d21a32c3 (diff) | |
download | serenity-00075b1c8a8b0d51b0cc565f22cfba39414bd8c3.zip |
Added functionality to make back and forward buttons work in FileManager. Also
fixed it so that directories don't get double-opened (first when they are
opened, and second when the selection changes to match in the file tree view)
Diffstat (limited to 'Applications/FileManager/DirectoryView.cpp')
-rw-r--r-- | Applications/FileManager/DirectoryView.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/Applications/FileManager/DirectoryView.cpp b/Applications/FileManager/DirectoryView.cpp index 5265943129..cf8187ecd4 100644 --- a/Applications/FileManager/DirectoryView.cpp +++ b/Applications/FileManager/DirectoryView.cpp @@ -108,8 +108,18 @@ void DirectoryView::set_view_mode(ViewMode mode) ASSERT_NOT_REACHED(); } +void DirectoryView::add_path_to_history(const String& path) +{ + if (m_path_history_position < m_path_history.size()) + m_path_history.resize(m_path_history_position + 1); + + m_path_history.append(path); + m_path_history_position = m_path_history.size() - 1; +} + void DirectoryView::open(const String& path) { + add_path_to_history(path); model().open(path); } @@ -121,10 +131,27 @@ void DirectoryView::set_status_message(const String& message) void DirectoryView::open_parent_directory() { - model().open(String::format("%s/..", model().path().characters())); + auto path = String::format("%s/..", model().path().characters()); + add_path_to_history(path); + model().open(path); } void DirectoryView::refresh() { model().update(); } + +void DirectoryView::open_previous_directory() +{ + if (m_path_history_position > 0) { + m_path_history_position--; + model().open(m_path_history[m_path_history_position]); + } +} +void DirectoryView::open_next_directory() +{ + if (m_path_history_position < m_path_history.size() - 1) { + m_path_history_position++; + model().open(m_path_history[m_path_history_position]); + } +} |