diff --git a/libs/wxutil/fsview/FileSystemView.cpp b/libs/wxutil/fsview/FileSystemView.cpp index 28d92a7d20..793053c518 100644 --- a/libs/wxutil/fsview/FileSystemView.cpp +++ b/libs/wxutil/fsview/FileSystemView.cpp @@ -112,11 +112,11 @@ void FileSystemView::Populate(const std::string& preselectPath) wxutil::TreeModel::Row row = _treeStore->AddItem(); - wxIcon prefabIcon; - prefabIcon.CopyFromBitmap( - wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "cmenu_add_prefab.png")); + wxIcon loadingIcon; + loadingIcon.CopyFromBitmap( + wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + _fileIcon)); - row[Columns().filename] = wxVariant(wxDataViewIconText(_("Loading..."), prefabIcon)); + row[Columns().filename] = wxVariant(wxDataViewIconText(_("Loading..."), loadingIcon)); row[Columns().isFolder] = false; row[Columns().vfspath] = "__loadingnode__"; // to prevent that item from being found row.SendItemAdded(); @@ -138,6 +138,13 @@ void FileSystemView::SelectPath(const std::string& path) SelectItem(_treeStore->FindString(path, Columns().vfspath)); } +void FileSystemView::ExpandPath(const std::string& path) +{ + if (path.empty()) return; + + Expand(_treeStore->FindString(path, Columns().vfspath)); +} + std::string FileSystemView::GetSelectedPath() { wxDataViewItem item = GetSelection(); @@ -213,6 +220,14 @@ void FileSystemView::OnTreeStorePopulationFinished(TreeModel::PopulationFinished // Auto-size the first level TriggerColumnSizeEvent(); + + // Call client code + _signalTreePopulated.emit(); +} + +sigc::signal& FileSystemView::signal_TreePopulated() +{ + return _signalTreePopulated; } } diff --git a/libs/wxutil/fsview/FileSystemView.h b/libs/wxutil/fsview/FileSystemView.h index 29b49d61ac..d7c5121b13 100644 --- a/libs/wxutil/fsview/FileSystemView.h +++ b/libs/wxutil/fsview/FileSystemView.h @@ -33,6 +33,8 @@ class FileSystemView : std::set _fileExtensions; + sigc::signal _signalTreePopulated; + public: class SelectionChangedEvent : public wxEvent @@ -83,6 +85,10 @@ class FileSystemView : std::string GetSelectedPath(); bool GetIsFolderSelected(); + void ExpandPath(const std::string& path); + + sigc::signal& signal_TreePopulated(); + private: TreeModel::Ptr CreateDefaultModel(); diff --git a/libs/wxutil/fsview/Populator.cpp b/libs/wxutil/fsview/Populator.cpp index 59604fdf3b..bcdefa0a2e 100644 --- a/libs/wxutil/fsview/Populator.cpp +++ b/libs/wxutil/fsview/Populator.cpp @@ -66,11 +66,12 @@ void Populator::visitFile(const vfs::FileInfo& fileInfo) { // The population callback will be called multiple times for deeper files, // but only one of them will be have isFolder == false, which is our actual file - + std::string fullPath = _basePath + path; + // Get the display path, everything after rightmost slash row[_columns.filename] = wxVariant(wxDataViewIconText(leafName, isFolder ? _folderIcon : GetIconForFile(leafName))); - row[_columns.vfspath] = _basePath + path; + row[_columns.vfspath] = isFolder ? os::standardPathWithSlash(fullPath) : fullPath; row[_columns.isFolder] = isFolder; if (!isFolder) diff --git a/radiant/ui/mapselector/MapSelector.cpp b/radiant/ui/mapselector/MapSelector.cpp index d971f28004..be5da32349 100644 --- a/radiant/ui/mapselector/MapSelector.cpp +++ b/radiant/ui/mapselector/MapSelector.cpp @@ -34,7 +34,7 @@ MapSelector::MapSelector() : vbox->Add(_treeView, 1, wxEXPAND); _buttons = CreateStdDialogButtonSizer(wxOK | wxCANCEL); - wxButton* reloadButton = new wxButton(this, wxID_ANY, _("Rescan")); + wxButton* reloadButton = new wxButton(this, wxID_ANY, _("Refresh")); reloadButton->Bind(wxEVT_BUTTON, &MapSelector::onRescanPath, this); _buttons->Prepend(reloadButton, 0, wxRIGHT, 32); @@ -87,7 +87,8 @@ void MapSelector::setupTreeView(wxWindow* parent) { _treeView = wxutil::FileSystemView::Create(parent, wxBORDER_STATIC | wxDV_NO_HEADER); _treeView->Bind(wxutil::EV_FSVIEW_SELECTION_CHANGED, &MapSelector::onSelectionChanged, this); - _treeView->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, &MapSelector::OnItemActivated, this);; + _treeView->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, &MapSelector::onItemActivated, this);; + _treeView->signal_TreePopulated().connect(sigc::mem_fun(this, &MapSelector::onFileViewTreePopulated)); // Get the extensions from all possible patterns (e.g. *.map or *.mapx) FileTypePatterns patterns = GlobalFiletypes().getPatternsForType(filetype::TYPE_MAP); @@ -185,7 +186,7 @@ void MapSelector::onSelectionChanged(wxutil::FileSystemView::SelectionChangedEve updateButtonSensitivity(); } -void MapSelector::OnItemActivated(wxDataViewEvent& ev) +void MapSelector::onItemActivated(wxDataViewEvent& ev) { auto selectedPath = _treeView->GetSelectedPath(); auto extension = string::to_lower_copy(os::getExtension(selectedPath)); @@ -201,6 +202,11 @@ void MapSelector::OnItemActivated(wxDataViewEvent& ev) } } +void MapSelector::onFileViewTreePopulated() +{ + _treeView->ExpandPath("maps/"); +} + std::string MapSelector::getSelectedPath() { return _treeView->GetSelectedPath(); diff --git a/radiant/ui/mapselector/MapSelector.h b/radiant/ui/mapselector/MapSelector.h index 1630f5f0c6..4108501e98 100644 --- a/radiant/ui/mapselector/MapSelector.h +++ b/radiant/ui/mapselector/MapSelector.h @@ -52,8 +52,9 @@ class MapSelector : std::string getSelectedPath(); void onRescanPath(wxCommandEvent& ev); - void OnItemActivated(wxDataViewEvent& ev); + void onItemActivated(wxDataViewEvent& ev); void onSelectionChanged(wxutil::FileSystemView::SelectionChangedEvent& ev); + void onFileViewTreePopulated(); void updateButtonSensitivity(); void onPathSelectionChanged();