diff --git a/src/gui/FileListWidget.cxx b/src/gui/FileListWidget.cxx index 3b758ca38..462f56d41 100644 --- a/src/gui/FileListWidget.cxx +++ b/src/gui/FileListWidget.cxx @@ -34,16 +34,19 @@ FileListWidget::FileListWidget(GuiObject* boss, const GUI::Font& font, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FileListWidget::setDirectory(const FilesystemNode& node, string select) +void FileListWidget::setDirectory(const FilesystemNode& node, + const string& select) { _node = node; // We always want a directory listing if(!_node.isDirectory() && _node.hasParent()) { - select = _node.getName(); + _selectedFile = _node.getName(); _node = _node.getParent(); } + else + _selectedFile = select; // Initialize history FilesystemNode tmp = _node; @@ -62,11 +65,12 @@ void FileListWidget::setDirectory(const FilesystemNode& node, string select) _history.reverse(); // Finally, go to this location - setLocation(_node, select); + setLocation(_node, _selectedFile); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FileListWidget::setLocation(const FilesystemNode& node, const string& select) +void FileListWidget::setLocation(const FilesystemNode& node, + const string& select) { _node = node; @@ -90,7 +94,7 @@ void FileListWidget::setLocation(const FilesystemNode& node, const string& selec void FileListWidget::selectDirectory() { _history.push(selected().getName()); - setLocation(selected()); + setLocation(selected(), _selectedFile); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/FileListWidget.hxx b/src/gui/FileListWidget.hxx index 459afd07c..552331b29 100644 --- a/src/gui/FileListWidget.hxx +++ b/src/gui/FileListWidget.hxx @@ -64,7 +64,7 @@ class FileListWidget : public StringListWidget will instead be used, and the file will be selected @param select An optional entry to select (if applicable) */ - void setDirectory(const FilesystemNode& node, string select = ""); + void setDirectory(const FilesystemNode& node, const string& select = EmptyString); /** Select parent directory (if applicable) */ void selectParent(); @@ -83,7 +83,7 @@ class FileListWidget : public StringListWidget private: /** Very similar to setDirectory(), but also updates the history */ - void setLocation(const FilesystemNode& node, const string& select = EmptyString); + void setLocation(const FilesystemNode& node, const string& select); /** Descend into currently selected directory */ void selectDirectory(); @@ -99,6 +99,7 @@ class FileListWidget : public StringListWidget Common::FixedStack _history; uInt32 _selected{0}; + string _selectedFile; string _quickSelectStr; uInt64 _quickSelectTime{0};