diff --git a/reactos/subsys/system/explorer/shell/filechild.cpp b/reactos/subsys/system/explorer/shell/filechild.cpp index ac22313aac4..be000793fc8 100644 --- a/reactos/subsys/system/explorer/shell/filechild.cpp +++ b/reactos/subsys/system/explorer/shell/filechild.cpp @@ -664,6 +664,7 @@ String FileChildWindow::jump_to_int(LPCTSTR url) if (SplitFileSysURL(url, dir, fname)) { Entry* entry = NULL; + // call read_tree() to iterate through the hierarchy and open all folders to reach dir if (_root._entry) switch(_root._entry->_etype) { case ET_SHELL: { //@@ separate into FileChildWindow in ShellChildWindow, WinChildWindow, UnixChildWindow ? @@ -672,27 +673,24 @@ String FileChildWindow::jump_to_int(LPCTSTR url) break;} #ifdef __WINE__ - case ET_UNIX: - { + case ET_UNIX: { LPCTSTR path = dir; if (!_tcsicmp(path, _root._path, _tcslen(_root._path))) path += _tcslen(_root._path); entry = _root.read_tree(path); - } - break; + break;} #endif - default: // ET_UNIX, ET_NTOBJS, ET_REGISTRY, ET_FAT, ET_WINDOWS - { + default: { // ET_NTOBJS, ET_REGISTRY, ET_FAT, ET_WINDOWS LPCTSTR path = dir; if (!_tcsnicmp(path, _root._path, _tcslen(_root._path))) path += _tcslen(_root._path); entry = _root.read_tree(path); - } + break;} } if (entry) { @@ -722,6 +720,8 @@ String FileChildWindow::jump_to_int(LPCTSTR url) } } + ///@todo use fname + return dir; //FmtString(TEXT("file://%s"), (LPCTSTR)dir); } } diff --git a/reactos/subsys/system/explorer/shell/shellbrowser.cpp b/reactos/subsys/system/explorer/shell/shellbrowser.cpp index 2dd766b83dd..f436b40e06e 100644 --- a/reactos/subsys/system/explorer/shell/shellbrowser.cpp +++ b/reactos/subsys/system/explorer/shell/shellbrowser.cpp @@ -107,6 +107,9 @@ LRESULT ShellBrowserChild::Init(LPCREATESTRUCT pcs) _hwnd, (HMENU)IDC_FILETREE, g_Globals._hInstance, 0); if (_left_hwnd) { + TreeView_SetImageList(_left_hwnd, _himlSmall, TVSIL_NORMAL); + TreeView_SetScrollTime(_left_hwnd, 100); + InitializeTree(); InitDragDrop(); @@ -121,9 +124,6 @@ void ShellBrowserChild::InitializeTree() { CONTEXT("ShellBrowserChild::InitializeTree()"); - TreeView_SetImageList(_left_hwnd, _himlSmall, TVSIL_NORMAL); - TreeView_SetScrollTime(_left_hwnd, 100); - TV_INSERTSTRUCT tvInsert; tvInsert.hParent = 0; @@ -477,7 +477,7 @@ HRESULT ShellBrowserChild::OnDefaultCommand(LPIDA pida) if (entry && (entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) if (entry->_etype == ET_SHELL) - if (expand_folder(static_cast(entry))) + if (_last_sel && select_entry(_last_sel, entry)) return S_OK; } } @@ -496,28 +496,27 @@ HRESULT ShellBrowserChild::OnDefaultCommand(LPIDA pida) } -bool ShellBrowserChild::expand_folder(ShellDirectory* entry) +HTREEITEM ShellBrowserChild::select_entry(HTREEITEM hitem, Entry* entry, bool expand) { - CONTEXT("ShellBrowserChild::expand_folder()"); + CONTEXT("ShellBrowserChild::select_entry()"); - //HTREEITEM hitem_sel = TreeView_GetSelection(_left_hwnd); - if (!_last_sel) - return false; + if (expand && !TreeView_Expand(_left_hwnd, hitem, TVE_EXPAND)) + return 0; - if (!TreeView_Expand(_left_hwnd, _last_sel, TVE_EXPAND)) - return false; + for(hitem=TreeView_GetChild(_left_hwnd,hitem); hitem; hitem=TreeView_GetNextSibling(_left_hwnd,hitem)) { + if ((Entry*)TreeView_GetItemData(_left_hwnd,hitem) == entry) { + if (TreeView_SelectItem(_left_hwnd, hitem)) { + if (expand) + TreeView_Expand(_left_hwnd, hitem, TVE_EXPAND); - for(HTREEITEM hitem=TreeView_GetChild(_left_hwnd,_last_sel); hitem; hitem=TreeView_GetNextSibling(_left_hwnd,hitem)) { - if ((ShellDirectory*)TreeView_GetItemData(_left_hwnd,hitem) == entry) { - if (TreeView_SelectItem(_left_hwnd, hitem) && - TreeView_Expand(_left_hwnd, hitem, TVE_EXPAND)) - return true; + return hitem; + } break; } } - return false; + return 0; } @@ -530,9 +529,13 @@ String ShellBrowserChild::jump_to_int(LPCTSTR url) return url; } - if (SplitFileSysURL(url, dir, fname)) + if (SplitFileSysURL(url, dir, fname)) { + + ///@todo use fname + if (jump_to_pidl(ShellPath(dir))) return FmtString(TEXT("file://%s"), (LPCTSTR)dir); + } return String(); } @@ -540,11 +543,31 @@ String ShellBrowserChild::jump_to_int(LPCTSTR url) bool ShellBrowserChild::jump_to_pidl(LPCITEMIDLIST pidl) { + if (!_root._entry) + return false; -/*@todo - we should call read_tree() here to iterate through the hierarchy and open all folders from shell_info._root_shell_path to shell_info._shell_path - -> see FileChildWindow::FileChildWindow() -*/ + // iterate through the hierarchy and open all folders to reach pidl + WaitCursor wait; + + HTREEITEM hitem = TreeView_GetRoot(_left_hwnd); + Entry* entry = _root._entry; + + for(const void*p=pidl;;) { + if (!p) + return true; + + if (!entry || !hitem) + break; + + entry->smart_scan(SORT_NAME); + + Entry* found = entry->find_entry(p); + p = entry->get_next_path_component(p); + + hitem = select_entry(hitem, found); + + entry = found; + } return false; } diff --git a/reactos/subsys/system/explorer/shell/shellbrowser.h b/reactos/subsys/system/explorer/shell/shellbrowser.h index 4849c538393..a7546d4b02d 100644 --- a/reactos/subsys/system/explorer/shell/shellbrowser.h +++ b/reactos/subsys/system/explorer/shell/shellbrowser.h @@ -135,5 +135,5 @@ protected: void UpdateFolderView(IShellFolder* folder); void Tree_DoItemMenu(HWND hwndTreeView, HTREEITEM hItem, LPPOINT pptScreen); - bool expand_folder(ShellDirectory* entry); + HTREEITEM select_entry(HTREEITEM hitem, Entry* entry, bool expand=true); };