From: <arn...@us...> - 2006-03-18 19:04:30
|
Revision: 591 Author: arnetheduck Date: 2006-03-18 11:04:20 -0800 (Sat, 18 Mar 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=591&view=rev Log Message: ----------- back/forward navigation, refactor ip getting Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/windows/DirectoryListingFrm.cpp dcplusplus/trunk/windows/DirectoryListingFrm.h dcplusplus/trunk/windows/SearchFrm.cpp dcplusplus/trunk/windows/SearchFrm.h dcplusplus/trunk/windows/WinUtil.h Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-03-18 16:14:10 UTC (rev 590) +++ dcplusplus/trunk/changelog.txt 2006-03-18 19:04:20 UTC (rev 591) @@ -7,6 +7,7 @@ * Files with invalid crc-32, as per their sfv file, are no longer shared * [bug 873] Added connect to hub option (thanks joakim tosteberg) * Fixed an issue with linux file reading (thanks bart vullings and steven) +* Added back/forward mouse/keyboard navigation to directory listing frame -- 0.687 2006-02-26 -- * Fixed XML file list generation for invalid filenames from other os's Modified: dcplusplus/trunk/windows/DirectoryListingFrm.cpp =================================================================== --- dcplusplus/trunk/windows/DirectoryListingFrm.cpp 2006-03-18 16:14:10 UTC (rev 590) +++ dcplusplus/trunk/windows/DirectoryListingFrm.cpp 2006-03-18 19:04:20 UTC (rev 591) @@ -38,7 +38,6 @@ static ResourceManager::Strings columnNames[] = { ResourceManager::FILE, ResourceManager::TYPE, ResourceManager::EXACT_SIZE, ResourceManager::SIZE, ResourceManager::TTH_ROOT }; - DirectoryListingFrame::UserMap DirectoryListingFrame::lists; void DirectoryListingFrame::openWindow(const tstring& aFile, const User::Ptr& aUser, int64_t aSpeed) { @@ -76,7 +75,8 @@ } DirectoryListingFrame::DirectoryListingFrame(const User::Ptr& aUser, int64_t aSpeed) : - statusContainer(STATUSCLASSNAME, this, STATUS_MESSAGE_MAP), + statusContainer(STATUSCLASSNAME, this, STATUS_MESSAGE_MAP), treeContainer(WC_TREEVIEW, this, CONTROL_MESSAGE_MAP), + listContainer(WC_LISTVIEW, this, CONTROL_MESSAGE_MAP), historyIndex(0), treeRoot(NULL), skipHits(0), files(0), speed(aSpeed), updating(false), dl(new DirectoryListing(aUser)), searching(false) { lists.insert(make_pair(aUser, this)); @@ -111,7 +111,9 @@ statusContainer.SubclassWindow(ctrlStatus.m_hWnd); ctrlTree.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_HASLINES | TVS_SHOWSELALWAYS | TVS_DISABLEDRAGDROP, WS_EX_CLIENTEDGE, IDC_DIRECTORIES); + treeContainer.SubclassWindow(ctrlTree); ctrlList.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS, WS_EX_CLIENTEDGE, IDC_FILES); + listContainer.SubclassWindow(ctrlList); ctrlList.SetExtendedListViewStyle(LVS_EX_LABELTIP | LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT); ctrlList.SetBkColor(WinUtil::bgColor); @@ -295,11 +297,20 @@ if(p->itemNew.state & TVIS_SELECTED) { DirectoryListing::Directory* d = (DirectoryListing::Directory*)p->itemNew.lParam; changeDir(d, TRUE); + addHistory(dl->getPath(d)); } return 0; } +void DirectoryListingFrame::addHistory(const string& name) { + history.erase(history.begin() + historyIndex, history.end()); + while(history.size() > 25) + history.pop_front(); + history.push_back(name); + historyIndex = history.size(); +} + void DirectoryListingFrame::changeDir(DirectoryListing::Directory* d, BOOL enableRedraw) { ctrlList.SetRedraw(FALSE); @@ -328,6 +339,25 @@ } } +void DirectoryListingFrame::back() { + if(history.size() > 1 && historyIndex > 1) { + size_t n = min(historyIndex, history.size()) - 1; + deque<string> tmp = history; + selectItem(Text::toT(history[n - 1])); + historyIndex = n; + history = tmp; + } +} +void DirectoryListingFrame::forward() { + if(history.size() > 1 && historyIndex < history.size()) { + size_t n = min(historyIndex, history.size() - 1); + deque<string> tmp = history; + selectItem(Text::toT(history[n])); + historyIndex = n + 1; + history = tmp; + } +} + LRESULT DirectoryListingFrame::onDoubleClickFiles(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) { NMITEMACTIVATE* item = (NMITEMACTIVATE*) pnmh; @@ -687,6 +717,18 @@ return FALSE; } +HRESULT DirectoryListingFrame::onXButtonUp(UINT /*uMsg*/, WPARAM wParam, LPARAM /* lParam */, BOOL& /* bHandled */) { + if(GET_XBUTTON_WPARAM(wParam) & XBUTTON1) { + back(); + return TRUE; + } else if(GET_XBUTTON_WPARAM(wParam) & XBUTTON2) { + forward(); + return TRUE; + } + + return FALSE; +} + LRESULT DirectoryListingFrame::onDownloadTarget(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { int newId = wID - IDC_DOWNLOAD_TARGET - 1; dcassert(newId >= 0); Modified: dcplusplus/trunk/windows/DirectoryListingFrm.h =================================================================== --- dcplusplus/trunk/windows/DirectoryListingFrm.h 2006-03-18 16:14:10 UTC (rev 590) +++ dcplusplus/trunk/windows/DirectoryListingFrm.h 2006-03-18 19:04:20 UTC (rev 591) @@ -36,7 +36,7 @@ #include "../client/FavoriteManager.h" #define STATUS_MESSAGE_MAP 9 - +#define CONTROL_MESSAGE_MAP 10 class DirectoryListingFrame : public MDITabChildWindowImpl<DirectoryListingFrame, RGB(255, 0, 255)>, public CSplitterImpl<DirectoryListingFrame>, public UCHandler<DirectoryListingFrame> @@ -115,6 +115,8 @@ COMMAND_ID_HANDLER(IDC_NEXT, onNext) COMMAND_ID_HANDLER(IDC_MATCH_QUEUE, onMatchQueue) COMMAND_ID_HANDLER(IDC_FILELIST_DIFF, onListDiff) + ALT_MSG_MAP(CONTROL_MESSAGE_MAP) + MESSAGE_HANDLER(WM_XBUTTONUP, onXButtonUp) END_MSG_MAP() LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled); @@ -132,6 +134,7 @@ LRESULT onDoubleClickFiles(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT onSelChangedDirectories(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT onContextMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled); + LRESULT onXButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled); LRESULT onDownloadFavoriteDirs(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT onDownloadWholeFavoriteDirs(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); @@ -226,6 +229,9 @@ HTREEITEM findFile(const StringSearch& str, HTREEITEM root, int &foundFile, int &skipHits); void updateStatus(); void initStatus(); + void addHistory(const string& name); + void back(); + void forward(); class ItemInfo : public FastAlloc<ItemInfo> { public: @@ -305,9 +311,14 @@ CMenu fileMenu; CMenu directoryMenu; CContainedWindow statusContainer; + CContainedWindow treeContainer; + CContainedWindow listContainer; StringList targets; + deque<string> history; + size_t historyIndex; + CTreeViewCtrl ctrlTree; TypedListViewCtrl<ItemInfo, IDC_FILES> ctrlList; CStatusBarCtrl ctrlStatus; Modified: dcplusplus/trunk/windows/SearchFrm.cpp =================================================================== --- dcplusplus/trunk/windows/SearchFrm.cpp 2006-03-18 16:14:10 UTC (rev 590) +++ dcplusplus/trunk/windows/SearchFrm.cpp 2006-03-18 19:04:20 UTC (rev 591) @@ -243,7 +243,7 @@ int n = ctrlHubs.GetItemCount(); for(int i = 0; i < n; i++) { if(ctrlHubs.GetCheckState(i)) { - clients.push_back(Text::fromT(ctrlHubs.getItemData(i)->ipPort)); + clients.push_back(Text::fromT(ctrlHubs.getItemData(i)->url)); } } @@ -1055,7 +1055,7 @@ if (!client->isConnected()) continue; - onHubAdded(new HubInfo(Text::toT(client->getIpPort()), Text::toT(client->getHubName()), client->getMyIdentity().isOp())); + onHubAdded(new HubInfo(Text::toT(client->getHubUrl()), Text::toT(client->getHubName()), client->getMyIdentity().isOp())); } clientMgr->unlock(); @@ -1073,7 +1073,7 @@ int nItem = 0; int n = ctrlHubs.GetItemCount(); for(; nItem < n; nItem++) { - if(ctrlHubs.getItemData(nItem)->ipPort == info->ipPort) + if(ctrlHubs.getItemData(nItem)->url == info->url) break; } if (nItem == n) @@ -1093,7 +1093,7 @@ int nItem = 0; int n = ctrlHubs.GetItemCount(); for(; nItem < n; nItem++) { - if(ctrlHubs.getItemData(nItem)->ipPort == info->ipPort) + if(ctrlHubs.getItemData(nItem)->url == info->url) break; } if (nItem == n) Modified: dcplusplus/trunk/windows/SearchFrm.h =================================================================== --- dcplusplus/trunk/windows/SearchFrm.h 2006-03-18 16:14:10 UTC (rev 590) +++ dcplusplus/trunk/windows/SearchFrm.h 2006-03-18 19:04:20 UTC (rev 591) @@ -330,7 +330,7 @@ }; struct HubInfo : public FastAlloc<HubInfo> { - HubInfo(const tstring& aIpPort, const tstring& aName, bool aOp) : ipPort(aIpPort), + HubInfo(const tstring& aUrl, const tstring& aName, bool aOp) : url(aUrl), name(aName), op(aOp) { } const tstring& getText(int col) const { @@ -339,7 +339,7 @@ static int compareItems(HubInfo* a, HubInfo* b, int col) { return (col == 0) ? lstrcmpi(a->name.c_str(), b->name.c_str()) : 0; } - tstring ipPort; + tstring url; tstring name; bool op; }; @@ -436,7 +436,7 @@ LRESULT onItemChangedHub(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); void speak(Speakers s, Client* aClient) { - HubInfo* hubInfo = new HubInfo(Text::toT(aClient->getIpPort()), Text::toT(aClient->getHubName()), aClient->getMyIdentity().isOp()); + HubInfo* hubInfo = new HubInfo(Text::toT(aClient->getHubUrl()), Text::toT(aClient->getHubName()), aClient->getMyIdentity().isOp()); PostMessage(WM_SPEAKER, WPARAM(s), LPARAM(hubInfo)); } }; Modified: dcplusplus/trunk/windows/WinUtil.h =================================================================== --- dcplusplus/trunk/windows/WinUtil.h 2006-03-18 16:14:10 UTC (rev 590) +++ dcplusplus/trunk/windows/WinUtil.h 2006-03-18 19:04:20 UTC (rev 591) @@ -335,6 +335,8 @@ SettingsManager::StrSetting widths, int n, int* indexes, int* sizes) throw(); static bool isShift() { return (GetKeyState(VK_SHIFT) & 0x8000) > 0; } + static bool isAlt() { return (GetKeyState(VK_MENU) & 0x8000) > 0; } + static bool isCtrl() { return (GetKeyState(VK_CONTROL) & 0x8000) > 0; } template<class T> static HWND hiddenCreateEx(T& p) throw() { HWND active = (HWND)::SendMessage(mdiClient, WM_MDIGETACTIVE, 0, 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |