ShellBrowserChild: jump to addressbar target

svn path=/trunk/; revision=9117
This commit is contained in:
Martin Fuchs 2004-04-12 19:49:12 +00:00
parent 77fbf2134e
commit bdf792d41a
3 changed files with 53 additions and 30 deletions

View file

@ -664,6 +664,7 @@ String FileChildWindow::jump_to_int(LPCTSTR url)
if (SplitFileSysURL(url, dir, fname)) { if (SplitFileSysURL(url, dir, fname)) {
Entry* entry = NULL; Entry* entry = NULL;
// call read_tree() to iterate through the hierarchy and open all folders to reach dir
if (_root._entry) if (_root._entry)
switch(_root._entry->_etype) { switch(_root._entry->_etype) {
case ET_SHELL: { //@@ separate into FileChildWindow in ShellChildWindow, WinChildWindow, UnixChildWindow ? case ET_SHELL: { //@@ separate into FileChildWindow in ShellChildWindow, WinChildWindow, UnixChildWindow ?
@ -672,27 +673,24 @@ String FileChildWindow::jump_to_int(LPCTSTR url)
break;} break;}
#ifdef __WINE__ #ifdef __WINE__
case ET_UNIX: case ET_UNIX: {
{
LPCTSTR path = dir; LPCTSTR path = dir;
if (!_tcsicmp(path, _root._path, _tcslen(_root._path))) if (!_tcsicmp(path, _root._path, _tcslen(_root._path)))
path += _tcslen(_root._path); path += _tcslen(_root._path);
entry = _root.read_tree(path); entry = _root.read_tree(path);
} break;}
break;
#endif #endif
default: // ET_UNIX, ET_NTOBJS, ET_REGISTRY, ET_FAT, ET_WINDOWS default: { // ET_NTOBJS, ET_REGISTRY, ET_FAT, ET_WINDOWS
{
LPCTSTR path = dir; LPCTSTR path = dir;
if (!_tcsnicmp(path, _root._path, _tcslen(_root._path))) if (!_tcsnicmp(path, _root._path, _tcslen(_root._path)))
path += _tcslen(_root._path); path += _tcslen(_root._path);
entry = _root.read_tree(path); entry = _root.read_tree(path);
} break;}
} }
if (entry) { if (entry) {
@ -722,6 +720,8 @@ String FileChildWindow::jump_to_int(LPCTSTR url)
} }
} }
///@todo use fname
return dir; //FmtString(TEXT("file://%s"), (LPCTSTR)dir); return dir; //FmtString(TEXT("file://%s"), (LPCTSTR)dir);
} }
} }

View file

@ -107,6 +107,9 @@ LRESULT ShellBrowserChild::Init(LPCREATESTRUCT pcs)
_hwnd, (HMENU)IDC_FILETREE, g_Globals._hInstance, 0); _hwnd, (HMENU)IDC_FILETREE, g_Globals._hInstance, 0);
if (_left_hwnd) { if (_left_hwnd) {
TreeView_SetImageList(_left_hwnd, _himlSmall, TVSIL_NORMAL);
TreeView_SetScrollTime(_left_hwnd, 100);
InitializeTree(); InitializeTree();
InitDragDrop(); InitDragDrop();
@ -121,9 +124,6 @@ void ShellBrowserChild::InitializeTree()
{ {
CONTEXT("ShellBrowserChild::InitializeTree()"); CONTEXT("ShellBrowserChild::InitializeTree()");
TreeView_SetImageList(_left_hwnd, _himlSmall, TVSIL_NORMAL);
TreeView_SetScrollTime(_left_hwnd, 100);
TV_INSERTSTRUCT tvInsert; TV_INSERTSTRUCT tvInsert;
tvInsert.hParent = 0; tvInsert.hParent = 0;
@ -477,7 +477,7 @@ HRESULT ShellBrowserChild::OnDefaultCommand(LPIDA pida)
if (entry && (entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) if (entry && (entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
if (entry->_etype == ET_SHELL) if (entry->_etype == ET_SHELL)
if (expand_folder(static_cast<ShellDirectory*>(entry))) if (_last_sel && select_entry(_last_sel, entry))
return S_OK; 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 (expand && !TreeView_Expand(_left_hwnd, hitem, TVE_EXPAND))
if (!_last_sel) return 0;
return false;
if (!TreeView_Expand(_left_hwnd, _last_sel, TVE_EXPAND)) for(hitem=TreeView_GetChild(_left_hwnd,hitem); hitem; hitem=TreeView_GetNextSibling(_left_hwnd,hitem)) {
return false; 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)) { return hitem;
if ((ShellDirectory*)TreeView_GetItemData(_left_hwnd,hitem) == entry) { }
if (TreeView_SelectItem(_left_hwnd, hitem) &&
TreeView_Expand(_left_hwnd, hitem, TVE_EXPAND))
return true;
break; break;
} }
} }
return false; return 0;
} }
@ -530,9 +529,13 @@ String ShellBrowserChild::jump_to_int(LPCTSTR url)
return url; return url;
} }
if (SplitFileSysURL(url, dir, fname)) if (SplitFileSysURL(url, dir, fname)) {
///@todo use fname
if (jump_to_pidl(ShellPath(dir))) if (jump_to_pidl(ShellPath(dir)))
return FmtString(TEXT("file://%s"), (LPCTSTR)dir); return FmtString(TEXT("file://%s"), (LPCTSTR)dir);
}
return String(); return String();
} }
@ -540,11 +543,31 @@ String ShellBrowserChild::jump_to_int(LPCTSTR url)
bool ShellBrowserChild::jump_to_pidl(LPCITEMIDLIST pidl) bool ShellBrowserChild::jump_to_pidl(LPCITEMIDLIST pidl)
{ {
if (!_root._entry)
return false;
/*@todo // iterate through the hierarchy and open all folders to reach pidl
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 WaitCursor wait;
-> see FileChildWindow::FileChildWindow()
*/ 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; return false;
} }

View file

@ -135,5 +135,5 @@ protected:
void UpdateFolderView(IShellFolder* folder); void UpdateFolderView(IShellFolder* folder);
void Tree_DoItemMenu(HWND hwndTreeView, HTREEITEM hItem, LPPOINT pptScreen); void Tree_DoItemMenu(HWND hwndTreeView, HTREEITEM hItem, LPPOINT pptScreen);
bool expand_folder(ShellDirectory* entry); HTREEITEM select_entry(HTREEITEM hitem, Entry* entry, bool expand=true);
}; };