Ticket #8406: focus_newly_created_directory.patch

File focus_newly_created_directory.patch, 5.8 KB (added by dudu, 10 years ago)

focus after mkdir patch re-done with full paths and parent checks

  • src/interface/LocalListView.cpp

     
    317317            ExitComparisonMode();
    318318
    319319        ClearSelection();
    320         focused = m_pState->GetPreviouslyVisitedLocalSubdir();
     320
     321        CLocalPath lastFocusedPath(m_pState->GetPreviouslyVisitedLocalSubdir());
     322        if (lastFocusedPath.GetParent() == dirname)
     323            focused = lastFocusedPath.GetLastSegment();
     324       
    321325        ensureVisible = !focused.empty();
    322326        if (focused.empty())
    323327            focused = _T("..");
     
    867871    wxString newdir = MenuMkdir();
    868872    if (!newdir.empty()) {
    869873        m_pState->RefreshLocal();
     874
     875        CLocalPath lp(newdir);
     876        FocusSingleItem(lp.GetLastSegment());
    870877    }
    871878}
    872879
     
    17931800        }
    17941801    }
    17951802}
     1803
     1804void CLocalListView::FocusSingleItem(const wxString& itemName, long int state /*= wxLIST_STATE_FOCUSED*/)
     1805{
     1806    if (itemName == _T(""))
     1807        return;
     1808
     1809    for (unsigned int i = 0; i < m_indexMapping.size(); i++)
     1810    {
     1811        const CLocalFileData &data = m_fileData[m_indexMapping[i]];
     1812        if (data.name == itemName)
     1813        {
     1814            SetItemState(i, state, state);
     1815            EnsureVisible(i);
     1816        }
     1817        else
     1818            SetItemState(i, 0, state);
     1819    }
     1820    return;
     1821}
  • src/interface/LocalListView.h

     
    5353    // ReselectItems
    5454    void ReselectItems(const std::list<wxString>& selectedNames, wxString focused, bool ensureVisible = false);
    5555
     56    // Set focus (or other) state on the named item, remove the same state from every other
     57    void FocusSingleItem(const wxString& itemName, long int state = wxLIST_STATE_FOCUSED);
     58
    5659#ifdef __WXMSW__
    5760    void DisplayDrives();
    5861    void DisplayShares(wxString computer);
  • src/interface/RemoteListView.cpp

     
    754754
    755755        ClearSelection();
    756756
    757         prevFocused = m_pState->GetPreviouslyVisitedRemoteSubdir();
     757        CServerPath lastFocusedPath(m_pState->GetPreviouslyVisitedRemoteSubdir());
     758        if (pDirectoryListing && lastFocusedPath.GetParent() == pDirectoryListing->path)
     759            prevFocused = lastFocusedPath.GetLastSegment();
     760
    758761        ensureVisible = !prevFocused.empty();
    759762    }
    760763    else
     
    761764    {
    762765        // Remember which items were selected
    763766        selectedNames = RememberSelectedItems(prevFocused);
     767        // instead of the previously focused item use the PreviouslySelectedRemoteSubdir
     768        // if the m_pState have that information 
     769        if (!m_pState->GetPreviouslyVisitedRemoteSubdir().IsEmpty())
     770        {
     771            CServerPath lastFocusedPath(m_pState->GetPreviouslyVisitedRemoteSubdir());
     772            if (pDirectoryListing && lastFocusedPath.GetParent().GetPath() == pDirectoryListing->path.GetPath())
     773                prevFocused = lastFocusedPath.GetLastSegment();
     774        }
    764775    }
    765776
    766777    if (m_pFilelistStatusBar)
     
    13581369        return CServerPath();
    13591370    }
    13601371
     1372    CServerPath cp(path);
     1373    m_pState->SetPreviouslyVisitedRemoteSubdir(cp.GetPath());
     1374
    13611375    m_pState->m_pCommandQueue->ProcessCommand(new CMkdirCommand(path));
    13621376
    13631377    // Return name of the New Directory
  • src/interface/state.cpp

     
    298298
    299299    if (dir == m_localDir.GetParent() && rememberPreviousSubdir) {
    300300#ifdef __WXMSW__
    301         if (dir.GetPath() == _T("\\")) {
    302             m_previouslyVisitedLocalSubdir = m_localDir.GetPath();
    303             m_previouslyVisitedLocalSubdir.RemoveLast();
    304         }
     301        if (dir.GetPath() == _T("\\"))
     302            SetPreviouslyVisitedLocalSubdir(m_localDir.GetPath().RemoveLast());
    305303        else
    306304#endif
    307             m_previouslyVisitedLocalSubdir = m_localDir.GetLastSegment();
     305            SetPreviouslyVisitedLocalSubdir(m_localDir.GetPath());
    308306    }
    309307    else
    310         m_previouslyVisitedLocalSubdir = _T("");
     308        SetPreviouslyVisitedLocalSubdir(_T(""));
    311309
    312310
    313311    m_localDir = dir;
     
    331329            m_pDirectoryListing = 0;
    332330            NotifyHandlers(STATECHANGE_REMOTE_DIR);
    333331        }
    334         m_previouslyVisitedRemoteSubdir = _T("");
     332        SetPreviouslyVisitedLocalSubdir(_T(""));
    335333        return true;
    336334    }
    337335
     
    339337
    340338    if (pDirectoryListing && m_pDirectoryListing &&
    341339        pDirectoryListing->path == m_pDirectoryListing->path.GetParent())
    342         m_previouslyVisitedRemoteSubdir = m_pDirectoryListing->path.GetLastSegment();
    343     else
    344         m_previouslyVisitedRemoteSubdir = _T("");
     340        SetPreviouslyVisitedRemoteSubdir(m_pDirectoryListing->path.GetPath());
     341    else if (!modified)
     342        SetPreviouslyVisitedRemoteSubdir(_T(""));
    345343
    346344    if (modified) {
    347345        if (!m_pDirectoryListing || m_pDirectoryListing->path != pDirectoryListing->path) {
  • src/interface/state.h

     
    169169    void SetSecurityInfo(CSftpEncryptionNotification const& info);
    170170
    171171    // If the previously selected directory was a direct child of the current directory, this
    172     // returns the relative name of the subdirectory.
     172    // returns the full path of that subdirectory or an empty string otherwise.
    173173    wxString GetPreviouslyVisitedLocalSubdir() const { return m_previouslyVisitedLocalSubdir; }
    174174    wxString GetPreviouslyVisitedRemoteSubdir() const { return m_previouslyVisitedRemoteSubdir; }
    175     void ClearPreviouslyVisitedLocalSubdir() { m_previouslyVisitedLocalSubdir = _T(""); }
    176     void ClearPreviouslyVisitedRemoteSubdir() { m_previouslyVisitedRemoteSubdir = _T(""); }
     175    void SetPreviouslyVisitedLocalSubdir(wxString path) { m_previouslyVisitedLocalSubdir = path; }
     176    void SetPreviouslyVisitedRemoteSubdir(wxString path) { m_previouslyVisitedRemoteSubdir = path; }
    177177
    178178protected:
    179179    void SetServer(const CServer* server);