Ignore:
Timestamp:
Jan 9, 2017, 11:09:38 AM (2 years ago)
Author:
jrpelegrina
Message:

Update new version: 3.15.02

File:
1 edited

Legend:

Unmodified
Added
Removed
  • filezilla/trunk/fuentes/src/interface/search.cpp

    r130 r3185  
    7575        virtual bool CanStartComparison() { return false; }
    7676        virtual void StartComparison() {}
    77         virtual bool GetNextFile(wxString&, bool &, int64_t&, CDateTime&) { return false; }
     77        virtual bool get_next_file(wxString&, bool &, int64_t&, fz::datetime&) { return false; }
    7878        virtual void CompareAddFile(CComparableListing::t_fileEntryFlags) {}
    7979        virtual void FinishComparison() {}
     
    292292        m_local_target = m_pState->GetLocalDir();
    293293
    294         m_pState->RegisterHandler(this, STATECHANGE_REMOTE_DIR_OTHER);
    295         m_pState->RegisterHandler(this, STATECHANGE_REMOTE_IDLE);
     294        m_pState->RegisterHandler(this, STATECHANGE_REMOTE_DIR_OTHER, m_pState->GetRecursiveOperationHandler());
     295        m_pState->RegisterHandler(this, STATECHANGE_REMOTE_IDLE, m_pState->GetRecursiveOperationHandler());
    296296
    297297        ShowModal();
     
    316316}
    317317
    318 void CSearchDialog::OnStateChange(CState* pState, enum t_statechange_notifications notification, const wxString& data, const void* data2)
     318void CSearchDialog::OnStateChange(CState* pState, enum t_statechange_notifications notification, const wxString&, const void* data2)
    319319{
    320320        if (notification == STATECHANGE_REMOTE_DIR_OTHER && data2) {
    321                 std::shared_ptr<CDirectoryListing> const& listing = *reinterpret_cast<std::shared_ptr<CDirectoryListing> const*>(data2);
    322                 ProcessDirectoryListing(listing);
     321                auto recursiveOperation = m_pState->GetRecursiveOperationHandler();
     322                if (recursiveOperation && recursiveOperation->GetOperationMode() == CRecursiveOperation::recursive_list) {
     323                        std::shared_ptr<CDirectoryListing> const& listing = *reinterpret_cast<std::shared_ptr<CDirectoryListing> const*>(data2);
     324                        ProcessDirectoryListing(listing);
     325                }
    323326        }
    324327        else if (notification == STATECHANGE_REMOTE_IDLE) {
     
    370373}
    371374
    372 void CSearchDialog::OnSearch(wxCommandEvent& event)
     375void CSearchDialog::OnSearch(wxCommandEvent&)
    373376{
    374377        if (!m_pState->IsRemoteIdle()) {
     
    419422        // Start
    420423        m_searching = true;
    421         m_pState->GetRecursiveOperationHandler()->AddDirectoryToVisitRestricted(path, _T(""), true);
     424        recursion_root root(path, true);
     425        root.add_dir_to_visit_restricted(path, _T(""), true);
     426        m_pState->GetRecursiveOperationHandler()->AddRecursionRoot(std::move(root));
    422427        std::vector<CFilter> const filters; // Empty, recurse into everything
    423         m_pState->GetRecursiveOperationHandler()->StartRecursiveOperation(CRecursiveOperation::recursive_list, path, filters, true);
    424 }
    425 
    426 void CSearchDialog::OnStop(wxCommandEvent& event)
     428        m_pState->GetRecursiveOperationHandler()->StartRecursiveOperation(CRecursiveOperation::recursive_list, filters, path);
     429}
     430
     431void CSearchDialog::OnStop(wxCommandEvent&)
    427432{
    428433        if (!m_pState->IsRemoteIdle()) {
     
    453458                pMenu->Enable(XRCID("ID_MENU_SEARCH_DOWNLOAD"), false);
    454459                pMenu->Enable(XRCID("ID_MENU_SEARCH_DELETE"), false);
     460                pMenu->Enable(XRCID("ID_MENU_SEARCH_EDIT"), false);
    455461        }
    456462
     
    501507END_EVENT_TABLE()
    502508
    503 void CSearchDownloadDialog::OnBrowse(wxCommandEvent& event)
     509void CSearchDownloadDialog::OnBrowse(wxCommandEvent&)
    504510{
    505511        wxTextCtrl *pText = XRCCTRL(*this, "ID_LOCALPATH", wxTextCtrl);
     
    510516}
    511517
    512 void CSearchDownloadDialog::OnOK(wxCommandEvent& event)
     518void CSearchDownloadDialog::OnOK(wxCommandEvent&)
    513519{
    514520        wxTextCtrl *pText = XRCCTRL(*this, "ID_LOCALPATH", wxTextCtrl);
     
    528534}
    529535
    530 void CSearchDialog::ProcessSelection(std::list<int> &selected_files, std::list<CServerPath> &selected_dirs)
    531 {
     536void CSearchDialog::ProcessSelection(std::list<int> &selected_files, std::deque<CServerPath> &selected_dirs)
     537{
     538        std::deque<CServerPath> dirs;
     539
    532540        int sel = -1;
    533541        while ((sel = m_results->GetNextItem(sel, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)) != -1) {
     
    542550                                continue;
    543551
    544                         bool replaced = false;
    545                         std::list<CServerPath>::iterator iter = selected_dirs.begin();
    546                         std::list<CServerPath>::iterator prev;
    547 
    548                         // Make sure that selected_dirs does not contain
    549                         // any directories that are in a parent-child relationship
    550                         // Resolve by only keeping topmost parents
    551                         while (iter != selected_dirs.end()) {
    552                                 if (*iter == path) {
    553                                         replaced = true;
    554                                         break;
    555                                 }
    556 
    557                                 if (iter->IsParentOf(path, false)) {
    558                                         replaced = true;
    559                                         break;
    560                                 }
    561 
    562                                 if (iter->IsSubdirOf(path, false)) {
    563                                         if (!replaced) {
    564                                                 *iter = path;
    565                                                 replaced = true;
    566                                         }
    567                                         else {
    568                                                 prev = iter++;
    569                                                 selected_dirs.erase(prev);
    570                                                 continue;
    571                                         }
    572                                 }
    573                                 ++iter;
    574                         }
    575                         if (!replaced)
    576                                 selected_dirs.push_back(path);
     552                        dirs.push_back(path);
    577553                }
    578554                else
     
    580556        }
    581557
     558        // Make sure that selected_dirs does not contain
     559        // any directories that are in a parent-child relationship
     560        // Resolve by only keeping topmost parents
     561        std::sort(dirs.begin(), dirs.end());
     562        for (CServerPath const& path : dirs) {
     563                if (!selected_dirs.empty() && (path.IsSubdirOf(selected_dirs.back(), false) || path == selected_dirs.back())) {
     564                        continue;
     565                }
     566                selected_dirs.push_back(path);
     567        }
     568
    582569        // Now in a second phase filter out all files that are also in a directory
    583570        std::list<int> selected_files_new;
    584571        for (auto const& sel_file : selected_files) {
    585                 CServerPath path = m_results->m_fileData[sel_file].path;
    586                 std::list<CServerPath>::const_iterator path_iter;
     572                CServerPath const& path = m_results->m_fileData[sel_file].path;
     573                std::deque<CServerPath>::iterator path_iter;
    587574                for (path_iter = selected_dirs.begin(); path_iter != selected_dirs.end(); ++path_iter) {
    588575                        if (*path_iter == path || path_iter->IsParentOf(path, false))
     
    605592
    606593        // Find all selected files and directories
    607         std::list<CServerPath> selected_dirs;
     594        std::deque<CServerPath> selected_dirs;
    608595        std::list<int> selected_files;
    609596        ProcessSelection(selected_files, selected_dirs);
     
    611598        if (selected_files.empty() && selected_dirs.empty())
    612599                return;
    613 
    614         if (selected_dirs.size() > 1) {
    615                 wxMessageBoxEx(_("Downloading multiple unrelated directories is not yet supported"), _("Downloading search results"), wxICON_EXCLAMATION);
    616                 return;
    617         }
    618600
    619601        CSearchDownloadDialog dlg;
     
    678660                        target_path.AddSegment(dir.GetLastSegment());
    679661
    680                 m_pState->GetRecursiveOperationHandler()->AddDirectoryToVisit(dir, _T(""), target_path, false);
    681                 std::vector<CFilter> const filters; // Empty, recurse into everything
    682                 m_pState->GetRecursiveOperationHandler()->StartRecursiveOperation(mode, dir, filters, true, m_original_dir);
    683         }
     662                recursion_root root(dir, true);
     663                root.add_dir_to_visit(dir, _T(""), target_path, false);
     664                m_pState->GetRecursiveOperationHandler()->AddRecursionRoot(std::move(root));
     665        }
     666        std::vector<CFilter> const filters; // Empty, recurse into everything
     667        m_pState->GetRecursiveOperationHandler()->StartRecursiveOperation(mode, filters, m_original_dir);
    684668}
    685669
     
    690674
    691675        // Find all selected files and directories
    692         std::list<CServerPath> selected_dirs;
     676        std::deque<CServerPath> selected_dirs;
    693677        std::list<int> selected_files;
    694678        ProcessSelection(selected_files, selected_dirs);
     
    743727
    744728        // Find all selected files and directories
    745         std::list<CServerPath> selected_dirs;
     729        std::deque<CServerPath> selected_dirs;
    746730        std::list<int> selected_files;
    747731        ProcessSelection(selected_files, selected_dirs);
     
    749733        if (selected_files.empty() && selected_dirs.empty())
    750734                return;
    751 
    752         if (selected_dirs.size() > 1) {
    753                 wxMessageBoxEx(_("Deleting multiple unrelated directories is not yet supported"), _("Deleting directories"), wxICON_EXCLAMATION);
    754                 return;
    755         }
    756735
    757736        wxString question;
     
    777756
    778757        for (auto path : selected_dirs) {
    779                 if (!path.HasParent())
    780                         m_pState->GetRecursiveOperationHandler()->AddDirectoryToVisit(path, _T(""));
    781                 else {
    782                         m_pState->GetRecursiveOperationHandler()->AddDirectoryToVisit(path.GetParent(), path.GetLastSegment());
     758                wxString segment;
     759                if (path.HasParent()) {
     760                        segment = path.GetLastSegment();
    783761                        path = path.GetParent();
    784762                }
    785 
    786                 std::vector<CFilter> const filters; // Empty, recurse into everything
    787                 m_pState->GetRecursiveOperationHandler()->StartRecursiveOperation(CRecursiveOperation::recursive_delete, path, filters, !path.HasParent(), m_original_dir);
    788         }
     763                recursion_root root(path, !path.HasParent());
     764                root.add_dir_to_visit(path, segment);
     765                m_pState->GetRecursiveOperationHandler()->AddRecursionRoot(std::move(root));
     766        }
     767        std::vector<CFilter> const filters; // Empty, recurse into everything
     768        m_pState->GetRecursiveOperationHandler()->StartRecursiveOperation(CRecursiveOperation::recursive_delete, filters, m_original_dir);
    789769}
    790770
Note: See TracChangeset for help on using the changeset viewer.