예제 #1
0
void CLocalTreeView::OnMenuUpload(wxCommandEvent& event)
{
	if (!m_contextMenuItem.IsOk())
		return;

	wxString path = GetDirFromItem(m_contextMenuItem);

	if (!CLocalPath(path).HasParent())
		return;

	if (!m_pState->IsRemoteConnected())
		return;

	const CServer server = *m_pState->GetServer();
	CServerPath remotePath = m_pState->GetRemotePath();
	if (remotePath.IsEmpty())
		return;

	if (!remotePath.ChangePath(GetItemText(m_contextMenuItem)))
		return;

	if (path.Last() == wxFileName::GetPathSeparator())
		path.RemoveLast();
	m_pQueueView->QueueFolder(event.GetId() == XRCID("ID_ADDTOQUEUE"), false, path, remotePath, server);
}
예제 #2
0
void CLocalListView::OnMenuUpload(wxCommandEvent& event)
{
	long item = -1;
	while (true)
	{
		item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
		if (item == -1)
			break;

		if (!item && m_hasParent)
			return;
	}

	item = -1;
	while (true)
	{
		item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
		if (item == -1)
			break;

		t_fileData *data = GetData(item);
		if (!data)
			return;

		if (!item && m_hasParent)
			m_pState->SetLocalDir(data->name);
		else
		{
			const CServer* pServer = m_pState->GetServer();
			if (!pServer)
			{
				wxBell();
				return;
			}

			CServerPath path = m_pState->GetRemotePath();
			if (path.IsEmpty())
			{
				wxBell();
				return;
			}

			if (data->dir)
			{
				path.ChangePath(data->name);

				wxFileName fn(m_dir, _T(""));
				fn.AppendDir(data->name);
				m_pQueue->QueueFolder(event.GetId() == XRCID("ID_ADDTOQUEUE"), false, fn.GetPath(), path, *pServer);
			}
			else
			{
				wxFileName fn(m_dir, data->name);

				m_pQueue->QueueFile(event.GetId() == XRCID("ID_ADDTOQUEUE"), false, fn.GetFullPath(), data->name, path, *pServer, data->size);
			}
		}
	}
}
예제 #3
0
void CRemoteTreeView::OnMkdir(wxCommandEvent& event)
{
	if (!m_pState->IsRemoteIdle())
		return;

	if (!m_contextMenuItem)
		return;

	const CServerPath& path = GetPathFromItem(m_contextMenuItem);
	if (path.IsEmpty())
		return;

	CInputDialog dlg;
	if (!dlg.Create(this, _("Create directory"), _("Please enter the name of the directory which should be created:")))
		return;

	CServerPath newPath = path;

	// Append a long segment which does (most likely) not exist in the path and
	// replace it with "New directory" later. This way we get the exact position of
	// "New directory" and can preselect it in the dialog.
	wxString tmpName = _T("25CF809E56B343b5A12D1F0466E3B37A49A9087FDCF8412AA9AF8D1E849D01CF");
	if (newPath.AddSegment(tmpName))
	{
		wxString pathName = newPath.GetPath();
		int pos = pathName.Find(tmpName);
		wxASSERT(pos != -1);
		wxString newName = _("New directory");
		pathName.Replace(tmpName, newName);
		dlg.SetValue(pathName);
		dlg.SelectText(pos, pos + newName.Length());
	}

	if (dlg.ShowModal() != wxID_OK)
		return;

	newPath = path;
	if (!newPath.ChangePath(dlg.GetValue()))
	{
		wxBell();
		return;
	}

	m_pState->m_pCommandQueue->ProcessCommand(new CMkdirCommand(newPath));
	CServerPath listed;
	if (newPath.HasParent())
	{
		listed = newPath.GetParent();
		m_pState->ChangeRemoteDir(listed);
	}

	CServerPath currentPath;
	const wxTreeItemId selected = GetSelection();
	if (selected)
		currentPath = GetPathFromItem(selected);
	if (!currentPath.IsEmpty() && currentPath != listed)
		m_pState->ChangeRemoteDir(currentPath);
}
예제 #4
0
void CLocalListView::OnMenuUpload(wxCommandEvent& event)
{
	const CServer* pServer = m_pState->GetServer();
	if (!pServer)
	{
		wxBell();
		return;
	}

	bool added = false;

	bool queue_only = event.GetId() == XRCID("ID_ADDTOQUEUE");

	long item = -1;
	for (;;)
	{
		item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
		if (!item && m_hasParent)
			continue;
		if (item == -1)
			break;

		const CLocalFileData *data = GetData(item);
		if (!data)
			break;

		if (data->flags == fill)
			continue;

		CServerPath path = m_pState->GetRemotePath();
		if (path.IsEmpty())
		{
			wxBell();
			break;
		}

		if (data->dir)
		{
			path.ChangePath(data->name);

			CLocalPath localPath(m_dir);
			localPath.AddSegment(data->name);
			m_pQueue->QueueFolder(event.GetId() == XRCID("ID_ADDTOQUEUE"), false, localPath, path, *pServer);
		}
		else
		{
			m_pQueue->QueueFile(queue_only, false, data->name, wxEmptyString, CLocalPath(m_dir), path, *pServer, data->size);
			added = true;
		}
	}
	if (added)
		m_pQueue->QueueFile_Finish(!queue_only);
}
예제 #5
0
void CRemoteViewHeader::OnTextEnter(wxCommandEvent& event)
{
	CServerPath path = m_path;
	wxString value = m_pComboBox->GetValue();
	if (value == _T("") || !path.ChangePath(value))
	{
		wxBell();
		return;
	}

	if (!m_pState->m_pCommandQueue->Idle())
	{
		wxBell();
		return;
	}

	m_pState->ChangeRemoteDir(path);
}
예제 #6
0
파일: search.cpp 프로젝트: robotenok/MILF
void CSearchDialog::ProcessSelection(std::list<int> &selected_files, std::list<CServerPath> &selected_dirs)
{
    int sel = -1;
    while ((sel = m_results->GetNextItem(sel, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)) != -1)
    {
        if (sel > (int)m_results->m_indexMapping.size())
            continue;
        int index = m_results->m_indexMapping[sel];

        if (m_results->m_fileData[index].entry.is_dir())
        {
            CServerPath path = m_results->m_fileData[index].path;
            path.ChangePath(m_results->m_fileData[index].entry.name);
            if (path.IsEmpty())
                continue;

            bool replaced = false;
            std::list<CServerPath>::iterator iter = selected_dirs.begin();
            std::list<CServerPath>::iterator prev;

            // Make sure that selected_dirs does not contain
            // any directories that are in a parent-child relationship
            // Resolve by only keeping topmost parents
            while (iter != selected_dirs.end())
            {
                if (*iter == path)
                {
                    replaced = true;
                    break;
                }

                if (iter->IsParentOf(path, false))
                {
                    replaced = true;
                    break;
                }

                if (iter->IsSubdirOf(path, false))
                {
                    if (!replaced)
                    {
                        *iter = path;
                        replaced = true;
                    }
                    else
                    {
                        prev = iter++;
                        selected_dirs.erase(prev);
                        continue;
                    }
                }
                ++iter;
            }
            if (!replaced)
                selected_dirs.push_back(path);
        }
        else
            selected_files.push_back(index);
    }

    // Now in a second phase filter out all files that are also in a directory
    std::list<int> selected_files_new;
    for (std::list<int>::const_iterator iter = selected_files.begin(); iter != selected_files.end(); ++iter)
    {
        CServerPath path = m_results->m_fileData[*iter].path;
        std::list<CServerPath>::const_iterator path_iter;
        for (path_iter = selected_dirs.begin(); path_iter != selected_dirs.end(); ++path_iter)
        {
            if (*path_iter == path || path_iter->IsParentOf(path, false))
                break;
        }
        if (path_iter == selected_dirs.end())
            selected_files_new.push_back(*iter);
    }
    selected_files.swap(selected_files_new);

    // At this point selected_dirs contains uncomparable
    // paths and selected_files contains only files not
    // covered by any of those directories.
}