Ticket #8344: reselect_item_we_are_coming_from_in_parent_directory.patch

File reselect_item_we_are_coming_from_in_parent_directory.patch, 3.9 KB (added by dudu, 12 years ago)

Patch implementing the ticket, version 3

  • src/interface/LocalListView.cpp

     
    318318            ExitComparisonMode();
    319319
    320320        ClearSelection();
    321         focused = _T("..");
     321        focused = m_pState->GetLastLocalFocused();
    322322
    323323        if (GetItemCount())
    324324            EnsureVisible(0);
     
    15381538            if (data.name == focused)
    15391539            {
    15401540                SetItemState(i, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
     1541                EnsureVisible(i);
    15411542                return;
    15421543            }
    15431544        }
     
    15551556            if (data.name == focused)
    15561557            {
    15571558                SetItemState(i, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
     1559                EnsureVisible(i);
    15581560                focused = _T("");
    15591561            }
    15601562            if (data.dir && *iter == (_T("d") + data.name))
  • src/interface/state.h

     
    163163    bool GetSecurityInfo(CSftpEncryptionNotification *& pInfo);
    164164    void SetSecurityInfo(CCertificateNotification const& info);
    165165    void SetSecurityInfo(CSftpEncryptionNotification const& info);
     166
     167    wxString GetLastLocalFocused() const { return m_last_local_focused_item_name; }
     168    wxString GetLastRemoteFocused() const { return m_last_remote_focused_item_name; }
     169
    166170protected:
    167171    void SetServer(const CServer* server);
    168172
     
    203207
    204208    CCertificateNotification* m_pCertificate;
    205209    CSftpEncryptionNotification* m_pSftpEncryptionInfo;
     210   
     211    wxString m_last_local_focused_item_name;
     212    wxString m_last_remote_focused_item_name;
    206213};
    207214
    208215class CStateEventHandler
  • src/interface/RemoteListView.cpp

     
    719719void CRemoteListView::SetDirectoryListing(const CSharedPointer<const CDirectoryListing> &pDirectoryListing, bool modified /*=false*/)
    720720{
    721721    CancelLabelEdit();
     722   
     723    wxString prevFocused = m_pState->GetLastRemoteFocused();
     724    std::list<wxString> selectedNames;
    722725
    723726    bool reset = false;
    724727    if (!pDirectoryListing || !m_pDirectoryListing)
     
    741744            wxASSERT(CFilterManager::HasActiveFilters() || GetItemCount() == (int)m_fileData.size());
    742745            wxASSERT(m_pDirectoryListing->GetCount() + 1 >= (unsigned int)GetItemCount());
    743746            wxASSERT(m_indexMapping[0] == m_pDirectoryListing->GetCount());
     747       
     748            ReselectItems(selectedNames, prevFocused);
    744749
    745750            RefreshListOnly();
    746751
     
    748753        }
    749754    }
    750755
    751     wxString prevFocused;
    752     std::list<wxString> selectedNames;
    753756    if (reset)
    754757    {
    755758        ResetSearchPrefix();
     
    22312234            if ((*m_pDirectoryListing)[index].name == focused)
    22322235            {
    22332236                SetItemState(i, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
     2237                EnsureVisible(i);
    22342238                return;
    22352239            }
    22362240        }
     
    22592263            if (entry.name == focused)
    22602264            {
    22612265                SetItemState(i, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
     2266                EnsureVisible(i);
    22622267                focused = _T("");
    22632268            }
    22642269            if (entry.is_dir() && *iter == (_T("d") + entry.name))
  • src/interface/state.cpp

     
    307307        }
    308308    }
    309309
     310    if (p == m_localDir.GetParent())
     311        m_last_local_focused_item_name = m_localDir.GetLastSegment();
     312    else
     313        m_last_local_focused_item_name = _T("");
     314   
     315
    310316    m_localDir = p;
    311317
    312318    COptions::Get()->SetOption(OPTION_LASTLOCALDIR, m_localDir.GetPath());
     
    333339    }
    334340
    335341    wxASSERT(pDirectoryListing->m_firstListTime.IsValid());
     342   
     343    if (pDirectoryListing && m_pDirectoryListing &&
     344        pDirectoryListing->path == m_pDirectoryListing->path.GetParent())
     345        m_last_remote_focused_item_name = m_pDirectoryListing->path.GetLastSegment();
     346    else
     347        m_last_remote_focused_item_name = _T("");
    336348
     349
    337350    if (modified)
    338351    {
    339352        if (!m_pDirectoryListing || m_pDirectoryListing->path != pDirectoryListing->path)