optimize favorites sidebar

svn path=/trunk/; revision=9090
This commit is contained in:
Martin Fuchs 2004-04-12 07:38:17 +00:00
parent 2a1a6cbf85
commit 387d641ed5
6 changed files with 90 additions and 41 deletions

View file

@ -136,20 +136,20 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
_right = NULL;
switch(info._etype) {
case ET_SHELL: { //@@ evtl. Aufteilung von FileChildWindow in ShellChildWindow, WinChildWindow, UnixChildWindow
case ET_SHELL: { //@@ separate into FileChildWindow in ShellChildWindow, WinChildWindow, UnixChildWindow ?
_root._drive_type = DRIVE_UNKNOWN;
lstrcpy(drv, TEXT("\\"));
lstrcpy(_root._volname, TEXT("Desktop"));
_root._fs_flags = 0;
lstrcpy(_root._fs, TEXT("Shell"));
const ShellChildWndInfo& shell_info = static_cast<const ShellChildWndInfo&>(info);
_root._entry = new ShellDirectory(GetDesktopFolder(), DesktopFolderPath(), hwnd);
const ShellChildWndInfo& shell_info = static_cast<const ShellChildWndInfo&>(info);
entry = _root._entry->read_tree((LPCTSTR)&*shell_info._shell_path, SORT_NAME);
break;}
#ifdef __WINE__
case ET_UNIX: {
case ET_UNIX:
_root._drive_type = GetDriveType(info._path);
_tsplitpath(info._path, drv, NULL, NULL, NULL);
@ -160,8 +160,7 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
lstrcpy(_root._path, TEXT("/"));
_root._entry = new UnixDirectory(_root._path);
entry = _root._entry->read_tree(info._path, SORT_NAME);
break;}
break;
#endif
case ET_NTOBJS:
@ -235,22 +234,22 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
_header_wdths_ok = false;
if (entry)
set_curdir(entry, hwnd);
set_curdir(entry);
if (_left_hwnd) {
int idx = ListBox_FindItemData(_left_hwnd, ListBox_GetCurSel(_left_hwnd), _left->_cur);
ListBox_SetCurSel(_left_hwnd, idx);
///@todo scroll to visibility
}
///@todo scroll to visibility
// store path into history
if (*info._path)
if (info._path && *info._path)
_url_history.push(info._path);
}
void FileChildWindow::set_curdir(Entry* entry, HWND hwnd)
void FileChildWindow::set_curdir(Entry* entry)
{
CONTEXT("FileChildWindow::set_curdir()");
@ -262,7 +261,7 @@ void FileChildWindow::set_curdir(Entry* entry, HWND hwnd)
if (entry) {
if (!entry->_scanned)
scan_entry(entry, hwnd);
scan_entry(entry);
else {
ListBox_ResetContent(_right_hwnd);
_right->insert_entries(entry->_down, -1);
@ -273,8 +272,8 @@ void FileChildWindow::set_curdir(Entry* entry, HWND hwnd)
entry->get_path(_path);
}
if (hwnd) // only change window title, if the window already exists
SetWindowText(hwnd, _path);
if (_hwnd) // only change window title if the window already exists
SetWindowText(_hwnd, _path);
if (_path[0])
if (SetCurrentDirectory(_path))
@ -459,14 +458,14 @@ LRESULT FileChildWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
case ID_REFRESH: {CONTEXT("ID_REFRESH");
bool expanded = _left->_cur->_expanded;
scan_entry(_left->_cur, _hwnd);
scan_entry(_left->_cur);
if (expanded)
expand_entry(_left->_cur);
break;}
case ID_ACTIVATE: {CONTEXT("ID_ACTIVATE");
activate_entry(pane, _hwnd);
activate_entry(pane);
break;}
default:
@ -536,13 +535,13 @@ int FileChildWindow::Command(int id, int code)
Entry* entry = (Entry*) ListBox_GetItemData(*pane, idx);
if (pane == _left)
set_curdir(entry, _hwnd);
set_curdir(entry);
else
pane->_cur = entry;
break;}
case LBN_DBLCLK:
activate_entry(pane, _hwnd);
activate_entry(pane);
break;
}
@ -550,7 +549,7 @@ int FileChildWindow::Command(int id, int code)
}
void FileChildWindow::activate_entry(Pane* pane, HWND hwnd)
void FileChildWindow::activate_entry(Pane* pane)
{
Entry* entry = pane->_cur;
@ -563,7 +562,7 @@ void FileChildWindow::activate_entry(Pane* pane, HWND hwnd)
int scanned_old = entry->_scanned;
if (!scanned_old)
scan_entry(entry, hwnd);
scan_entry(entry);
if (entry->_data.cFileName[0]==TEXT('.') && entry->_data.cFileName[1]==TEXT('\0'))
return;
@ -580,7 +579,8 @@ void FileChildWindow::activate_entry(Pane* pane, HWND hwnd)
if (!pane->_treePane) focus_entry: {
int idx = ListBox_FindItemData(_left_hwnd, ListBox_GetCurSel(_left_hwnd), entry);
ListBox_SetCurSel(_left_hwnd, idx);
set_curdir(entry, _hwnd);
set_curdir(entry);
}
}
@ -595,7 +595,7 @@ void FileChildWindow::activate_entry(Pane* pane, HWND hwnd)
}
void FileChildWindow::scan_entry(Entry* entry, HWND hwnd)
void FileChildWindow::scan_entry(Entry* entry)
{
CONTEXT("FileChildWindow::scan_entry()");
@ -646,9 +646,49 @@ String FileChildWindow::jump_to_int(LPCTSTR url)
String dir, fname;
if (SplitFileSysURL(url, dir, fname)) {
//@@jump_to(path);
Entry* entry = NULL;
return FmtString(TEXT("file://%s"), (LPCTSTR)dir);
if (_root._entry)
switch(_root._entry->_etype) {
case ET_SHELL: { //@@ separate into FileChildWindow in ShellChildWindow, WinChildWindow, UnixChildWindow ?
ShellPath shell_path(dir);
entry = _root._entry->read_tree((LPCTSTR)&*shell_path, SORT_NAME);
break;}
#ifdef __WINE__
case ET_UNIX:
entry = _root._entry->read_tree(info._path, SORT_NAME);
break;
#endif
case ET_NTOBJS:
entry = _root._entry->read_tree(dir, SORT_NAME);
break;
case ET_REGISTRY:
entry = _root._entry->read_tree(dir, SORT_NONE);
break;
case ET_FAT: {
entry = _root._entry->read_tree(dir, SORT_NONE);
break;}
default: // ET_WINDOWS
entry = _root._entry->read_tree(dir, SORT_NAME); //@@ smart_scan() ?!
}
if (entry) {
set_curdir(entry);
if (_left_hwnd) {
int idx = ListBox_FindItemData(_left_hwnd, ListBox_GetCurSel(_left_hwnd), entry);
ListBox_SetCurSel(_left_hwnd, idx);
///@todo scroll to visibility
}
return FmtString(TEXT("file://%s"), (LPCTSTR)dir);
}
}
return String();

View file

@ -101,13 +101,13 @@ protected:
virtual void resize_children(int cx, int cy);
virtual String jump_to_int(LPCTSTR url);
void scan_entry(Entry* entry, HWND hwnd);
void scan_entry(Entry* entry);
bool expand_entry(Entry* dir);
static void collapse_entry(Pane* pane, Entry* dir);
void set_curdir(Entry* entry, HWND hwnd);
void activate_entry(Pane* pane, HWND hwnd);
void set_curdir(Entry* entry);
void activate_entry(Pane* pane);
protected:
Root _root;

View file

@ -265,7 +265,7 @@ MainFrame::MainFrame(HWND hwnd)
new EditController(_haddressedit);
_hcommandedit = CreateWindow(TEXT("EDIT"), TEXT("> "), WS_CHILD|WS_VISIBLE, 0, 0, 0, rect.bottom,
hwnd, (HMENU)IDW_ADDRESSBAR, g_Globals._hInstance, 0);
hwnd, (HMENU)IDW_COMMANDBAR, g_Globals._hInstance, 0);
SetWindowFont(_hcommandedit, hfont, FALSE);
new EditController(_hcommandedit);
@ -278,14 +278,12 @@ MainFrame::MainFrame(HWND hwnd)
CheckMenuItem(_menu_info._hMenuView, ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
_hsidebar = CreateWindowEx(WS_EX_STATICEDGE, WC_TREEVIEW, TEXT("Sidebar"),
WS_CHILD|WS_TABSTOP|WS_BORDER|WS_VISIBLE|WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_SHOWSELALWAYS|TVS_INFOTIP,
WS_CHILD|WS_TABSTOP|WS_BORDER|/*WS_VISIBLE|*/WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_SHOWSELALWAYS|TVS_INFOTIP,
-1, -1, 200, 0, _hwnd, (HMENU)IDW_SIDEBAR, g_Globals._hInstance, 0);
TreeView_SetImageList(_hsidebar, _himl, TVSIL_NORMAL);
CheckMenuItem(_menu_info._hMenuView, ID_VIEW_SIDE_BAR, MF_BYCOMMAND|MF_CHECKED);
FillBookmarks();
CheckMenuItem(_menu_info._hMenuView, ID_VIEW_SIDE_BAR, MF_BYCOMMAND|MF_UNCHECKED/*MF_CHECKED*/);
}
@ -625,6 +623,10 @@ int MainFrame::Command(int id, int code)
break;
case ID_VIEW_SIDE_BAR:
// lazy initialization
if (!TreeView_GetCount(_hsidebar))
FillBookmarks();
toggle_child(_hwnd, id, _hsidebar);
break;

View file

@ -44,7 +44,7 @@ ShellBrowserChild::ShellBrowserChild(HWND hwnd, const ShellChildWndInfo& info)
_last_sel = 0;
// store path into history
if (*info._path)
if (info._path && *info._path)
_url_history.push(info._path);
}
@ -442,8 +442,8 @@ int ShellBrowserChild::Notify(int id, NMHDR* pnmh)
{
switch(pnmh->code) {
case TVN_GETDISPINFO: OnTreeGetDispInfo(id, pnmh); break;
case TVN_ITEMEXPANDING: OnTreeItemExpanding(id, (LPNMTREEVIEW)pnmh); break;
case TVN_SELCHANGED: OnTreeItemSelected(id, (LPNMTREEVIEW)pnmh); break;
case TVN_ITEMEXPANDING: OnTreeItemExpanding(id, (LPNMTREEVIEW)pnmh); break;
case NM_RCLICK: OnTreeItemRClick(id, pnmh); break;
default: return super::Notify(id, pnmh);
}
@ -539,7 +539,10 @@ String ShellBrowserChild::jump_to_int(LPCTSTR url)
bool ShellBrowserChild::jump_to_pidl(LPCITEMIDLIST pidl)
{
//@@
/*@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()
*/
return false;
}

View file

@ -156,11 +156,13 @@ bool ShellDirectory::get_path(PTSTR path) const
path[0] = TEXT('\0');
SFGAOF attribs = 0;
if (_folder.empty())
return false;
if (!_folder.empty())
if (FAILED(const_cast<ShellFolder&>(_folder)->GetAttributesOf(1, (LPCITEMIDLIST*)&_pidl, &attribs)))
return false;
SFGAOF attribs = SFGAO_FILESYSTEM;
if (FAILED(const_cast<ShellFolder&>(_folder)->GetAttributesOf(1, (LPCITEMIDLIST*)&_pidl, &attribs)))
return false;
if (!(attribs & SFGAO_FILESYSTEM))
return false;

View file

@ -257,14 +257,16 @@ protected:
struct HiddenWindow : public WindowHandle
{
HiddenWindow(HWND hwnd)
: WindowHandle(hwnd)
: WindowHandle(IsWindowVisible(hwnd)? hwnd: 0)
{
SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW|SWP_NOREDRAW|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER);
if (_hwnd)
SetWindowPos(_hwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW|SWP_NOREDRAW|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER);
}
~HiddenWindow()
{
SetWindowPos(_hwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER);
if (_hwnd)
SetWindowPos(_hwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER);
}
};